redesigning the app settings

This commit is contained in:
tibbi 2023-02-12 23:02:23 +01:00
parent 8125a6ef06
commit 7b8a2de649
5 changed files with 104 additions and 129 deletions

View File

@ -63,9 +63,9 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:0828fecd09' implementation 'com.github.SimpleMobileTools:Simple-Commons:c457573200'
kapt "androidx.room:room-compiler:2.4.3" kapt "androidx.room:room-compiler:2.5.0"
implementation "androidx.room:room-runtime:2.4.3" implementation "androidx.room:room-runtime:2.5.0"
annotationProcessor "androidx.room:room-compiler:2.4.3" annotationProcessor "androidx.room:room-compiler:2.5.0"
} }

View File

@ -77,7 +77,6 @@ class MainActivity : SimpleActivity(), FlingListener {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false useDynamicTheme = false
showTransparentNavigation = true
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)

View File

@ -15,14 +15,19 @@ import kotlin.system.exitProcess
class SettingsActivity : SimpleActivity() { class SettingsActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings) setContentView(R.layout.activity_settings)
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
setupOptionsMenu() setupOptionsMenu()
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
setupToolbar(settings_toolbar, NavigationIcon.Arrow) setupToolbar(settings_toolbar, NavigationIcon.Arrow)
refreshMenuItems()
setupPurchaseThankYou() setupPurchaseThankYou()
setupCustomizeColors() setupCustomizeColors()
@ -31,44 +36,38 @@ class SettingsActivity : SimpleActivity() {
setupManageHiddenIcons() setupManageHiddenIcons()
updateTextColors(settings_holder) updateTextColors(settings_holder)
arrayOf(settings_color_customization_label, settings_general_settings_label).forEach { arrayOf(settings_color_customization_section_label, settings_general_settings_label).forEach {
it.setTextColor(getProperPrimaryColor()) it.setTextColor(getProperPrimaryColor())
} }
arrayOf(
settings_color_customization_holder,
settings_general_settings_holder
).forEach {
it.background.applyColorFilter(getProperBackgroundColor().getContrastColor())
}
} }
private fun setupOptionsMenu() { private fun setupOptionsMenu() {
settings_toolbar.setOnMenuItemClickListener { menuItem -> settings_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) { when (menuItem.itemId) {
R.id.about -> launchAbout() R.id.about -> launchAbout()
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
else -> return@setOnMenuItemClickListener false else -> return@setOnMenuItemClickListener false
} }
return@setOnMenuItemClickListener true return@setOnMenuItemClickListener true
} }
} }
private fun setupPurchaseThankYou() { private fun refreshMenuItems() {
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled()) settings_toolbar.menu.apply {
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
// make sure the corners at ripple fit the stroke rounded corners }
if (settings_purchase_thank_you_holder.isGone()) {
settings_use_english_holder.background = resources.getDrawable(R.drawable.ripple_top_corners, theme)
settings_language_holder.background = resources.getDrawable(R.drawable.ripple_top_corners, theme)
} }
private fun setupPurchaseThankYou() {
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())
settings_purchase_thank_you_holder.setOnClickListener { settings_purchase_thank_you_holder.setOnClickListener {
launchPurchaseThankYouIntent() launchPurchaseThankYouIntent()
} }
} }
private fun setupCustomizeColors() { private fun setupCustomizeColors() {
settings_customize_colors_holder.setOnClickListener { settings_color_customization_label.text = getCustomizeColorsString()
settings_color_customization_holder.setOnClickListener {
startCustomizationActivity() startCustomizationActivity()
} }
} }
@ -92,12 +91,6 @@ class SettingsActivity : SimpleActivity() {
} }
private fun setupManageHiddenIcons() { private fun setupManageHiddenIcons() {
if (settings_purchase_thank_you_holder.isGone() && settings_use_english_holder.isGone() && settings_language_holder.isGone()) {
settings_manage_hidden_icons_holder.background = resources.getDrawable(R.drawable.ripple_all_corners, theme)
} else {
settings_manage_hidden_icons_holder.background = resources.getDrawable(R.drawable.ripple_bottom_corners, theme)
}
settings_manage_hidden_icons_holder.setOnClickListener { settings_manage_hidden_icons_holder.setOnClickListener {
startActivity(Intent(this, HiddenIconsActivity::class.java)) startActivity(Intent(this, HiddenIconsActivity::class.java))
} }

View File

@ -6,30 +6,22 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/settings_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/settings_toolbar" android:id="@+id/settings_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary" android:background="@color/color_primary"
app:layout_scrollFlags="scroll|enterAlways"
app:menu="@menu/menu_settings" app:menu="@menu/menu_settings"
app:title="@string/settings" app:title="@string/settings"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" /> app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/settings_nested_scrollview" android:id="@+id/settings_nested_scrollview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:fillViewport="true" android:fillViewport="true"
android:scrollbars="none" android:scrollbars="none">
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout <LinearLayout
android:id="@+id/settings_holder" android:id="@+id/settings_holder"
@ -38,36 +30,32 @@
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/settings_color_customization_label" android:id="@+id/settings_color_customization_section_label"
style="@style/SettingsSectionLabelStyle" style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/color_customization" /> android:text="@string/color_customization" />
<LinearLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/settings_color_customization_holder" android:id="@+id/settings_color_customization_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_customize_colors_holder"
style="@style/SettingsHolderTextViewOneLinerStyle" style="@style/SettingsHolderTextViewOneLinerStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:background="@drawable/ripple_all_corners">
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_customize_colors_label" android:id="@+id/settings_color_customization_label"
style="@style/SettingsTextLabelStyle" style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/customize_colors" /> android:text="@string/customize_colors"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<include
android:id="@+id/settings_color_customization_divider"
layout="@layout/divider" />
<TextView <TextView
android:id="@+id/settings_general_settings_label" android:id="@+id/settings_general_settings_label"
@ -76,14 +64,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/general_settings" /> android:text="@string/general_settings" />
<LinearLayout
android:id="@+id/settings_general_settings_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout <RelativeLayout
android:id="@+id/settings_purchase_thank_you_holder" android:id="@+id/settings_purchase_thank_you_holder"
style="@style/SettingsHolderTextViewOneLinerStyle" style="@style/SettingsHolderTextViewOneLinerStyle"
@ -156,6 +136,5 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -2,10 +2,14 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu 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:ignore="AppCompatResource"> tools:ignore="AppCompatResource,AlwaysShowAction">
<item <item
android:id="@+id/about" android:id="@+id/about"
android:icon="@drawable/ic_info_vector" android:icon="@drawable/ic_info_vector"
android:title="@string/about" android:title="@string/about"
app:showAsAction="always" /> app:showAsAction="always" />
<item
android:id="@+id/more_apps_from_us"
android:title="@string/more_apps_from_us"
app:showAsAction="never" />
</menu> </menu>