SettingsController: color section headers

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-07-21 16:06:26 +02:00 committed by Andy Scherzinger
parent d60fdd03c5
commit 5abdacab25
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
3 changed files with 38 additions and 3 deletions

View File

@ -78,6 +78,7 @@ import com.nextcloud.talk.jobs.ContactAddressBookWorker.Companion.deleteAll
import com.nextcloud.talk.models.json.generic.GenericOverall
import com.nextcloud.talk.models.json.userprofile.UserProfileOverall
import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.LoggingUtils.sendMailWithAttachment
@ -118,6 +119,9 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
@Inject
lateinit var currentUserProvider: CurrentUserProviderNew
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
private var saveStateHandler: LovelySaveStateHandler? = null
private var currentUser: User? = null
private var credentials: String? = null
@ -402,7 +406,8 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
.setIcon(
DisplayUtils.getTintedDrawable(
resources,
R.drawable.ic_delete_black_24dp, R.color.bg_default
R.drawable.ic_delete_black_24dp,
R.color.bg_default
)
)
.setPositiveButtonColor(context!!.resources.getColor(R.color.nc_darkRed))
@ -511,6 +516,20 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
)
}
themeCategories()
}
private fun themeCategories() {
binding.run {
listOf(
settingsNotificationsCategory,
settingsAboutCategory,
settingsAdvancedCategory,
settingsAppearanceCategory,
settingsPrivacyCategory
).forEach(viewThemeUtils::colorPreferenceCategory)
}
}
private fun setupProxyTypeSettings() {
@ -952,7 +971,9 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
val phoneNumber = textInputLayout.editText!!.text.toString()
ncApi.setUserData(
ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token),
ApiUtils.getUrlForUserData(currentUser!!.baseUrl, currentUser!!.userId), "phone", phoneNumber
ApiUtils.getUrlForUserData(currentUser!!.baseUrl, currentUser!!.userId),
"phone",
phoneNumber
).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<GenericOverall> {

View File

@ -30,6 +30,7 @@ import android.widget.TextView
import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.yarolegovich.mp.MaterialPreferenceCategory
import javax.inject.Inject
class ViewThemeUtils @Inject constructor(val theme: ServerTheme) {
@ -113,4 +114,11 @@ class ViewThemeUtils @Inject constructor(val theme: ServerTheme) {
card.setCardBackgroundColor(color)
}
}
// TODO split this util into classes depending on framework views vs library views
fun colorPreferenceCategory(category: MaterialPreferenceCategory) {
withElementColor(category) { color ->
category.setTitleColor(color)
}
}
}

View File

@ -27,6 +27,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:background="@color/white"
android:id="@+id/settings_screen"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -43,6 +44,7 @@
android:id="@+id/message_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:text="This is a test message"
android:gravity="center" />
</com.yarolegovich.mp.MaterialPreferenceCategory>
@ -105,10 +107,10 @@
android:id="@+id/server_age_warning_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_toEndOf="@id/server_age_warning_icon"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="0dp"
android:layout_centerHorizontal="true"
android:textAlignment="viewStart"
android:textColor="@color/nc_darkRed"
tools:text="@string/nc_settings_server_almost_eol" />
@ -142,6 +144,7 @@
<com.yarolegovich.mp.MaterialPreferenceCategory
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/settings_appearance_category"
android:animateLayoutChanges="true"
apc:cardBackgroundColor="@color/bg_default"
apc:cardElevation="0dp"
@ -186,6 +189,7 @@
</com.yarolegovich.mp.MaterialPreferenceCategory>
<com.yarolegovich.mp.MaterialPreferenceCategory
android:id="@+id/settings_privacy_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
@ -249,6 +253,7 @@
</com.yarolegovich.mp.MaterialPreferenceCategory>
<com.yarolegovich.mp.MaterialPreferenceCategory
android:id="@+id/settings_advanced_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
@ -323,6 +328,7 @@
</com.yarolegovich.mp.MaterialPreferenceCategory>
<com.yarolegovich.mp.MaterialPreferenceCategory
android:id="@+id/settings_about_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"