Cleaned up the settings
This commit is contained in:
parent
cee223cdbb
commit
e42867e066
11 changed files with 62 additions and 100 deletions
|
|
@ -43,7 +43,6 @@ import com.kabouzeid.gramophone.ui.activities.tageditor.AlbumTagEditorActivity;
|
|||
import com.kabouzeid.gramophone.util.ColorUtil;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
|
|
@ -103,10 +102,11 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
postponeEnterTransition();
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarAlbum())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
}
|
||||
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
|
||||
getAlbumFromIntentExtras();
|
||||
setUpObservableListViewParams();
|
||||
setUpToolBar();
|
||||
|
|
@ -255,7 +255,7 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
|||
albumTitleView.setBackgroundColor(vibrantColor);
|
||||
albumTitleView.setTextColor(ColorUtil.getTextColorForBackground(vibrantColor));
|
||||
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarArtist())
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarColor(vibrantColor);
|
||||
|
||||
notifyTaskColorChange(vibrantColor);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ import com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity;
|
|||
import com.kabouzeid.gramophone.util.ColorUtil;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||
import com.kabouzeid.gramophone.views.SquareIfPlaceImageView;
|
||||
|
|
@ -120,10 +119,11 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
postponeEnterTransition();
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarArtist())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
}
|
||||
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
|
||||
lastFMRestClient = new LastFMRestClient(this);
|
||||
|
||||
getArtistFromIntentExtras();
|
||||
|
|
@ -379,7 +379,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
artistName.setBackgroundColor(vibrantColor);
|
||||
artistName.setTextColor(ColorUtil.getTextColorForBackground(vibrantColor));
|
||||
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarArtist())
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarColor(vibrantColor);
|
||||
|
||||
notifyTaskColorChange(vibrantColor);
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
setUpToolbar();
|
||||
setUpViewPager();
|
||||
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarOtherScreens())
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarThemeColor();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ public class MusicControllerActivity extends AbsSlidingMusicPanelActivity {
|
|||
if (opaqueStatusBar) setStatusBarColor(newColor);
|
||||
else setStatusBarColor(Color.TRANSPARENT);
|
||||
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarCurrentPlaying())
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarColor(newColor);
|
||||
lastFooterColor = newColor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import com.kabouzeid.gramophone.model.smartplaylist.AbsSmartPlaylist;
|
|||
import com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -67,7 +66,7 @@ public class PlaylistDetailActivity extends AbsSlidingMusicPanelActivity impleme
|
|||
|
||||
setUpToolBar();
|
||||
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarPlaylist())
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarThemeColor();
|
||||
setStatusBarThemeColor();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
if (savedInstanceState == null)
|
||||
getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
|
||||
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarOtherScreens())
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarThemeColor();
|
||||
setStatusBarThemeColor();
|
||||
}
|
||||
|
|
@ -123,10 +123,19 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
}
|
||||
});
|
||||
|
||||
Preference colorNavBar = findPreference("colored_navigation_bar");
|
||||
Preference colorNavBar = findPreference("should_color_navigation_bar");
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
colorNavBar.setEnabled(false);
|
||||
colorNavBar.setSummary(R.string.pref_only_lollipop);
|
||||
} else {
|
||||
colorNavBar.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
PreferenceUtil.getInstance(getActivity()).setColoredNavigationBar((boolean) newValue);
|
||||
((SettingsActivity) getActivity()).recreateIfThemeChanged();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Preference ignoreMediaStoreArtwork = findPreference("ignore_media_store_artwork");
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public abstract class AbsThemeActivity extends AppCompatActivity implements KabV
|
|||
private int colorPrimaryDarker;
|
||||
private int colorAccent;
|
||||
private boolean darkTheme;
|
||||
private boolean coloredNavigationBar;
|
||||
|
||||
@Nullable
|
||||
private ActivityManager.TaskDescription taskDescription;
|
||||
|
|
@ -45,6 +46,7 @@ public abstract class AbsThemeActivity extends AppCompatActivity implements KabV
|
|||
colorPrimaryDarker = ColorUtil.shiftColorDown(colorPrimary);
|
||||
colorAccent = PreferenceUtil.getInstance(this).getThemeColorAccent(this);
|
||||
darkTheme = PreferenceUtil.getInstance(this).getGeneralTheme() == R.style.Theme_MaterialMusic;
|
||||
coloredNavigationBar = PreferenceUtil.getInstance(this).shouldUseColoredNavigationBar();
|
||||
|
||||
ThemeSingleton.get().positiveColor = colorAccent;
|
||||
ThemeSingleton.get().negativeColor = colorAccent;
|
||||
|
|
@ -64,7 +66,8 @@ public abstract class AbsThemeActivity extends AppCompatActivity implements KabV
|
|||
}
|
||||
|
||||
private boolean didThemeChanged() {
|
||||
return colorPrimary != PreferenceUtil.getInstance(this).getThemeColorPrimary(this) ||
|
||||
return coloredNavigationBar != PreferenceUtil.getInstance(this).shouldUseColoredNavigationBar() ||
|
||||
colorPrimary != PreferenceUtil.getInstance(this).getThemeColorPrimary(this) ||
|
||||
colorAccent != PreferenceUtil.getInstance(this).getThemeColorAccent(this) ||
|
||||
darkTheme != (PreferenceUtil.getInstance(this).getGeneralTheme() == R.style.Theme_MaterialMusic);
|
||||
}
|
||||
|
|
@ -94,6 +97,10 @@ public abstract class AbsThemeActivity extends AppCompatActivity implements KabV
|
|||
return colorAccent;
|
||||
}
|
||||
|
||||
public boolean shouldColorNavigationBar() {
|
||||
return coloredNavigationBar;
|
||||
}
|
||||
|
||||
protected void setStatusBarTransparent() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
Util.setAllowDrawUnderStatusBar(getWindow());
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import com.kabouzeid.gramophone.R;
|
|||
import com.kabouzeid.gramophone.misc.SmallObservableScrollViewCallbacks;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
|
@ -203,7 +202,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
paletteColorPrimary = getThemeColorPrimary();
|
||||
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarTagEditor())
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarColor(paletteColorPrimary);
|
||||
header.setBackgroundColor(paletteColorPrimary);
|
||||
notifyTaskColorChange(paletteColorPrimary);
|
||||
|
|
@ -256,9 +255,9 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
toolbar.setBackgroundColor(paletteColorPrimary);
|
||||
header.setBackgroundColor(paletteColorPrimary);
|
||||
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarTagEditor())
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarColor(paletteColorPrimary);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
}
|
||||
|
||||
protected void dataChanged() {
|
||||
|
|
@ -299,9 +298,9 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
if (vibrantSwatch != null) {
|
||||
paletteColorPrimary = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
||||
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (PreferenceUtil.getInstance(AbsTagEditorActivity.this).coloredNavigationBarTagEditor())
|
||||
if (shouldColorNavigationBar())
|
||||
setNavigationBarColor(paletteColorPrimary);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
header.setBackgroundColor(paletteColorPrimary);
|
||||
notifyTaskColorChange(paletteColorPrimary);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,6 @@ import android.support.annotation.Nullable;
|
|||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.helper.SortOrder;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class PreferenceUtil {
|
||||
public static final String GENERAL_THEME = "general_theme";
|
||||
public static final String DEFAULT_START_PAGE = "default_start_page";
|
||||
|
|
@ -25,13 +22,8 @@ public final class PreferenceUtil {
|
|||
public static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
|
||||
public static final String SONG_SORT_ORDER = "song_sort_order";
|
||||
|
||||
public static final String COLORED_NAVIGATION_BAR = "colored_navigation_bar";
|
||||
public static final String COLORED_NAVIGATION_BAR_ALBUM = "colored_navigation_bar_album";
|
||||
public static final String COLORED_NAVIGATION_BAR_ARTIST = "colored_navigation_bar_artist";
|
||||
public static final String COLORED_NAVIGATION_BAR_CURRENT_PLAYING = "colored_navigation_bar_current_playing";
|
||||
public static final String COLORED_NAVIGATION_BAR_PLAYLIST = "colored_navigation_bar_playlist";
|
||||
public static final String COLORED_NAVIGATION_BAR_TAG_EDITOR = "colored_navigation_bar_tag_editor";
|
||||
public static final String COLORED_NAVIGATION_BAR_OTHER_SCREENS = "colored_navigation_bar_other_screens";
|
||||
// don't use "colored_navigation_bar" key here as this causes a class cast exception for users upgrading from older versions
|
||||
public static final String COLORED_NAVIGATION_BAR = "should_color_navigation_bar";
|
||||
|
||||
public static final String ALBUM_LAYOUT_MODE = "album_layout_mode";
|
||||
public static final String ALBUM_COLORED_FOOTERS = "album_colored_footers";
|
||||
|
|
@ -127,6 +119,17 @@ public final class PreferenceUtil {
|
|||
mPreferences.edit().putInt("accent_color", color).commit();
|
||||
}
|
||||
|
||||
public final boolean shouldUseColoredNavigationBar() {
|
||||
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR, true);
|
||||
}
|
||||
|
||||
@SuppressLint("CommitPrefEdits")
|
||||
public void setColoredNavigationBar(boolean coloredNavigationBar) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(COLORED_NAVIGATION_BAR, coloredNavigationBar);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public final int getDefaultStartPage() {
|
||||
return Integer.parseInt(mPreferences.getString(DEFAULT_START_PAGE, "-1"));
|
||||
}
|
||||
|
|
@ -144,52 +147,7 @@ public final class PreferenceUtil {
|
|||
}
|
||||
|
||||
public final boolean coloredNotification() {
|
||||
return mPreferences.getBoolean(COLORED_NOTIFICATION, false);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarAlbum() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_ALBUM);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarArtist() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_ARTIST);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarCurrentPlaying() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_CURRENT_PLAYING);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarPlaylist() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_PLAYLIST);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarTagEditor() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_TAG_EDITOR);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarOtherScreens() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_OTHER_SCREENS);
|
||||
}
|
||||
|
||||
@SuppressLint("CommitPrefEdits")
|
||||
private boolean coloredNavigationBarFor(String key) {
|
||||
final Set<String> defaultVals = new HashSet<>();
|
||||
defaultVals.add(COLORED_NAVIGATION_BAR_ALBUM);
|
||||
defaultVals.add(COLORED_NAVIGATION_BAR_ARTIST);
|
||||
defaultVals.add(COLORED_NAVIGATION_BAR_CURRENT_PLAYING);
|
||||
defaultVals.add(COLORED_NAVIGATION_BAR_PLAYLIST);
|
||||
defaultVals.add(COLORED_NAVIGATION_BAR_TAG_EDITOR);
|
||||
defaultVals.add(COLORED_NAVIGATION_BAR_OTHER_SCREENS);
|
||||
|
||||
if (!mPreferences.contains(COLORED_NAVIGATION_BAR))
|
||||
mPreferences.edit().putStringSet(COLORED_NAVIGATION_BAR, defaultVals).commit();
|
||||
|
||||
try {
|
||||
//noinspection ConstantConditions
|
||||
return mPreferences.getStringSet(COLORED_NAVIGATION_BAR, defaultVals).contains(key);
|
||||
} catch (NullPointerException e) {
|
||||
return false;
|
||||
}
|
||||
return mPreferences.getBoolean(COLORED_NOTIFICATION, true);
|
||||
}
|
||||
|
||||
public final boolean opaqueStatusbarNowPlaying() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue