|
@@ -44,14 +44,10 @@ import android.widget.Filter;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.ProgressBar;
|
|
-import android.widget.RelativeLayout;
|
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
-import com.bumptech.glide.Glide;
|
|
|
|
-import com.bumptech.glide.request.target.BitmapImageViewTarget;
|
|
|
|
import com.elyeproj.loaderviewlibrary.LoaderImageView;
|
|
import com.elyeproj.loaderviewlibrary.LoaderImageView;
|
|
import com.nextcloud.client.account.User;
|
|
import com.nextcloud.client.account.User;
|
|
-import com.nextcloud.client.account.UserAccountManager;
|
|
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
import com.owncloud.android.MainApp;
|
|
import com.owncloud.android.MainApp;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.R;
|
|
@@ -73,7 +69,7 @@ import com.owncloud.android.lib.resources.shares.ShareeUser;
|
|
import com.owncloud.android.operations.RefreshFolderOperation;
|
|
import com.owncloud.android.operations.RefreshFolderOperation;
|
|
import com.owncloud.android.operations.RemoteOperationFailedException;
|
|
import com.owncloud.android.operations.RemoteOperationFailedException;
|
|
import com.owncloud.android.services.OperationsService;
|
|
import com.owncloud.android.services.OperationsService;
|
|
-import com.owncloud.android.ui.TextDrawable;
|
|
|
|
|
|
+import com.owncloud.android.ui.AvatarGroupLayout;
|
|
import com.owncloud.android.ui.activity.ComponentsGetter;
|
|
import com.owncloud.android.ui.activity.ComponentsGetter;
|
|
import com.owncloud.android.ui.fragment.ExtendedListFragment;
|
|
import com.owncloud.android.ui.fragment.ExtendedListFragment;
|
|
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
|
|
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
|
|
@@ -83,10 +79,8 @@ import com.owncloud.android.utils.DisplayUtils;
|
|
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.ThemeDrawableUtils;
|
|
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
|
-import com.owncloud.android.utils.theme.ThemeUtils;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -101,8 +95,6 @@ import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.core.content.res.ResourcesCompat;
|
|
import androidx.core.content.res.ResourcesCompat;
|
|
-import androidx.core.graphics.drawable.RoundedBitmapDrawable;
|
|
|
|
-import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
import butterknife.ButterKnife;
|
|
import butterknife.ButterKnife;
|
|
@@ -118,7 +110,6 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
private final String userId;
|
|
private final String userId;
|
|
private Activity activity;
|
|
private Activity activity;
|
|
private AppPreferences preferences;
|
|
private AppPreferences preferences;
|
|
- private UserAccountManager accountManager;
|
|
|
|
private List<OCFile> mFiles = new ArrayList<>();
|
|
private List<OCFile> mFiles = new ArrayList<>();
|
|
private List<OCFile> mFilesAll = new ArrayList<>();
|
|
private List<OCFile> mFilesAll = new ArrayList<>();
|
|
private boolean hideItemOptions;
|
|
private boolean hideItemOptions;
|
|
@@ -149,7 +140,6 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
Activity activity,
|
|
Activity activity,
|
|
User user,
|
|
User user,
|
|
AppPreferences preferences,
|
|
AppPreferences preferences,
|
|
- UserAccountManager accountManager,
|
|
|
|
ComponentsGetter transferServiceGetter,
|
|
ComponentsGetter transferServiceGetter,
|
|
OCFileListFragmentInterface ocFileListFragmentInterface,
|
|
OCFileListFragmentInterface ocFileListFragmentInterface,
|
|
boolean argHideItemOptions,
|
|
boolean argHideItemOptions,
|
|
@@ -158,7 +148,6 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
this.ocFileListFragmentInterface = ocFileListFragmentInterface;
|
|
this.ocFileListFragmentInterface = ocFileListFragmentInterface;
|
|
this.activity = activity;
|
|
this.activity = activity;
|
|
this.preferences = preferences;
|
|
this.preferences = preferences;
|
|
- this.accountManager = accountManager;
|
|
|
|
this.user = user;
|
|
this.user = user;
|
|
hideItemOptions = argHideItemOptions;
|
|
hideItemOptions = argHideItemOptions;
|
|
this.gridView = gridView;
|
|
this.gridView = gridView;
|
|
@@ -401,9 +390,6 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
if (holder instanceof OCFileListItemViewHolder) {
|
|
if (holder instanceof OCFileListItemViewHolder) {
|
|
OCFileListItemViewHolder itemViewHolder = (OCFileListItemViewHolder) holder;
|
|
OCFileListItemViewHolder itemViewHolder = (OCFileListItemViewHolder) holder;
|
|
|
|
|
|
- Resources resources = activity.getResources();
|
|
|
|
- float avatarRadius = resources.getDimension(R.dimen.list_item_avatar_icon_radius);
|
|
|
|
-
|
|
|
|
if ((file.isSharedWithMe() || file.isSharedWithSharee()) && !multiSelect && !gridView &&
|
|
if ((file.isSharedWithMe() || file.isSharedWithSharee()) && !multiSelect && !gridView &&
|
|
!hideItemOptions) {
|
|
!hideItemOptions) {
|
|
itemViewHolder.sharedAvatars.setVisibility(View.VISIBLE);
|
|
itemViewHolder.sharedAvatars.setVisibility(View.VISIBLE);
|
|
@@ -424,58 +410,9 @@ 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);
|
|
|
|
|
|
- int shareeSize = Math.min(sharees.size(), 3);
|
|
|
|
- int w = DisplayUtils.convertDpToPixel(40, activity);
|
|
|
|
- int margin = DisplayUtils.convertDpToPixel(24, activity);
|
|
|
|
- int size = 60 * (shareeSize - 1) + w;
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < shareeSize; i++) {
|
|
|
|
- ShareeUser sharee = sharees.get(i);
|
|
|
|
-
|
|
|
|
- ImageView avatar = new ImageView(activity);
|
|
|
|
-
|
|
|
|
- if (i == 0 && sharees.size() > 3) {
|
|
|
|
- avatar.setImageResource(R.drawable.ic_people);
|
|
|
|
- ThemeDrawableUtils.setIconColor(avatar.getDrawable());
|
|
|
|
- } else {
|
|
|
|
- switch (sharee.getShareType()) {
|
|
|
|
- case GROUP:
|
|
|
|
- case EMAIL:
|
|
|
|
- case ROOM:
|
|
|
|
- case CIRCLE:
|
|
|
|
- ThemeAvatarUtils.createAvatar(sharee.getShareType(), avatar, activity);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case FEDERATED:
|
|
|
|
- showFederatedShareAvatar(sharee.getUserId(), avatarRadius, resources, avatar);
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- avatar.setTag(sharee);
|
|
|
|
- DisplayUtils.setAvatar(user,
|
|
|
|
- sharee.getUserId(),
|
|
|
|
- sharee.getDisplayName(),
|
|
|
|
- this,
|
|
|
|
- avatarRadius,
|
|
|
|
- resources,
|
|
|
|
- avatar,
|
|
|
|
- activity);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- avatar.setOnClickListener(view -> ocFileListFragmentInterface.onShareIconClick(file));
|
|
|
|
-
|
|
|
|
- RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(w, w);
|
|
|
|
- layoutParams.setMargins(0, 0, i * margin, 0);
|
|
|
|
- layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
|
|
|
- avatar.setLayoutParams(layoutParams);
|
|
|
|
- itemViewHolder.sharedAvatars.addView(avatar);
|
|
|
|
-
|
|
|
|
- ViewGroup.LayoutParams rememberParam = itemViewHolder.sharedAvatars.getLayoutParams();
|
|
|
|
- rememberParam.width = size;
|
|
|
|
-
|
|
|
|
- itemViewHolder.sharedAvatars.setLayoutParams(rememberParam);
|
|
|
|
- }
|
|
|
|
|
|
+ itemViewHolder.sharedAvatars.setAvatars(user, sharees);
|
|
|
|
+ itemViewHolder.sharedAvatars.setOnClickListener(
|
|
|
|
+ view -> ocFileListFragmentInterface.onShareIconClick(file));
|
|
} else {
|
|
} else {
|
|
itemViewHolder.sharedAvatars.setVisibility(View.GONE);
|
|
itemViewHolder.sharedAvatars.setVisibility(View.GONE);
|
|
itemViewHolder.sharedAvatars.removeAllViews();
|
|
itemViewHolder.sharedAvatars.removeAllViews();
|
|
@@ -570,42 +507,6 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void showFederatedShareAvatar(String user, float avatarRadius, Resources resources, ImageView avatar) {
|
|
|
|
- // maybe federated share
|
|
|
|
- String[] split = user.split("@");
|
|
|
|
- String userId = split[0];
|
|
|
|
- String server = split[1];
|
|
|
|
-
|
|
|
|
- String url = "https://" + server + "/index.php/avatar/" + userId + "/" +
|
|
|
|
- DisplayUtils.convertDpToPixel(avatarRadius, activity);
|
|
|
|
-
|
|
|
|
- Drawable placeholder;
|
|
|
|
- try {
|
|
|
|
- placeholder = TextDrawable.createAvatarByUserId(userId, avatarRadius);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
|
|
|
|
- placeholder = ThemeDrawableUtils.tintDrawable(ResourcesCompat.getDrawable(resources,
|
|
|
|
- R.drawable.account_circle_white,
|
|
|
|
- null),
|
|
|
|
- R.color.black);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- avatar.setTag(null);
|
|
|
|
- Glide.with(activity).load(url)
|
|
|
|
- .asBitmap()
|
|
|
|
- .placeholder(placeholder)
|
|
|
|
- .error(placeholder)
|
|
|
|
- .into(new BitmapImageViewTarget(avatar) {
|
|
|
|
- @Override
|
|
|
|
- protected void setResource(Bitmap resource) {
|
|
|
|
- RoundedBitmapDrawable circularBitmapDrawable =
|
|
|
|
- RoundedBitmapDrawableFactory.create(activity.getResources(), resource);
|
|
|
|
- circularBitmapDrawable.setCircular(true);
|
|
|
|
- avatar.setImageDrawable(circularBitmapDrawable);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public static void setThumbnail(OCFile file,
|
|
public static void setThumbnail(OCFile file,
|
|
ImageView thumbnailView,
|
|
ImageView thumbnailView,
|
|
User user,
|
|
User user,
|
|
@@ -1287,7 +1188,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
public ImageView overflowMenu;
|
|
public ImageView overflowMenu;
|
|
|
|
|
|
@BindView(R.id.sharedAvatars)
|
|
@BindView(R.id.sharedAvatars)
|
|
- public RelativeLayout sharedAvatars;
|
|
|
|
|
|
+ public AvatarGroupLayout sharedAvatars;
|
|
|
|
|
|
private OCFileListItemViewHolder(View itemView) {
|
|
private OCFileListItemViewHolder(View itemView) {
|
|
super(itemView);
|
|
super(itemView);
|