- PR [#1100](https://github.com/owncloud/android/pull/1100) "Material FAB with speed dial implementation" merged
- PR [#1209](https://github.com/owncloud/android/pull/1209) "Material buttons - before in #1090" merged
- PR [#1205](https://github.com/owncloud/android/pull/1205) "Switch between online and offline files" merged
+- PR [#1195](https://github.com/owncloud/android/pull/1195) "Resize Cache" merged
# 2015-10-26
<string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
<string name="action_switch_grid_view">Switch to grid view</string>
<string name="action_switch_list_view">Switch to list view</string>
+ <string name="common_category">Common</string>
+ <string name="pref_cache_size">Cache size</string>
+
</resources>
<Preference android:key="log_history"
android:title="@string/prefs_log_title_history"
android:summary="@string/prefs_log_summary_history"/ -->
- <Preference android:title="@string/prefs_help" android:key="help" />
- <Preference android:title="@string/prefs_recommend" android:key="recommend" />
- <Preference android:title="@string/prefs_feedback" android:key="feedback" />
- <Preference android:title="@string/prefs_imprint" android:key="imprint" />
+
+ </PreferenceCategory>
+
+ <PreferenceCategory android:title="@string/common_category" android:key="common_category">
+ <EditTextPreference android:title="@string/pref_cache_size"
+ android:key="pref_cache_size"
+ android:digits="0123456789"/>
+ </PreferenceCategory>
- <Preference android:id="@+id/about_app"
- android:title="@string/about_title"
- android:key="about_app" />
+ <PreferenceCategory android:title="@string/prefs_category_more" android:key="more">
+ <Preference android:title="@string/prefs_help" android:key="help" />
+ <Preference android:title="@string/prefs_recommend" android:key="recommend" />
+ <Preference android:title="@string/prefs_feedback" android:key="feedback" />
+ <Preference android:title="@string/prefs_imprint" android:key="imprint" />
+
+ <Preference android:id="@+id/about_app"
+ android:title="@string/about_title"
+ android:key="about_app" />
</PreferenceCategory>
return null;
}
+ /**
+ * Sets max size of cache
+ * @param maxSize in MB
+ * @return
+ */
+ public static boolean setMaxSize(long maxSize){
+ if (mThumbnailCache != null){
+ mThumbnailCache.setMaxSize(maxSize * 1024 * 1024);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static long getMaxSize(){
+ if (mThumbnailCache != null) {
+ return mThumbnailCache.getMaxSize();
+ } else {
+ return -1l;
+ }
+ }
+
public static class ThumbnailGenerationTask extends AsyncTask<Object, Void, Bitmap> {
private final WeakReference<ImageView> mImageViewReference;
private WeakReference<ProgressBar> mProgressWheelRef;
import com.owncloud.android.authentication.AuthenticatorActivity;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.db.DbHandler;
import com.owncloud.android.files.FileOperationsHelper;
import com.owncloud.android.files.services.FileDownloader;
}
+ final Preference pCacheSize = findPreference("pref_cache_size");
+ if (pCacheSize != null){
+ final SharedPreferences appPrefs =
+ PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ Long cacheSize = ThumbnailsCacheManager.getMaxSize();
+ pCacheSize.setSummary(cacheSize + " Mb");
+ pCacheSize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Long size = Long.decode((String) newValue);
+ if (ThumbnailsCacheManager.setMaxSize(size)){
+ appPrefs.edit().putString("pref_cache_size", size.toString());
+ pCacheSize.setSummary(size + " MB");
+ return true;
+ } else {
+ return false;
+ }
+ }
+ });
+ }
+
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("more");
boolean helpEnabled = getResources().getBoolean(R.bool.help_enabled);
e.printStackTrace();
}
}
+
+ public void setMaxSize(long maxSize){
+ mDiskCache.setMaxSize(maxSize);
+ }
+
+ public long getMaxSize(){
+ return mDiskCache.getMaxSize();
+ }
}
\ No newline at end of file