Massiv design optimizations and settings
This commit is contained in:
parent
2ae6dd8c91
commit
b302abc2e1
117 changed files with 1104 additions and 962 deletions
|
|
@ -4,13 +4,20 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
|
||||
public final class PreferenceUtils {
|
||||
|
||||
/* Default start page (Artist page) */
|
||||
public static final int DEFAULT_PAGE = 2;
|
||||
/* Default start page (Album page) */
|
||||
public static final int DEFAULT_PAGE = 1;
|
||||
|
||||
/* Saves the last page the pager was on in {@link MusicBrowserPhoneFragment} */
|
||||
public static final String START_PAGE = "start_page";
|
||||
public static final String GENERAL_THEME = "general_theme";
|
||||
|
||||
/* Saves the last page the pager was on in {@link MainActivity} */
|
||||
public static final String DEFAULT_START_PAGE = "default_start_page";
|
||||
|
||||
/* Saves the last page the pager was on in {@link MainActivity} */
|
||||
public static final String LAST_START_PAGE = "last_start_page";
|
||||
|
||||
// Sort order for the artist list
|
||||
public static final String ARTIST_SORT_ORDER = "artist_sort_order";
|
||||
|
|
@ -31,10 +38,25 @@ public final class PreferenceUtils {
|
|||
public static final String SONG_SORT_ORDER = "song_sort_order";
|
||||
|
||||
// Key used to download images only on Wi-Fi
|
||||
public static final String ONLY_ON_WIFI = "only_on_wifi";
|
||||
public static final String ONLY_ON_WIFI = "auto_download_artist_images";
|
||||
|
||||
// Key that gives permissions to download missing artist images
|
||||
public static final String DOWNLOAD_MISSING_ARTIST_IMAGES = "download_missing_artist_images";
|
||||
public static final String DOWNLOAD_MISSING_ARTIST_IMAGES = "auto_download_artist_images";
|
||||
|
||||
// Key used to en or disable palette
|
||||
public static final String COLORED_ALBUM_FOOTERS = "colored_album_footers";
|
||||
|
||||
// Key used to en or disable the colored navigation bar
|
||||
public static final String COLORED_NAVIGATION_BAR_ALBUM = "colored_navigation_bar_album";
|
||||
|
||||
// Key used to en or disable the colored navigation bar
|
||||
public static final String COLORED_NAVIGATION_BAR_ARTIST = "colored_navigation_bar_artist";
|
||||
|
||||
// Key used to en or disable the colored navigation bar
|
||||
public static final String COLORED_NAVIGATION_BAR_CURRENT_PLAYING = "colored_navigation_bar_current_playing_enabled";
|
||||
|
||||
// Key used to en or disable the colored navigation bar
|
||||
public static final String PLAYBACK_CONTROLLER_BOX = "playback_controller_card";
|
||||
|
||||
private static PreferenceUtils sInstance;
|
||||
|
||||
|
|
@ -44,33 +66,122 @@ public final class PreferenceUtils {
|
|||
mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
public static final PreferenceUtils getInstace(final Context context) {
|
||||
public static final PreferenceUtils getInstance(final Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new PreferenceUtils(context.getApplicationContext());
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void setStartPage(final int value) {
|
||||
public int getGeneralTheme() {
|
||||
int value = Integer.parseInt(mPreferences.getString(GENERAL_THEME, "1"));
|
||||
switch (value){
|
||||
case 0:
|
||||
return R.style.Theme_MaterialMusic_Light;
|
||||
case 1:
|
||||
return R.style.Theme_MaterialMusic;
|
||||
}
|
||||
return R.style.Theme_MaterialMusic;
|
||||
}
|
||||
|
||||
public void setGeneralTheme(int appTheme) {
|
||||
int value = -1;
|
||||
switch (appTheme) {
|
||||
case R.style.Theme_MaterialMusic_Light:
|
||||
value = 0;
|
||||
break;
|
||||
case R.style.Theme_MaterialMusic:
|
||||
value = 1;
|
||||
break;
|
||||
}
|
||||
if (value != 0 && value != 1) {
|
||||
return;
|
||||
}
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putInt(START_PAGE, value);
|
||||
editor.putString(GENERAL_THEME, String.valueOf(value));
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final int getStartPage() {
|
||||
return mPreferences.getInt(START_PAGE, DEFAULT_PAGE);
|
||||
public void setDefaultStartPage(final int value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putString(DEFAULT_START_PAGE, String.valueOf(value));
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean onlyOnWifi() {
|
||||
return mPreferences.getBoolean(ONLY_ON_WIFI, true);
|
||||
public final int getDefaultStartPage() {
|
||||
return Integer.parseInt(mPreferences.getString(DEFAULT_START_PAGE, "-1"));
|
||||
}
|
||||
|
||||
public void setOnlyOnWifi(final boolean value) {
|
||||
public void setLastStartPage(final int value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putInt(LAST_START_PAGE, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final int getLastStartPage() {
|
||||
return mPreferences.getInt(LAST_START_PAGE, DEFAULT_PAGE);
|
||||
}
|
||||
|
||||
public final boolean autoDownloadOnlyOnWifi() {
|
||||
return mPreferences.getBoolean(ONLY_ON_WIFI, false);
|
||||
}
|
||||
|
||||
public void setAutoDownloadOnlyOnWifi(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(ONLY_ON_WIFI, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean coloredAlbumFootersEnabled() {
|
||||
return mPreferences.getBoolean(COLORED_ALBUM_FOOTERS, true);
|
||||
}
|
||||
|
||||
public void setColoredAlbumFootersEnabled(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(COLORED_ALBUM_FOOTERS, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarAlbumEnabled() {
|
||||
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR_ALBUM, true);
|
||||
}
|
||||
|
||||
public void setColoredNavigationBarAlbumEnabled(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(COLORED_NAVIGATION_BAR_ALBUM, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarArtistEnabled() {
|
||||
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR_ARTIST, true);
|
||||
}
|
||||
|
||||
public void setColoredNavigationBarArtistEnabled(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(COLORED_NAVIGATION_BAR_ARTIST, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarCurrentPlayingEnabled() {
|
||||
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR_CURRENT_PLAYING, true);
|
||||
}
|
||||
|
||||
public void setColoredNavigationBarCurrentPlayingEnabled(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(COLORED_NAVIGATION_BAR_CURRENT_PLAYING, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean playbackControllerBoxEnabled() {
|
||||
return mPreferences.getBoolean(PLAYBACK_CONTROLLER_BOX, true);
|
||||
}
|
||||
|
||||
public void setPlaybackControllerBoxEnabled(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(PLAYBACK_CONTROLLER_BOX, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean downloadMissingArtistImages() {
|
||||
return mPreferences.getBoolean(DOWNLOAD_MISSING_ARTIST_IMAGES, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,18 @@ import android.annotation.TargetApi;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
|
@ -35,7 +39,7 @@ public class Util {
|
|||
|
||||
public static int resolveColor(Context context, int color) {
|
||||
TypedArray a = context.obtainStyledAttributes(new int[]{color});
|
||||
int resId = a.getColor(0, context.getResources().getColor(R.color.materialmusic_color));
|
||||
int resId = a.getColor(0, 0);
|
||||
a.recycle();
|
||||
return resId;
|
||||
}
|
||||
|
|
@ -115,7 +119,7 @@ public class Util {
|
|||
}
|
||||
|
||||
boolean state = false;
|
||||
final boolean onlyOnWifi = PreferenceUtils.getInstace(context).onlyOnWifi();
|
||||
final boolean onlyOnWifi = PreferenceUtils.getInstance(context).autoDownloadOnlyOnWifi();
|
||||
|
||||
/* Monitor network connections */
|
||||
final ConnectivityManager connectivityManager = (ConnectivityManager) context
|
||||
|
|
@ -196,4 +200,12 @@ public class Util {
|
|||
public static boolean isInPortraitMode(final Context context) {
|
||||
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
|
||||
}
|
||||
|
||||
public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, int color) {
|
||||
Drawable drawable = res.getDrawable(drawableResId);
|
||||
if (drawable != null) {
|
||||
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
return drawable;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue