From fec82c1c6e498e6d3e396ce5f0e7463465f19f00 Mon Sep 17 00:00:00 2001 From: A117870935 Date: Thu, 25 May 2023 16:20:08 +0530 Subject: [PATCH 1/2] Auto Upload behaviour customized. --- .../owncloud/android/ui/adapter/SyncedFolderAdapter.java | 5 ++++- app/src/main/res/values/attrs.xml | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java index 194c3f50680d..b43ed44ab5b1 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java @@ -35,6 +35,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; +import androidx.core.content.res.ResourcesCompat; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; @@ -445,7 +446,9 @@ private MainViewHolder(GridSyncItemBinding binding) { private void setSyncButtonActiveIcon(ImageButton syncStatusButton, boolean enabled) { if (enabled) { syncStatusButton.setImageDrawable( - viewThemeUtils.platform.tintPrimaryDrawable(context, R.drawable.ic_cloud_sync_on) + viewThemeUtils.platform.colorDrawable(ResourcesCompat.getDrawable(context.getResources(), + R.drawable.ic_cloud_sync_on, null), + ResourcesCompat.getColor(context.getResources(), R.color.primary, null)) ); } else { syncStatusButton.setImageResource(R.drawable.ic_cloud_sync_off); diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 7317a84ee0e1..fd243acd3978 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -9,13 +9,15 @@ @string/pref_behaviour_entries_keep_file - @string/pref_behaviour_entries_move + + @string/pref_behaviour_entries_delete_file LOCAL_BEHAVIOUR_FORGET - LOCAL_BEHAVIOUR_MOVE + + LOCAL_BEHAVIOUR_DELETE From 6f8823257f46660fbb91bc46775416d59d6ed155 Mon Sep 17 00:00:00 2001 From: A117870935 Date: Thu, 26 Oct 2023 21:54:01 +0530 Subject: [PATCH 2/2] Fix scroll lagging for auto-upload files. (NMC-2589) --- .../datamodel/ThumbnailsCacheManager.java | 34 +++++++++++++++---- .../ui/adapter/SyncedFolderAdapter.java | 3 ++ .../dialog/parcel/SyncedFolderParcelable.java | 7 ++-- app/src/main/res/values-sw600dp/dims.xml | 1 + app/src/main/res/values/dims.xml | 1 + 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 198f9258d2f6..2f857dd3f250 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -68,6 +68,7 @@ import java.net.URLEncoder; import java.util.List; +import androidx.annotation.DimenRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -158,9 +159,19 @@ protected Void doInBackground(File... params) { * @return int */ public static int getThumbnailDimension() { + return getThumbnailDimension(R.dimen.file_icon_size_grid); + } + + /** + * Converts size of file icon from dp to pixel + * this function is required for custom thumbnail sizes + * @param thumbnailDimension dimension to be converted + * @return int + */ + public static int getThumbnailDimension(@DimenRes int thumbnailDimension) { // Converts dp to pixel Resources r = MainApp.getAppContext().getResources(); - return Math.round(r.getDimension(R.dimen.file_icon_size_grid)); + return Math.round(r.getDimension(thumbnailDimension)); } /** @@ -815,14 +826,25 @@ private enum Type {IMAGE, VIDEO} private String mImageKey; private final Context mContext; private final ViewThemeUtils viewThemeUtils; + @DimenRes + private final int thumbnailDimension; + + public MediaThumbnailGenerationTask(ImageView imageView, + Context context, + ViewThemeUtils viewThemeUtils) { + this(imageView, context, R.dimen.file_icon_size_grid, viewThemeUtils); + } + // constructor to generate thumbnails for the requested size public MediaThumbnailGenerationTask(ImageView imageView, Context context, + @DimenRes int thumbnailDimension, ViewThemeUtils viewThemeUtils) { // Use a WeakReference to ensure the ImageView can be garbage collected mImageViewReference = new WeakReference<>(imageView); mContext = context; this.viewThemeUtils = viewThemeUtils; + this.thumbnailDimension = thumbnailDimension; } @Override @@ -837,9 +859,9 @@ protected Bitmap doInBackground(Object... params) { } if (MimeTypeUtil.isImage(mFile)) { - thumbnail = doFileInBackground(mFile, Type.IMAGE); + thumbnail = doFileInBackground(mFile, Type.IMAGE, thumbnailDimension); } else if (MimeTypeUtil.isVideo(mFile)) { - thumbnail = doFileInBackground(mFile, Type.VIDEO); + thumbnail = doFileInBackground(mFile, Type.VIDEO, thumbnailDimension); } } } // the app should never break due to a problem with thumbnails @@ -885,7 +907,7 @@ protected void onPostExecute(Bitmap bitmap) { } } - private Bitmap doFileInBackground(File file, Type type) { + private Bitmap doFileInBackground(File file, Type type, @DimenRes int thumbnailDimension) { final String imageKey; if (mImageKey != null) { @@ -901,7 +923,7 @@ private Bitmap doFileInBackground(File file, Type type) { if (thumbnail == null) { if (Type.IMAGE == type) { - int px = getThumbnailDimension(); + int px = getThumbnailDimension(thumbnailDimension); Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(file.getAbsolutePath(), px, px); @@ -927,7 +949,7 @@ private Bitmap doFileInBackground(File file, Type type) { if (thumbnail != null) { // Scale down bitmap if too large. - int px = getThumbnailDimension(); + int px = getThumbnailDimension(thumbnailDimension); int width = thumbnail.getWidth(); int height = thumbnail.getHeight(); int max = Math.max(width, height); diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java index b43ed44ab5b1..ac7082d96105 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java @@ -338,6 +338,9 @@ public void onBindViewHolder(SectionedViewHolder commonHolder, int section, int ThumbnailsCacheManager.MediaThumbnailGenerationTask task = new ThumbnailsCacheManager.MediaThumbnailGenerationTask(holder.binding.thumbnail, context, + // due to 512dp(NMC) thumb size there was scroll lagging in auto upload + // so for auto upload we have to use different thumb size (NMC-2589) + R.dimen.auto_upload_file_thumb_size, viewThemeUtils); ThumbnailsCacheManager.AsyncMediaThumbnailDrawable asyncDrawable = diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java b/app/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java index a5ee925e9529..696b94d1c7b7 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java +++ b/app/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java @@ -127,10 +127,11 @@ public Integer getUploadActionInteger() { switch (uploadAction) { case FileUploadWorker.LOCAL_BEHAVIOUR_FORGET: return 0; - case FileUploadWorker.LOCAL_BEHAVIOUR_MOVE: - return 1; + // NMC customization: No required move + /*case FileUploadWorker.LOCAL_BEHAVIOUR_MOVE: + return 1;*/ case FileUploadWorker.LOCAL_BEHAVIOUR_DELETE: - return 2; + return 1; } return 0; } diff --git a/app/src/main/res/values-sw600dp/dims.xml b/app/src/main/res/values-sw600dp/dims.xml index e4a56e63b0e4..9dddeb69f894 100644 --- a/app/src/main/res/values-sw600dp/dims.xml +++ b/app/src/main/res/values-sw600dp/dims.xml @@ -9,4 +9,5 @@ 6 512dp + 512dp diff --git a/app/src/main/res/values/dims.xml b/app/src/main/res/values/dims.xml index ce0b68648bc5..494d4edc8141 100644 --- a/app/src/main/res/values/dims.xml +++ b/app/src/main/res/values/dims.xml @@ -132,6 +132,7 @@ 24dp -3dp 80dp + 128dp 16sp 18sp 24dp