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.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.LinearLayout
|
import android.widget.RadioGroup
|
||||||
import com.keylesspalace.tusky.R
|
import com.keylesspalace.tusky.R
|
||||||
import com.keylesspalace.tusky.entity.Status
|
import com.keylesspalace.tusky.entity.Status
|
||||||
import kotlinx.android.synthetic.main.view_compose_options.view.*
|
|
||||||
|
|
||||||
|
class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : RadioGroup(context, attrs) {
|
||||||
class ComposeOptionsView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : LinearLayout(context, attrs, defStyleAttr) {
|
|
||||||
|
|
||||||
var listener: ComposeOptionsListener? = null
|
var listener: ComposeOptionsListener? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
inflate(context, R.layout.view_compose_options, this)
|
inflate(context, R.layout.view_compose_options, this)
|
||||||
|
|
||||||
publicRadioButton.setButtonDrawable(R.drawable.ic_public_24dp)
|
setOnCheckedChangeListener { _, checkedId ->
|
||||||
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 ->
|
|
||||||
val visibility = when (checkedId) {
|
val visibility = when (checkedId) {
|
||||||
R.id.publicRadioButton ->
|
R.id.publicRadioButton ->
|
||||||
Status.Visibility.PUBLIC
|
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:layout_height="wrap_content"
|
||||||
android:background="?attr/colorSurface"
|
android:background="?attr/colorSurface"
|
||||||
android:elevation="12dp"
|
android:elevation="12dp"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="24dp"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="12dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="24dp"
|
||||||
android:paddingBottom="52dp"
|
android:paddingBottom="60dp"
|
||||||
app:behavior_hideable="true"
|
app:behavior_hideable="true"
|
||||||
app:behavior_peekHeight="0dp"
|
app:behavior_peekHeight="0dp"
|
||||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
|
||||||
|
|
|
@ -1,68 +1,62 @@
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:parentTag="android.widget.LinearLayout">
|
tools:layout_height="wrap_content"
|
||||||
|
tools:layout_width="match_parent"
|
||||||
|
tools:parentTag="RadioGroup">
|
||||||
|
|
||||||
<RadioGroup
|
<RadioButton
|
||||||
android:id="@+id/visibilityRadioGroup"
|
android:id="@+id/publicRadioButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
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" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/unlistedRadioButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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:layout_marginTop="4dp"
|
||||||
android:orientation="vertical">
|
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" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/publicRadioButton"
|
android:id="@+id/privateRadioButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_weight="1"
|
android:layout_marginBottom="4dp"
|
||||||
android:paddingEnd="0dp"
|
android:layout_weight="1"
|
||||||
android:paddingStart="10dp"
|
android:button="@drawable/ic_lock_outline_24dp"
|
||||||
android:text="@string/visibility_public"
|
android:paddingStart="10dp"
|
||||||
android:textColor="?android:textColorTertiary"
|
android:paddingEnd="0dp"
|
||||||
app:buttonTint="@color/compound_button_color" />
|
android:text="@string/visibility_private"
|
||||||
|
android:textColor="?android:textColorTertiary"
|
||||||
|
app:buttonTint="@color/compound_button_color" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/unlistedRadioButton"
|
android:id="@+id/directRadioButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_weight="1"
|
||||||
android:layout_weight="1"
|
android:button="@drawable/ic_email_24dp"
|
||||||
android:paddingEnd="0dp"
|
android:paddingStart="10dp"
|
||||||
android:paddingStart="10dp"
|
android:paddingEnd="0dp"
|
||||||
android:text="@string/visibility_unlisted"
|
android:text="@string/visibility_direct"
|
||||||
android:textColor="?android:textColorTertiary"
|
android:textColor="?android:textColorTertiary"
|
||||||
app:buttonTint="@color/compound_button_color" />
|
app:buttonTint="@color/compound_button_color" />
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/privateRadioButton"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="4dp"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:paddingEnd="0dp"
|
|
||||||
android:paddingStart="10dp"
|
|
||||||
android:text="@string/visibility_private"
|
|
||||||
android:textColor="?android:textColorTertiary"
|
|
||||||
app:buttonTint="@color/compound_button_color" />
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/directRadioButton"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:paddingEnd="0dp"
|
|
||||||
android:paddingStart="10dp"
|
|
||||||
android:text="@string/visibility_direct"
|
|
||||||
android:textColor="?android:textColorTertiary"
|
|
||||||
app:buttonTint="@color/compound_button_color" />
|
|
||||||
|
|
||||||
</RadioGroup>
|
|
||||||
|
|
||||||
</merge>
|
</merge>
|
Loading…
Reference in New Issue