Add email support option in hamburger menu

This commit is contained in:
Moez Bhatti
2018-01-12 14:03:04 -05:00
parent 4cfe674945
commit 649596fa0f
7 changed files with 72 additions and 21 deletions
@@ -82,6 +82,13 @@ class Navigator @Inject constructor(val context: Context) {
startActivity(intent)
}
fun showSupport() {
val intent = Intent(Intent.ACTION_SENDTO)
intent.data = Uri.parse("mailto:")
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("team@qklabs.com"))
startActivity(intent)
}
@TargetApi(Build.VERSION_CODES.O)
fun showNotificationSettings() {
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
@@ -95,23 +102,10 @@ class Navigator @Inject constructor(val context: Context) {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return when (modelClass) {
MainViewModel::class.java -> {
MainViewModel()
}
SetupViewModel::class.java -> {
SetupViewModel()
}
ComposeViewModel::class.java -> {
ComposeViewModel(intent)
}
SettingsViewModel::class.java -> {
SettingsViewModel()
}
MainViewModel::class.java -> MainViewModel()
SetupViewModel::class.java -> SetupViewModel()
ComposeViewModel::class.java -> ComposeViewModel(intent)
SettingsViewModel::class.java -> SettingsViewModel()
else -> throw IllegalArgumentException("Invalid ViewModel class. If this is a new ViewModel, please add it to Navigator.kt")
} as T
}
@@ -72,7 +72,8 @@ class MainActivity : QkActivity<MainViewModel>(), MainView {
archived.clicks().map { DrawerItem.ARCHIVED },
scheduled.clicks().map { DrawerItem.SCHEDULED },
blocked.clicks().map { DrawerItem.BLOCKED },
settings.clicks().map { DrawerItem.SETTINGS }))
settings.clicks().map { DrawerItem.SETTINGS },
help.clicks().map { DrawerItem.HELP }))
}
override val conversationClickIntent by lazy { conversationsAdapter.clicks }
override val conversationLongClickIntent by lazy { conversationsAdapter.longClicks }
@@ -134,14 +135,17 @@ class MainActivity : QkActivity<MainViewModel>(), MainView {
}
}
// Set the theme color tint to the progressbar and FAB
disposables += colors.theme
.doOnNext { color -> syncingProgress.indeterminateTintList = ColorStateList.valueOf(color) }
.doOnNext { color -> compose.setBackgroundTint(color) }
.subscribe()
// Set the hamburger icon color
disposables += colors.textSecondary
.subscribe { color -> toggle.drawerArrowDrawable.color = color }
// Set the color for the drawer icons
disposables += Observables
.combineLatest(colors.theme, colors.textSecondary, { theme, textSecondary ->
ColorStateList(states, intArrayOf(theme, textSecondary))
@@ -151,8 +155,10 @@ class MainActivity : QkActivity<MainViewModel>(), MainView {
.doOnNext { tintList -> scheduledIcon.imageTintList = tintList }
.doOnNext { tintList -> blockedIcon.imageTintList = tintList }
.doOnNext { tintList -> settingsIcon.imageTintList = tintList }
.doOnNext { tintList -> helpIcon.imageTintList = tintList }
.subscribe()
// Set the background highlight for the drawer options
disposables += colors.separator
.doOnNext { color -> inbox.background = rowBackground(color) }
.doOnNext { color -> archived.background = rowBackground(color) }
@@ -18,9 +18,9 @@
*/
package presentation.feature.main
import presentation.common.base.QkView
import io.reactivex.Observable
import io.reactivex.subjects.Subject
import presentation.common.base.QkView
interface MainView : QkView<MainState> {
@@ -39,4 +39,4 @@ interface MainView : QkView<MainState> {
}
enum class DrawerItem { INBOX, ARCHIVED, SCHEDULED, BLOCKED, SETTINGS }
enum class DrawerItem { INBOX, ARCHIVED, SCHEDULED, BLOCKED, SETTINGS, HELP }
@@ -125,6 +125,7 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
intents += view.drawerItemIntent
.doOnNext { newState { it.copy(drawerOpen = false) } }
.doOnNext { if (it == DrawerItem.SETTINGS) navigator.showSettings() }
.doOnNext { if (it == DrawerItem.HELP) navigator.showSupport() }
.distinctUntilChanged()
.doOnNext {
when (it) {
@@ -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="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"/>
</vector>
+22 -1
View File
@@ -89,9 +89,15 @@
<presentation.common.widget.Separator
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp" />
<presentation.common.widget.QkTextView
style="@style/TextSecondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/drawer_more" />
<LinearLayout
android:id="@+id/settings"
style="@style/DrawerRow">
@@ -107,4 +113,19 @@
</LinearLayout>
<LinearLayout
android:id="@+id/help"
style="@style/DrawerRow">
<ImageView
android:id="@+id/helpIcon"
style="@style/DrawerIcon"
android:src="@drawable/ic_help_black_24dp" />
<presentation.common.widget.QkTextView
style="@style/DrawerText"
android:text="@string/drawer_help" />
</LinearLayout>
</LinearLayout>
+2
View File
@@ -51,7 +51,9 @@
<string name="drawer_archived">Archived</string>
<string name="drawer_scheduled">Scheduled</string>
<string name="drawer_blocked">Blocked</string>
<string name="drawer_more">More</string>
<string name="drawer_settings">Settings</string>
<string name="drawer_help">Help &amp; support</string>
<string name="settings_default_sms_title">Default SMS app</string>
<string name="settings_default_sms_summary_true">QKSMS is your default SMS app</string>