disable sound notification settings when main notification permission is is not permitted.

Otherwise user can't enable them anyway

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2024-11-25 19:55:36 +01:00
parent b63325ae8d
commit c2b99c591f
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
2 changed files with 47 additions and 38 deletions

View file

@ -333,12 +333,22 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
binding.ncDiagnoseNotificationPermissionSubtitle.setTextColor( binding.ncDiagnoseNotificationPermissionSubtitle.setTextColor(
resources.getColor(R.color.high_emphasis_text, null) resources.getColor(R.color.high_emphasis_text, null)
) )
binding.settingsCallSound.isEnabled = true
binding.settingsCallSound.alpha = ENABLED_ALPHA
binding.settingsMessageSound.isEnabled = true
binding.settingsMessageSound.alpha = ENABLED_ALPHA
} else { } else {
binding.ncDiagnoseNotificationPermissionSubtitle.text = binding.ncDiagnoseNotificationPermissionSubtitle.text =
resources.getString(R.string.nc_settings_notifications_declined) resources.getString(R.string.nc_settings_notifications_declined)
binding.ncDiagnoseNotificationPermissionSubtitle.setTextColor( binding.ncDiagnoseNotificationPermissionSubtitle.setTextColor(
resources.getColor(R.color.nc_darkRed, null) resources.getColor(R.color.nc_darkRed, null)
) )
binding.settingsCallSound.isEnabled = false
binding.settingsCallSound.alpha = DISABLED_ALPHA
binding.settingsMessageSound.isEnabled = false
binding.settingsMessageSound.alpha = DISABLED_ALPHA
binding.settingsNotificationsPermissionWrapper.setOnClickListener { binding.settingsNotificationsPermissionWrapper.setOnClickListener {
requestPermissions( requestPermissions(
arrayOf(Manifest.permission.POST_NOTIFICATIONS), arrayOf(Manifest.permission.POST_NOTIFICATIONS),

View file

@ -247,46 +247,25 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/settings_notifications_permission_wrapper" android:id="@+id/settings_notifications_permission_wrapper"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:orientation="vertical"
android:padding="@dimen/standard_padding">
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:text="@string/nc_diagnose_notification_permission"
android:padding="@dimen/standard_padding" android:textSize="@dimen/headline_text_size" />
android:background="?android:attr/selectableItemBackground">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content" android:id="@+id/nc_diagnose_notification_permission_subtitle"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:textSize="@dimen/headline_text_size" android:layout_height="wrap_content" />
android:text="@string/nc_diagnose_notification_permission" /> </LinearLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/nc_diagnose_notification_permission_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="@+id/settings_battery_optimization_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/standard_padding"
android:background="?android:attr/selectableItemBackground">
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/headline_text_size"
android:text="@string/nc_diagnose_battery_optimization_title" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/battery_optimization_ignored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="@string/nc_diagnose_battery_optimization_ignored"/>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/settings_gplay_not_available" android:id="@+id/settings_gplay_not_available"
@ -349,7 +328,27 @@
android:layout_marginBottom="@dimen/standard_margin" android:layout_marginBottom="@dimen/standard_margin"
android:text="@string/nc_settings_default_ringtone" android:text="@string/nc_settings_default_ringtone"
android:textSize="@dimen/supporting_text_text_size"/> android:textSize="@dimen/supporting_text_text_size"/>
</LinearLayout>
<LinearLayout
android:id="@+id/settings_battery_optimization_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:orientation="vertical"
android:padding="@dimen/standard_padding">
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nc_diagnose_battery_optimization_title"
android:textSize="@dimen/headline_text_size" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/battery_optimization_ignored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="@string/nc_diagnose_battery_optimization_ignored"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>