diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-07-04 20:44:46 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-07-04 20:44:46 +0300 |
commit | 41a935038373204dd0fc7568b653eab5d75d12f5 (patch) | |
tree | fe32c2bb9870812356a30933cadbc5bb5c945cc7 /app/src/main/java/it/niedermann/nextcloud/deck/ui/view | |
parent | bd3f91a310ede663ae242038c2a3f21d7e85f042 (diff) |
Offer new default board colors like server
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/ColorChooser.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java index d444e075e..30dc0ada4 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/ColorChooser.java @@ -5,21 +5,30 @@ import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import androidx.annotation.Nullable; +import com.google.android.flexbox.FlexboxLayout; import com.skydoves.colorpickerview.listeners.ColorEnvelopeListener; import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.databinding.WidgetColorChooserBinding; import it.niedermann.nextcloud.deck.util.ViewUtil; +import static it.niedermann.nextcloud.deck.util.DimensionUtil.dpToPx; + public class ColorChooser extends LinearLayout { private WidgetColorChooserBinding binding; + private final FlexboxLayout.LayoutParams params = new FlexboxLayout.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ); + private Context context; private String[] colors; @@ -32,6 +41,9 @@ public class ColorChooser extends LinearLayout { super(context, attrs); this.context = context; + params.setMargins(0, dpToPx(context, R.dimen.spacer_1x), 0, 0); + params.setFlexBasisPercent(.15f); + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorChooser, 0, 0); colors = getResources().getStringArray(a.getResourceId(R.styleable.ColorChooser_colors, 0)); @@ -40,6 +52,7 @@ public class ColorChooser extends LinearLayout { binding = WidgetColorChooserBinding.inflate(LayoutInflater.from(context), this, true); for (final String color : colors) { ImageView image = new ImageView(getContext()); + image.setLayoutParams(params); image.setOnClickListener((imageView) -> { if (previouslySelectedImageView != null) { // null when first selection previouslySelectedImageView.setImageDrawable(ViewUtil.getTintedImageView(this.context, R.drawable.circle_grey600_36dp, previouslySelectedColor)); |