consolidate automatic styling methods into AbsThemeActivity
This commit is contained in:
parent
e507495fa5
commit
70a561e9d1
16 changed files with 27 additions and 80 deletions
|
|
@ -58,12 +58,6 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
|
||||||
supportBinding = CardSupportDevelopmentBinding.bind(findViewById(R.id.support_layout));
|
supportBinding = CardSupportDevelopmentBinding.bind(findViewById(R.id.support_layout));
|
||||||
thanksBinding = CardSpecialThanksBinding.bind(findViewById(R.id.thanks_layout));
|
thanksBinding = CardSpecialThanksBinding.bind(findViewById(R.id.thanks_layout));
|
||||||
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
setStatusBarColorAuto();
|
|
||||||
|
|
||||||
setNavigationBarColorAuto();
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
|
|
||||||
setUpViews();
|
setUpViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,6 @@ public class LoginActivity extends AbsBaseActivity implements View.OnClickListen
|
||||||
binding = ActivityLoginBinding.inflate(getLayoutInflater());
|
binding = ActivityLoginBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
setStatusBarColorAuto();
|
|
||||||
|
|
||||||
setNavigationBarColorAuto();
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
|
|
||||||
setUpViews();
|
setUpViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,10 @@ public class MainActivity extends AbsMusicContentActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setDrawUnderStatusBar();
|
|
||||||
|
|
||||||
state = savedInstanceState;
|
state = savedInstanceState;
|
||||||
|
|
||||||
|
setColor(PreferenceUtil.getInstance(this).getPrimaryColor());
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
||||||
binding.navigationView.setFitsSystemWindows(false);
|
binding.navigationView.setFitsSystemWindows(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,6 @@ public class SearchActivity extends AbsMusicContentActivity implements SearchVie
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
setStatusBarColorAuto();
|
|
||||||
|
|
||||||
setNavigationBarColorAuto();
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
setUpToolBar();
|
setUpToolBar();
|
||||||
|
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,6 @@ public class SelectActivity extends AbsBaseActivity {
|
||||||
startActivity(new Intent(context, LoginActivity.class));
|
startActivity(new Intent(context, LoginActivity.class));
|
||||||
});
|
});
|
||||||
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
setStatusBarColorAuto();
|
|
||||||
|
|
||||||
setNavigationBarColorAuto();
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
|
|
||||||
int primaryColor = PreferenceUtil.getInstance(this).getPrimaryColor();
|
int primaryColor = PreferenceUtil.getInstance(this).getPrimaryColor();
|
||||||
|
|
||||||
binding.add.setBackgroundColor(primaryColor);
|
binding.add.setBackgroundColor(primaryColor);
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,6 @@ public class SettingsActivity extends AbsBaseActivity {
|
||||||
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
|
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
setStatusBarColorAuto();
|
|
||||||
|
|
||||||
setNavigationBarColorAuto();
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
|
|
||||||
binding.toolbar.setBackgroundColor(PreferenceUtil.getInstance(this).getPrimaryColor());
|
binding.toolbar.setBackgroundColor(PreferenceUtil.getInstance(this).getPrimaryColor());
|
||||||
setSupportActionBar(binding.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,6 @@ public class SplashActivity extends AbsBaseActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.activity_splash);
|
setContentView(R.layout.activity_splash);
|
||||||
setDrawUnderStatusBar();
|
|
||||||
|
|
||||||
setStatusBarColorAuto();
|
|
||||||
setNavigationBarColorAuto();
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ public abstract class AbsMusicPanelActivity extends AbsMusicServiceActivity impl
|
||||||
|
|
||||||
|
|
||||||
public SlidingUpPanelLayout.PanelState getPanelState() {
|
public SlidingUpPanelLayout.PanelState getPanelState() {
|
||||||
return binding.slidingLayout.getPanelState();
|
return binding == null ? null : binding.slidingLayout.getPanelState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void collapsePanel() {
|
public void collapsePanel() {
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,7 @@ import android.view.View;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import com.dkanada.gramophone.util.NavigationUtil;
|
|
||||||
import com.kabouzeid.appthemehelper.ATH;
|
import com.kabouzeid.appthemehelper.ATH;
|
||||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
|
||||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||||
import com.kabouzeid.appthemehelper.util.MaterialDialogsUtil;
|
import com.kabouzeid.appthemehelper.util.MaterialDialogsUtil;
|
||||||
import com.dkanada.gramophone.R;
|
import com.dkanada.gramophone.R;
|
||||||
|
|
@ -23,6 +21,7 @@ public abstract class AbsThemeActivity extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setTheme(PreferenceUtil.getInstance(this).getTheme().style);
|
setTheme(PreferenceUtil.getInstance(this).getTheme().style);
|
||||||
|
setColor(PreferenceUtil.getInstance(this).getPrimaryColor());
|
||||||
MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this);
|
MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,11 +29,8 @@ public abstract class AbsThemeActivity extends AppCompatActivity {
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
// for some reason the recreate method has issues here
|
|
||||||
if (PreferenceUtil.getInstance(this).getTheme().style != currentTheme) {
|
if (PreferenceUtil.getInstance(this).getTheme().style != currentTheme) {
|
||||||
NavigationUtil.startMain(this);
|
recreate();
|
||||||
overridePendingTransition(0, android.R.anim.fade_out);
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,6 +41,18 @@ public abstract class AbsThemeActivity extends AppCompatActivity {
|
||||||
currentTheme = resId;
|
currentTheme = resId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setColor(int color) {
|
||||||
|
boolean light = ColorUtil.isColorLight(color);
|
||||||
|
|
||||||
|
setLightStatusBar(light);
|
||||||
|
setLightNavigationBar(light);
|
||||||
|
setDrawUnderStatusBar();
|
||||||
|
|
||||||
|
setStatusBarColor(color);
|
||||||
|
setTaskDescriptionColor(color);
|
||||||
|
setNavigationBarColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
protected void setDrawUnderStatusBar() {
|
protected void setDrawUnderStatusBar() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
Util.setAllowDrawUnderStatusBar(getWindow());
|
Util.setAllowDrawUnderStatusBar(getWindow());
|
||||||
|
|
@ -68,32 +76,19 @@ public abstract class AbsThemeActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatusBarColorAuto() {
|
|
||||||
// ignore status bar color because we are darkening the color on our own to support KitKat
|
|
||||||
setStatusBarColor(ThemeStore.primaryColor(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTaskDescriptionColor(int color) {
|
public void setTaskDescriptionColor(int color) {
|
||||||
ATH.setTaskDescriptionColor(this, color);
|
ATH.setTaskDescriptionColor(this, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTaskDescriptionColorAuto() {
|
|
||||||
setTaskDescriptionColor(ThemeStore.primaryColor(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNavigationBarColor(int color) {
|
public void setNavigationBarColor(int color) {
|
||||||
ATH.setNavigationbarColor(this, color);
|
ATH.setNavigationbarColor(this, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNavigationBarColorAuto() {
|
|
||||||
setNavigationBarColor(ThemeStore.navigationBarColor(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLightStatusBar(boolean enabled) {
|
public void setLightStatusBar(boolean enabled) {
|
||||||
ATH.setLightStatusbar(this, enabled);
|
ATH.setLightStatusbar(this, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLightStatusBarAuto(int bgColor) {
|
public void setLightNavigationBar(boolean enabled) {
|
||||||
setLightStatusBar(ColorUtil.isColorLight(bgColor));
|
ATH.setLightNavigationbar(this, enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ public class AlbumDetailActivity extends AbsMusicContentActivity implements Pale
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
setUpObservableListViewParams();
|
setUpObservableListViewParams();
|
||||||
setUpToolbar();
|
setUpToolbar();
|
||||||
setUpViews();
|
setUpViews();
|
||||||
|
|
@ -119,13 +118,11 @@ public class AlbumDetailActivity extends AbsMusicContentActivity implements Pale
|
||||||
toolbarColor = color;
|
toolbarColor = color;
|
||||||
binding.appBarLayout.setBackgroundColor(color);
|
binding.appBarLayout.setBackgroundColor(color);
|
||||||
|
|
||||||
setNavigationBarColor(color);
|
setColor(color);
|
||||||
setTaskDescriptionColor(color);
|
|
||||||
|
|
||||||
binding.toolbar.setBackgroundColor(color);
|
binding.toolbar.setBackgroundColor(color);
|
||||||
// needed to auto readjust the toolbar content color
|
// needed to auto readjust the toolbar content color
|
||||||
setSupportActionBar(binding.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
setStatusBarColor(color);
|
|
||||||
|
|
||||||
int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
|
int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
|
||||||
binding.artistIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
binding.artistIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
@ -226,6 +223,8 @@ public class AlbumDetailActivity extends AbsMusicContentActivity implements Pale
|
||||||
@Override
|
@Override
|
||||||
public void setStatusBarColor(int color) {
|
public void setStatusBarColor(int color) {
|
||||||
super.setStatusBarColor(color);
|
super.setStatusBarColor(color);
|
||||||
|
|
||||||
|
// the toolbar is always light at the moment
|
||||||
setLightStatusBar(false);
|
setLightStatusBar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,6 @@ public class ArtistDetailActivity extends AbsMusicContentActivity implements Pal
|
||||||
// must be loaded before album adapter
|
// must be loaded before album adapter
|
||||||
usePalette = PreferenceUtil.getInstance(this).getAlbumArtistColoredFooters();
|
usePalette = PreferenceUtil.getInstance(this).getAlbumArtistColoredFooters();
|
||||||
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
setUpObservableListViewParams();
|
setUpObservableListViewParams();
|
||||||
setUpToolbar();
|
setUpToolbar();
|
||||||
setUpViews();
|
setUpViews();
|
||||||
|
|
@ -169,13 +168,11 @@ public class ArtistDetailActivity extends AbsMusicContentActivity implements Pal
|
||||||
toolbarColor = color;
|
toolbarColor = color;
|
||||||
binding.appBarLayout.setBackgroundColor(color);
|
binding.appBarLayout.setBackgroundColor(color);
|
||||||
|
|
||||||
setNavigationBarColor(color);
|
setColor(color);
|
||||||
setTaskDescriptionColor(color);
|
|
||||||
|
|
||||||
binding.toolbar.setBackgroundColor(color);
|
binding.toolbar.setBackgroundColor(color);
|
||||||
// needed to auto readjust the toolbar content color
|
// needed to auto readjust the toolbar content color
|
||||||
setSupportActionBar(binding.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
setStatusBarColor(color);
|
|
||||||
|
|
||||||
int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
|
int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
|
||||||
binding.durationIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
binding.durationIcon.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
@ -254,6 +251,8 @@ public class ArtistDetailActivity extends AbsMusicContentActivity implements Pal
|
||||||
@Override
|
@Override
|
||||||
public void setStatusBarColor(int color) {
|
public void setStatusBarColor(int color) {
|
||||||
super.setStatusBarColor(color);
|
super.setStatusBarColor(color);
|
||||||
|
|
||||||
|
// the toolbar is always light at the moment
|
||||||
setLightStatusBar(false);
|
setLightStatusBar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,6 @@ public class GenreDetailActivity extends AbsMusicContentActivity implements CabH
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
setStatusBarColorAuto();
|
|
||||||
|
|
||||||
setNavigationBarColorAuto();
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
|
|
||||||
setUpRecyclerView();
|
setUpRecyclerView();
|
||||||
setUpToolBar();
|
setUpToolBar();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,12 +55,6 @@ public class PlaylistDetailActivity extends AbsMusicContentActivity implements C
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
setStatusBarColorAuto();
|
|
||||||
|
|
||||||
setNavigationBarColorAuto();
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
|
|
||||||
setUpRecyclerView();
|
setUpRecyclerView();
|
||||||
setUpToolbar();
|
setUpToolbar();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ public class ShuffleButtonSongAdapter extends AbsOffsetSongAdapter {
|
||||||
public void onBindViewHolder(@NonNull final SongAdapter.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final SongAdapter.ViewHolder holder, int position) {
|
||||||
if (holder.getItemViewType() == OFFSET_ITEM) {
|
if (holder.getItemViewType() == OFFSET_ITEM) {
|
||||||
int accentColor = PreferenceUtil.getInstance(activity).getAccentColor();
|
int accentColor = PreferenceUtil.getInstance(activity).getAccentColor();
|
||||||
|
|
||||||
if (holder.title != null) {
|
if (holder.title != null) {
|
||||||
holder.title.setText(activity.getResources().getString(R.string.action_shuffle_all).toUpperCase());
|
holder.title.setText(activity.getResources().getString(R.string.action_shuffle_all).toUpperCase());
|
||||||
holder.title.setTextColor(accentColor);
|
holder.title.setTextColor(accentColor);
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
PreferenceUtil.getInstance(getActivity()).registerOnSharedPreferenceChangedListener(this);
|
PreferenceUtil.getInstance(getActivity()).registerOnSharedPreferenceChangedListener(this);
|
||||||
getMainActivity().setStatusBarColorAuto();
|
|
||||||
getMainActivity().setNavigationBarColorAuto();
|
|
||||||
getMainActivity().setTaskDescriptionColorAuto();
|
|
||||||
|
|
||||||
setUpToolbar();
|
setUpToolbar();
|
||||||
setUpViewPager();
|
setUpViewPager();
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ public class ThemeUtil {
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Palette generatePalette(Bitmap bitmap) {
|
public static Palette generatePalette(Bitmap bitmap) {
|
||||||
if (bitmap == null) return null;
|
if (bitmap == null) return null;
|
||||||
|
|
||||||
return Palette.from(bitmap).generate();
|
return Palette.from(bitmap).generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue