rework a lot of preferences
This commit is contained in:
parent
491b01406a
commit
5346c66f9a
14 changed files with 61 additions and 70 deletions
|
|
@ -19,11 +19,11 @@ public class CustomGlideModule implements GlideModule {
|
|||
@Override
|
||||
public File getCacheDirectory() {
|
||||
String folder = "/Gelli/images";
|
||||
return PreferenceUtil.getInstance(App.getInstance()).getImagesExternalDirectory()
|
||||
return PreferenceUtil.getInstance(App.getInstance()).getExternalDirectory()
|
||||
? new File(Environment.getExternalStorageDirectory() + folder)
|
||||
: new File(App.getInstance().getApplicationInfo().dataDir + folder);
|
||||
}
|
||||
}, PreferenceUtil.getInstance(App.getInstance()).getImagesCacheSize()));
|
||||
}, PreferenceUtil.getInstance(App.getInstance()).getCacheSize()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ public class SearchActivity extends AbsMusicServiceActivity implements SearchVie
|
|||
|
||||
private void search(@NonNull String query) {
|
||||
this.query = query;
|
||||
|
||||
ItemQuery itemQuery = new ItemQuery();
|
||||
itemQuery.setSearchTerm(query);
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
|
@ -108,8 +109,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
if (preference instanceof ListPreference) {
|
||||
ListPreference listPreference = (ListPreference) preference;
|
||||
int index = listPreference.findIndexOfValue(stringValue);
|
||||
preference.setSummary(
|
||||
index >= 0 ? listPreference.getEntries()[index] : null);
|
||||
preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
|
||||
} else {
|
||||
preference.setSummary(stringValue);
|
||||
}
|
||||
|
|
@ -124,7 +124,6 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
addPreferencesFromResource(R.xml.pref_lockscreen);
|
||||
addPreferencesFromResource(R.xml.pref_audio);
|
||||
addPreferencesFromResource(R.xml.pref_images);
|
||||
addPreferencesFromResource(R.xml.pref_direct_play);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
@ -164,7 +163,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
|
||||
ThemeStore.markChanged(getActivity());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
// Set the new theme so that updateAppShortcuts can pull it
|
||||
// set the new theme so that updateAppShortcuts can pull it
|
||||
getActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue(themeName));
|
||||
new DynamicShortcutManager(getActivity()).updateDynamicShortcuts();
|
||||
}
|
||||
|
|
@ -173,7 +172,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
return true;
|
||||
});
|
||||
|
||||
final ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference("primary_color");
|
||||
final ATEColorPreference primaryColorPref = findPreference(PreferenceUtil.PRIMARY_COLOR);
|
||||
final int primaryColor = ThemeStore.primaryColor(getActivity());
|
||||
primaryColorPref.setColor(primaryColor, ColorUtil.darkenColor(primaryColor));
|
||||
primaryColorPref.setOnPreferenceClickListener(preference -> {
|
||||
|
|
@ -186,7 +185,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
return true;
|
||||
});
|
||||
|
||||
final ATEColorPreference accentColorPref = (ATEColorPreference) findPreference("accent_color");
|
||||
final ATEColorPreference accentColorPref = findPreference(PreferenceUtil.ACCENT_COLOR);
|
||||
final int accentColor = ThemeStore.accentColor(getActivity());
|
||||
accentColorPref.setColor(accentColor, ColorUtil.darkenColor(accentColor));
|
||||
accentColorPref.setOnPreferenceClickListener(preference -> {
|
||||
|
|
@ -199,7 +198,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
return true;
|
||||
});
|
||||
|
||||
TwoStatePreference colorNavBar = (TwoStatePreference) findPreference(PreferenceUtil.COLORED_NAVIGATION_BAR);
|
||||
TwoStatePreference colorNavBar = findPreference(PreferenceUtil.COLORED_NAVIGATION_BAR);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
colorNavBar.setVisible(false);
|
||||
} else {
|
||||
|
|
@ -213,42 +212,38 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
});
|
||||
}
|
||||
|
||||
final TwoStatePreference classicNotification = (TwoStatePreference) findPreference(PreferenceUtil.CLASSIC_NOTIFICATION);
|
||||
final TwoStatePreference classicNotification = findPreference(PreferenceUtil.CLASSIC_NOTIFICATION);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
classicNotification.setVisible(false);
|
||||
} else {
|
||||
classicNotification.setChecked(PreferenceUtil.getInstance(getActivity()).getClassicNotification());
|
||||
classicNotification.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
// Save preference
|
||||
PreferenceUtil.getInstance(getActivity()).setClassicNotification((Boolean) newValue);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
final TwoStatePreference coloredNotification = (TwoStatePreference) findPreference(PreferenceUtil.COLORED_NOTIFICATION);
|
||||
final TwoStatePreference coloredNotification = findPreference(PreferenceUtil.COLORED_NOTIFICATION);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
coloredNotification.setEnabled(PreferenceUtil.getInstance(getActivity()).getClassicNotification());
|
||||
} else {
|
||||
coloredNotification.setChecked(PreferenceUtil.getInstance(getActivity()).getColoredNotification());
|
||||
coloredNotification.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
// Save preference
|
||||
PreferenceUtil.getInstance(getActivity()).setColoredNotification((Boolean) newValue);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
final TwoStatePreference colorAppShortcuts = (TwoStatePreference) findPreference("should_color_app_shortcuts");
|
||||
final TwoStatePreference colorAppShortcuts = findPreference(PreferenceUtil.COLORED_SHORTCUTS);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
|
||||
colorAppShortcuts.setVisible(false);
|
||||
} else {
|
||||
colorAppShortcuts.setChecked(PreferenceUtil.getInstance(getActivity()).getColoredShortcuts());
|
||||
colorAppShortcuts.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
// Save preference
|
||||
PreferenceUtil.getInstance(getActivity()).setColoredShortcuts((Boolean) newValue);
|
||||
|
||||
// Update app shortcuts
|
||||
// update app shortcuts
|
||||
new DynamicShortcutManager(getActivity()).updateDynamicShortcuts();
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public abstract class AbsLibraryPagerRecyclerViewFragment<A extends RecyclerView
|
|||
last = layoutManager.findLastVisibleItemPosition();
|
||||
}
|
||||
|
||||
int page = PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize();
|
||||
int page = PreferenceUtil.getInstance(App.getInstance()).getPageSize();
|
||||
int total = getAdapter().getItemCount();
|
||||
if (last > total - page / 2 && total < size) {
|
||||
query = createQuery();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class AlbumsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFra
|
|||
query.setIncludeItemTypes(new String[]{"MusicAlbum"});
|
||||
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||
query.setRecursive(true);
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize());
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getPageSize());
|
||||
query.setStartIndex(getAdapter().getItemCount());
|
||||
query.setParentId(QueryUtil.currentLibrary.getId());
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class ArtistsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFr
|
|||
query.setFields(new ItemFields[]{ItemFields.Genres});
|
||||
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||
query.setRecursive(true);
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize());
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getPageSize());
|
||||
query.setStartIndex(getAdapter().getItemCount());
|
||||
query.setParentId(QueryUtil.currentLibrary.getId());
|
||||
|
||||
|
|
@ -112,7 +112,6 @@ public class ArtistsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFr
|
|||
|
||||
@Override
|
||||
protected String loadSortOrder() {
|
||||
// TODO check artist support
|
||||
return SortOrder.ASCENDING;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class GenresFragment extends AbsLibraryPagerRecyclerViewFragment<GenreAda
|
|||
|
||||
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||
query.setRecursive(true);
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize());
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getPageSize());
|
||||
query.setStartIndex(getAdapter().getItemCount());
|
||||
query.setParentId(QueryUtil.currentLibrary.getId());
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class PlaylistsFragment extends AbsLibraryPagerRecyclerViewFragment<Playl
|
|||
query.setIncludeItemTypes(new String[]{"Playlist"});
|
||||
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||
query.setRecursive(true);
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize());
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getPageSize());
|
||||
query.setStartIndex(getAdapter().getItemCount());
|
||||
query.setParentId(QueryUtil.currentLibrary.getId());
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class SongsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFrag
|
|||
query.setFields(new ItemFields[]{ItemFields.MediaSources});
|
||||
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||
query.setRecursive(true);
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize());
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getPageSize());
|
||||
query.setStartIndex(getAdapter().getItemCount());
|
||||
query.setParentId(QueryUtil.currentLibrary.getId());
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ import com.dkanada.gramophone.model.CategoryInfo;
|
|||
import com.dkanada.gramophone.model.DirectPlayCodec;
|
||||
import com.dkanada.gramophone.ui.fragments.player.NowPlayingScreen;
|
||||
|
||||
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -25,9 +27,9 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
public final class PreferenceUtil {
|
||||
public static final String CATEGORIES = "library_categories";
|
||||
public static final String DIRECT_PLAY_CODECS = "direct_play_codecs";
|
||||
public static final String MAXIMUM_LIST_SIZE = "maximum_list_size";
|
||||
public static final String LIBRARIES = "libraries";
|
||||
public static final String CATEGORIES = "categories";
|
||||
public static final String PAGE_SIZE = "page_size";
|
||||
public static final String REMEMBER_LAST_TAB = "remember_last_tab";
|
||||
public static final String LAST_TAB = "last_tab";
|
||||
|
||||
|
|
@ -54,7 +56,9 @@ public final class PreferenceUtil {
|
|||
public static final String ALBUM_ARTIST_COLORED_FOOTERS = "album_artist_colored_footers";
|
||||
|
||||
public static final String GENERAL_THEME = "general_theme";
|
||||
public static final String COLORED_NAVIGATION_BAR = "should_color_navigation_bar";
|
||||
public static final String PRIMARY_COLOR = "primary_color";
|
||||
public static final String ACCENT_COLOR = "accent_color";
|
||||
public static final String COLORED_NAVIGATION_BAR = "colored_navigation_bar";
|
||||
public static final String COLORED_SHORTCUTS = "colored_shortcuts";
|
||||
|
||||
public static final String CLASSIC_NOTIFICATION = "classic_notification";
|
||||
|
|
@ -64,13 +68,14 @@ public final class PreferenceUtil {
|
|||
public static final String BLUR_ALBUM_COVER = "blur_album_cover";
|
||||
|
||||
public static final String TRANSCODE_CODEC = "transcode_codec";
|
||||
public static final String DIRECT_PLAY_CODECS = "direct_play_codecs";
|
||||
public static final String MAXIMUM_BITRATE = "maximum_bitrate";
|
||||
public static final String AUDIO_DUCKING = "audio_ducking";
|
||||
public static final String REMEMBER_SHUFFLE = "remember_shuffle";
|
||||
public static final String REMEMBER_QUEUE = "remember_queue";
|
||||
|
||||
public static final String IMAGES_CACHE_SIZE = "images_cache_size";
|
||||
public static final String IMAGES_EXTERNAL_DIRECTORY = "images_external_directory";
|
||||
public static final String CACHE_SIZE = "cache_size";
|
||||
public static final String EXTERNAL_DIRECTORY = "external_directory";
|
||||
|
||||
public static final String SLEEP_TIMER_LAST_VALUE = "sleep_timer_last_value";
|
||||
public static final String SLEEP_TIMER_ELAPSED_REALTIME = "sleep_timer_elapsed_real_time";
|
||||
|
|
@ -122,16 +127,8 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getBoolean(REMEMBER_LAST_TAB, true);
|
||||
}
|
||||
|
||||
public final int getMaximumListSize() {
|
||||
return Integer.parseInt(mPreferences.getString(MAXIMUM_LIST_SIZE, "100"));
|
||||
}
|
||||
|
||||
public final int getImagesCacheSize() {
|
||||
return Integer.parseInt(mPreferences.getString(IMAGES_CACHE_SIZE, "400000000"));
|
||||
}
|
||||
|
||||
public final boolean getImagesExternalDirectory() {
|
||||
return mPreferences.getBoolean(IMAGES_EXTERNAL_DIRECTORY, false);
|
||||
public final int getPageSize() {
|
||||
return Integer.parseInt(mPreferences.getString(PAGE_SIZE, "100"));
|
||||
}
|
||||
|
||||
public final int getLastTab() {
|
||||
|
|
@ -357,16 +354,6 @@ public final class PreferenceUtil {
|
|||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean getAlbumArtistColoredFooters() {
|
||||
return mPreferences.getBoolean(ALBUM_ARTIST_COLORED_FOOTERS, true);
|
||||
}
|
||||
|
||||
public void setAlbumArtistColoredFooters(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(ALBUM_ARTIST_COLORED_FOOTERS, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean getSongColoredFooters() {
|
||||
return mPreferences.getBoolean(SONG_COLORED_FOOTERS, true);
|
||||
}
|
||||
|
|
@ -387,6 +374,24 @@ public final class PreferenceUtil {
|
|||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean getAlbumArtistColoredFooters() {
|
||||
return mPreferences.getBoolean(ALBUM_ARTIST_COLORED_FOOTERS, true);
|
||||
}
|
||||
|
||||
public void setAlbumArtistColoredFooters(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(ALBUM_ARTIST_COLORED_FOOTERS, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final int getCacheSize() {
|
||||
return Integer.parseInt(mPreferences.getString(CACHE_SIZE, "400000000"));
|
||||
}
|
||||
|
||||
public final boolean getExternalDirectory() {
|
||||
return mPreferences.getBoolean(EXTERNAL_DIRECTORY, false);
|
||||
}
|
||||
|
||||
public List<CategoryInfo> getCategories() {
|
||||
String data = mPreferences.getString(CATEGORIES, null);
|
||||
if (data != null) {
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public class QueryUtil {
|
|||
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||
query.setRecursive(true);
|
||||
if (query.getParentId() == null && query.getArtistIds().length == 0) {
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize());
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getPageSize());
|
||||
}
|
||||
|
||||
if (currentLibrary == null || query.getParentId() != null) return;
|
||||
|
|
@ -200,7 +200,7 @@ public class QueryUtil {
|
|||
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||
query.setRecursive(true);
|
||||
if (query.getParentId() == null) {
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize());
|
||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getPageSize());
|
||||
}
|
||||
|
||||
if (currentLibrary == null || query.getParentId() != null) return;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@
|
|||
android:positiveButtonText="@null"
|
||||
android:title="@string/pref_title_transcode_codec" />
|
||||
|
||||
<com.dkanada.gramophone.preferences.DirectPlayPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:key="direct_play_codecs"
|
||||
android:summary="@string/pref_summary_direct_play_codecs"
|
||||
android:title="@string/direct_play_codecs" />
|
||||
|
||||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="10000000"
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
|
||||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="false"
|
||||
android:key="should_color_navigation_bar"
|
||||
android:defaultValue="true"
|
||||
android:key="colored_navigation_bar"
|
||||
android:persistent="false"
|
||||
android:summary="@string/pref_summary_colored_navigation_bar"
|
||||
android:title="@string/pref_title_navigation_bar" />
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="true"
|
||||
android:key="should_color_app_shortcuts"
|
||||
android:key="colored_shortcuts"
|
||||
android:summary="@string/pref_summary_colored_app_shortcuts"
|
||||
android:title="@string/pref_title_app_shortcuts" />
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_directplay">
|
||||
|
||||
<com.dkanada.gramophone.preferences.DirectPlayPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:key="direct_play_codecs"
|
||||
android:summary="@string/pref_summary_direct_play_codecs"
|
||||
android:title="@string/direct_play_codecs" />
|
||||
|
||||
</com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
Loading…
Add table
Add a link
Reference in a new issue