From adac296e04c9aaf48ef0607d644bfddc1c926df5 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Tue, 24 Mar 2020 21:07:10 +0100 Subject: [PATCH] simplify ComposeOptionsView (#1734) --- .../compose/view/ComposeOptionsView.kt | 15 +-- app/src/main/res/layout/activity_compose.xml | 8 +- .../main/res/layout/view_compose_options.xml | 108 +++++++++--------- 3 files changed, 59 insertions(+), 72 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeOptionsView.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeOptionsView.kt index c99df40f2..8f80c76df 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeOptionsView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeOptionsView.kt @@ -17,25 +17,18 @@ package com.keylesspalace.tusky.components.compose.view import android.content.Context import android.util.AttributeSet -import android.widget.LinearLayout +import android.widget.RadioGroup import com.keylesspalace.tusky.R import com.keylesspalace.tusky.entity.Status -import kotlinx.android.synthetic.main.view_compose_options.view.* - -class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : LinearLayout(context, attrs, defStyleAttr) { +class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : RadioGroup(context, attrs) { var listener: ComposeOptionsListener? = null init { inflate(context, R.layout.view_compose_options, this) - publicRadioButton.setButtonDrawable(R.drawable.ic_public_24dp) - unlistedRadioButton.setButtonDrawable(R.drawable.ic_lock_open_24dp) - privateRadioButton.setButtonDrawable(R.drawable.ic_lock_outline_24dp) - directRadioButton.setButtonDrawable(R.drawable.ic_email_24dp) - - visibilityRadioGroup.setOnCheckedChangeListener { _, checkedId -> + setOnCheckedChangeListener { _, checkedId -> val visibility = when (checkedId) { R.id.publicRadioButton -> Status.Visibility.PUBLIC @@ -67,7 +60,7 @@ class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: Attr } - visibilityRadioGroup.check(selectedButton) + check(selectedButton) } } diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml index c0f934289..d25b2b094 100644 --- a/app/src/main/res/layout/activity_compose.xml +++ b/app/src/main/res/layout/activity_compose.xml @@ -215,10 +215,10 @@ android:layout_height="wrap_content" android:background="?attr/colorSurface" android:elevation="12dp" - android:paddingStart="16dp" - android:paddingTop="8dp" - android:paddingEnd="16dp" - android:paddingBottom="52dp" + android:paddingStart="24dp" + android:paddingTop="12dp" + android:paddingEnd="24dp" + android:paddingBottom="60dp" app:behavior_hideable="true" app:behavior_peekHeight="0dp" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" /> diff --git a/app/src/main/res/layout/view_compose_options.xml b/app/src/main/res/layout/view_compose_options.xml index 21f4659a9..ee8c70e87 100644 --- a/app/src/main/res/layout/view_compose_options.xml +++ b/app/src/main/res/layout/view_compose_options.xml @@ -1,68 +1,62 @@ + tools:layout_height="wrap_content" + tools:layout_width="match_parent" + tools:parentTag="RadioGroup"> - + + + android:layout_marginBottom="4dp" + android:layout_weight="1" + android:button="@drawable/ic_lock_open_24dp" + android:paddingStart="10dp" + android:paddingEnd="0dp" + android:text="@string/visibility_unlisted" + android:textColor="?android:textColorTertiary" + app:buttonTint="@color/compound_button_color" /> - + - - - - - - - + \ No newline at end of file