From 9811fac105c60222d91f81815420ad9899844965 Mon Sep 17 00:00:00 2001 From: moezbhatti Date: Thu, 22 Aug 2019 22:50:17 +0200 Subject: [PATCH] Fix padding/layout in blocking screen --- .../java/com/moez/QKSMS/util/Preferences.kt | 5 +++-- .../feature/blocking/BlockingPresenter.kt | 14 ++++++++++++-- .../main/res/layout/blocking_controller.xml | 18 ++++++++---------- presentation/src/main/res/values/strings.xml | 8 ++++---- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt b/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt index e32f7986..5114b3c3 100644 --- a/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt +++ b/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt @@ -69,6 +69,9 @@ class Preferences @Inject constructor(private val rxPrefs: RxSharedPreferences) // Internal val night = rxPrefs.getBoolean("night", false) val canUseSubId = rxPrefs.getBoolean("canUseSubId", true) + @Deprecated("This should only be accessed when migrating to @blockingManager") + val sia = rxPrefs.getBoolean("sia", false) + // User configurable val nightMode = rxPrefs.getInteger("nightMode", when (Build.VERSION.SDK_INT >= 29) { @@ -80,8 +83,6 @@ class Preferences @Inject constructor(private val rxPrefs: RxSharedPreferences) val black = rxPrefs.getBoolean("black", false) val systemFont = rxPrefs.getBoolean("systemFont", false) val textSize = rxPrefs.getInteger("textSize", TEXT_SIZE_NORMAL) - @Deprecated("This should only be accessed when migrating to @blockingManager") - val sia = rxPrefs.getBoolean("sia", false) val blockingManager = rxPrefs.getInteger("blockingManager", BLOCKING_MANAGER_QKSMS) val drop = rxPrefs.getBoolean("drop", false) val notifAction1 = rxPrefs.getInteger("notifAction1", NOTIFICATION_ACTION_READ) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/BlockingPresenter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/BlockingPresenter.kt index 7f158f95..e7fb260e 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/BlockingPresenter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/BlockingPresenter.kt @@ -22,6 +22,7 @@ import android.content.Context import com.moez.QKSMS.R import com.moez.QKSMS.common.Navigator import com.moez.QKSMS.common.base.QkPresenter +import com.moez.QKSMS.extensions.asObservable import com.moez.QKSMS.repository.ConversationRepository import com.moez.QKSMS.util.Preferences import com.uber.autodispose.android.lifecycle.scope @@ -31,13 +32,14 @@ import javax.inject.Inject class BlockingPresenter @Inject constructor( context: Context, - private val conversationRepo: ConversationRepository, + conversationRepo: ConversationRepository, private val navigator: Navigator, private val prefs: Preferences ) : QkPresenter(BlockingState()) { init { - newState { copy(data = conversationRepo.getBlockedConversations()) } + val blockedConversations = conversationRepo.getBlockedConversations() + newState { copy(data = blockedConversations) } disposables += prefs.blockingManager.asObservable() .map { client -> @@ -52,6 +54,14 @@ class BlockingPresenter @Inject constructor( disposables += prefs.drop.asObservable() .subscribe { enabled -> newState { copy(dropEnabled = enabled) } } + + // Trigger a refresh if we go between having some/no blocked conversations, otherwise the header won't update + disposables += blockedConversations + .asObservable() + .filter { it.isValid && it.isLoaded } + .map { it.isEmpty() } + .distinctUntilChanged() + .subscribe { newState { copy() } } } override fun bindIntents(view: BlockingView) { diff --git a/presentation/src/main/res/layout/blocking_controller.xml b/presentation/src/main/res/layout/blocking_controller.xml index dd9df8cc..7d5506de 100644 --- a/presentation/src/main/res/layout/blocking_controller.xml +++ b/presentation/src/main/res/layout/blocking_controller.xml @@ -23,9 +23,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="?android:attr/windowBackground" - android:clipToPadding="false" - android:paddingTop="8dp" - android:paddingBottom="8dp"> + android:clipToPadding="false"> @@ -56,8 +53,9 @@ android:id="@+id/conversationsDivider" android:layout_width="match_parent" android:layout_height="1dp" + android:layout_marginTop="16dp" android:background="?android:attr/divider" - app:layout_constraintTop_toBottomOf="@id/drop" /> + app:layout_constraintTop_toBottomOf="@+id/drop" /> + app:layout_constraintTop_toBottomOf="@+id/blockedLabel" /> diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index eb8f47e3..42ee26a2 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -275,12 +275,12 @@ Block - Would you also like to block this number in %s? - Would you also like to block these numbers in %s? + Continue to %s to block this number + Continue to %s to block these numbers - Would you also like to unblock this number in %s? - Would you also like to unblock these numbers in %s? + Continue to %s to unblock this number + Continue to %s to unblock these numbers About