From 764b9dfa9590a0438aa94bee657344e29d5544bc Mon Sep 17 00:00:00 2001 From: A117870935 Date: Thu, 25 May 2023 16:52:59 +0530 Subject: [PATCH] Tinting removed for folder and file icons and not overlaying icon for folders. --- .../main/java/com/nextcloud/utils/ShortcutUtil.kt | 8 ++++++-- .../android/ui/activity/EditorWebView.java | 6 ++++-- .../android/ui/activity/ShareActivity.java | 5 +++-- .../android/ui/adapter/UploaderAdapter.java | 9 ++++----- .../com/owncloud/android/utils/DisplayUtils.java | 9 +++------ .../com/owncloud/android/utils/MimeTypeUtil.java | 15 ++++++--------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt b/app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt index b45432c7944f..f1e5a4318baa 100644 --- a/app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt +++ b/app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt @@ -29,6 +29,7 @@ import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable +import androidx.core.content.ContextCompat import androidx.core.content.pm.ShortcutInfoCompat import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.graphics.drawable.IconCompat @@ -72,10 +73,13 @@ class ShortcutUtil @Inject constructor(private val mContext: Context) { icon = IconCompat.createWithAdaptiveBitmap(thumbnail) } else if (file.isFolder) { val isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user) - val isDarkModeActive = syncedFolderProvider.preferences.isDarkModeEnabled val overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder) - val drawable = MimeTypeUtil.getFileIcon(isDarkModeActive, overlayIconId, mContext, viewThemeUtils) + // NMC Customization: No overlay icon will be used. Directly using folder icons + val drawable = ContextCompat.getDrawable(mContext, overlayIconId) ?: MimeTypeUtil.getDefaultFolderIcon( + mContext, + viewThemeUtils + ) val bitmapIcon = drawable.toBitmap() icon = IconCompat.createWithBitmap(bitmapIcon) } else { diff --git a/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java b/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java index e82c0ac26ffd..6fb6fc132b07 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java @@ -52,6 +52,8 @@ import javax.inject.Inject; +import androidx.core.content.ContextCompat; + public abstract class EditorWebView extends ExternalSiteWebView { public static final int REQUEST_LOCAL_FILE = 101; public ValueCallback uploadMessage; @@ -225,8 +227,8 @@ protected void setThumbnailView(final User user) { boolean isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user); Integer overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder); - LayerDrawable drawable = MimeTypeUtil.getFileIcon(preferences.isDarkModeEnabled(), overlayIconId, this, viewThemeUtils); - binding.thumbnail.setImageDrawable(drawable); + // NMC Customization: No overlay icon will be used. Directly using folder icons + binding.thumbnail.setImageDrawable(ContextCompat.getDrawable(this, overlayIconId)); } else { if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) { // Thumbnail in cache? diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java index 83764ae75796..923ed15974a2 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java @@ -48,6 +48,7 @@ import javax.inject.Inject; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -82,8 +83,8 @@ protected void onCreate(Bundle savedInstanceState) { boolean isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, optionalUser.get()); Integer overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder); - LayerDrawable drawable = MimeTypeUtil.getFileIcon(preferences.isDarkModeEnabled(), overlayIconId, this, viewThemeUtils); - binding.shareFileIcon.setImageDrawable(drawable); + // NMC Customization: No overlay icon will be used. Directly using folder icons + binding.shareFileIcon.setImageDrawable(ContextCompat.getDrawable(this, overlayIconId)); } else { binding.shareFileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(), diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploaderAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploaderAdapter.java index 3b63a8aeb328..ec36c89b71b2 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploaderAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploaderAdapter.java @@ -23,7 +23,6 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -32,7 +31,6 @@ import android.widget.TextView; import com.nextcloud.client.account.User; -import com.nextcloud.client.preferences.DarkMode; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; @@ -47,6 +45,8 @@ import java.util.List; import java.util.Map; +import androidx.core.content.ContextCompat; + public class UploaderAdapter extends SimpleAdapter { private final Context mContext; @@ -107,11 +107,10 @@ public View getView(int position, View convertView, ViewGroup parent) { if (file.isFolder()) { boolean isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user); - boolean isDarkModeActive = syncedFolderProvider.getPreferences().isDarkModeEnabled(); Integer overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder); - final LayerDrawable icon = MimeTypeUtil.getFileIcon(isDarkModeActive, overlayIconId, mContext, viewThemeUtils); - fileIcon.setImageDrawable(icon); + // NMC Customization: No overlay icon will be used. Directly using folder icons + fileIcon.setImageDrawable(ContextCompat.getDrawable(mContext, overlayIconId)); } else { // get Thumbnail if file is image if (MimeTypeUtil.isImage(file) && file.getRemoteId() != null) { diff --git a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java index 5550e85405cc..67bc70277ac3 100644 --- a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -38,7 +38,6 @@ import android.graphics.Point; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; import android.net.Uri; import android.os.AsyncTask; import android.text.Spannable; @@ -67,7 +66,6 @@ import com.nextcloud.client.account.User; import com.nextcloud.client.network.ClientFactory; import com.nextcloud.client.preferences.AppPreferences; -import com.nextcloud.client.preferences.DarkMode; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.datamodel.ArbitraryDataProvider; @@ -112,6 +110,7 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.widget.AppCompatDrawableManager; +import androidx.core.content.ContextCompat; import androidx.core.content.res.ResourcesCompat; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; @@ -856,11 +855,9 @@ public static void setThumbnail(OCFile file, stopShimmer(shimmerThumbnail, thumbnailView); boolean isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user); - boolean isDarkModeActive = preferences.isDarkModeEnabled(); - Integer overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder); - LayerDrawable fileIcon = MimeTypeUtil.getFileIcon(isDarkModeActive, overlayIconId, context, viewThemeUtils); - thumbnailView.setImageDrawable(fileIcon); + // NMC Customization: No overlay icon will be used. Directly using folder icons + thumbnailView.setImageDrawable(ContextCompat.getDrawable(context, overlayIconId)); } else { if (file.getRemoteId() != null && file.isPreviewAvailable()) { // Thumbnail in cache? diff --git a/app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java b/app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java index 761db3853d36..33bbdd2f2589 100644 --- a/app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java +++ b/app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java @@ -108,13 +108,8 @@ public static Drawable getFileTypeIcon(String mimetype, ViewThemeUtils viewThemeUtils) { if (context != null) { int iconId = MimeTypeUtil.getFileTypeIconId(mimetype, filename); - Drawable icon = ContextCompat.getDrawable(context, iconId); - - if (R.drawable.file_zip == iconId) { - viewThemeUtils.platform.tintPrimaryDrawable(context, icon); - } - - return icon; + //NMC Customization + return ContextCompat.getDrawable(context, iconId); } else { return null; } @@ -142,11 +137,13 @@ public static Drawable getDefaultFolderIcon(Context context, ViewThemeUtils view Drawable drawable = ContextCompat.getDrawable(context, R.drawable.folder); assert(drawable != null); - viewThemeUtils.platform.tintDrawable(context, drawable, ColorRole.PRIMARY); return drawable; } - public static LayerDrawable getFileIcon(Boolean isDarkModeActive, Integer overlayIconId, Context context, ViewThemeUtils viewThemeUtils) { + // NMC Note: This funtion won't be used in NMC as we are using different folder icons with inbuilt overlay. So this function is of no use for us. + // changed access to PRIVATE, in case if NC will use this function in more areas then we will get compile error which can be fixed by us + // so that UI won't be impacted. + private static LayerDrawable getFileIcon(Boolean isDarkModeActive, Integer overlayIconId, Context context, ViewThemeUtils viewThemeUtils) { Drawable folderDrawable = getDefaultFolderIcon(context, viewThemeUtils); assert(folderDrawable != null);