diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-04-28 19:47:12 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-04-28 19:47:12 +0300 |
commit | afc19e8928c4ac60df15bdf2f6215f071d2b57ae (patch) | |
tree | 688e8ea6f43524b970a47446ece59df96682f9af /app/src/main/java/it/niedermann/nextcloud/deck/ui/view | |
parent | 46d4c2cfd5487600eb6b84aa042d72f5c233f7af (diff) |
Fix #433 Separate overlapping avatars with 2dp
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/view')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/view/OverlappingAvatars.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/OverlappingAvatars.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/OverlappingAvatars.java index 2bf6ec13c..63be42465 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/OverlappingAvatars.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/OverlappingAvatars.java @@ -1,6 +1,7 @@ package it.niedermann.nextcloud.deck.ui.view; import android.content.Context; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.util.AttributeSet; import android.view.ViewGroup; @@ -8,6 +9,8 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import androidx.annotation.NonNull; +import androidx.annotation.Px; +import androidx.core.graphics.drawable.DrawableCompat; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; @@ -22,7 +25,12 @@ import static it.niedermann.nextcloud.deck.util.DimensionUtil.dpToPx; public class OverlappingAvatars extends RelativeLayout { final int maxAvatarCount; + @Px final int avatarSize; + @Px + final int avatarBorderSize; + final Drawable borderDrawable; + @Px final int overlapPx; public OverlappingAvatars(Context context) { @@ -36,8 +44,11 @@ public class OverlappingAvatars extends RelativeLayout { public OverlappingAvatars(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); maxAvatarCount = context.getResources().getInteger(R.integer.max_avatar_count); - avatarSize = dpToPx(context, R.dimen.avatar_size_small); + avatarBorderSize = dpToPx(context, R.dimen.avatar_size_small_overlapping_border); + avatarSize = dpToPx(context, R.dimen.avatar_size_small) + avatarBorderSize * 2; overlapPx = dpToPx(context, R.dimen.avatar_size_small_overlapping); + borderDrawable = getResources().getDrawable(R.drawable.avatar_border); + DrawableCompat.setTint(borderDrawable, getResources().getColor(R.color.avatars_overlapping_border_color)); } public void setAvatars(@NonNull Account account, @NonNull List<User> assignedUsers) { @@ -49,8 +60,12 @@ public class OverlappingAvatars extends RelativeLayout { avatarLayoutParams = new RelativeLayout.LayoutParams(avatarSize, avatarSize); avatarLayoutParams.setMargins(0, 0, avatarCount * overlapPx, 0); avatarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + final ImageView avatar = new ImageView(context); avatar.setLayoutParams(avatarLayoutParams); + avatar.setPadding(avatarBorderSize, avatarBorderSize, avatarBorderSize, avatarBorderSize); + + avatar.setBackground(borderDrawable); addView(avatar); avatar.requestLayout(); Glide.with(context) |