Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.29] Nmc/2140 Tinting removed for folder and file icons #205

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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
Expand Down Expand Up @@ -59,10 +60,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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<Uri[]> uploadMessage;
Expand Down Expand Up @@ -217,8 +219,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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import javax.inject.Inject;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

Expand Down Expand Up @@ -73,8 +74,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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.nextcloud.client.account.User
import com.owncloud.android.databinding.UploaderListItemLayoutBinding
Expand Down Expand Up @@ -113,10 +114,9 @@ class ReceiveExternalFilesAdapter(

private fun setupThumbnailForFolder(thumbnailImageView: ImageView, file: OCFile) {
val isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user)
val isDarkModeActive = syncedFolderProvider.preferences.isDarkModeEnabled
val overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder)
val icon = MimeTypeUtil.getFileIcon(isDarkModeActive, overlayIconId, context, viewThemeUtils)
thumbnailImageView.setImageDrawable(icon)
// NMC Customization: No overlay icon will be used. Directly using folder icons
thumbnailImageView.setImageDrawable(ContextCompat.getDrawable(context, overlayIconId))
}

@Suppress("NestedBlockDepth")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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;
Expand Down Expand Up @@ -105,6 +104,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;
Expand Down Expand Up @@ -849,11 +849,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?
Expand Down
15 changes: 6 additions & 9 deletions app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,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;
}
Expand Down Expand Up @@ -128,11 +123,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);

Expand Down