add two settings to configure image caching
This commit is contained in:
parent
14e1d9bb80
commit
ee6fd61d43
7 changed files with 93 additions and 0 deletions
|
|
@ -74,6 +74,9 @@
|
|||
<meta-data
|
||||
android:name="com.lge.support.SPLIT_WINDOW"
|
||||
android:value="true" />
|
||||
<meta-data
|
||||
android:name="com.dkanada.gramophone.glide.CustomGlideModule"
|
||||
android:value="GlideModule" />
|
||||
<meta-data
|
||||
android:name="com.bumptech.glide.integration.okhttp3.OkHttpGlideModule"
|
||||
android:value="GlideModule" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.dkanada.gramophone.glide;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.GlideBuilder;
|
||||
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
|
||||
import com.bumptech.glide.module.GlideModule;
|
||||
import com.dkanada.gramophone.App;
|
||||
import com.dkanada.gramophone.util.PreferenceUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CustomGlideModule implements GlideModule {
|
||||
@Override
|
||||
public void applyOptions(Context context, GlideBuilder builder) {
|
||||
builder.setDiskCache(new DiskLruCacheFactory(new DiskLruCacheFactory.CacheDirectoryGetter() {
|
||||
@Override
|
||||
public File getCacheDirectory() {
|
||||
String folder = "/Gelli/images";
|
||||
return PreferenceUtil.getInstance(App.getInstance()).getImagesExternalDirectory()
|
||||
? new File(Environment.getExternalStorageDirectory() + folder)
|
||||
: new File(App.getInstance().getApplicationInfo().dataDir + folder);
|
||||
}
|
||||
}, PreferenceUtil.getInstance(App.getInstance()).getImagesCacheSize()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerComponents(Context context, Glide glide) {
|
||||
}
|
||||
}
|
||||
|
|
@ -121,6 +121,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
addPreferencesFromResource(R.xml.pref_now_playing_screen);
|
||||
addPreferencesFromResource(R.xml.pref_lockscreen);
|
||||
addPreferencesFromResource(R.xml.pref_audio);
|
||||
addPreferencesFromResource(R.xml.pref_images);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ public final class PreferenceUtil {
|
|||
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 SLEEP_TIMER_LAST_VALUE = "sleep_timer_last_value";
|
||||
public static final String SLEEP_TIMER_ELAPSED_REALTIME = "sleep_timer_elapsed_real_time";
|
||||
public static final String SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_music";
|
||||
|
|
@ -118,6 +121,14 @@ public final class PreferenceUtil {
|
|||
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 getLastTab() {
|
||||
return mPreferences.getInt(LAST_TAB, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,4 +52,20 @@
|
|||
<item>100</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_images_cache_size_titles">
|
||||
<item>@string/unlimited</item>
|
||||
<item>2GB</item>
|
||||
<item>1GB</item>
|
||||
<item>400MB</item>
|
||||
<item>200MB</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_images_cache_size_values">
|
||||
<item>10000000000</item>
|
||||
<item>2000000000</item>
|
||||
<item>1000000000</item>
|
||||
<item>400000000</item>
|
||||
<item>200000000</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@
|
|||
<string name="pref_header_colors">Colors</string>
|
||||
<string name="pref_header_now_playing_screen">Now Playing</string>
|
||||
<string name="pref_header_audio">Audio</string>
|
||||
<string name="pref_header_images">Images</string>
|
||||
<string name="pref_header_library">Library</string>
|
||||
<string name="pref_header_lockscreen">Lockscreen</string>
|
||||
<string name="pref_header_notification">Notification</string>
|
||||
|
|
@ -116,6 +117,9 @@
|
|||
<string name="pref_title_remember_shuffle">Remember Shuffle</string>
|
||||
<string name="pref_title_remember_queue">Remember Queue</string>
|
||||
<string name="pref_title_maximum_list_size">Maximum List Size</string>
|
||||
<string name="pref_title_images_cache_size">Cache Size</string>
|
||||
<string name="pref_title_images_external_directory">External Directory</string>
|
||||
<string name="pref_summary_images_external_directory">Store the image cache in an external directory to keep the files between installs.</string>
|
||||
<string name="primary_color_desc">The primary theme color for control elements.</string>
|
||||
<string name="accent_color_desc">An alternate color used to accent elements.</string>
|
||||
<string name="pref_summary_album_art_on_lockscreen">Uses the current song\'s album cover as the lockscreen wallpaper.</string>
|
||||
|
|
|
|||
26
app/src/main/res/xml/pref_images.xml
Normal file
26
app/src/main/res/xml/pref_images.xml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?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_images">
|
||||
|
||||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="400000000"
|
||||
android:entries="@array/pref_images_cache_size_titles"
|
||||
android:entryValues="@array/pref_images_cache_size_values"
|
||||
android:key="images_cache_size"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="@string/pref_title_images_cache_size" />
|
||||
|
||||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="false"
|
||||
android:key="images_external_directory"
|
||||
android:summary="@string/pref_summary_images_external_directory"
|
||||
android:title="@string/pref_title_images_external_directory" />
|
||||
|
||||
</com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
Loading…
Add table
Add a link
Reference in a new issue