mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 02:38:58 +03:00
Replace ThemeAvatarUtils with common material3 utils
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
e969024a11
commit
b3a4a5f29f
13 changed files with 102 additions and 174 deletions
|
@ -355,7 +355,7 @@ dependencies {
|
||||||
gplayImplementation "com.google.firebase:firebase-messaging:23.0.7"
|
gplayImplementation "com.google.firebase:firebase-messaging:23.0.7"
|
||||||
|
|
||||||
// TODO change back to tag before merging
|
// TODO change back to tag before merging
|
||||||
implementation 'com.github.nextcloud.android-common:ui:f02df7f'
|
implementation 'com.github.nextcloud.android-common:ui:8d8cd09'
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
|
|
|
@ -22,7 +22,6 @@ package com.nextcloud.client.di
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
||||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils
|
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils
|
import com.owncloud.android.utils.theme.ThemeColorUtils
|
||||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils
|
import com.owncloud.android.utils.theme.ThemeDrawableUtils
|
||||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils
|
import com.owncloud.android.utils.theme.ThemeSnackbarUtils
|
||||||
|
@ -78,12 +77,6 @@ internal abstract class ThemeModule {
|
||||||
return ThemeSnackbarUtils()
|
return ThemeSnackbarUtils()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun themeAvatarUtils(): ThemeAvatarUtils {
|
|
||||||
return ThemeAvatarUtils()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
fun provideMaterialSchemes(materialSchemesProvider: MaterialSchemesProvider): MaterialSchemes {
|
fun provideMaterialSchemes(materialSchemesProvider: MaterialSchemesProvider): MaterialSchemes {
|
||||||
return materialSchemesProvider.getMaterialSchemesForCurrentUser()
|
return materialSchemesProvider.getMaterialSchemesForCurrentUser()
|
||||||
|
|
|
@ -38,9 +38,8 @@ import com.owncloud.android.R;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
import com.owncloud.android.lib.resources.shares.ShareeUser;
|
import com.owncloud.android.lib.resources.shares.ShareeUser;
|
||||||
import com.owncloud.android.utils.DisplayUtils;
|
import com.owncloud.android.utils.DisplayUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils;
|
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
|
||||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
||||||
|
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -86,9 +85,8 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
|
||||||
|
|
||||||
public void setAvatars(@NonNull User user,
|
public void setAvatars(@NonNull User user,
|
||||||
@NonNull List<ShareeUser> sharees,
|
@NonNull List<ShareeUser> sharees,
|
||||||
ThemeColorUtils themeColorUtils,
|
|
||||||
ThemeDrawableUtils themeDrawableUtils,
|
ThemeDrawableUtils themeDrawableUtils,
|
||||||
ThemeAvatarUtils themeAvatarUtils) {
|
final ViewThemeUtils viewThemeUtils) {
|
||||||
@NonNull Context context = getContext();
|
@NonNull Context context = getContext();
|
||||||
removeAllViews();
|
removeAllViews();
|
||||||
RelativeLayout.LayoutParams avatarLayoutParams;
|
RelativeLayout.LayoutParams avatarLayoutParams;
|
||||||
|
@ -122,7 +120,7 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
|
||||||
case EMAIL:
|
case EMAIL:
|
||||||
case ROOM:
|
case ROOM:
|
||||||
case CIRCLE:
|
case CIRCLE:
|
||||||
themeAvatarUtils.createAvatar(sharee.getShareType(), avatar, context, themeColorUtils);
|
viewThemeUtils.files.createAvatar(sharee.getShareType(), avatar, context);
|
||||||
break;
|
break;
|
||||||
case FEDERATED:
|
case FEDERATED:
|
||||||
showFederatedShareAvatar(context,
|
showFederatedShareAvatar(context,
|
||||||
|
|
|
@ -35,8 +35,7 @@ import com.owncloud.android.databinding.FileDetailsShareLinkShareItemBinding;
|
||||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||||
import com.owncloud.android.ui.fragment.util.SharingMenuHelper;
|
import com.owncloud.android.ui.fragment.util.SharingMenuHelper;
|
||||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils;
|
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
@ -45,8 +44,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
class LinkShareViewHolder extends RecyclerView.ViewHolder {
|
class LinkShareViewHolder extends RecyclerView.ViewHolder {
|
||||||
private FileDetailsShareLinkShareItemBinding binding;
|
private FileDetailsShareLinkShareItemBinding binding;
|
||||||
private Context context;
|
private Context context;
|
||||||
private ThemeColorUtils themeColorUtils;
|
private ViewThemeUtils viewThemeUtils;
|
||||||
private ThemeAvatarUtils themeAvatarUtils;
|
|
||||||
|
|
||||||
public LinkShareViewHolder(@NonNull View itemView) {
|
public LinkShareViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
@ -54,13 +52,11 @@ class LinkShareViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
public LinkShareViewHolder(FileDetailsShareLinkShareItemBinding binding,
|
public LinkShareViewHolder(FileDetailsShareLinkShareItemBinding binding,
|
||||||
Context context,
|
Context context,
|
||||||
ThemeColorUtils themeColorUtils,
|
final ViewThemeUtils viewThemeUtils) {
|
||||||
ThemeAvatarUtils themeAvatarUtils) {
|
|
||||||
this(binding.getRoot());
|
this(binding.getRoot());
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.themeColorUtils = themeColorUtils;
|
this.viewThemeUtils = viewThemeUtils;
|
||||||
this.themeAvatarUtils = themeAvatarUtils;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind(OCShare publicShare, ShareeListAdapterListener listener) {
|
public void bind(OCShare publicShare, ShareeListAdapterListener listener) {
|
||||||
|
@ -83,7 +79,7 @@ class LinkShareViewHolder extends RecyclerView.ViewHolder {
|
||||||
binding.name.setText(R.string.share_link);
|
binding.name.setText(R.string.share_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
themeAvatarUtils.colorIconImageViewWithBackground(binding.icon, context, themeColorUtils);
|
viewThemeUtils.platform.colorImageViewBackgroundAndIcon(binding.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
String permissionName = SharingMenuHelper.getPermissionName(context, publicShare);
|
String permissionName = SharingMenuHelper.getPermissionName(context, publicShare);
|
||||||
|
|
|
@ -76,9 +76,9 @@ import com.owncloud.android.utils.FileSortOrder;
|
||||||
import com.owncloud.android.utils.FileStorageUtils;
|
import com.owncloud.android.utils.FileStorageUtils;
|
||||||
import com.owncloud.android.utils.MimeTypeUtil;
|
import com.owncloud.android.utils.MimeTypeUtil;
|
||||||
import com.owncloud.android.utils.theme.CapabilityUtils;
|
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils;
|
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
||||||
|
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -133,7 +133,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM yyyy", Locale.getDefault());
|
private final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM yyyy", Locale.getDefault());
|
||||||
private final ThemeColorUtils themeColorUtils;
|
private final ThemeColorUtils themeColorUtils;
|
||||||
private final ThemeDrawableUtils themeDrawableUtils;
|
private final ThemeDrawableUtils themeDrawableUtils;
|
||||||
private final ThemeAvatarUtils themeAvatarUtils;
|
private final ViewThemeUtils viewThemeUtils;
|
||||||
private SearchType searchType;
|
private SearchType searchType;
|
||||||
|
|
||||||
public OCFileListAdapter(
|
public OCFileListAdapter(
|
||||||
|
@ -146,8 +146,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
boolean gridView,
|
boolean gridView,
|
||||||
ThemeColorUtils themeColorUtils,
|
ThemeColorUtils themeColorUtils,
|
||||||
ThemeDrawableUtils themeDrawableUtils,
|
ThemeDrawableUtils themeDrawableUtils,
|
||||||
ThemeAvatarUtils themeAvatarUtils
|
final ViewThemeUtils viewThemeUtils) {
|
||||||
) {
|
|
||||||
this.ocFileListFragmentInterface = ocFileListFragmentInterface;
|
this.ocFileListFragmentInterface = ocFileListFragmentInterface;
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.preferences = preferences;
|
this.preferences = preferences;
|
||||||
|
@ -167,7 +166,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
|
|
||||||
this.themeColorUtils = themeColorUtils;
|
this.themeColorUtils = themeColorUtils;
|
||||||
this.themeDrawableUtils = themeDrawableUtils;
|
this.themeDrawableUtils = themeDrawableUtils;
|
||||||
this.themeAvatarUtils = themeAvatarUtils;
|
this.viewThemeUtils = viewThemeUtils;
|
||||||
|
|
||||||
ocFileListDelegate = new OCFileListDelegate(activity,
|
ocFileListDelegate = new OCFileListDelegate(activity,
|
||||||
ocFileListFragmentInterface,
|
ocFileListFragmentInterface,
|
||||||
|
@ -416,7 +415,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
|
|
||||||
Log_OC.d(this, "sharees of " + file.getFileName() + ": " + sharees);
|
Log_OC.d(this, "sharees of " + file.getFileName() + ": " + sharees);
|
||||||
|
|
||||||
holder.getSharedAvatars().setAvatars(user, sharees,themeColorUtils, themeDrawableUtils, themeAvatarUtils);
|
holder.getSharedAvatars().setAvatars(user, sharees, themeDrawableUtils, viewThemeUtils);
|
||||||
holder.getSharedAvatars().setOnClickListener(
|
holder.getSharedAvatars().setOnClickListener(
|
||||||
view -> ocFileListFragmentInterface.onShareIconClick(file));
|
view -> ocFileListFragmentInterface.onShareIconClick(file));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -36,8 +36,7 @@ import com.owncloud.android.lib.resources.shares.OCShare;
|
||||||
import com.owncloud.android.ui.TextDrawable;
|
import com.owncloud.android.ui.TextDrawable;
|
||||||
import com.owncloud.android.ui.fragment.util.SharingMenuHelper;
|
import com.owncloud.android.ui.fragment.util.SharingMenuHelper;
|
||||||
import com.owncloud.android.utils.DisplayUtils;
|
import com.owncloud.android.utils.DisplayUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils;
|
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -48,8 +47,7 @@ class ShareViewHolder extends RecyclerView.ViewHolder {
|
||||||
private float avatarRadiusDimension;
|
private float avatarRadiusDimension;
|
||||||
private User user;
|
private User user;
|
||||||
private Context context;
|
private Context context;
|
||||||
private ThemeColorUtils themeColorUtils;
|
private ViewThemeUtils viewThemeUtils;
|
||||||
private ThemeAvatarUtils themeAvatarUtils;
|
|
||||||
|
|
||||||
public ShareViewHolder(@NonNull View itemView) {
|
public ShareViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
@ -58,14 +56,12 @@ class ShareViewHolder extends RecyclerView.ViewHolder {
|
||||||
public ShareViewHolder(FileDetailsShareShareItemBinding binding,
|
public ShareViewHolder(FileDetailsShareShareItemBinding binding,
|
||||||
User user,
|
User user,
|
||||||
Context context,
|
Context context,
|
||||||
ThemeColorUtils themeColorUtils,
|
final ViewThemeUtils viewThemeUtils) {
|
||||||
ThemeAvatarUtils themeAvatarUtils) {
|
|
||||||
this(binding.getRoot());
|
this(binding.getRoot());
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.themeColorUtils = themeColorUtils;
|
this.viewThemeUtils = viewThemeUtils;
|
||||||
this.themeAvatarUtils = themeAvatarUtils;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind(OCShare share,
|
public void bind(OCShare share,
|
||||||
|
@ -80,14 +76,14 @@ class ShareViewHolder extends RecyclerView.ViewHolder {
|
||||||
switch (share.getShareType()) {
|
switch (share.getShareType()) {
|
||||||
case GROUP:
|
case GROUP:
|
||||||
name = context.getString(R.string.share_group_clarification, name);
|
name = context.getString(R.string.share_group_clarification, name);
|
||||||
themeAvatarUtils.createAvatar(share.getShareType(), binding.icon, context, themeColorUtils);
|
viewThemeUtils.files.createAvatar(share.getShareType(), binding.icon, context);
|
||||||
break;
|
break;
|
||||||
case ROOM:
|
case ROOM:
|
||||||
name = context.getString(R.string.share_room_clarification, name);
|
name = context.getString(R.string.share_room_clarification, name);
|
||||||
themeAvatarUtils.createAvatar(share.getShareType(), binding.icon, context, themeColorUtils);
|
viewThemeUtils.files.createAvatar(share.getShareType(), binding.icon, context);
|
||||||
break;
|
break;
|
||||||
case CIRCLE:
|
case CIRCLE:
|
||||||
themeAvatarUtils.createAvatar(share.getShareType(), binding.icon, context, themeColorUtils);
|
viewThemeUtils.files.createAvatar(share.getShareType(), binding.icon, context);
|
||||||
break;
|
break;
|
||||||
case FEDERATED:
|
case FEDERATED:
|
||||||
name = context.getString(R.string.share_remote_clarification, name);
|
name = context.getString(R.string.share_remote_clarification, name);
|
||||||
|
|
|
@ -40,8 +40,7 @@ import com.owncloud.android.lib.resources.shares.OCShare;
|
||||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||||
import com.owncloud.android.ui.activity.FileActivity;
|
import com.owncloud.android.ui.activity.FileActivity;
|
||||||
import com.owncloud.android.utils.DisplayUtils;
|
import com.owncloud.android.utils.DisplayUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils;
|
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -62,23 +61,20 @@ public class ShareeListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
private final float avatarRadiusDimension;
|
private final float avatarRadiusDimension;
|
||||||
private final String userId;
|
private final String userId;
|
||||||
private final User user;
|
private final User user;
|
||||||
private final ThemeColorUtils themeColorUtils;
|
private final ViewThemeUtils viewThemeUtils;
|
||||||
private final ThemeAvatarUtils themeAvatarUtils;
|
|
||||||
|
|
||||||
public ShareeListAdapter(FileActivity fileActivity,
|
public ShareeListAdapter(FileActivity fileActivity,
|
||||||
List<OCShare> shares,
|
List<OCShare> shares,
|
||||||
ShareeListAdapterListener listener,
|
ShareeListAdapterListener listener,
|
||||||
String userId,
|
String userId,
|
||||||
User user,
|
User user,
|
||||||
ThemeColorUtils themeColorUtils,
|
final ViewThemeUtils viewThemeUtils) {
|
||||||
ThemeAvatarUtils themeAvatarUtils) {
|
|
||||||
this.fileActivity = fileActivity;
|
this.fileActivity = fileActivity;
|
||||||
this.shares = shares;
|
this.shares = shares;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.themeColorUtils = themeColorUtils;
|
this.viewThemeUtils = viewThemeUtils;
|
||||||
this.themeAvatarUtils = themeAvatarUtils;
|
|
||||||
|
|
||||||
avatarRadiusDimension = fileActivity.getResources().getDimension(R.dimen.user_icon_radius);
|
avatarRadiusDimension = fileActivity.getResources().getDimension(R.dimen.user_icon_radius);
|
||||||
|
|
||||||
|
@ -101,8 +97,7 @@ public class ShareeListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
parent,
|
parent,
|
||||||
false),
|
false),
|
||||||
fileActivity,
|
fileActivity,
|
||||||
themeColorUtils,
|
viewThemeUtils);
|
||||||
themeAvatarUtils);
|
|
||||||
case NEW_PUBLIC_LINK:
|
case NEW_PUBLIC_LINK:
|
||||||
return new NewLinkShareViewHolder(
|
return new NewLinkShareViewHolder(
|
||||||
FileDetailsSharePublicLinkAddNewItemBinding.inflate(LayoutInflater.from(fileActivity),
|
FileDetailsSharePublicLinkAddNewItemBinding.inflate(LayoutInflater.from(fileActivity),
|
||||||
|
@ -119,8 +114,7 @@ public class ShareeListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
false),
|
false),
|
||||||
user,
|
user,
|
||||||
fileActivity,
|
fileActivity,
|
||||||
themeColorUtils,
|
viewThemeUtils);
|
||||||
themeAvatarUtils);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,11 @@ import com.owncloud.android.ui.fragment.util.FileDetailSharingFragmentHelper;
|
||||||
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||||
import com.owncloud.android.utils.ClipboardUtil;
|
import com.owncloud.android.utils.ClipboardUtil;
|
||||||
import com.owncloud.android.utils.DisplayUtils;
|
import com.owncloud.android.utils.DisplayUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils;
|
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
|
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
||||||
|
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -105,7 +105,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
||||||
@Inject ThemeToolbarUtils themeToolbarUtils;
|
@Inject ThemeToolbarUtils themeToolbarUtils;
|
||||||
@Inject ThemeSnackbarUtils themeSnackbarUtils;
|
@Inject ThemeSnackbarUtils themeSnackbarUtils;
|
||||||
@Inject ThemeDrawableUtils themeDrawableUtils;
|
@Inject ThemeDrawableUtils themeDrawableUtils;
|
||||||
@Inject ThemeAvatarUtils themeAvatarUtils;
|
@Inject ViewThemeUtils viewThemeUtils;
|
||||||
|
|
||||||
public static FileDetailSharingFragment newInstance(OCFile file, User user) {
|
public static FileDetailSharingFragment newInstance(OCFile file, User user) {
|
||||||
FileDetailSharingFragment fragment = new FileDetailSharingFragment();
|
FileDetailSharingFragment fragment = new FileDetailSharingFragment();
|
||||||
|
@ -171,8 +171,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
||||||
this,
|
this,
|
||||||
userId,
|
userId,
|
||||||
user,
|
user,
|
||||||
themeColorUtils,
|
viewThemeUtils));
|
||||||
themeAvatarUtils));
|
|
||||||
binding.sharesList.setLayoutManager(new LinearLayoutManager(getContext()));
|
binding.sharesList.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
setupView();
|
setupView();
|
||||||
|
|
|
@ -27,7 +27,6 @@ package com.owncloud.android.ui.fragment;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -43,7 +42,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
|
||||||
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior;
|
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
@ -109,7 +107,6 @@ import com.owncloud.android.utils.EncryptionUtils;
|
||||||
import com.owncloud.android.utils.FileSortOrder;
|
import com.owncloud.android.utils.FileSortOrder;
|
||||||
import com.owncloud.android.utils.FileStorageUtils;
|
import com.owncloud.android.utils.FileStorageUtils;
|
||||||
import com.owncloud.android.utils.MimeTypeUtil;
|
import com.owncloud.android.utils.MimeTypeUtil;
|
||||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils;
|
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
||||||
import com.owncloud.android.utils.theme.ThemeUtils;
|
import com.owncloud.android.utils.theme.ThemeUtils;
|
||||||
|
@ -198,7 +195,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||||
@Inject ThemeColorUtils themeColorUtils;
|
@Inject ThemeColorUtils themeColorUtils;
|
||||||
@Inject ThemeToolbarUtils themeToolbarUtils;
|
@Inject ThemeToolbarUtils themeToolbarUtils;
|
||||||
@Inject ThemeUtils themeUtils;
|
@Inject ThemeUtils themeUtils;
|
||||||
@Inject ThemeAvatarUtils themeAvatarUtils;
|
|
||||||
@Inject ArbitraryDataProvider arbitraryDataProvider;
|
@Inject ArbitraryDataProvider arbitraryDataProvider;
|
||||||
@Inject BackgroundJobManager backgroundJobManager;
|
@Inject BackgroundJobManager backgroundJobManager;
|
||||||
@Inject ViewThemeUtils viewThemeUtils;
|
@Inject ViewThemeUtils viewThemeUtils;
|
||||||
|
@ -428,7 +424,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||||
isGridViewPreferred(mFile),
|
isGridViewPreferred(mFile),
|
||||||
themeColorUtils,
|
themeColorUtils,
|
||||||
themeDrawableUtils,
|
themeDrawableUtils,
|
||||||
themeAvatarUtils
|
viewThemeUtils
|
||||||
);
|
);
|
||||||
|
|
||||||
setRecyclerViewAdapter(mAdapter);
|
setRecyclerViewAdapter(mAdapter);
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
/*
|
|
||||||
* Nextcloud Android client application
|
|
||||||
*
|
|
||||||
* @author Tobias Kaminsky
|
|
||||||
* @author Andy Scherzinger
|
|
||||||
* Copyright (C) 2017 Tobias Kaminsky
|
|
||||||
* Copyright (C) 2017 Nextcloud GmbH
|
|
||||||
* Copyright (C) 2018 Andy Scherzinger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.owncloud.android.utils.theme;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import com.owncloud.android.R;
|
|
||||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
|
||||||
|
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility class with methods for client side button theming.
|
|
||||||
*/
|
|
||||||
public final class ThemeAvatarUtils {
|
|
||||||
public void colorIconImageViewWithBackground(ImageView imageView,
|
|
||||||
Context context,
|
|
||||||
ThemeColorUtils themeColorUtils) {
|
|
||||||
int primaryColor = themeColorUtils.primaryColor(null, true, false, context);
|
|
||||||
|
|
||||||
imageView.getBackground().setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
imageView.getDrawable().mutate().setColorFilter(themeColorUtils.getColorForPrimary(primaryColor, context),
|
|
||||||
PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressFBWarnings(
|
|
||||||
value = "SF_SWITCH_NO_DEFAULT",
|
|
||||||
justification = "We only create avatars for a subset of share types")
|
|
||||||
public void createAvatar(ShareType type,
|
|
||||||
ImageView avatar,
|
|
||||||
Context context,
|
|
||||||
ThemeColorUtils themeColorUtils) {
|
|
||||||
switch (type) {
|
|
||||||
case GROUP:
|
|
||||||
avatar.setImageResource(R.drawable.ic_group);
|
|
||||||
avatar.setBackground(ResourcesCompat.getDrawable(context.getResources(),
|
|
||||||
R.drawable.round_bgnd,
|
|
||||||
null));
|
|
||||||
avatar.setCropToPadding(true);
|
|
||||||
avatar.setPadding(4, 4, 4, 4);
|
|
||||||
colorIconImageViewWithBackground(avatar, context, themeColorUtils);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ROOM:
|
|
||||||
avatar.setImageResource(R.drawable.first_run_talk);
|
|
||||||
avatar.setBackground(ResourcesCompat.getDrawable(context.getResources(),
|
|
||||||
R.drawable.round_bgnd,
|
|
||||||
null));
|
|
||||||
avatar.setCropToPadding(true);
|
|
||||||
avatar.setPadding(8, 8, 8, 8);
|
|
||||||
colorIconImageViewWithBackground(avatar, context, themeColorUtils);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CIRCLE:
|
|
||||||
avatar.setImageResource(R.drawable.ic_circles);
|
|
||||||
avatar.setBackground(ResourcesCompat.getDrawable(context.getResources(),
|
|
||||||
R.drawable.round_bgnd,
|
|
||||||
null));
|
|
||||||
avatar.getBackground().setColorFilter(context.getResources().getColor(R.color.nc_grey),
|
|
||||||
PorterDuff.Mode.SRC_IN);
|
|
||||||
avatar.getDrawable().mutate().setColorFilter(context.getResources().getColor(R.color.icon_on_nc_grey),
|
|
||||||
PorterDuff.Mode.SRC_IN);
|
|
||||||
avatar.setCropToPadding(true);
|
|
||||||
avatar.setPadding(4, 4, 4, 4);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EMAIL:
|
|
||||||
avatar.setImageResource(R.drawable.ic_email);
|
|
||||||
avatar.setBackground(ResourcesCompat.getDrawable(context.getResources(),
|
|
||||||
R.drawable.round_bgnd,
|
|
||||||
null));
|
|
||||||
avatar.setCropToPadding(true);
|
|
||||||
avatar.setPadding(8, 8, 8, 8);
|
|
||||||
avatar.getBackground().setColorFilter(context.getResources().getColor(R.color.nc_grey),
|
|
||||||
PorterDuff.Mode.SRC_IN);
|
|
||||||
avatar.getDrawable().mutate().setColorFilter(context.getResources().getColor(R.color.icon_on_nc_grey),
|
|
||||||
PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,15 +22,28 @@
|
||||||
|
|
||||||
package com.owncloud.android.utils.theme.newm3
|
package com.owncloud.android.utils.theme.newm3
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.PorterDuff
|
||||||
import android.preference.PreferenceCategory
|
import android.preference.PreferenceCategory
|
||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
|
import android.widget.ImageView
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.annotation.Px
|
||||||
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
||||||
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
|
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
|
||||||
|
import com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils
|
||||||
|
import com.owncloud.android.R
|
||||||
|
import com.owncloud.android.lib.common.utils.Log_OC
|
||||||
|
import com.owncloud.android.lib.resources.shares.ShareType
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FilesSpecificViewThemeUtils @Inject constructor(schemes: MaterialSchemes) : ViewThemeUtilsBase(schemes) {
|
class FilesSpecificViewThemeUtils @Inject constructor(
|
||||||
|
schemes: MaterialSchemes,
|
||||||
|
private val androidViewThemeUtils: AndroidViewThemeUtils
|
||||||
|
) : ViewThemeUtilsBase(schemes) {
|
||||||
// not ported to common lib because PreferenceCategory is deprecated
|
// not ported to common lib because PreferenceCategory is deprecated
|
||||||
fun themePreferenceCategory(category: PreferenceCategory) {
|
fun themePreferenceCategory(category: PreferenceCategory) {
|
||||||
withScheme(category.context) {
|
withScheme(category.context) {
|
||||||
|
@ -44,4 +57,57 @@ class FilesSpecificViewThemeUtils @Inject constructor(schemes: MaterialSchemes)
|
||||||
category.title = text
|
category.title = text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun createAvatar(type: ShareType?, avatar: ImageView, context: Context) {
|
||||||
|
fun createAvatarBase(@DrawableRes icon: Int, padding: Int = AvatarPadding.SMALL) {
|
||||||
|
avatar.setImageResource(icon)
|
||||||
|
avatar.background = ResourcesCompat.getDrawable(
|
||||||
|
context.resources,
|
||||||
|
R.drawable.round_bgnd,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
avatar.cropToPadding = true
|
||||||
|
avatar.setPadding(padding, padding, padding, padding)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO figure out why circle and email use grey background instead of primary
|
||||||
|
when (type) {
|
||||||
|
ShareType.GROUP -> {
|
||||||
|
createAvatarBase(R.drawable.ic_group)
|
||||||
|
androidViewThemeUtils.colorImageViewBackgroundAndIcon(avatar)
|
||||||
|
}
|
||||||
|
ShareType.ROOM -> {
|
||||||
|
createAvatarBase(R.drawable.first_run_talk, AvatarPadding.LARGE)
|
||||||
|
androidViewThemeUtils.colorImageViewBackgroundAndIcon(avatar)
|
||||||
|
}
|
||||||
|
ShareType.CIRCLE -> {
|
||||||
|
createAvatarBase(R.drawable.ic_circles)
|
||||||
|
avatar.background.setColorFilter(
|
||||||
|
context.resources.getColor(R.color.nc_grey),
|
||||||
|
PorterDuff.Mode.SRC_IN
|
||||||
|
)
|
||||||
|
avatar.drawable.mutate().setColorFilter(
|
||||||
|
context.resources.getColor(R.color.icon_on_nc_grey),
|
||||||
|
PorterDuff.Mode.SRC_IN
|
||||||
|
)
|
||||||
|
}
|
||||||
|
ShareType.EMAIL -> {
|
||||||
|
createAvatarBase(R.drawable.ic_email, AvatarPadding.LARGE)
|
||||||
|
androidViewThemeUtils.colorImageViewBackgroundAndIcon(avatar)
|
||||||
|
}
|
||||||
|
else -> Log_OC.d(TAG, "Unknown share type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val TAG = FilesSpecificViewThemeUtils::class.simpleName
|
||||||
|
|
||||||
|
private object AvatarPadding {
|
||||||
|
@Px
|
||||||
|
const val SMALL = 4
|
||||||
|
|
||||||
|
@Px
|
||||||
|
const val LARGE = 8
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,5 +50,5 @@ class ViewThemeUtils @Inject constructor(
|
||||||
val dialog = DialogViewThemeUtils(schemes)
|
val dialog = DialogViewThemeUtils(schemes)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val files = FilesSpecificViewThemeUtils(schemes)
|
val files = FilesSpecificViewThemeUtils(schemes, platform)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,7 @@ import com.nextcloud.client.account.AnonymousUser
|
||||||
import com.owncloud.android.lib.resources.shares.OCShare
|
import com.owncloud.android.lib.resources.shares.OCShare
|
||||||
import com.owncloud.android.lib.resources.shares.ShareType
|
import com.owncloud.android.lib.resources.shares.ShareType
|
||||||
import com.owncloud.android.ui.activity.FileActivity
|
import com.owncloud.android.ui.activity.FileActivity
|
||||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils
|
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
|
||||||
import com.owncloud.android.utils.theme.ThemeColorUtils
|
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -43,10 +42,7 @@ class ShareeListAdapterTest {
|
||||||
private val fileActivity: FileActivity? = null
|
private val fileActivity: FileActivity? = null
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var themeColorUtils: ThemeColorUtils
|
private lateinit var viewThemeUtils: ViewThemeUtils
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var themeAvatarUtils: ThemeAvatarUtils
|
|
||||||
|
|
||||||
private val orderedShares = listOf(
|
private val orderedShares = listOf(
|
||||||
OCShare("/1").apply {
|
OCShare("/1").apply {
|
||||||
|
@ -91,8 +87,7 @@ class ShareeListAdapterTest {
|
||||||
null,
|
null,
|
||||||
user.accountName,
|
user.accountName,
|
||||||
user,
|
user,
|
||||||
themeColorUtils,
|
viewThemeUtils
|
||||||
themeAvatarUtils
|
|
||||||
)
|
)
|
||||||
sut.sortShares()
|
sut.sortShares()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue