<string name="file_list__footer__files">%1$d files</string>
<string name="file_list__footer__files_and_folder">%1$d files, 1 folder</string>
<string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
+ <string name="common_category">Common</string>
+ <string name="pref_cache_size">Cache size</string>
<string name="share_dialog_title">Sharing</string>
<string name="share_with_user_section_title">Share with Users and Groups</string>
android:summary="@string/prefs_log_summary_history"/ -->
</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>
+
<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" />
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;
+ }
+ }
+
+ /**
+ * Shows max cache size
+ * @return max cache size in MB.
+ */
+ public static long getMaxSize(){
+ if (mThumbnailCache != null) {
+ return mThumbnailCache.getMaxSize() / 1024 / 1024;
+ } else {
+ return -1l;
+ }
+ }
+
public static class ThumbnailGenerationTask extends AsyncTask<Object, Void, Bitmap> {
private final WeakReference<ImageView> mImageViewReference;
private static Account mAccount;
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