Add button downstates to appearance settings screen (#1224)

This commit is contained in:
Andrew 2023-06-20 12:04:24 +09:30 committed by GitHub
parent 92a6447b8a
commit b9f24bc4bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 230 additions and 169 deletions

View File

@ -78,8 +78,6 @@ class AppearanceSettingsActivity: PassphraseRequiredActionBarActivity(), View.On
viewModel.setNewAccent(R.style.PrimaryGreen) viewModel.setNewAccent(R.style.PrimaryGreen)
} }
} }
} else if (v == binding.systemSettingsSwitch) {
viewModel.setNewFollowSystemSettings((v as SwitchCompat).isChecked)
} }
} }
@ -115,12 +113,8 @@ class AppearanceSettingsActivity: PassphraseRequiredActionBarActivity(), View.On
super.onCreate(savedInstanceState, ready) super.onCreate(savedInstanceState, ready)
binding = ActivityAppearanceSettingsBinding.inflate(layoutInflater) binding = ActivityAppearanceSettingsBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
savedInstanceState?.let { bundle -> savedInstanceState?.getSparseParcelableArray<Parcelable>(SCROLL_PARCEL)
val scrollStateParcel = bundle.getSparseParcelableArray<Parcelable>(SCROLL_PARCEL) ?.let(binding.scrollView::restoreHierarchyState)
if (scrollStateParcel != null) {
binding.scrollView.restoreHierarchyState(scrollStateParcel)
}
}
supportActionBar!!.title = getString(R.string.activity_settings_message_appearance_button_title) supportActionBar!!.title = getString(R.string.activity_settings_message_appearance_button_title)
with (binding) { with (binding) {
// accent toggles // accent toggles
@ -132,7 +126,8 @@ class AppearanceSettingsActivity: PassphraseRequiredActionBarActivity(), View.On
it.setOnClickListener(this@AppearanceSettingsActivity) it.setOnClickListener(this@AppearanceSettingsActivity)
} }
// system settings toggle // system settings toggle
systemSettingsSwitch.setOnClickListener(this@AppearanceSettingsActivity) systemSettingsSwitch.setOnCheckedChangeListener { _, isChecked -> viewModel.setNewFollowSystemSettings(isChecked) }
systemSettingsSwitchHolder.setOnClickListener { systemSettingsSwitch.toggle() }
} }
lifecycleScope.launchWhenResumed { lifecycleScope.launchWhenResumed {
@ -148,6 +143,5 @@ class AppearanceSettingsActivity: PassphraseRequiredActionBarActivity(), View.On
} }
} }
} }
} }
} }

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?colorControlHighlight">
<item android:left="@dimen/medium_spacing" <item android:left="@dimen/medium_spacing"
android:right="@dimen/medium_spacing" android:right="@dimen/medium_spacing"
android:bottom="@dimen/small_spacing" android:bottom="@dimen/small_spacing"
@ -10,4 +11,4 @@
android:bottomRightRadius="?preferenceCornerRadius"/> android:bottomRightRadius="?preferenceCornerRadius"/>
</shape> </shape>
</item> </item>
</layer-list> </ripple>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?colorControlHighlight">
<item android:left="@dimen/medium_spacing" <item android:left="@dimen/medium_spacing"
android:right="@dimen/medium_spacing"> android:right="@dimen/medium_spacing">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
@ -14,4 +15,4 @@
<solid android:color="@color/transparent_white_15"/> <solid android:color="@color/transparent_white_15"/>
</shape> </shape>
</item> </item>
</layer-list> </ripple>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?colorControlHighlight">
<item android:left="@dimen/medium_spacing" <item android:left="@dimen/medium_spacing"
android:top="@dimen/small_spacing" android:top="@dimen/small_spacing"
android:right="@dimen/medium_spacing" android:right="@dimen/medium_spacing"
@ -9,4 +10,4 @@
<corners android:radius="?preferenceCornerRadius"/> <corners android:radius="?preferenceCornerRadius"/>
</shape> </shape>
</item> </item>
</layer-list> </ripple>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?colorControlHighlight">
<item android:left="@dimen/medium_spacing" <item android:left="@dimen/medium_spacing"
android:right="@dimen/medium_spacing" android:right="@dimen/medium_spacing"
android:top="@dimen/small_spacing" android:top="@dimen/small_spacing"
@ -18,4 +19,4 @@
<solid android:color="@color/transparent_white_15"/> <solid android:color="@color/transparent_white_15"/>
</shape> </shape>
</item> </item>
</layer-list> </ripple>

View File

@ -1,12 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?colorControlHighlight">
<item android:state_selected="true"> <item>
<selector>
<item android:state_selected="true">
<shape android:shape="oval">
<stroke android:width="1dp" android:color="?android:textColorPrimary"/>
</shape>
</item>
<item android:state_selected="false">
<shape android:shape="oval">
</shape>
</item>
</selector>
</item>
<item android:id="@android:id/mask">
<shape android:shape="oval"> <shape android:shape="oval">
<stroke android:width="1dp" android:color="?android:textColorPrimary"/> <solid android:color="@color/black"/>
</shape> </shape>
</item> </item>
<item android:state_selected="false"> </ripple>
<shape android:shape="oval">
</shape>
</item>
</selector>

View File

@ -11,6 +11,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView <TextView
android:textColor="?android:textColorTertiary" android:textColor="?android:textColorTertiary"
android:textSize="@dimen/medium_font_size" android:textSize="@dimen/medium_font_size"
@ -20,127 +21,170 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/activity_appearance_themes_category"/> android:text="@string/activity_appearance_themes_category"/>
<LinearLayout <androidx.cardview.widget.CardView
android:id="@+id/theme_option_classic_dark" app:cardElevation="0dp"
android:background="@drawable/preference_top" app:cardCornerRadius="@dimen/dialog_corner_radius"
android:layout_marginHorizontal="@dimen/medium_spacing"
app:cardBackgroundColor="?colorSettingsBackground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:paddingHorizontal="@dimen/large_spacing" <LinearLayout
android:paddingVertical="@dimen/medium_spacing" android:orientation="vertical"
android:orientation="horizontal"> android:layout_width="match_parent"
<ImageView android:layout_height="wrap_content">
android:theme="@style/Classic.Dark" <LinearLayout
android:layout_width="wrap_content" android:id="@+id/theme_option_classic_dark"
android:layout_height="wrap_content" android:addStatesFromChildren="true"
android:src="@drawable/ic_themepreview"/> android:background="?selectableItemBackground"
<TextView android:layout_width="match_parent"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" android:layout_height="wrap_content"
android:lines="1" android:paddingHorizontal="@dimen/small_spacing"
android:textSize="16sp" android:paddingVertical="@dimen/small_spacing"
android:text="@string/classic_dark_theme_name" android:orientation="horizontal">
android:padding="@dimen/medium_spacing" <ImageView
android:layout_gravity="center" android:theme="@style/Classic.Dark"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_height="wrap_content"/> android:src="@drawable/ic_themepreview"/>
<RadioButton <TextView
android:id="@+id/theme_radio_classic_dark" android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:layout_gravity="center" android:lines="1"
android:layout_margin="@dimen/small_spacing" android:textSize="16sp"
android:layout_width="wrap_content" android:text="@string/classic_dark_theme_name"
android:layout_height="wrap_content"/> android:padding="@dimen/medium_spacing"
</LinearLayout> android:layout_gravity="center"
<LinearLayout android:layout_width="0dp"
android:id="@+id/theme_option_classic_light" android:layout_weight="1"
android:layout_width="match_parent" android:layout_height="wrap_content"/>
android:layout_height="wrap_content" <RadioButton
android:background="@drawable/preference_middle" android:id="@+id/theme_radio_classic_dark"
android:paddingHorizontal="@dimen/large_spacing" android:layout_gravity="center"
android:paddingVertical="@dimen/small_spacing" android:layout_margin="@dimen/small_spacing"
android:orientation="horizontal"> android:layout_width="wrap_content"
<ImageView android:layout_height="wrap_content"/>
android:theme="@style/Classic.Light" </LinearLayout>
android:layout_width="wrap_content"
android:layout_height="wrap_content" <View
android:src="@drawable/ic_themepreview"/> android:alpha="0.15"
<TextView android:layout_width="match_parent"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" android:layout_height="1dp"
android:textSize="16sp" android:background="?android:textColorPrimary"/>
android:lines="1"
android:text="@string/classic_light_theme_name" <LinearLayout
android:padding="@dimen/medium_spacing" android:id="@+id/theme_option_classic_light"
android:layout_gravity="center" android:addStatesFromChildren="true"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_height="wrap_content"/> android:background="?selectableItemBackground"
<RadioButton android:paddingHorizontal="@dimen/small_spacing"
android:id="@+id/theme_radio_classic_light" android:paddingVertical="@dimen/small_spacing"
android:layout_gravity="center" android:orientation="horizontal">
android:layout_margin="@dimen/small_spacing" <ImageView
android:layout_width="wrap_content" android:theme="@style/Classic.Light"
android:layout_height="wrap_content"/> android:layout_width="wrap_content"
</LinearLayout> android:layout_height="wrap_content"
<LinearLayout android:src="@drawable/ic_themepreview"/>
android:id="@+id/theme_option_ocean_dark" <TextView
android:layout_width="match_parent" android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:layout_height="wrap_content" android:textSize="16sp"
android:background="@drawable/preference_middle" android:lines="1"
android:paddingHorizontal="@dimen/large_spacing" android:text="@string/classic_light_theme_name"
android:paddingVertical="@dimen/medium_spacing" android:padding="@dimen/medium_spacing"
android:orientation="horizontal"> android:layout_gravity="center"
<ImageView android:layout_width="0dp"
android:theme="@style/Ocean.Dark" android:layout_weight="1"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
android:layout_height="wrap_content" <RadioButton
android:src="@drawable/ic_themepreview"/> android:id="@+id/theme_radio_classic_light"
<TextView android:layout_gravity="center"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" android:layout_margin="@dimen/small_spacing"
android:textSize="16sp" android:layout_width="wrap_content"
android:lines="1" android:layout_height="wrap_content"/>
android:text="@string/ocean_dark_theme_name" </LinearLayout>
android:padding="@dimen/medium_spacing"
android:layout_gravity="center" <View
android:layout_width="0dp" android:alpha="0.15"
android:layout_weight="1" android:layout_marginHorizontal="@dimen/medium_spacing"
android:layout_height="wrap_content"/> android:layout_width="match_parent"
<RadioButton android:layout_height="1dp"
android:id="@+id/theme_radio_ocean_dark" android:background="?android:textColorPrimary"/>
android:layout_gravity="center"
android:layout_margin="@dimen/small_spacing" <LinearLayout
android:layout_width="wrap_content" android:id="@+id/theme_option_ocean_dark"
android:layout_height="wrap_content"/> android:addStatesFromChildren="true"
</LinearLayout> android:layout_width="match_parent"
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/theme_option_ocean_light" android:background="?selectableItemBackground"
android:layout_width="match_parent" android:paddingHorizontal="@dimen/small_spacing"
android:layout_height="wrap_content" android:paddingVertical="@dimen/small_spacing"
android:background="@drawable/preference_bottom" android:orientation="horizontal">
android:paddingHorizontal="@dimen/large_spacing" <ImageView
android:paddingTop="@dimen/medium_spacing" android:theme="@style/Ocean.Dark"
android:paddingBottom="@dimen/large_spacing" android:layout_width="wrap_content"
android:orientation="horizontal"> android:layout_height="wrap_content"
<ImageView android:src="@drawable/ic_themepreview"/>
android:theme="@style/Ocean.Light" <TextView
android:layout_width="wrap_content" android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:layout_height="wrap_content" android:textSize="16sp"
android:src="@drawable/ic_themepreview"/> android:lines="1"
<TextView android:text="@string/ocean_dark_theme_name"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" android:padding="@dimen/medium_spacing"
android:textSize="16sp" android:layout_gravity="center"
android:lines="1" android:layout_width="0dp"
android:text="@string/ocean_light_theme_name" android:layout_weight="1"
android:padding="@dimen/medium_spacing" android:layout_height="wrap_content"/>
android:layout_gravity="center" <RadioButton
android:layout_width="0dp" android:id="@+id/theme_radio_ocean_dark"
android:layout_weight="1" android:layout_gravity="center"
android:layout_height="wrap_content"/> android:layout_margin="@dimen/small_spacing"
<RadioButton android:layout_width="wrap_content"
android:id="@+id/theme_radio_ocean_light" android:layout_height="wrap_content"/>
android:layout_gravity="center" </LinearLayout>
android:layout_margin="@dimen/small_spacing"
android:layout_width="wrap_content" <View
android:layout_height="wrap_content"/> android:alpha="0.15"
</LinearLayout> android:layout_marginHorizontal="@dimen/medium_spacing"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:textColorPrimary"/>
<LinearLayout
android:id="@+id/theme_option_ocean_light"
android:addStatesFromChildren="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:paddingHorizontal="@dimen/small_spacing"
android:paddingVertical="@dimen/small_spacing"
android:orientation="horizontal">
<ImageView
android:theme="@style/Ocean.Light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_themepreview"/>
<TextView
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:textSize="16sp"
android:lines="1"
android:text="@string/ocean_light_theme_name"
android:padding="@dimen/medium_spacing"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"/>
<RadioButton
android:id="@+id/theme_radio_ocean_light"
android:layout_gravity="center"
android:layout_margin="@dimen/small_spacing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<TextView <TextView
android:textColor="?android:textColorTertiary" android:textColor="?android:textColorTertiary"
android:textSize="@dimen/medium_font_size" android:textSize="@dimen/medium_font_size"
@ -208,8 +252,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_marginVertical="@dimen/medium_spacing" android:layout_marginVertical="@dimen/small_spacing"
android:layout_marginHorizontal="@dimen/large_spacing"> android:layout_marginHorizontal="@dimen/small_spacing">
<View <View
android:id="@+id/accent_green" android:id="@+id/accent_green"
android:background="@drawable/padded_circle_tintable" android:background="@drawable/padded_circle_tintable"
@ -270,29 +314,39 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/activity_appearance_follow_system_category"/> android:text="@string/activity_appearance_follow_system_category"/>
<LinearLayout <androidx.cardview.widget.CardView
android:padding="@dimen/medium_spacing" app:cardElevation="0dp"
android:elevation="0dp"
app:cardBackgroundColor="?colorSettingsBackground"
app:cardCornerRadius="@dimen/dialog_corner_radius"
android:layout_margin="@dimen/medium_spacing"
android:layout_marginBottom="@dimen/massive_spacing" android:layout_marginBottom="@dimen/massive_spacing"
android:background="@drawable/preference_single"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:gravity="center"> <LinearLayout
<TextView android:id="@+id/system_settings_switch_holder"
android:textColor="?android:textColorPrimary" android:background="?selectableItemBackground"
android:textStyle="bold" android:layout_width="match_parent"
android:textSize="@dimen/medium_font_size"
android:paddingHorizontal="@dimen/large_spacing"
android:paddingVertical="@dimen/small_spacing"
android:text="@string/activity_appearance_follow_system_explanation"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"/> android:addStatesFromChildren="true"
<androidx.appcompat.widget.SwitchCompat android:gravity="center">
android:id="@+id/system_settings_switch" <TextView
android:paddingHorizontal="@dimen/large_spacing" android:textColor="?android:textColorPrimary"
android:layout_width="wrap_content" android:textStyle="bold"
android:layout_height="wrap_content"/> android:textSize="@dimen/medium_font_size"
</LinearLayout> android:paddingHorizontal="@dimen/large_spacing"
android:paddingVertical="@dimen/small_spacing"
android:text="@string/activity_appearance_follow_system_explanation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/system_settings_switch"
android:paddingHorizontal="@dimen/large_spacing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>