From 22517c8ec9feb0e8c77b837eaa4fc840da5c7ea5 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 29 Nov 2024 18:04:31 +0100 Subject: [PATCH 1/2] new notification warner Signed-off-by: Marcel Hibbe --- .../ConversationsListActivity.kt | 64 ++++++++++++------ .../talk/settings/SettingsActivity.kt | 9 ++- .../utils/preferences/AppPreferences.java | 8 ++- .../utils/preferences/AppPreferencesImpl.kt | 26 +++++--- .../res/layout/activity_conversations.xml | 16 ++--- .../main/res/layout/notifications_warning.xml | 66 +++++++++++++++++++ app/src/main/res/values/strings.xml | 5 +- 7 files changed, 148 insertions(+), 46 deletions(-) create mode 100644 app/src/main/res/layout/notifications_warning.xml 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 79c2185d0a..ea857c0029 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -275,7 +275,7 @@ class ConversationsListActivity : adapter!!.addListener(this) prepareViews() - updateNotificationWarning() + showNotificationWarning() showShareToScreen = hasActivityActionSendIntent() @@ -296,6 +296,11 @@ class ConversationsListActivity : loadUserAvatar(binding.switchAccountButton) viewThemeUtils.material.colorMaterialTextButton(binding.switchAccountButton) viewThemeUtils.material.themeCardView(binding.conversationListHintInclude.hintLayoutCardview) + viewThemeUtils.material.themeCardView(binding.conversationListNotificationWarning.hintLayoutCardview) + viewThemeUtils.material.colorMaterialButtonText(binding.conversationListNotificationWarning.notNowButton) + viewThemeUtils.material.colorMaterialButtonText( + binding.conversationListNotificationWarning.showSettingsButton + ) searchBehaviorSubject.onNext(false) fetchRooms() fetchPendingInvitations() @@ -307,14 +312,6 @@ class ConversationsListActivity : showSearchOrToolbar() } - private fun updateNotificationWarning() { - if (shouldShowNotificationWarning()) { - showNotificationWarning() - } else { - binding.chatListNotificationWarning.visibility = View.GONE - } - } - private fun initObservers() { this.lifecycleScope.launch { networkMonitor.isOnline.onEach { isOnline -> @@ -1502,17 +1499,46 @@ class ConversationsListActivity : } private fun showNotificationWarning() { - binding.chatListNotificationWarning.visibility = View.VISIBLE - binding.chatListNotificationWarning.setOnClickListener { - val bundle = Bundle() - bundle.putBoolean(KEY_SCROLL_TO_NOTIFICATION_CATEGORY, true) - val settingsIntent = Intent(context, SettingsActivity::class.java) - settingsIntent.putExtras(bundle) - startActivity(settingsIntent) + if (shouldShowNotificationWarning()) { + binding.conversationListNotificationWarning.conversationListHintLayout.visibility = View.VISIBLE + binding.conversationListNotificationWarning.notNowButton.setOnClickListener { + binding.conversationListNotificationWarning.conversationListHintLayout.visibility = View.GONE + val lastWarningDate = System.currentTimeMillis() + appPreferences.setNotificationWarningLastPostponedDate(lastWarningDate) + } + binding.conversationListNotificationWarning.showSettingsButton.setOnClickListener { + val bundle = Bundle() + bundle.putBoolean(KEY_SCROLL_TO_NOTIFICATION_CATEGORY, true) + val settingsIntent = Intent(context, SettingsActivity::class.java) + settingsIntent.putExtras(bundle) + startActivity(settingsIntent) + } + } else { + binding.conversationListNotificationWarning.conversationListHintLayout.visibility = View.GONE } } private fun shouldShowNotificationWarning(): Boolean { + fun shouldShowWarningIfDateTooOld(date1: Long): Boolean { + val currentTimeMillis = System.currentTimeMillis() + val differenceMillis = currentTimeMillis - date1 + val daysForWarningInMillis = TimeUnit.DAYS.toMillis(DAYS_FOR_NOTIFICATION_WARNING) + return differenceMillis > daysForWarningInMillis + } + + fun shouldShowNotificationWarningByUserChoice(): Boolean { + if (appPreferences.showRegularNotificationWarning) { + val lastWarningDate = appPreferences.getNotificationWarningLastPostponedDate() + return if (lastWarningDate == NOTIFICATION_WARNING_DATE_NOT_SET) { + true + } else { + shouldShowWarningIfDateTooOld(lastWarningDate) + } + } else { + return false + } + } + val notificationPermissionNotGranted = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !platformPermissionUtil.isPostNotificationsPermissionGranted() val batteryOptimizationNotIgnored = !PowerManagerUtils().isIgnoringBatteryOptimizations() @@ -1529,10 +1555,8 @@ class ConversationsListActivity : callsChannelNotEnabled || !serverNotificationAppInstalled - val userWantsToBeNotifiedAboutWrongSettings = appPreferences.getShowNotificationWarning() - return settingsOfUserAreWrong && - userWantsToBeNotifiedAboutWrongSettings && + shouldShowNotificationWarningByUserChoice() && ClosedInterfaceImpl().isGooglePlayServicesAvailable } @@ -1927,5 +1951,7 @@ class ConversationsListActivity : const val MAINTENANCE_MODE_HEADER_KEY = "X-Nextcloud-Maintenance-Mode" const val REQUEST_POST_NOTIFICATIONS_PERMISSION = 111 const val BADGE_OFFSET = 35 + const val DAYS_FOR_NOTIFICATION_WARNING = 5L + const val NOTIFICATION_WARNING_DATE_NOT_SET = 0L } } 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 06dd2e80f0..11217b80ee 100644 --- a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt @@ -54,6 +54,7 @@ import com.nextcloud.talk.api.NcApiCoroutines import com.nextcloud.talk.application.NextcloudTalkApplication import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.setAppTheme import com.nextcloud.talk.conversationlist.ConversationsListActivity +import com.nextcloud.talk.conversationlist.ConversationsListActivity.Companion.NOTIFICATION_WARNING_DATE_NOT_SET import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.databinding.ActivitySettingsBinding import com.nextcloud.talk.diagnose.DiagnoseActivity @@ -927,13 +928,16 @@ class SettingsActivity : private fun setupCheckables() { binding.settingsShowNotificationWarningSwitch.isChecked = - appPreferences.showNotificationWarning + appPreferences.showRegularNotificationWarning if (ClosedInterfaceImpl().isGooglePlayServicesAvailable) { binding.settingsShowNotificationWarning.setOnClickListener { val isChecked = binding.settingsShowNotificationWarningSwitch.isChecked binding.settingsShowNotificationWarningSwitch.isChecked = !isChecked - appPreferences.setShowNotificationWarning(!isChecked) + appPreferences.setShowRegularNotificationWarning(!isChecked) + if (!isChecked) { + appPreferences.setNotificationWarningLastPostponedDate(NOTIFICATION_WARNING_DATE_NOT_SET) + } } } else { binding.settingsShowNotificationWarning.visibility = View.GONE @@ -1427,5 +1431,6 @@ class SettingsActivity : private const val LINEBREAK = "\n" const val HTTP_CODE_OK: Int = 200 const val HTTP_ERROR_CODE_BAD_REQUEST: Int = 400 + const val NO_NOTIFICATION_REMINDER_WANTED = 0L } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java index ffe3e063b9..7c23556ecb 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java @@ -178,9 +178,13 @@ public interface AppPreferences { void deleteAllMessageQueuesFor(String userId); - boolean getShowNotificationWarning(); + Long getNotificationWarningLastPostponedDate(); - void setShowNotificationWarning(boolean showNotificationWarning); + void setNotificationWarningLastPostponedDate(Long showNotificationWarning); + + Boolean getShowRegularNotificationWarning(); + + void setShowRegularNotificationWarning(boolean value); void clear(); } diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt index 1b6725162c..99318715f6 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt @@ -392,6 +392,17 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } } + override fun getShowRegularNotificationWarning (): Boolean { + return runBlocking { async { readBoolean(SHOW_REGULAR_NOTIFICATION_WARNING, true).first() } }.getCompleted() + } + + override fun setShowRegularNotificationWarning(value: Boolean) = + runBlocking { + async { + writeBoolean(SHOW_REGULAR_NOTIFICATION_WARNING, value) + } + } + override fun setPhoneBookIntegrationLastRun(currentTimeMillis: Long) = runBlocking { async { @@ -544,18 +555,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } } - override fun getShowNotificationWarning(): Boolean { - return runBlocking { - async { - readBoolean(SHOW_NOTIFICATION_WARNING, true).first() - } - }.getCompleted() + override fun getNotificationWarningLastPostponedDate(): Long { + return runBlocking { async { readLong(LAST_NOTIFICATION_WARNING).first() } }.getCompleted() } - override fun setShowNotificationWarning(showNotificationWarning: Boolean) = + override fun setNotificationWarningLastPostponedDate(showNotificationWarning: Long) = runBlocking { async { - writeBoolean(SHOW_NOTIFICATION_WARNING, showNotificationWarning) + writeLong(LAST_NOTIFICATION_WARNING, showNotificationWarning) } } @@ -643,7 +650,8 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { const val PHONE_BOOK_INTEGRATION_LAST_RUN = "phone_book_integration_last_run" const val TYPING_STATUS = "typing_status" const val MESSAGE_QUEUE = "@message_queue" - const val SHOW_NOTIFICATION_WARNING = "show_notification_warning" + const val SHOW_REGULAR_NOTIFICATION_WARNING = "show_regular_notification_warning" + const val LAST_NOTIFICATION_WARNING = "last_notification_warning" private fun String.convertStringToArray(): Array { var varString = this val floatList = mutableListOf() diff --git a/app/src/main/res/layout/activity_conversations.xml b/app/src/main/res/layout/activity_conversations.xml index 7518b482d5..7cf3800b6a 100644 --- a/app/src/main/res/layout/activity_conversations.xml +++ b/app/src/main/res/layout/activity_conversations.xml @@ -37,18 +37,6 @@ android:visibility="gone" tools:visibility="visible" /> - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a4c02a73f3..e9513b882d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -182,9 +182,10 @@ How to translate with transifex: Ignore battery optimization Battery optimization is not ignored. This should be changed to make sure that notifications work in the background! Please click OK and select \"All apps\" -> %1$s -> Do not optimize - Show notification warning - When notifications are not set up correctly, show a warning + Show regular notification warning + When notifications are not set up correctly, show a regular warning Notifications are not set up correctly + Not now Meta information Generation of system report From 366c2b577704038dcd94458e8b53d9788dd6e7d3 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 2 Dec 2024 16:55:32 +0100 Subject: [PATCH 2/2] reformat code + fix lint warnings Signed-off-by: Marcel Hibbe --- .../ConversationsListActivity.kt | 21 ++- .../utils/preferences/AppPreferencesImpl.kt | 143 ++++++++++-------- .../main/res/layout/notifications_warning.xml | 4 +- app/src/main/res/values/colors.xml | 1 - 4 files changed, 93 insertions(+), 76 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 ea857c0029..962a9358ed 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -296,7 +296,9 @@ class ConversationsListActivity : loadUserAvatar(binding.switchAccountButton) viewThemeUtils.material.colorMaterialTextButton(binding.switchAccountButton) viewThemeUtils.material.themeCardView(binding.conversationListHintInclude.hintLayoutCardview) - viewThemeUtils.material.themeCardView(binding.conversationListNotificationWarning.hintLayoutCardview) + viewThemeUtils.material.themeCardView( + binding.conversationListNotificationWarning.notificationWarningCardview + ) viewThemeUtils.material.colorMaterialButtonText(binding.conversationListNotificationWarning.notNowButton) viewThemeUtils.material.colorMaterialButtonText( binding.conversationListNotificationWarning.showSettingsButton @@ -323,14 +325,17 @@ class ConversationsListActivity : conversationsListViewModel.getFederationInvitationsViewState.observe(this) { state -> when (state) { is ConversationsListViewModel.GetFederationInvitationsStartState -> { - binding.conversationListHintInclude.conversationListHintLayout.visibility = View.GONE + binding.conversationListHintInclude.conversationListHintLayout.visibility = + View.GONE } is ConversationsListViewModel.GetFederationInvitationsSuccessState -> { if (state.showInvitationsHint) { - binding.conversationListHintInclude.conversationListHintLayout.visibility = View.VISIBLE + binding.conversationListHintInclude.conversationListHintLayout.visibility = + View.VISIBLE } else { - binding.conversationListHintInclude.conversationListHintLayout.visibility = View.GONE + binding.conversationListHintInclude.conversationListHintLayout.visibility = + View.GONE } } @@ -1500,9 +1505,11 @@ class ConversationsListActivity : private fun showNotificationWarning() { if (shouldShowNotificationWarning()) { - binding.conversationListNotificationWarning.conversationListHintLayout.visibility = View.VISIBLE + binding.conversationListNotificationWarning.conversationListNotificationWarningLayout.visibility = + View.VISIBLE binding.conversationListNotificationWarning.notNowButton.setOnClickListener { - binding.conversationListNotificationWarning.conversationListHintLayout.visibility = View.GONE + binding.conversationListNotificationWarning.conversationListNotificationWarningLayout.visibility = + View.GONE val lastWarningDate = System.currentTimeMillis() appPreferences.setNotificationWarningLastPostponedDate(lastWarningDate) } @@ -1514,7 +1521,7 @@ class ConversationsListActivity : startActivity(settingsIntent) } } else { - binding.conversationListNotificationWarning.conversationListHintLayout.visibility = View.GONE + binding.conversationListNotificationWarning.conversationListNotificationWarningLayout.visibility = View.GONE } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt index 99318715f6..d4ec5e7121 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt @@ -28,11 +28,10 @@ import kotlinx.coroutines.runBlocking @Suppress("TooManyFunctions", "DeferredResultUnused", "EmptyFunctionBlock") class AppPreferencesImpl(val context: Context) : AppPreferences { - override fun getProxyType(): String { - return runBlocking { + override fun getProxyType(): String = + runBlocking { async { readString(PROXY_TYPE, context.resources.getString(R.string.nc_no_proxy)).first() } }.getCompleted() - } override fun setProxyType(proxyType: String?) = runBlocking { @@ -47,9 +46,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { proxyType = "" } - override fun getProxyHost(): String { - return runBlocking { async { readString(PROXY_HOST).first() } }.getCompleted() - } + override fun getProxyHost(): String = runBlocking { async { readString(PROXY_HOST).first() } }.getCompleted() override fun setProxyHost(proxyHost: String?) = runBlocking { @@ -64,9 +61,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { proxyHost = "" } - override fun getProxyPort(): String { - return runBlocking { async { readString(PROXY_PORT).first() } }.getCompleted() - } + override fun getProxyPort(): String = runBlocking { async { readString(PROXY_PORT).first() } }.getCompleted() override fun setProxyPort(proxyPort: String?) = runBlocking { @@ -81,9 +76,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { proxyPort = "" } - override fun getProxyCredentials(): Boolean { - return runBlocking { async { readBoolean(PROXY_CRED).first() } }.getCompleted() - } + override fun getProxyCredentials(): Boolean = + runBlocking { + async { readBoolean(PROXY_CRED).first() } + }.getCompleted() override fun setProxyNeedsCredentials(proxyNeedsCredentials: Boolean) = runBlocking { @@ -96,9 +92,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { setProxyNeedsCredentials(false) } - override fun getProxyUsername(): String { - return runBlocking { async { readString(PROXY_USERNAME).first() } }.getCompleted() - } + override fun getProxyUsername(): String = + runBlocking { + async { readString(PROXY_USERNAME).first() } + }.getCompleted() override fun setProxyUsername(proxyUsername: String?) = runBlocking { @@ -113,9 +110,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { proxyUsername = "" } - override fun getProxyPassword(): String { - return runBlocking { async { readString(PROXY_PASSWORD).first() } }.getCompleted() - } + override fun getProxyPassword(): String = + runBlocking { + async { readString(PROXY_PASSWORD).first() } + }.getCompleted() override fun setProxyPassword(proxyPassword: String?) = runBlocking { @@ -130,9 +128,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { proxyPassword = "" } - override fun getPushToken(): String { - return runBlocking { async { readString(PUSH_TOKEN).first() } }.getCompleted() - } + override fun getPushToken(): String = runBlocking { async { readString(PUSH_TOKEN).first() } }.getCompleted() override fun setPushToken(pushToken: String?) = runBlocking { @@ -147,9 +143,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { pushToken = "" } - override fun getPushTokenLatestGeneration(): Long { - return runBlocking { async { readLong(PUSH_TOKEN_LATEST_GENERATION).first() } }.getCompleted() - } + override fun getPushTokenLatestGeneration(): Long = + runBlocking { + async { readLong(PUSH_TOKEN_LATEST_GENERATION).first() } + }.getCompleted() override fun setPushTokenLatestGeneration(date: Long) = runBlocking { @@ -158,9 +155,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } } - override fun getPushTokenLatestFetch(): Long { - return runBlocking { async { readLong(PUSH_TOKEN_LATEST_FETCH).first() } }.getCompleted() - } + override fun getPushTokenLatestFetch(): Long = + runBlocking { + async { readLong(PUSH_TOKEN_LATEST_FETCH).first() } + }.getCompleted() override fun setPushTokenLatestFetch(date: Long) = runBlocking { @@ -169,9 +167,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } } - override fun getTemporaryClientCertAlias(): String { - return runBlocking { async { readString(TEMP_CLIENT_CERT_ALIAS).first() } }.getCompleted() - } + override fun getTemporaryClientCertAlias(): String = + runBlocking { + async { readString(TEMP_CLIENT_CERT_ALIAS).first() } + }.getCompleted() override fun setTemporaryClientCertAlias(alias: String?) = runBlocking { @@ -186,9 +185,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { temporaryClientCertAlias = "" } - override fun getPushToTalkIntroShown(): Boolean { - return runBlocking { async { readBoolean(PUSH_TO_TALK_INTRO_SHOWN).first() } }.getCompleted() - } + override fun getPushToTalkIntroShown(): Boolean = + runBlocking { + async { readBoolean(PUSH_TO_TALK_INTRO_SHOWN).first() } + }.getCompleted() override fun setPushToTalkIntroShown(shown: Boolean) = runBlocking { @@ -201,9 +201,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { pushToTalkIntroShown = false } - override fun getCallRingtoneUri(): String { - return runBlocking { async { readString(CALL_RINGTONE).first() } }.getCompleted() - } + override fun getCallRingtoneUri(): String = + runBlocking { + async { readString(CALL_RINGTONE).first() } + }.getCompleted() override fun setCallRingtoneUri(value: String?) = runBlocking { @@ -218,9 +219,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { callRingtoneUri = "" } - override fun getMessageRingtoneUri(): String { - return runBlocking { async { readString(MESSAGE_RINGTONE).first() } }.getCompleted() - } + override fun getMessageRingtoneUri(): String = + runBlocking { + async { readString(MESSAGE_RINGTONE).first() } + }.getCompleted() override fun setMessageRingtoneUri(value: String?) = runBlocking { @@ -235,9 +237,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { messageRingtoneUri = "" } - override fun getIsNotificationChannelUpgradedToV2(): Boolean { - return runBlocking { async { readBoolean(NOTIFY_UPGRADE_V2).first() } }.getCompleted() - } + override fun getIsNotificationChannelUpgradedToV2(): Boolean = + runBlocking { + async { readBoolean(NOTIFY_UPGRADE_V2).first() } + }.getCompleted() override fun setNotificationChannelIsUpgradedToV2(value: Boolean) = runBlocking { @@ -250,9 +253,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { setNotificationChannelIsUpgradedToV2(false) } - override fun getIsNotificationChannelUpgradedToV3(): Boolean { - return runBlocking { async { readBoolean(NOTIFY_UPGRADE_V3).first() } }.getCompleted() - } + override fun getIsNotificationChannelUpgradedToV3(): Boolean = + runBlocking { + async { readBoolean(NOTIFY_UPGRADE_V3).first() } + }.getCompleted() override fun setNotificationChannelIsUpgradedToV3(value: Boolean) = runBlocking { @@ -265,9 +269,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { setNotificationChannelIsUpgradedToV3(false) } - override fun getIsScreenSecured(): Boolean { - return runBlocking { async { readBoolean(SCREEN_SECURITY).first() } }.getCompleted() - } + override fun getIsScreenSecured(): Boolean = + runBlocking { + async { readBoolean(SCREEN_SECURITY).first() } + }.getCompleted() override fun setScreenSecurity(value: Boolean) = runBlocking { @@ -280,9 +285,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { setScreenSecurity(false) } - override fun getIsScreenLocked(): Boolean { - return runBlocking { async { readBoolean(SCREEN_LOCK).first() } }.getCompleted() - } + override fun getIsScreenLocked(): Boolean = + runBlocking { + async { readBoolean(SCREEN_LOCK).first() } + }.getCompleted() override fun setScreenLock(value: Boolean) = runBlocking { @@ -311,9 +317,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { setIncognitoKeyboard(false) } - override fun isPhoneBookIntegrationEnabled(): Boolean { - return runBlocking { async { readBoolean(PHONE_BOOK_INTEGRATION).first() } }.getCompleted() - } + override fun isPhoneBookIntegrationEnabled(): Boolean = + runBlocking { + async { readBoolean(PHONE_BOOK_INTEGRATION).first() } + }.getCompleted() override fun setPhoneBookIntegration(value: Boolean) = runBlocking { @@ -381,9 +388,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } } - override fun getIsDbRoomMigrated(): Boolean { - return runBlocking { async { readBoolean(DB_ROOM_MIGRATED).first() } }.getCompleted() - } + override fun getIsDbRoomMigrated(): Boolean = + runBlocking { + async { readBoolean(DB_ROOM_MIGRATED).first() } + }.getCompleted() override fun setIsDbRoomMigrated(value: Boolean) = runBlocking { @@ -392,9 +400,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } } - override fun getShowRegularNotificationWarning (): Boolean { - return runBlocking { async { readBoolean(SHOW_REGULAR_NOTIFICATION_WARNING, true).first() } }.getCompleted() - } + override fun getShowRegularNotificationWarning(): Boolean = + runBlocking { + async { readBoolean(SHOW_REGULAR_NOTIFICATION_WARNING, true).first() } + }.getCompleted() override fun setShowRegularNotificationWarning(value: Boolean) = runBlocking { @@ -440,9 +449,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } } - override fun getTypingStatus(): Boolean { - return runBlocking { async { readBoolean(TYPING_STATUS).first() } }.getCompleted() - } + override fun getTypingStatus(): Boolean = + runBlocking { + async { readBoolean(TYPING_STATUS).first() } + }.getCompleted() override fun setSorting(value: String?) = runBlocking { @@ -555,9 +565,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } } - override fun getNotificationWarningLastPostponedDate(): Long { - return runBlocking { async { readLong(LAST_NOTIFICATION_WARNING).first() } }.getCompleted() - } + override fun getNotificationWarningLastPostponedDate(): Long = + runBlocking { + async { readLong(LAST_NOTIFICATION_WARNING).first() } + }.getCompleted() override fun setNotificationWarningLastPostponedDate(showNotificationWarning: Long) = runBlocking { diff --git a/app/src/main/res/layout/notifications_warning.xml b/app/src/main/res/layout/notifications_warning.xml index 7ec6c6506f..4155ba3518 100644 --- a/app/src/main/res/layout/notifications_warning.xml +++ b/app/src/main/res/layout/notifications_warning.xml @@ -8,7 +8,7 @@ #99000000 #EF3B02 #DBE2E9 - #FF9800