mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 02:38:58 +03:00
Migrate MimeTypeUtil.getFileTypeIcon to User model
Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
This commit is contained in:
parent
6b431a388e
commit
eb722457ca
3 changed files with 15 additions and 13 deletions
|
@ -156,7 +156,7 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
|
|||
|
||||
thumbnail.setImageDrawable(MimeTypeUtil.getFileTypeIcon(creator.getMimetype(),
|
||||
creator.getExtension(),
|
||||
user.toPlatformAccount(),
|
||||
user,
|
||||
getContext()));
|
||||
|
||||
creatorView.setOnClickListener(v -> {
|
||||
|
|
|
@ -92,8 +92,7 @@ public final class MimeTypeUtil {
|
|||
* @return Drawable of an image resource.
|
||||
*/
|
||||
public static Drawable getFileTypeIcon(String mimetype, String filename, Context context) {
|
||||
final Account nullAccount = null;
|
||||
return getFileTypeIcon(mimetype, filename, nullAccount, context);
|
||||
return getFileTypeIcon(mimetype, filename, null, context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,18 +100,17 @@ public final class MimeTypeUtil {
|
|||
*
|
||||
* @param mimetype MIME type string; if NULL, the method tries to guess it from the extension in filename
|
||||
* @param filename Name, with extension.
|
||||
* @param account account which color should be used
|
||||
* @param user user which color should be used
|
||||
* @return Drawable of an image resource.
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public static Drawable getFileTypeIcon(String mimetype, String filename, Account account, Context context) {
|
||||
public static Drawable getFileTypeIcon(String mimetype, String filename, @Nullable User user, Context context) {
|
||||
if (context != null) {
|
||||
int iconId = MimeTypeUtil.getFileTypeIconId(mimetype, filename);
|
||||
Drawable icon = ContextCompat.getDrawable(context, iconId);
|
||||
|
||||
if (R.drawable.file_zip == iconId) {
|
||||
ThemeUtils.tintDrawable(icon, ThemeUtils.primaryColor(account, true, context));
|
||||
ThemeUtils.tintDrawable(icon, ThemeUtils.primaryColor(user, true, context));
|
||||
}
|
||||
|
||||
return icon;
|
||||
|
@ -121,11 +119,6 @@ public final class MimeTypeUtil {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Drawable getFileTypeIcon(String mimetype, String filename, User user, Context context) {
|
||||
return getFileTypeIcon(mimetype, filename, user.toPlatformAccount(), context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resource identifier of an image to use as icon associated to a known MIME type.
|
||||
*
|
||||
|
|
|
@ -50,6 +50,7 @@ import com.google.android.material.button.MaterialButton;
|
|||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
|
@ -138,7 +139,15 @@ public final class ThemeUtils {
|
|||
}
|
||||
|
||||
public static int primaryColor(Context context, boolean replaceEdgeColors) {
|
||||
return primaryColor(null, replaceEdgeColors, context);
|
||||
User nullUser = null;
|
||||
return primaryColor(nullUser, replaceEdgeColors, context);
|
||||
}
|
||||
|
||||
public static int primaryColor(User user, boolean replaceEdgeColors, Context context) {
|
||||
return primaryColor(user != null ? user.toPlatformAccount() : null,
|
||||
replaceEdgeColors,
|
||||
false,
|
||||
context);
|
||||
}
|
||||
|
||||
public static int primaryColor(Account account, boolean replaceEdgeColors, Context context) {
|
||||
|
|
Loading…
Reference in a new issue