From 6f6c1896ed6c582d1480245ce7bdbe5fed38ac7c Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 26 Nov 2024 00:01:33 +0100 Subject: [PATCH] add check if server notification app is installed for current user Signed-off-by: Marcel Hibbe --- .../ConversationsListActivity.kt | 5 ++- .../talk/settings/SettingsActivity.kt | 20 +++++++++++ app/src/main/res/layout/activity_settings.xml | 35 ++++++++++++++----- app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index c318d6e50..bfc7bce2c 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -1522,8 +1522,11 @@ class ConversationsListActivity : val messagesChannelNotEnabled = !NotificationUtils.isMessagesNotificationChannelEnabled(this) val callsChannelNotEnabled = !NotificationUtils.isCallsNotificationChannelEnabled(this) + val serverNotificationAppInstalled = + userManager.currentUser.blockingGet().capabilities?.notificationsCapability?.features?.isNotEmpty() ?: false + val settingsOfUserAreWrong = notificationPermissionNotGranted || batteryOptimizationNotIgnored || - messagesChannelNotEnabled || callsChannelNotEnabled + messagesChannelNotEnabled || callsChannelNotEnabled || !serverNotificationAppInstalled val userWantsToBeNotifiedAboutWrongSettings = appPreferences.getShowNotificationWarning() diff --git a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt index 8bdba8ccc..ab3caa003 100644 --- a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt @@ -284,6 +284,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu private fun setupNotificationSettings() { setupNotificationSoundsSettings() setupNotificationPermissionSettings() + setupServerNotificationAppCheck() } @SuppressLint("StringFormatInvalid") @@ -476,6 +477,24 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu } } + private fun setupServerNotificationAppCheck() { + val serverNotificationAppInstalled = + userManager.currentUser.blockingGet().capabilities?.notificationsCapability?.features?.isNotEmpty() ?: false + if (!serverNotificationAppInstalled) { + binding.settingsServerNotificationAppWrapper.visibility = View.VISIBLE + + val description = context.getString(R.string.nc_settings_contact_admin_of) + LINEBREAK + + userManager.currentUser.blockingGet().baseUrl!! + + binding.settingsServerNotificationAppDescription.text = description + if (openedByNotificationWarning) { + blinkRipple(binding.settingsServerNotificationAppWrapper.background) + } + } else { + binding.settingsServerNotificationAppWrapper.visibility = View.GONE + } + } + private fun setupSourceCodeUrl() { if (!TextUtils.isEmpty(resources!!.getString(R.string.nc_source_code_url))) { binding.settingsSourceCode.setOnClickListener { @@ -1421,6 +1440,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu private const val START_DELAY: Long = 5000 private const val DISABLED_ALPHA: Float = 0.38f private const val ENABLED_ALPHA: Float = 1.0f + private const val LINEBREAK = "\n" const val HTTP_CODE_OK: Int = 200 const val HTTP_ERROR_CODE_BAD_REQUEST: Int = 400 } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 412403443..beb24732f 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -311,12 +311,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/selectableItemBackground" - android:orientation="vertical"> + android:orientation="vertical" + android:padding="@dimen/standard_padding"> @@ -324,8 +324,6 @@ android:id="@+id/calls_ringtone" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/standard_margin" - android:layout_marginBottom="@dimen/standard_margin" android:text="@string/nc_settings_default_ringtone" android:textSize="@dimen/supporting_text_text_size"/> @@ -335,12 +333,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/selectableItemBackground" - android:orientation="vertical"> + android:orientation="vertical" + android:padding="@dimen/standard_padding"> @@ -348,12 +346,33 @@ android:id="@+id/messages_ringtone" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/standard_margin" - android:layout_marginBottom="@dimen/standard_margin" android:text="@string/nc_settings_default_ringtone" android:textSize="@dimen/supporting_text_text_size"/> + + + + + + + message_ringtone Librem by feandesign No sound + Server notification app not installed + Please contact the administrator of Appearance Theme