reformat code + fix lint warnings

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2024-12-02 16:55:32 +01:00
parent 22517c8ec9
commit 366c2b5777
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
4 changed files with 93 additions and 76 deletions

View file

@ -296,7 +296,9 @@ class ConversationsListActivity :
loadUserAvatar(binding.switchAccountButton) loadUserAvatar(binding.switchAccountButton)
viewThemeUtils.material.colorMaterialTextButton(binding.switchAccountButton) viewThemeUtils.material.colorMaterialTextButton(binding.switchAccountButton)
viewThemeUtils.material.themeCardView(binding.conversationListHintInclude.hintLayoutCardview) 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.notNowButton)
viewThemeUtils.material.colorMaterialButtonText( viewThemeUtils.material.colorMaterialButtonText(
binding.conversationListNotificationWarning.showSettingsButton binding.conversationListNotificationWarning.showSettingsButton
@ -323,14 +325,17 @@ class ConversationsListActivity :
conversationsListViewModel.getFederationInvitationsViewState.observe(this) { state -> conversationsListViewModel.getFederationInvitationsViewState.observe(this) { state ->
when (state) { when (state) {
is ConversationsListViewModel.GetFederationInvitationsStartState -> { is ConversationsListViewModel.GetFederationInvitationsStartState -> {
binding.conversationListHintInclude.conversationListHintLayout.visibility = View.GONE binding.conversationListHintInclude.conversationListHintLayout.visibility =
View.GONE
} }
is ConversationsListViewModel.GetFederationInvitationsSuccessState -> { is ConversationsListViewModel.GetFederationInvitationsSuccessState -> {
if (state.showInvitationsHint) { if (state.showInvitationsHint) {
binding.conversationListHintInclude.conversationListHintLayout.visibility = View.VISIBLE binding.conversationListHintInclude.conversationListHintLayout.visibility =
View.VISIBLE
} else { } else {
binding.conversationListHintInclude.conversationListHintLayout.visibility = View.GONE binding.conversationListHintInclude.conversationListHintLayout.visibility =
View.GONE
} }
} }
@ -1500,9 +1505,11 @@ class ConversationsListActivity :
private fun showNotificationWarning() { private fun showNotificationWarning() {
if (shouldShowNotificationWarning()) { if (shouldShowNotificationWarning()) {
binding.conversationListNotificationWarning.conversationListHintLayout.visibility = View.VISIBLE binding.conversationListNotificationWarning.conversationListNotificationWarningLayout.visibility =
View.VISIBLE
binding.conversationListNotificationWarning.notNowButton.setOnClickListener { binding.conversationListNotificationWarning.notNowButton.setOnClickListener {
binding.conversationListNotificationWarning.conversationListHintLayout.visibility = View.GONE binding.conversationListNotificationWarning.conversationListNotificationWarningLayout.visibility =
View.GONE
val lastWarningDate = System.currentTimeMillis() val lastWarningDate = System.currentTimeMillis()
appPreferences.setNotificationWarningLastPostponedDate(lastWarningDate) appPreferences.setNotificationWarningLastPostponedDate(lastWarningDate)
} }
@ -1514,7 +1521,7 @@ class ConversationsListActivity :
startActivity(settingsIntent) startActivity(settingsIntent)
} }
} else { } else {
binding.conversationListNotificationWarning.conversationListHintLayout.visibility = View.GONE binding.conversationListNotificationWarning.conversationListNotificationWarningLayout.visibility = View.GONE
} }
} }

View file

@ -28,11 +28,10 @@ import kotlinx.coroutines.runBlocking
@Suppress("TooManyFunctions", "DeferredResultUnused", "EmptyFunctionBlock") @Suppress("TooManyFunctions", "DeferredResultUnused", "EmptyFunctionBlock")
class AppPreferencesImpl(val context: Context) : AppPreferences { class AppPreferencesImpl(val context: Context) : AppPreferences {
override fun getProxyType(): String { override fun getProxyType(): String =
return runBlocking { runBlocking {
async { readString(PROXY_TYPE, context.resources.getString(R.string.nc_no_proxy)).first() } async { readString(PROXY_TYPE, context.resources.getString(R.string.nc_no_proxy)).first() }
}.getCompleted() }.getCompleted()
}
override fun setProxyType(proxyType: String?) = override fun setProxyType(proxyType: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -47,9 +46,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
proxyType = "" proxyType = ""
} }
override fun getProxyHost(): String { override fun getProxyHost(): String = runBlocking { async { readString(PROXY_HOST).first() } }.getCompleted()
return runBlocking { async { readString(PROXY_HOST).first() } }.getCompleted()
}
override fun setProxyHost(proxyHost: String?) = override fun setProxyHost(proxyHost: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -64,9 +61,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
proxyHost = "" proxyHost = ""
} }
override fun getProxyPort(): String { override fun getProxyPort(): String = runBlocking { async { readString(PROXY_PORT).first() } }.getCompleted()
return runBlocking { async { readString(PROXY_PORT).first() } }.getCompleted()
}
override fun setProxyPort(proxyPort: String?) = override fun setProxyPort(proxyPort: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -81,9 +76,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
proxyPort = "" proxyPort = ""
} }
override fun getProxyCredentials(): Boolean { override fun getProxyCredentials(): Boolean =
return runBlocking { async { readBoolean(PROXY_CRED).first() } }.getCompleted() runBlocking {
} async { readBoolean(PROXY_CRED).first() }
}.getCompleted()
override fun setProxyNeedsCredentials(proxyNeedsCredentials: Boolean) = override fun setProxyNeedsCredentials(proxyNeedsCredentials: Boolean) =
runBlocking<Unit> { runBlocking<Unit> {
@ -96,9 +92,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
setProxyNeedsCredentials(false) setProxyNeedsCredentials(false)
} }
override fun getProxyUsername(): String { override fun getProxyUsername(): String =
return runBlocking { async { readString(PROXY_USERNAME).first() } }.getCompleted() runBlocking {
} async { readString(PROXY_USERNAME).first() }
}.getCompleted()
override fun setProxyUsername(proxyUsername: String?) = override fun setProxyUsername(proxyUsername: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -113,9 +110,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
proxyUsername = "" proxyUsername = ""
} }
override fun getProxyPassword(): String { override fun getProxyPassword(): String =
return runBlocking { async { readString(PROXY_PASSWORD).first() } }.getCompleted() runBlocking {
} async { readString(PROXY_PASSWORD).first() }
}.getCompleted()
override fun setProxyPassword(proxyPassword: String?) = override fun setProxyPassword(proxyPassword: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -130,9 +128,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
proxyPassword = "" proxyPassword = ""
} }
override fun getPushToken(): String { override fun getPushToken(): String = runBlocking { async { readString(PUSH_TOKEN).first() } }.getCompleted()
return runBlocking { async { readString(PUSH_TOKEN).first() } }.getCompleted()
}
override fun setPushToken(pushToken: String?) = override fun setPushToken(pushToken: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -147,9 +143,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
pushToken = "" pushToken = ""
} }
override fun getPushTokenLatestGeneration(): Long { override fun getPushTokenLatestGeneration(): Long =
return runBlocking { async { readLong(PUSH_TOKEN_LATEST_GENERATION).first() } }.getCompleted() runBlocking {
} async { readLong(PUSH_TOKEN_LATEST_GENERATION).first() }
}.getCompleted()
override fun setPushTokenLatestGeneration(date: Long) = override fun setPushTokenLatestGeneration(date: Long) =
runBlocking<Unit> { runBlocking<Unit> {
@ -158,9 +155,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
} }
} }
override fun getPushTokenLatestFetch(): Long { override fun getPushTokenLatestFetch(): Long =
return runBlocking { async { readLong(PUSH_TOKEN_LATEST_FETCH).first() } }.getCompleted() runBlocking {
} async { readLong(PUSH_TOKEN_LATEST_FETCH).first() }
}.getCompleted()
override fun setPushTokenLatestFetch(date: Long) = override fun setPushTokenLatestFetch(date: Long) =
runBlocking<Unit> { runBlocking<Unit> {
@ -169,9 +167,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
} }
} }
override fun getTemporaryClientCertAlias(): String { override fun getTemporaryClientCertAlias(): String =
return runBlocking { async { readString(TEMP_CLIENT_CERT_ALIAS).first() } }.getCompleted() runBlocking {
} async { readString(TEMP_CLIENT_CERT_ALIAS).first() }
}.getCompleted()
override fun setTemporaryClientCertAlias(alias: String?) = override fun setTemporaryClientCertAlias(alias: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -186,9 +185,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
temporaryClientCertAlias = "" temporaryClientCertAlias = ""
} }
override fun getPushToTalkIntroShown(): Boolean { override fun getPushToTalkIntroShown(): Boolean =
return runBlocking { async { readBoolean(PUSH_TO_TALK_INTRO_SHOWN).first() } }.getCompleted() runBlocking {
} async { readBoolean(PUSH_TO_TALK_INTRO_SHOWN).first() }
}.getCompleted()
override fun setPushToTalkIntroShown(shown: Boolean) = override fun setPushToTalkIntroShown(shown: Boolean) =
runBlocking<Unit> { runBlocking<Unit> {
@ -201,9 +201,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
pushToTalkIntroShown = false pushToTalkIntroShown = false
} }
override fun getCallRingtoneUri(): String { override fun getCallRingtoneUri(): String =
return runBlocking { async { readString(CALL_RINGTONE).first() } }.getCompleted() runBlocking {
} async { readString(CALL_RINGTONE).first() }
}.getCompleted()
override fun setCallRingtoneUri(value: String?) = override fun setCallRingtoneUri(value: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -218,9 +219,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
callRingtoneUri = "" callRingtoneUri = ""
} }
override fun getMessageRingtoneUri(): String { override fun getMessageRingtoneUri(): String =
return runBlocking { async { readString(MESSAGE_RINGTONE).first() } }.getCompleted() runBlocking {
} async { readString(MESSAGE_RINGTONE).first() }
}.getCompleted()
override fun setMessageRingtoneUri(value: String?) = override fun setMessageRingtoneUri(value: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -235,9 +237,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
messageRingtoneUri = "" messageRingtoneUri = ""
} }
override fun getIsNotificationChannelUpgradedToV2(): Boolean { override fun getIsNotificationChannelUpgradedToV2(): Boolean =
return runBlocking { async { readBoolean(NOTIFY_UPGRADE_V2).first() } }.getCompleted() runBlocking {
} async { readBoolean(NOTIFY_UPGRADE_V2).first() }
}.getCompleted()
override fun setNotificationChannelIsUpgradedToV2(value: Boolean) = override fun setNotificationChannelIsUpgradedToV2(value: Boolean) =
runBlocking<Unit> { runBlocking<Unit> {
@ -250,9 +253,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
setNotificationChannelIsUpgradedToV2(false) setNotificationChannelIsUpgradedToV2(false)
} }
override fun getIsNotificationChannelUpgradedToV3(): Boolean { override fun getIsNotificationChannelUpgradedToV3(): Boolean =
return runBlocking { async { readBoolean(NOTIFY_UPGRADE_V3).first() } }.getCompleted() runBlocking {
} async { readBoolean(NOTIFY_UPGRADE_V3).first() }
}.getCompleted()
override fun setNotificationChannelIsUpgradedToV3(value: Boolean) = override fun setNotificationChannelIsUpgradedToV3(value: Boolean) =
runBlocking<Unit> { runBlocking<Unit> {
@ -265,9 +269,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
setNotificationChannelIsUpgradedToV3(false) setNotificationChannelIsUpgradedToV3(false)
} }
override fun getIsScreenSecured(): Boolean { override fun getIsScreenSecured(): Boolean =
return runBlocking { async { readBoolean(SCREEN_SECURITY).first() } }.getCompleted() runBlocking {
} async { readBoolean(SCREEN_SECURITY).first() }
}.getCompleted()
override fun setScreenSecurity(value: Boolean) = override fun setScreenSecurity(value: Boolean) =
runBlocking<Unit> { runBlocking<Unit> {
@ -280,9 +285,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
setScreenSecurity(false) setScreenSecurity(false)
} }
override fun getIsScreenLocked(): Boolean { override fun getIsScreenLocked(): Boolean =
return runBlocking { async { readBoolean(SCREEN_LOCK).first() } }.getCompleted() runBlocking {
} async { readBoolean(SCREEN_LOCK).first() }
}.getCompleted()
override fun setScreenLock(value: Boolean) = override fun setScreenLock(value: Boolean) =
runBlocking<Unit> { runBlocking<Unit> {
@ -311,9 +317,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
setIncognitoKeyboard(false) setIncognitoKeyboard(false)
} }
override fun isPhoneBookIntegrationEnabled(): Boolean { override fun isPhoneBookIntegrationEnabled(): Boolean =
return runBlocking { async { readBoolean(PHONE_BOOK_INTEGRATION).first() } }.getCompleted() runBlocking {
} async { readBoolean(PHONE_BOOK_INTEGRATION).first() }
}.getCompleted()
override fun setPhoneBookIntegration(value: Boolean) = override fun setPhoneBookIntegration(value: Boolean) =
runBlocking<Unit> { runBlocking<Unit> {
@ -381,9 +388,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
} }
} }
override fun getIsDbRoomMigrated(): Boolean { override fun getIsDbRoomMigrated(): Boolean =
return runBlocking { async { readBoolean(DB_ROOM_MIGRATED).first() } }.getCompleted() runBlocking {
} async { readBoolean(DB_ROOM_MIGRATED).first() }
}.getCompleted()
override fun setIsDbRoomMigrated(value: Boolean) = override fun setIsDbRoomMigrated(value: Boolean) =
runBlocking<Unit> { runBlocking<Unit> {
@ -392,9 +400,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
} }
} }
override fun getShowRegularNotificationWarning (): Boolean { override fun getShowRegularNotificationWarning(): Boolean =
return runBlocking { async { readBoolean(SHOW_REGULAR_NOTIFICATION_WARNING, true).first() } }.getCompleted() runBlocking {
} async { readBoolean(SHOW_REGULAR_NOTIFICATION_WARNING, true).first() }
}.getCompleted()
override fun setShowRegularNotificationWarning(value: Boolean) = override fun setShowRegularNotificationWarning(value: Boolean) =
runBlocking<Unit> { runBlocking<Unit> {
@ -440,9 +449,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
} }
} }
override fun getTypingStatus(): Boolean { override fun getTypingStatus(): Boolean =
return runBlocking { async { readBoolean(TYPING_STATUS).first() } }.getCompleted() runBlocking {
} async { readBoolean(TYPING_STATUS).first() }
}.getCompleted()
override fun setSorting(value: String?) = override fun setSorting(value: String?) =
runBlocking<Unit> { runBlocking<Unit> {
@ -555,9 +565,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
} }
} }
override fun getNotificationWarningLastPostponedDate(): Long { override fun getNotificationWarningLastPostponedDate(): Long =
return runBlocking { async { readLong(LAST_NOTIFICATION_WARNING).first() } }.getCompleted() runBlocking {
} async { readLong(LAST_NOTIFICATION_WARNING).first() }
}.getCompleted()
override fun setNotificationWarningLastPostponedDate(showNotificationWarning: Long) = override fun setNotificationWarningLastPostponedDate(showNotificationWarning: Long) =
runBlocking<Unit> { runBlocking<Unit> {

View file

@ -8,7 +8,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/conversation_list_hint_layout" android:id="@+id/conversation_list_notification_warning_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
@ -16,7 +16,7 @@
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/hint_layout_cardview" android:id="@+id/notification_warning_cardview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/standard_margin" android:layout_marginStart="@dimen/standard_margin"

View file

@ -92,6 +92,5 @@
<color name="icon_on_bg_default">#99000000</color> <color name="icon_on_bg_default">#99000000</color>
<color name="badge_color">#EF3B02</color> <color name="badge_color">#EF3B02</color>
<color name="secondary_button_background">#DBE2E9</color> <color name="secondary_button_background">#DBE2E9</color>
<color name="nc_warning">#FF9800</color>
</resources> </resources>