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

View File

@ -1,5 +1,6 @@
<?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"
android:right="@dimen/medium_spacing"
android:bottom="@dimen/small_spacing"
@ -10,4 +11,4 @@
android:bottomRightRadius="?preferenceCornerRadius"/>
</shape>
</item>
</layer-list>
</ripple>

View File

@ -1,5 +1,6 @@
<?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"
android:right="@dimen/medium_spacing">
<shape android:shape="rectangle">
@ -14,4 +15,4 @@
<solid android:color="@color/transparent_white_15"/>
</shape>
</item>
</layer-list>
</ripple>

View File

@ -1,5 +1,6 @@
<?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"
android:top="@dimen/small_spacing"
android:right="@dimen/medium_spacing"
@ -9,4 +10,4 @@
<corners android:radius="?preferenceCornerRadius"/>
</shape>
</item>
</layer-list>
</ripple>

View File

@ -1,5 +1,6 @@
<?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"
android:right="@dimen/medium_spacing"
android:top="@dimen/small_spacing"
@ -18,4 +19,4 @@
<solid android:color="@color/transparent_white_15"/>
</shape>
</item>
</layer-list>
</ripple>

View File

@ -1,5 +1,7 @@
<?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>
<selector>
<item android:state_selected="true">
<shape android:shape="oval">
<stroke android:width="1dp" android:color="?android:textColorPrimary"/>
@ -10,3 +12,10 @@
</shape>
</item>
</selector>
</item>
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="@color/black"/>
</shape>
</item>
</ripple>

View File

@ -11,6 +11,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="?android:textColorTertiary"
android:textSize="@dimen/medium_font_size"
@ -20,13 +21,25 @@
android:layout_height="wrap_content"
android:text="@string/activity_appearance_themes_category"/>
<androidx.cardview.widget.CardView
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/dialog_corner_radius"
android:layout_marginHorizontal="@dimen/medium_spacing"
app:cardBackgroundColor="?colorSettingsBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/theme_option_classic_dark"
android:background="@drawable/preference_top"
android:addStatesFromChildren="true"
android:background="?selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/large_spacing"
android:paddingVertical="@dimen/medium_spacing"
android:paddingHorizontal="@dimen/small_spacing"
android:paddingVertical="@dimen/small_spacing"
android:orientation="horizontal">
<ImageView
android:theme="@style/Classic.Dark"
@ -50,12 +63,20 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:alpha="0.15"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:textColorPrimary"/>
<LinearLayout
android:id="@+id/theme_option_classic_light"
android:addStatesFromChildren="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/preference_middle"
android:paddingHorizontal="@dimen/large_spacing"
android:background="?selectableItemBackground"
android:paddingHorizontal="@dimen/small_spacing"
android:paddingVertical="@dimen/small_spacing"
android:orientation="horizontal">
<ImageView
@ -80,13 +101,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:alpha="0.15"
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_dark"
android:addStatesFromChildren="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/preference_middle"
android:paddingHorizontal="@dimen/large_spacing"
android:paddingVertical="@dimen/medium_spacing"
android:background="?selectableItemBackground"
android:paddingHorizontal="@dimen/small_spacing"
android:paddingVertical="@dimen/small_spacing"
android:orientation="horizontal">
<ImageView
android:theme="@style/Ocean.Dark"
@ -110,14 +140,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:alpha="0.15"
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="@drawable/preference_bottom"
android:paddingHorizontal="@dimen/large_spacing"
android:paddingTop="@dimen/medium_spacing"
android:paddingBottom="@dimen/large_spacing"
android:background="?selectableItemBackground"
android:paddingHorizontal="@dimen/small_spacing"
android:paddingVertical="@dimen/small_spacing"
android:orientation="horizontal">
<ImageView
android:theme="@style/Ocean.Light"
@ -141,6 +179,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<TextView
android:textColor="?android:textColorTertiary"
android:textSize="@dimen/medium_font_size"
@ -208,8 +252,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginVertical="@dimen/medium_spacing"
android:layout_marginHorizontal="@dimen/large_spacing">
android:layout_marginVertical="@dimen/small_spacing"
android:layout_marginHorizontal="@dimen/small_spacing">
<View
android:id="@+id/accent_green"
android:background="@drawable/padded_circle_tintable"
@ -270,12 +314,21 @@
android:layout_height="wrap_content"
android:text="@string/activity_appearance_follow_system_category"/>
<LinearLayout
android:padding="@dimen/medium_spacing"
<androidx.cardview.widget.CardView
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:background="@drawable/preference_single"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/system_settings_switch_holder"
android:background="?selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:addStatesFromChildren="true"
android:gravity="center">
<TextView
android:textColor="?android:textColorPrimary"
@ -287,12 +340,13 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<androidx.appcompat.widget.SwitchCompat
<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>
</ScrollView>