simplify ComposeOptionsView (#1734)

main
Konrad Pozniak 5 years ago committed by Alibek Omarov
parent 57af67bf49
commit ae651c3cf1
  1. 15
      app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeOptionsView.kt
  2. 8
      app/src/main/res/layout/activity_compose.xml
  3. 32
      app/src/main/res/layout/view_compose_options.xml

@ -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)
} }
} }

@ -273,10 +273,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,17 +1,9 @@
<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"
<RadioGroup tools:parentTag="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">
<RadioButton <RadioButton
android:id="@+id/publicRadioButton" android:id="@+id/publicRadioButton"
@ -19,8 +11,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:layout_weight="1" android:layout_weight="1"
android:paddingEnd="0dp" android:button="@drawable/ic_public_24dp"
android:paddingStart="10dp" android:paddingStart="10dp"
android:paddingEnd="0dp"
android:text="@string/visibility_public" android:text="@string/visibility_public"
android:textColor="?android:textColorTertiary" android:textColor="?android:textColorTertiary"
app:buttonTint="@color/compound_button_color" /> app:buttonTint="@color/compound_button_color" />
@ -29,11 +22,12 @@
android:id="@+id/unlistedRadioButton" 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="4dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_weight="1" android:layout_weight="1"
android:paddingEnd="0dp" android:button="@drawable/ic_lock_open_24dp"
android:paddingStart="10dp" android:paddingStart="10dp"
android:paddingEnd="0dp"
android:text="@string/visibility_unlisted" android:text="@string/visibility_unlisted"
android:textColor="?android:textColorTertiary" android:textColor="?android:textColorTertiary"
app:buttonTint="@color/compound_button_color" /> app:buttonTint="@color/compound_button_color" />
@ -42,11 +36,12 @@
android:id="@+id/privateRadioButton" 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_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_weight="1" android:layout_weight="1"
android:paddingEnd="0dp" android:button="@drawable/ic_lock_outline_24dp"
android:paddingStart="10dp" android:paddingStart="10dp"
android:paddingEnd="0dp"
android:text="@string/visibility_private" android:text="@string/visibility_private"
android:textColor="?android:textColorTertiary" android:textColor="?android:textColorTertiary"
app:buttonTint="@color/compound_button_color" /> app:buttonTint="@color/compound_button_color" />
@ -57,12 +52,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_weight="1" android:layout_weight="1"
android:paddingEnd="0dp" android:button="@drawable/ic_email_24dp"
android:paddingStart="10dp" android:paddingStart="10dp"
android:paddingEnd="0dp"
android:text="@string/visibility_direct" 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" />
</RadioGroup>
</merge> </merge>
Loading…
Cancel
Save