From 0454ab14f31139b9114ff76be99bfa0f7a9650b9 Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Tue, 15 Aug 2017 18:07:19 +0200 Subject: [PATCH] use ocs api header --- .../datamodel/ThumbnailsCacheManager.java | 5 ++ .../ui/adapter/ActivityListAdapter.java | 60 +++++++++---------- .../utils/glide/HttpStreamFetcher.java | 8 +-- 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 7ed0a3a8bd..507e10f56b 100644 --- a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -43,6 +43,7 @@ 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; +import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import com.owncloud.android.ui.adapter.DiskLruImageCache; @@ -352,6 +353,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(); diff --git a/src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java index f1caabbbef..cea515475b 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java @@ -75,8 +75,8 @@ import java.util.List; public class ActivityListAdapter extends RecyclerView.Adapter { - public static final int HEADER_TYPE = 100; - public static final int ACTIVITY_TYPE = 101; + private static final int HEADER_TYPE = 100; + private static final int ACTIVITY_TYPE = 101; private final ActivityListInterface activityListInterface; private final int px; private static final String TAG = ActivityListAdapter.class.getSimpleName(); @@ -101,7 +101,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter { + int w = activityViewHolder.list.getMeasuredWidth(); + int elPxSize = px + 20; + int totalColumnCount = (int) Math.floor(w / elPxSize); - try { - activityViewHolder.list.setColumnCount(totalColumnCount); - } catch (IllegalArgumentException e) { - Log_OC.e(TAG, "error setting column count to " + totalColumnCount); - } + try { + activityViewHolder.list.setColumnCount(totalColumnCount); + } catch (IllegalArgumentException e) { + Log_OC.e(TAG, "error setting column count to " + totalColumnCount); } }); @@ -231,12 +228,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter activityListInterface.onActivityClicked(richObject)); setBitmap(file, imageView); return imageView; @@ -246,11 +238,19 @@ public class ActivityListAdapter extends RecyclerView.Adapter()); - + .listener(new SvgSoftwareLayerSetter<>()); Uri uri = Uri.parse(icon); requestBuilder @@ -319,7 +315,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter richObjectList, String name) { + private RichObject searchObjectByName(ArrayList richObjectList, String name) { for (RichObject richObject : richObjectList) { if (richObject.getTag().equalsIgnoreCase(name)) return richObject; diff --git a/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java b/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java index cb7dd6d18c..d86dd4d6c3 100644 --- a/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java +++ b/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java @@ -28,6 +28,7 @@ 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; +import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.status.OwnCloudVersion; @@ -65,12 +66,11 @@ public class HttpStreamFetcher implements DataFetcher { GetMethod get = null; try { get = new GetMethod(mURL); - get.setRequestHeader("Cookie", - "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true"); + get.setRequestHeader("Cookie", "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true"); + get.setRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE); int status = mClient.executeMethod(get); if (status == HttpStatus.SC_OK) { - InputStream inputStream = get.getResponseBodyAsStream(); - return inputStream; + return get.getResponseBodyAsStream(); } else { mClient.exhaustResponse(get.getResponseBodyAsStream()); }