From 3e23f9d8ecd78bdeadb976f3c56c5c3c623da241 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 17 Nov 2021 17:38:07 +0100 Subject: [PATCH] redesigning the app settings --- app/build.gradle | 2 +- .../pro/activities/SettingsActivity.kt | 68 ++- app/src/main/res/layout/activity_settings.xml | 551 +++++++++--------- app/src/main/res/menu/menu.xml | 20 +- 4 files changed, 317 insertions(+), 324 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2e1d40a7..e7da8848 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,7 +56,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:df457fe86a' + implementation 'com.github.SimpleMobileTools:Simple-Commons:f86699e092' implementation 'joda-time:joda-time:2.10.3' implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5' implementation 'com.github.tibbi:IndicatorFastScroll:c3de1d040a' diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt index 24c2c69d..dc20665d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt @@ -3,10 +3,7 @@ package com.simplemobiletools.contacts.pro.activities import android.os.Bundle import android.view.Menu import com.simplemobiletools.commons.dialogs.RadioGroupDialog -import com.simplemobiletools.commons.extensions.baseConfig -import com.simplemobiletools.commons.extensions.beVisibleIf -import com.simplemobiletools.commons.extensions.getFontSizeText -import com.simplemobiletools.commons.extensions.updateTextColors +import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.contacts.pro.R @@ -44,6 +41,19 @@ class SettingsActivity : SimpleActivity() { setupDefaultTab() updateTextColors(settings_holder) invalidateOptionsMenu() + + arrayOf(settings_color_customization_label, settings_general_settings_label, settings_main_screen_label, settings_list_view_label).forEach { + it.setTextColor(getAdjustedPrimaryColor()) + } + + arrayOf( + settings_color_customization_holder, + settings_general_settings_holder, + settings_main_screen_holder, + settings_list_view_holder + ).forEach { + it.background.applyColorFilter(baseConfig.backgroundColor.getContrastColor()) + } } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -64,7 +74,7 @@ class SettingsActivity : SimpleActivity() { } private fun setupManageShownTabs() { - settings_manage_tabs_holder.setOnClickListener { + settings_manage_shown_tabs_holder.setOnClickListener { ManageVisibleTabsDialog(this) } } @@ -76,7 +86,8 @@ class SettingsActivity : SimpleActivity() { RadioItem(TAB_CONTACTS, getString(R.string.contacts_tab)), RadioItem(TAB_FAVORITES, getString(R.string.favorites_tab)), RadioItem(TAB_GROUPS, getString(R.string.groups_tab)), - RadioItem(TAB_LAST_USED, getString(R.string.last_used_tab))) + RadioItem(TAB_LAST_USED, getString(R.string.last_used_tab)) + ) RadioGroupDialog(this@SettingsActivity, items, config.defaultTab) { config.defaultTab = it as Int @@ -85,12 +96,14 @@ class SettingsActivity : SimpleActivity() { } } - private fun getDefaultTabText() = getString(when (baseConfig.defaultTab) { - TAB_CONTACTS -> R.string.contacts_tab - TAB_FAVORITES -> R.string.favorites_tab - TAB_GROUPS -> R.string.groups_tab - else -> R.string.last_used_tab - }) + private fun getDefaultTabText() = getString( + when (baseConfig.defaultTab) { + TAB_CONTACTS -> R.string.contacts_tab + TAB_FAVORITES -> R.string.favorites_tab + TAB_GROUPS -> R.string.groups_tab + else -> R.string.last_used_tab + } + ) private fun setupFontSize() { settings_font_size.text = getFontSizeText() @@ -99,7 +112,8 @@ class SettingsActivity : SimpleActivity() { RadioItem(FONT_SIZE_SMALL, getString(R.string.small)), RadioItem(FONT_SIZE_MEDIUM, getString(R.string.medium)), RadioItem(FONT_SIZE_LARGE, getString(R.string.large)), - RadioItem(FONT_SIZE_EXTRA_LARGE, getString(R.string.extra_large))) + RadioItem(FONT_SIZE_EXTRA_LARGE, getString(R.string.extra_large)) + ) RadioGroupDialog(this@SettingsActivity, items, config.fontSize) { config.fontSize = it as Int @@ -111,6 +125,11 @@ class SettingsActivity : SimpleActivity() { private fun setupUseEnglish() { settings_use_english_holder.beVisibleIf(config.wasUseEnglishToggled || Locale.getDefault().language != "en") settings_use_english.isChecked = config.useEnglish + + if (settings_use_english_holder.isGone()) { + settings_font_size_holder.background = resources.getDrawable(R.drawable.ripple_top_corners, theme) + } + settings_use_english_holder.setOnClickListener { settings_use_english.toggle() config.useEnglish = settings_use_english.isChecked @@ -143,10 +162,10 @@ class SettingsActivity : SimpleActivity() { } private fun setupStartNameWithSurname() { - settings_start_with_surname.isChecked = config.startNameWithSurname - settings_start_with_surname_holder.setOnClickListener { - settings_start_with_surname.toggle() - config.startNameWithSurname = settings_start_with_surname.isChecked + settings_start_name_with_surname.isChecked = config.startNameWithSurname + settings_start_name_with_surname_holder.setOnClickListener { + settings_start_name_with_surname.toggle() + config.startNameWithSurname = settings_start_name_with_surname.isChecked } } @@ -172,7 +191,8 @@ class SettingsActivity : SimpleActivity() { val items = arrayListOf( RadioItem(ON_CLICK_CALL_CONTACT, getString(R.string.call_contact)), RadioItem(ON_CLICK_VIEW_CONTACT, getString(R.string.view_contact)), - RadioItem(ON_CLICK_EDIT_CONTACT, getString(R.string.edit_contact))) + RadioItem(ON_CLICK_EDIT_CONTACT, getString(R.string.edit_contact)) + ) RadioGroupDialog(this@SettingsActivity, items, config.onContactClick) { config.onContactClick = it as Int @@ -181,11 +201,13 @@ class SettingsActivity : SimpleActivity() { } } - private fun getOnContactClickText() = getString(when (config.onContactClick) { - ON_CLICK_CALL_CONTACT -> R.string.call_contact - ON_CLICK_VIEW_CONTACT -> R.string.view_contact - else -> R.string.edit_contact - }) + private fun getOnContactClickText() = getString( + when (config.onContactClick) { + ON_CLICK_CALL_CONTACT -> R.string.call_contact + ON_CLICK_VIEW_CONTACT -> R.string.view_contact + else -> R.string.edit_contact + } + ) private fun setupShowCallConfirmation() { settings_show_call_confirmation.isChecked = config.showCallConfirmation diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index a75ed952..5ff9a0de 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,6 +1,6 @@ @@ -11,348 +11,317 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + android:text="@string/color_customization" /> - - - - - + android:layout_margin="@dimen/medium_margin" + android:background="@drawable/section_holder_stroke" + android:orientation="vertical"> - + android:background="@drawable/ripple_all_corners"> - + - + + + + android:text="@string/general_settings" /> - - - - - + android:layout_margin="@dimen/medium_margin" + android:background="@drawable/section_holder_stroke" + android:orientation="vertical"> - + android:background="@drawable/ripple_top_corners"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:text="@string/main_screen" /> - - - - - - - + android:layout_margin="@dimen/medium_margin" + android:background="@drawable/section_holder_stroke" + android:orientation="vertical"> - + android:background="@drawable/ripple_top_corners"> - + + + + + android:background="@drawable/ripple_background"> - + + - + + + + + + + + + + + + + + + + + + + + + + + + android:text="@string/list_view" /> - - - - - - - + android:layout_margin="@dimen/medium_margin" + android:background="@drawable/section_holder_stroke" + android:orientation="vertical"> - + android:background="@drawable/ripple_top_corners"> - + - + - + android:background="@drawable/ripple_background"> - + - + - + android:background="@drawable/ripple_bottom_corners"> - + - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml index ac7e1b82..077b741a 100644 --- a/app/src/main/res/menu/menu.xml +++ b/app/src/main/res/menu/menu.xml @@ -1,41 +1,43 @@ + xmlns:app="http://schemas.android.com/apk/res-auto"> + app:showAsAction="collapseActionView|always" /> + app:showAsAction="always" /> + app:showAsAction="always" /> + app:showAsAction="ifRoom" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + app:showAsAction="ifRoom" /> + app:showAsAction="ifRoom" />