Make nav drawer scrollable, improve banner for QKSMS+

This commit is contained in:
Moez Bhatti
2018-07-18 14:41:06 -04:00
parent cb1ba7f8c3
commit 08dbd7d72a
7 changed files with 313 additions and 200 deletions
@@ -28,6 +28,7 @@ import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.core.app.ActivityCompat
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.ItemTouchHelper
@@ -87,6 +88,7 @@ class MainActivity : QkThemedActivity(), MainView {
help.clicks().map { DrawerItem.HELP }))
}
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
override val plusBannerIntent by lazy { plusBanner.clicks() }
override val dismissRatingIntent by lazy { rateDismiss.clicks() }
override val rateIntent by lazy { rateOkay.clicks() }
override val conversationsSelectedIntent by lazy { conversationsAdapter.selectionChanges }
@@ -140,6 +142,7 @@ class MainActivity : QkThemedActivity(), MainView {
// Miscellaneous views
syncingProgress.indeterminateTintList = ColorStateList.valueOf(theme.theme)
itemTouchCallback.color = theme.theme
plusIcon.setTint(theme.theme)
rateIcon.setTint(theme.theme)
compose.setBackgroundTint(theme.theme)
}
@@ -185,6 +188,8 @@ class MainActivity : QkThemedActivity(), MainView {
toolbar.menu.findItem(R.id.block)?.isVisible = selectedConversations != 0
toolbar.menu.findItem(R.id.delete)?.isVisible = selectedConversations != 0
plus.isVisible = state.upgraded
plusBanner.isVisible = !state.upgraded
rateLayout.setVisible(state.showRating)
compose.setVisible(state.page is Inbox || state.page is Archived)
@@ -27,6 +27,7 @@ data class MainState(
val hasError: Boolean = false,
val page: MainPage = Inbox(),
val drawerOpen: Boolean = false,
val upgraded: Boolean = true,
val showRating: Boolean = false,
val syncing: SyncRepository.SyncProgress = SyncRepository.SyncProgress.Idle(),
val defaultSms: Boolean = false,
@@ -30,6 +30,7 @@ interface MainView : QkView<MainState> {
val homeIntent: Observable<*>
val drawerItemIntent: Observable<DrawerItem>
val optionsItemIntent: Observable<Int>
val plusBannerIntent: Observable<*>
val dismissRatingIntent: Observable<*>
val rateIntent: Observable<*>
val conversationsSelectedIntent: Observable<List<Long>>
@@ -22,6 +22,7 @@ import com.moez.QKSMS.R
import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.androidxcompat.scope
import com.moez.QKSMS.common.base.QkViewModel
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.extensions.removeAccents
import com.moez.QKSMS.interactor.DeleteConversations
import com.moez.QKSMS.interactor.MarkAllSeen
@@ -49,7 +50,10 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject
class MainViewModel @Inject constructor(
private val markAllSeen: MarkAllSeen,
billingManager: BillingManager,
markAllSeen: MarkAllSeen,
migratePreferences: MigratePreferences,
syncRepository: SyncRepository,
private val conversationRepo: ConversationRepository,
private val deleteConversations: DeleteConversations,
private val markRead: MarkRead,
@@ -57,12 +61,10 @@ class MainViewModel @Inject constructor(
private val markArchived: MarkArchived,
private val markUnarchived: MarkUnarchived,
private val markBlocked: MarkBlocked,
private val migratePreferences: MigratePreferences,
private val navigator: Navigator,
private val permissionManager: PermissionManager,
private val ratingManager: RatingManager,
private val syncMessages: SyncMessages,
private val syncRepository: SyncRepository
private val syncMessages: SyncMessages
) : QkViewModel<MainView, MainState>(MainState(page = Inbox(data = conversationRepo.getConversations()))) {
init {
@@ -78,6 +80,9 @@ class MainViewModel @Inject constructor(
.distinctUntilChanged()
.subscribe { syncing -> newState { copy(syncing = syncing) } }
// Update the upgraded status
disposables += billingManager.upgradeStatus
.subscribe { upgraded -> newState { copy(upgraded = upgraded) } }
// Show the rating UI
disposables += ratingManager.shouldShowRating
@@ -231,6 +236,13 @@ class MainViewModel @Inject constructor(
.autoDisposable(view.scope())
.subscribe()
view.plusBannerIntent
.autoDisposable(view.scope())
.subscribe {
newState { copy(drawerOpen = false) }
navigator.showQksmsPlusActivity("main_banner")
}
view.rateIntent
.autoDisposable(view.scope())
.subscribe {
@@ -0,0 +1,27 @@
<!--
~ Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
~
~ This file is part of QKSMS.
~
~ QKSMS is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ QKSMS is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z"/>
</vector>
+261 -196
View File
@@ -17,218 +17,283 @@
~ You should have received a copy of the GNU General Public License
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/windowBackground"
android:orientation="vertical"
android:paddingTop="8dp">
android:background="?android:attr/windowBackground">
<LinearLayout
android:id="@+id/inbox"
style="@style/DrawerRow">
<ImageView
android:id="@+id/inboxIcon"
style="@style/DrawerIcon"
android:src="@drawable/ic_inbox_black_24dp"
tools:tint="@color/tools_theme" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_inbox" />
</LinearLayout>
<LinearLayout
android:id="@+id/archived"
style="@style/DrawerRow">
<ImageView
android:id="@+id/archivedIcon"
style="@style/DrawerIcon"
android:src="@drawable/ic_archive_black_24dp"
tools:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_archived" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/divider" />
<LinearLayout
android:id="@+id/scheduled"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_event_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_scheduled" />
</LinearLayout>
<LinearLayout
android:id="@+id/blocking"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_block_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_blocking" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/divider" />
<LinearLayout
android:id="@+id/settings"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_settings_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_settings" />
</LinearLayout>
<LinearLayout
android:id="@+id/plus"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_star_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_plus" />
</LinearLayout>
<LinearLayout
android:id="@+id/help"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_help_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_help" />
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/rateLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="@drawable/rounded_rectangle_outline_2dp"
android:backgroundTint="?android:attr/divider">
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingTop="8dp">
<ImageView
android:id="@+id/rateIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_favorite_black_24dp"
app:layout_constraintBottom_toBottomOf="@id/rateSummary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/rateTitle"
tools:tint="@color/tools_theme" />
<LinearLayout
android:id="@+id/inbox"
style="@style/DrawerRow">
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/rateTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/rate_title"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/rateIcon"
app:layout_constraintTop_toTopOf="parent"
app:textColor="primary"
app:textSize="primary" />
<ImageView
android:id="@+id/inboxIcon"
style="@style/DrawerIcon"
android:src="@drawable/ic_inbox_black_24dp"
tools:tint="@color/tools_theme" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/rateSummary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/rate_summary"
app:layout_constraintEnd_toEndOf="@id/rateTitle"
app:layout_constraintStart_toStartOf="@id/rateTitle"
app:layout_constraintTop_toBottomOf="@id/rateTitle"
app:textColor="secondary"
app:textSize="secondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_inbox" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/rateDismiss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
</LinearLayout>
<LinearLayout
android:id="@+id/archived"
style="@style/DrawerRow">
<ImageView
android:id="@+id/archivedIcon"
style="@style/DrawerIcon"
android:src="@drawable/ic_archive_black_24dp"
tools:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_archived" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:paddingBottom="16dp"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:text="@string/rate_dismiss"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@id/rateOkay"
app:layout_constraintTop_toBottomOf="@id/rateSummary"
app:textColor="tertiary"
app:textSize="secondary" />
android:background="?android:attr/divider" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/rateOkay"
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/scheduled"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_event_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_scheduled" />
</LinearLayout>
<LinearLayout
android:id="@+id/blocking"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_block_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_blocking" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/divider" />
<LinearLayout
android:id="@+id/settings"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_settings_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_settings" />
</LinearLayout>
<LinearLayout
android:id="@+id/plus"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_star_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_plus" />
</LinearLayout>
<LinearLayout
android:id="@+id/help"
style="@style/DrawerRow">
<ImageView
style="@style/DrawerIcon"
android:src="@drawable/ic_help_black_24dp"
android:tint="?android:attr/textColorSecondary" />
<com.moez.QKSMS.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_help" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/plusBanner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
android:padding="16dp"
android:text="@string/rate_okay"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/rateSummary"
app:textColor="secondary"
app:textSize="secondary" />
android:background="@drawable/rounded_rectangle_outline_2dp"
android:backgroundTint="?android:attr/divider"
android:foreground="?attr/selectableItemBackground"
android:padding="16dp">
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/plusIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_star_black_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:tint="@color/tools_theme" />
</LinearLayout>
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/plusTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:text="@string/drawer_plus_banner_title"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@id/plusNext"
app:layout_constraintStart_toEndOf="@id/plusIcon"
app:layout_constraintTop_toTopOf="parent"
app:textColor="primary"
app:textSize="primary" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/plusSummary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="@string/drawer_plus_banner_summary"
app:layout_constraintEnd_toEndOf="@id/plusTitle"
app:layout_constraintStart_toStartOf="@id/plusTitle"
app:layout_constraintTop_toBottomOf="@id/plusTitle"
app:textColor="secondary"
app:textSize="secondary" />
<ImageView
android:id="@+id/plusNext"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_chevron_right_black_24dp"
android:tint="?android:attr/textColorTertiary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/rateLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/rounded_rectangle_outline_2dp"
android:backgroundTint="?android:attr/divider">
<ImageView
android:id="@+id/rateIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_favorite_black_24dp"
app:layout_constraintBottom_toBottomOf="@id/rateSummary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/rateTitle"
tools:tint="@color/tools_theme" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/rateTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/rate_title"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/rateIcon"
app:layout_constraintTop_toTopOf="parent"
app:textColor="primary"
app:textSize="primary" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/rateSummary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="2dp"
android:text="@string/rate_summary"
app:layout_constraintEnd_toEndOf="@id/rateTitle"
app:layout_constraintStart_toStartOf="@id/rateTitle"
app:layout_constraintTop_toBottomOf="@id/rateTitle"
app:textColor="secondary"
app:textSize="secondary" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/rateDismiss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:paddingBottom="16dp"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:text="@string/rate_dismiss"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@id/rateOkay"
app:layout_constraintTop_toBottomOf="@id/rateSummary"
app:textColor="tertiary"
app:textSize="secondary" />
<com.moez.QKSMS.common.widget.QkTextView
android:id="@+id/rateOkay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
android:padding="16dp"
android:text="@string/rate_okay"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/rateSummary"
app:textColor="secondary"
app:textSize="secondary" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
@@ -68,6 +68,8 @@
<string name="drawer_settings">Settings</string>
<string name="drawer_plus">QKSMS+</string>
<string name="drawer_help">Help &amp; feedback</string>
<string name="drawer_plus_banner_title">QKSMS+</string>
<string name="drawer_plus_banner_summary">Unlock amazing new features, and support development</string>
<string name="rate_title">Enjoying QKSMS?</string>
<string name="rate_summary">Share some love and rate us on Google Play!</string>