diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-07-08 14:47:21 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-07-08 15:21:08 +0300 |
commit | 7d349fae5fce71762dcfa1aa7844ccc2c759834d (patch) | |
tree | 65e029b588aad709776d39e6d39446c6390e38be /app/src/main | |
parent | 93123c828101aae745812a3583bbd2365a0cede2 (diff) |
#579 Compact mode - refactoring
Diffstat (limited to 'app/src/main')
8 files changed, 56 insertions, 19 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/labelchip/CompactLabelChip.java index 8659cef36..cf872f406 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/CompactLabelChip.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labelchip/CompactLabelChip.java @@ -1,4 +1,4 @@ -package it.niedermann.nextcloud.deck.ui.view; +package it.niedermann.nextcloud.deck.ui.view.labelchip; import android.annotation.SuppressLint; import android.content.Context; @@ -18,6 +18,5 @@ public class CompactLabelChip extends LabelChip { 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/labelchip/DefaultLabelChip.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labelchip/DefaultLabelChip.java new file mode 100644 index 000000000..80e44d7e0 --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labelchip/DefaultLabelChip.java @@ -0,0 +1,21 @@ +package it.niedermann.nextcloud.deck.ui.view.labelchip; + +import android.annotation.SuppressLint; +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Px; + +import it.niedermann.nextcloud.deck.model.Label; + +import static android.text.TextUtils.TruncateAt.MIDDLE; + +@SuppressLint("ViewConstructor") +public class DefaultLabelChip extends LabelChip { + + public DefaultLabelChip(@NonNull Context context, @NonNull Label label, @Px int gutter) { + super(context, label, gutter); + setText(label.getTitle()); + setEllipsize(MIDDLE); + } +}
\ No newline at end of file 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/LabelChip.java index a41cdcc22..ba3331457 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/LabelChip.java @@ -1,4 +1,4 @@ -package it.niedermann.nextcloud.deck.ui.view; +package it.niedermann.nextcloud.deck.ui.view.labelchip; import android.annotation.SuppressLint; import android.content.Context; @@ -16,8 +16,6 @@ import it.niedermann.nextcloud.deck.DeckLog; import it.niedermann.nextcloud.deck.model.Label; import it.niedermann.nextcloud.deck.util.ColorUtil; -import static android.text.TextUtils.TruncateAt.MIDDLE; - @SuppressLint("ViewConstructor") public class LabelChip extends Chip { @@ -43,9 +41,6 @@ public class LabelChip extends Chip { setTextEndPadding(gutter); setChipEndPadding(gutter); - setText(label.getTitle()); - setEllipsize(MIDDLE); - try { int labelColor = Color.parseColor("#" + label.getColor()); ColorStateList c = ColorStateList.valueOf(labelColor); 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/labellayout/CompactLabelLayout.java index ae44b2dde..1c5e35d97 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/CompactLabelLayout.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labellayout/CompactLabelLayout.java @@ -1,4 +1,4 @@ -package it.niedermann.nextcloud.deck.ui.view; +package it.niedermann.nextcloud.deck.ui.view.labellayout; import android.content.Context; import android.util.AttributeSet; @@ -6,6 +6,8 @@ import android.util.AttributeSet; import androidx.annotation.NonNull; import it.niedermann.nextcloud.deck.model.Label; +import it.niedermann.nextcloud.deck.ui.view.labelchip.CompactLabelChip; +import it.niedermann.nextcloud.deck.ui.view.labelchip.LabelChip; public class CompactLabelLayout extends LabelLayout { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labellayout/DefaultLabelLayout.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labellayout/DefaultLabelLayout.java new file mode 100644 index 000000000..f2d6d0752 --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/labellayout/DefaultLabelLayout.java @@ -0,0 +1,21 @@ +package it.niedermann.nextcloud.deck.ui.view.labellayout; + +import android.content.Context; +import android.util.AttributeSet; + +import androidx.annotation.NonNull; + +import it.niedermann.nextcloud.deck.model.Label; +import it.niedermann.nextcloud.deck.ui.view.labelchip.DefaultLabelChip; + +public class DefaultLabelLayout extends LabelLayout { + + public DefaultLabelLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected DefaultLabelChip createLabelChip(@NonNull Label label) { + return new DefaultLabelChip(getContext(), label, gutter); + } +} 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/LabelLayout.java index ffe7190a3..9a1d60021 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/LabelLayout.java @@ -1,4 +1,4 @@ -package it.niedermann.nextcloud.deck.ui.view; +package it.niedermann.nextcloud.deck.ui.view.labellayout; import android.content.Context; import android.util.AttributeSet; @@ -14,15 +14,16 @@ import java.util.List; import it.niedermann.nextcloud.deck.DeckLog; import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.model.Label; +import it.niedermann.nextcloud.deck.ui.view.labelchip.LabelChip; import static it.niedermann.nextcloud.deck.util.DimensionUtil.dpToPx; -public class LabelLayout extends FlexboxLayout { +public abstract class LabelLayout extends FlexboxLayout { @Px - protected int gutter; + final protected int gutter; @NonNull - private List<LabelChip> chipList = new LinkedList<>(); + final private List<LabelChip> chipList = new LinkedList<>(); public LabelLayout(Context context, AttributeSet attrs) { super(context, attrs); @@ -83,13 +84,11 @@ public class LabelLayout extends FlexboxLayout { continue labelList; } } - LabelChip chip = createLabelChip(label); + final LabelChip chip = createLabelChip(label); addView(chip); chipList.add(chip); } } - protected LabelChip createLabelChip(@NonNull Label label) { - return new LabelChip(getContext(), label, gutter); - } + protected abstract LabelChip createLabelChip(@NonNull Label label); } diff --git a/app/src/main/res/layout/item_card.xml b/app/src/main/res/layout/item_card.xml index c0457f5e4..01970ef57 100644 --- a/app/src/main/res/layout/item_card.xml +++ b/app/src/main/res/layout/item_card.xml @@ -69,7 +69,7 @@ </LinearLayout> </LinearLayout> - <it.niedermann.nextcloud.deck.ui.view.LabelLayout + <it.niedermann.nextcloud.deck.ui.view.labellayout.DefaultLabelLayout android:id="@+id/labels" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/app/src/main/res/layout/item_card_compact.xml b/app/src/main/res/layout/item_card_compact.xml index e7fdb9732..ffa20c071 100644 --- a/app/src/main/res/layout/item_card_compact.xml +++ b/app/src/main/res/layout/item_card_compact.xml @@ -79,7 +79,7 @@ app:srcCompat="@drawable/ic_menu" /> </LinearLayout> - <it.niedermann.nextcloud.deck.ui.view.CompactLabelLayout + <it.niedermann.nextcloud.deck.ui.view.labellayout.CompactLabelLayout android:id="@+id/labels" android:layout_width="match_parent" android:layout_height="wrap_content" |