simplify ComposeOptionsView (#1734)
This commit is contained in:
parent
cf782f039f
commit
adac296e04
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:parentTag="android.widget.LinearLayout">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/visibilityRadioGroup"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/compose_options_margin"
|
||||
android:layout_marginLeft="@dimen/compose_options_margin"
|
||||
android:layout_marginRight="@dimen/compose_options_margin"
|
||||
android:layout_marginTop="4dp"
|
||||
android:orientation="vertical">
|
||||
tools:layout_height="wrap_content"
|
||||
tools:layout_width="match_parent"
|
||||
tools:parentTag="RadioGroup">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/publicRadioButton"
|
||||
|
@ -19,8 +11,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="0dp"
|
||||
android:button="@drawable/ic_public_24dp"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:text="@string/visibility_public"
|
||||
android:textColor="?android:textColorTertiary"
|
||||
app:buttonTint="@color/compound_button_color" />
|
||||
|
@ -29,11 +22,12 @@
|
|||
android:id="@+id/unlistedRadioButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="0dp"
|
||||
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" />
|
||||
|
@ -42,11 +36,12 @@
|
|||
android:id="@+id/privateRadioButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="0dp"
|
||||
android:button="@drawable/ic_lock_outline_24dp"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:text="@string/visibility_private"
|
||||
android:textColor="?android:textColorTertiary"
|
||||
app:buttonTint="@color/compound_button_color" />
|
||||
|
@ -57,12 +52,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="0dp"
|
||||
android:button="@drawable/ic_email_24dp"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:text="@string/visibility_direct"
|
||||
android:textColor="?android:textColorTertiary"
|
||||
app:buttonTint="@color/compound_button_color" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
</merge>
|
Loading…
Reference in New Issue