|
@@ -22,7 +22,6 @@
|
|
|
package com.owncloud.android.datamodel;
|
|
|
|
|
|
import android.accounts.Account;
|
|
|
-import android.accounts.AccountManager;
|
|
|
import android.content.Context;
|
|
|
import android.content.res.Resources;
|
|
|
import android.graphics.Bitmap;
|
|
@@ -47,7 +46,6 @@ import android.widget.ImageView;
|
|
|
|
|
|
import com.owncloud.android.MainApp;
|
|
|
import com.owncloud.android.R;
|
|
|
-import com.owncloud.android.authentication.AccountUtils;
|
|
|
import com.owncloud.android.lib.common.OwnCloudAccount;
|
|
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
|
|
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
|
@@ -560,10 +558,10 @@ public class ThumbnailsCacheManager {
|
|
|
getMethod = new GetMethod(uri);
|
|
|
getMethod.setRequestHeader("Cookie",
|
|
|
"nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
|
|
|
-
|
|
|
+
|
|
|
getMethod.setRequestHeader(RemoteOperation.OCS_API_HEADER,
|
|
|
RemoteOperation.OCS_API_HEADER_VALUE);
|
|
|
-
|
|
|
+
|
|
|
int status = mClient.executeMethod(getMethod);
|
|
|
if (status == HttpStatus.SC_OK) {
|
|
|
InputStream inputStream = getMethod.getResponseBodyAsStream();
|
|
@@ -572,7 +570,7 @@ public class ThumbnailsCacheManager {
|
|
|
} else {
|
|
|
mClient.exhaustResponse(getMethod.getResponseBodyAsStream());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Handle PNG
|
|
|
if (file.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) {
|
|
|
thumbnail = handlePNG(thumbnail, pxW, pxH);
|
|
@@ -583,6 +581,7 @@ public class ThumbnailsCacheManager {
|
|
|
if (getMethod != null) {
|
|
|
getMethod.releaseConnection();
|
|
|
}
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -595,7 +594,6 @@ public class ThumbnailsCacheManager {
|
|
|
}
|
|
|
|
|
|
return thumbnail;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -812,9 +810,9 @@ public class ThumbnailsCacheManager {
|
|
|
|
|
|
thumbnail = doAvatarInBackground();
|
|
|
|
|
|
- } catch(OutOfMemoryError oome) {
|
|
|
+ } catch (OutOfMemoryError oome) {
|
|
|
Log_OC.e(TAG, "Out of memory");
|
|
|
- } catch(Throwable t){
|
|
|
+ } catch (Throwable t) {
|
|
|
// the app should never break due to a problem with avatars
|
|
|
Log_OC.e(TAG, "Generation of avatar for " + mUserId + " failed", t);
|
|
|
}
|
|
@@ -835,6 +833,7 @@ public class ThumbnailsCacheManager {
|
|
|
|
|
|
/**
|
|
|
* Converts size of file icon from dp to pixel
|
|
|
+ *
|
|
|
* @return int
|
|
|
*/
|
|
|
private int getAvatarDimension() {
|
|
@@ -866,9 +865,9 @@ public class ThumbnailsCacheManager {
|
|
|
|
|
|
// only use eTag if available and corresponding avatar is still there
|
|
|
// (might be deleted from cache)
|
|
|
- if (!eTag.isEmpty() && getBitmapFromDiskCache(avatarKey) != null) {
|
|
|
- get.setRequestHeader("If-None-Match", eTag);
|
|
|
- }
|
|
|
+ if (!eTag.isEmpty() && getBitmapFromDiskCache(avatarKey) != null) {
|
|
|
+ get.setRequestHeader("If-None-Match", eTag);
|
|
|
+ }
|
|
|
|
|
|
int status = mClient.executeMethod(get);
|
|
|
|
|
@@ -908,28 +907,26 @@ public class ThumbnailsCacheManager {
|
|
|
mClient.exhaustResponse(get.getResponseBodyAsStream());
|
|
|
break;
|
|
|
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- try {
|
|
|
- return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
|
|
|
- } catch (Exception e1) {
|
|
|
- Log_OC.e(TAG, "Error generating fallback avatar");
|
|
|
- }
|
|
|
- } finally {
|
|
|
- if (get != null) {
|
|
|
- get.releaseConnection();
|
|
|
- }
|
|
|
}
|
|
|
- } else {
|
|
|
- Log_OC.d(TAG, "Server too old");
|
|
|
-
|
|
|
+ } catch (Exception e) {
|
|
|
try {
|
|
|
return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
|
|
|
- } catch (Exception e) {
|
|
|
+ } catch (Exception e1) {
|
|
|
Log_OC.e(TAG, "Error generating fallback avatar");
|
|
|
}
|
|
|
+ } finally {
|
|
|
+ if (get != null) {
|
|
|
+ get.releaseConnection();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log_OC.e(TAG, "Error generating fallback avatar");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return BitmapUtils.bitmapToCircularBitmapDrawable(mResources, avatar);
|
|
|
}
|
|
|
}
|
|
@@ -1085,6 +1082,7 @@ public class ThumbnailsCacheManager {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public static class AsyncThumbnailDrawable extends BitmapDrawable {
|
|
|
private final WeakReference<ThumbnailGenerationTask> bitmapWorkerTaskReference;
|
|
|
|