Merge branch 'beta' of github.com:owncloud/android into beta
authortobiasKaminsky <tobias@kaminsky.me>
Sun, 29 Nov 2015 19:12:20 +0000 (20:12 +0100)
committertobiasKaminsky <tobias@kaminsky.me>
Sun, 29 Nov 2015 19:12:20 +0000 (20:12 +0100)
AndroidManifest.xml
android-release.apk [new file with mode: 0644]
apks/latest
apks/owncloud-beta-20151120.apk [deleted file]
apks/owncloud-beta-20151129.apk [new file with mode: 0644]
build.gradle
src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
src/com/owncloud/android/ui/activity/Preferences.java

index a1fb074..aef1bc6 100644 (file)
@@ -18,8 +18,9 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -->
 <manifest package="com.owncloud.android"
-    android:versionCode="20151128"
-    android:versionName="ownCloud beta" xmlns:android="http://schemas.android.com/apk/res/android">
+    android:versionCode="20151129"
+    android:versionName="20151129"
+    xmlns:android="http://schemas.android.com/apk/res/android">
 
     <uses-sdk
         android:minSdkVersion="14"
diff --git a/android-release.apk b/android-release.apk
new file mode 100644 (file)
index 0000000..570f4db
Binary files /dev/null and b/android-release.apk differ
index 6317405..79b90d0 100644 (file)
@@ -1 +1 @@
-20151128
+20151129
diff --git a/apks/owncloud-beta-20151120.apk b/apks/owncloud-beta-20151120.apk
deleted file mode 100644 (file)
index 056d0ec..0000000
Binary files a/apks/owncloud-beta-20151120.apk and /dev/null differ
diff --git a/apks/owncloud-beta-20151129.apk b/apks/owncloud-beta-20151129.apk
new file mode 100644 (file)
index 0000000..271ec0d
Binary files /dev/null and b/apks/owncloud-beta-20151129.apk differ
index 8c68fa7..635cf8a 100644 (file)
@@ -36,7 +36,7 @@ android {
 
     defaultConfig {
         applicationId "com.owncloud.android.beta"
-        versionCode 20151128
+        versionCode 20151129
         versionName "ownCloud beta"
     }
 
index 8c36fa2..b9087bc 100644 (file)
@@ -33,6 +33,7 @@ import org.apache.commons.httpclient.methods.GetMethod;
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.content.Context;
+import android.content.SharedPreferences;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.CompressFormat;
@@ -47,6 +48,7 @@ import android.graphics.drawable.Drawable;
 import android.media.ThumbnailUtils;
 import android.net.Uri;
 import android.os.AsyncTask;
+import android.preference.PreferenceManager;
 import android.view.Display;
 import android.view.View;
 import android.view.WindowManager;
@@ -74,12 +76,12 @@ public class ThumbnailsCacheManager {
     private static final String TAG = ThumbnailsCacheManager.class.getSimpleName();
     
     private static final String CACHE_FOLDER = "thumbnailCache";
+    private static final Integer CACHE_SIZE_MB = 10;
 
     private static final Object mThumbnailsDiskCacheLock = new Object();
     private static DiskLruImageCache mThumbnailCache = null;
     private static boolean mThumbnailCacheStarting = true;
     
-    private static final int DISK_CACHE_SIZE = 1024 * 1024 * 10; // 10MB
     private static final CompressFormat mCompressFormat = CompressFormat.JPEG;
     private static final int mCompressQuality = 70;
     private static OwnCloudClient mClient = null;
@@ -100,6 +102,18 @@ public class ThumbnailsCacheManager {
 
                 if (mThumbnailCache == null) {
                     try {
+                        SharedPreferences appPrefs =
+                                PreferenceManager.getDefaultSharedPreferences(MainApp.getAppContext());
+                        // due to backward compatibility
+                        Integer cacheSize = CACHE_SIZE_MB * 1024 * 1024;
+                        try {
+                            cacheSize = appPrefs.getInt("pref_cache_size", cacheSize);
+                        } catch (ClassCastException e) {
+                            String temp = appPrefs.getString("pref_cache_size",
+                                    cacheSize.toString());
+                            cacheSize = Integer.decode(temp) * 1024 * 1024;
+                        }
+
                         // Check if media is mounted or storage is built-in, if so, 
                         // try and use external cache dir; otherwise use internal cache dir
                         final String cachePath = 
@@ -109,7 +123,7 @@ public class ThumbnailsCacheManager {
                         final File diskCacheDir = new File(cachePath);
                         mThumbnailCache = new DiskLruImageCache(
                                 diskCacheDir, 
-                                DISK_CACHE_SIZE, 
+                                cacheSize,
                                 mCompressFormat, 
                                 mCompressQuality
                         );
@@ -171,11 +185,10 @@ public class ThumbnailsCacheManager {
      * @return max cache size in MB.
      */
     public static long getMaxSize(){
-        if (mThumbnailCache != null) {
-            return mThumbnailCache.getMaxSize() / 1024 / 1024;
-        } else {
-            return -1l;
+        if (mThumbnailCache == null) {
+            new ThumbnailsCacheManager.InitDiskCacheTask().execute();
         }
+        return mThumbnailCache.getMaxSize() / 1024 / 1024;
     }
 
     public static class ThumbnailGenerationTask extends AsyncTask<Object, Void, Bitmap> {
index 863a0e4..61b4702 100644 (file)
@@ -270,9 +270,9 @@ public class Preferences extends PreferenceActivity
             pCacheSize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
                 @Override
                 public boolean onPreferenceChange(Preference preference, Object newValue) {
-                    Long size = Long.decode((String) newValue);
+                    int size = Integer.decode((String) newValue);
                     if (ThumbnailsCacheManager.setMaxSize(size)){
-                        appPrefs.edit().putString("pref_cache_size", size.toString());
+                        appPrefs.edit().putInt("pref_cache_size", size);
                         pCacheSize.setSummary(size + " MB");
                         return true;
                     } else {