diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-07-08 14:26:01 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-07-08 15:21:08 +0300 |
commit | e008f7db066a70fdbed79705a0b8e40743d15d08 (patch) | |
tree | e0a93a23f6fc7df2c76fb85fb0acc3fb73ef24da /app/src/main/java/it/niedermann/nextcloud/deck/ui/view | |
parent | b2d3e3ad177163a241e5398770c5f6acf4f5c39b (diff) |
#579 Compact mode
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/view')
4 files changed, 55 insertions, 7 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/CompactLabelChip.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/CompactLabelChip.java new file mode 100644 index 000000000..8659cef36 --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/CompactLabelChip.java @@ -0,0 +1,23 @@ +package it.niedermann.nextcloud.deck.ui.view; + +import android.annotation.SuppressLint; +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Px; + +import it.niedermann.nextcloud.deck.R; +import it.niedermann.nextcloud.deck.model.Label; + +import static it.niedermann.nextcloud.deck.util.DimensionUtil.dpToPx; + +@SuppressLint("ViewConstructor") +public class CompactLabelChip extends LabelChip { + + public CompactLabelChip(@NonNull Context context, @NonNull Label label, @Px int gutter) { + super(context, label, gutter); + params.setFlexBasisPercent(1 / 6.5f); + setHeight(dpToPx(context, R.dimen.compact_label_height)); + setText(""); + } +}
\ No newline at end of file diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/CompactLabelLayout.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/CompactLabelLayout.java new file mode 100644 index 000000000..ae44b2dde --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/CompactLabelLayout.java @@ -0,0 +1,20 @@ +package it.niedermann.nextcloud.deck.ui.view; + +import android.content.Context; +import android.util.AttributeSet; + +import androidx.annotation.NonNull; + +import it.niedermann.nextcloud.deck.model.Label; + +public class CompactLabelLayout extends LabelLayout { + + public CompactLabelLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected LabelChip createLabelChip(@NonNull Label label) { + return new CompactLabelChip(getContext(), label, gutter); + } +} diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelChip.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelChip.java index db4e123d3..a41cdcc22 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelChip.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelChip.java @@ -23,15 +23,15 @@ public class LabelChip extends Chip { private final Label label; + protected final FlexboxLayout.LayoutParams params = new FlexboxLayout.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ); + public LabelChip(@NonNull Context context, @NonNull Label label, @Px int gutter) { super(context); this.label = label; - FlexboxLayout.LayoutParams params = new FlexboxLayout.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT - ); - params.setMargins(0, 0, gutter, 0); setLayoutParams(params); setEnsureMinTouchTargetSize(false); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelLayout.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelLayout.java index 814c63ce1..ffe7190a3 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelLayout.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelLayout.java @@ -20,7 +20,8 @@ import static it.niedermann.nextcloud.deck.util.DimensionUtil.dpToPx; public class LabelLayout extends FlexboxLayout { @Px - private int gutter; + protected int gutter; + @NonNull private List<LabelChip> chipList = new LinkedList<>(); public LabelLayout(Context context, AttributeSet attrs) { @@ -82,9 +83,13 @@ public class LabelLayout extends FlexboxLayout { continue labelList; } } - LabelChip chip = new LabelChip(getContext(), label, gutter); + LabelChip chip = createLabelChip(label); addView(chip); chipList.add(chip); } } + + protected LabelChip createLabelChip(@NonNull Label label) { + return new LabelChip(getContext(), label, gutter); + } } |