forked from upstream-mirrors/quik
Move scheduled management to separate activity
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
android:taskAffinity=""
|
||||
android:theme="@style/AppThemeLightDialog" />
|
||||
<activity android:name=".feature.settings.about.AboutActivity" />
|
||||
<activity android:name=".feature.scheduled.ScheduledActivity" />
|
||||
|
||||
<receiver android:name=".receiver.DefaultSmsChangedReceiver">
|
||||
<intent-filter>
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.moez.QKSMS.feature.conversationinfo.ConversationInfoActivity
|
||||
import com.moez.QKSMS.feature.gallery.GalleryActivity
|
||||
import com.moez.QKSMS.feature.notificationprefs.NotificationPrefsActivity
|
||||
import com.moez.QKSMS.feature.plus.PlusActivity
|
||||
import com.moez.QKSMS.feature.scheduled.ScheduledActivity
|
||||
import com.moez.QKSMS.feature.settings.SettingsActivity
|
||||
import com.moez.QKSMS.feature.settings.about.AboutActivity
|
||||
import com.moez.QKSMS.feature.themepicker.ThemePickerActivity
|
||||
@@ -115,6 +116,11 @@ class Navigator @Inject constructor(private val context: Context, private val no
|
||||
from.startActivity(intent, options.toBundle())
|
||||
}
|
||||
|
||||
fun showScheduled() {
|
||||
val intent = Intent(context, ScheduledActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
fun showSettings() {
|
||||
val intent = Intent(context, SettingsActivity::class.java)
|
||||
startActivity(intent)
|
||||
|
||||
@@ -49,7 +49,6 @@ import com.moez.QKSMS.common.util.extensions.setTint
|
||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||
import com.moez.QKSMS.feature.conversations.ConversationItemTouchCallback
|
||||
import com.moez.QKSMS.feature.conversations.ConversationsAdapter
|
||||
import com.moez.QKSMS.feature.scheduled.ScheduledMessageAdapter
|
||||
import com.moez.QKSMS.repository.SyncRepository
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import dagger.android.AndroidInjection
|
||||
@@ -64,7 +63,6 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
|
||||
@Inject lateinit var navigator: Navigator
|
||||
@Inject lateinit var conversationsAdapter: ConversationsAdapter
|
||||
@Inject lateinit var scheduledMessageAdapter: ScheduledMessageAdapter
|
||||
@Inject lateinit var searchAdapter: SearchAdapter
|
||||
@Inject lateinit var itemTouchCallback: ConversationItemTouchCallback
|
||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
@@ -194,7 +192,6 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
|
||||
compose.setVisible(state.page is Inbox || state.page is Archived)
|
||||
conversationsAdapter.emptyView = empty.takeIf { state.page is Inbox || state.page is Archived }
|
||||
scheduledMessageAdapter.emptyView = empty.takeIf { state.page is Archived }
|
||||
|
||||
when (state.page) {
|
||||
is Inbox -> {
|
||||
@@ -225,14 +222,6 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
itemTouchHelper.attachToRecyclerView(null)
|
||||
empty.setText(R.string.archived_empty_text)
|
||||
}
|
||||
|
||||
is Scheduled -> {
|
||||
setTitle(R.string.title_scheduled)
|
||||
if (recyclerView.adapter !== scheduledMessageAdapter) recyclerView.adapter = scheduledMessageAdapter
|
||||
scheduledMessageAdapter.updateData(state.page.data)
|
||||
itemTouchHelper.attachToRecyclerView(null)
|
||||
empty.setText(R.string.scheduled_empty_text)
|
||||
}
|
||||
}
|
||||
|
||||
when (state.page is Inbox && state.page.showArchivedSnackbar) {
|
||||
@@ -242,7 +231,6 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
|
||||
inbox.isSelected = state.page is Inbox
|
||||
archived.isSelected = state.page is Archived
|
||||
scheduled.isSelected = state.page is Scheduled
|
||||
|
||||
if (drawerLayout.isDrawerOpen(Gravity.START) && !state.drawerOpen) drawerLayout.closeDrawer(Gravity.START)
|
||||
else if (!drawerLayout.isDrawerVisible(Gravity.START) && state.drawerOpen) drawerLayout.openDrawer(Gravity.START)
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
*/
|
||||
package com.moez.QKSMS.feature.main
|
||||
|
||||
import com.moez.QKSMS.feature.scheduled.ScheduledMessageAdapter
|
||||
import com.moez.QKSMS.model.Conversation
|
||||
import com.moez.QKSMS.model.ScheduledMessage
|
||||
import com.moez.QKSMS.model.SearchResult
|
||||
import com.moez.QKSMS.repository.SyncRepository
|
||||
import io.realm.RealmResults
|
||||
@@ -54,7 +52,4 @@ data class Archived(
|
||||
val showClearButton: Boolean = false,
|
||||
val markRead: Boolean = false,
|
||||
val data: RealmResults<Conversation>? = null,
|
||||
val selected: Int = 0) : MainPage()
|
||||
|
||||
data class Scheduled(
|
||||
val data: RealmResults<ScheduledMessage>) : MainPage()
|
||||
val selected: Int = 0) : MainPage()
|
||||
@@ -36,7 +36,6 @@ import com.moez.QKSMS.manager.PermissionManager
|
||||
import com.moez.QKSMS.manager.RatingManager
|
||||
import com.moez.QKSMS.model.SyncLog
|
||||
import com.moez.QKSMS.repository.ConversationRepository
|
||||
import com.moez.QKSMS.repository.ScheduledMessageRepository
|
||||
import com.moez.QKSMS.repository.SyncRepository
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import io.reactivex.Observable
|
||||
@@ -62,7 +61,6 @@ class MainViewModel @Inject constructor(
|
||||
private val navigator: Navigator,
|
||||
private val permissionManager: PermissionManager,
|
||||
private val ratingManager: RatingManager,
|
||||
private val scheduledMessageRepo: ScheduledMessageRepository,
|
||||
private val syncMessages: SyncMessages,
|
||||
private val syncRepository: SyncRepository
|
||||
) : QkViewModel<MainView, MainState>(MainState(page = Inbox(data = conversationRepo.getConversations()))) {
|
||||
@@ -182,6 +180,7 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
view.drawerItemIntent
|
||||
.doOnNext { newState { copy(drawerOpen = false) } }
|
||||
.doOnNext { if (it == DrawerItem.SCHEDULED) navigator.showScheduled() }
|
||||
.doOnNext { if (it == DrawerItem.SETTINGS) navigator.showSettings() }
|
||||
.doOnNext { if (it == DrawerItem.PLUS) navigator.showQksmsPlusActivity() }
|
||||
.doOnNext { if (it == DrawerItem.HELP) navigator.showSupport() }
|
||||
@@ -190,7 +189,6 @@ class MainViewModel @Inject constructor(
|
||||
when (it) {
|
||||
DrawerItem.INBOX -> newState { copy(page = Inbox(data = conversationRepo.getConversations())) }
|
||||
DrawerItem.ARCHIVED -> newState { copy(page = Archived(data = conversationRepo.getConversations(true))) }
|
||||
DrawerItem.SCHEDULED -> newState { copy(page = Scheduled(data = scheduledMessageRepo.getScheduledMessages())) }
|
||||
else -> {
|
||||
} // Do nothing
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.moez.QKSMS.feature.scheduled
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.base.QkThemedActivity
|
||||
import dagger.android.AndroidInjection
|
||||
import kotlinx.android.synthetic.main.scheduled_activity.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class ScheduledActivity : QkThemedActivity(), ScheduledView {
|
||||
|
||||
@Inject lateinit var adapter: ScheduledMessageAdapter
|
||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
|
||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ScheduledViewModel::class.java] }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.scheduled_activity)
|
||||
setTitle(R.string.scheduled_title)
|
||||
showBackButton(true)
|
||||
viewModel.bindView(this)
|
||||
|
||||
adapter.emptyView = empty
|
||||
messages.adapter = adapter
|
||||
}
|
||||
|
||||
override fun render(state: ScheduledState) {
|
||||
adapter.updateData(state.scheduledMessages)
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.moez.QKSMS.feature.scheduled
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.moez.QKSMS.injection.ViewModelKey
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.multibindings.IntoMap
|
||||
|
||||
@Module
|
||||
class ScheduledActivityModule {
|
||||
|
||||
@Provides
|
||||
@IntoMap
|
||||
@ViewModelKey(ScheduledViewModel::class)
|
||||
fun provideScheduledViewModel(viewModel: ScheduledViewModel): ViewModel = viewModel
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.moez.QKSMS.feature.scheduled
|
||||
|
||||
import com.moez.QKSMS.model.ScheduledMessage
|
||||
import io.realm.RealmResults
|
||||
|
||||
data class ScheduledState(
|
||||
val scheduledMessages: RealmResults<ScheduledMessage>? = null
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.moez.QKSMS.feature.scheduled
|
||||
|
||||
import com.moez.QKSMS.common.base.QkView
|
||||
|
||||
interface ScheduledView : QkView<ScheduledState> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.moez.QKSMS.feature.scheduled
|
||||
|
||||
import com.moez.QKSMS.common.base.QkViewModel
|
||||
import com.moez.QKSMS.repository.ScheduledMessageRepository
|
||||
import javax.inject.Inject
|
||||
|
||||
class ScheduledViewModel @Inject constructor(
|
||||
scheduledMessageRepo: ScheduledMessageRepository
|
||||
) : QkViewModel<ScheduledView, ScheduledState>(ScheduledState(
|
||||
scheduledMessages = scheduledMessageRepo.getScheduledMessages()
|
||||
)) {
|
||||
|
||||
}
|
||||
@@ -16,6 +16,8 @@ import com.moez.QKSMS.feature.plus.PlusActivity
|
||||
import com.moez.QKSMS.feature.plus.PlusActivityModule
|
||||
import com.moez.QKSMS.feature.qkreply.QkReplyActivity
|
||||
import com.moez.QKSMS.feature.qkreply.QkReplyActivityModule
|
||||
import com.moez.QKSMS.feature.scheduled.ScheduledActivity
|
||||
import com.moez.QKSMS.feature.scheduled.ScheduledActivityModule
|
||||
import com.moez.QKSMS.feature.settings.SettingsActivity
|
||||
import com.moez.QKSMS.feature.settings.SettingsActivityModule
|
||||
import com.moez.QKSMS.feature.settings.about.AboutActivity
|
||||
@@ -60,6 +62,10 @@ abstract class ActivityBuilderModule {
|
||||
@ContributesAndroidInjector(modules = [QkReplyActivityModule::class])
|
||||
abstract fun bindQkReplyActivity(): QkReplyActivity
|
||||
|
||||
@ActivityScope
|
||||
@ContributesAndroidInjector(modules = [ScheduledActivityModule::class])
|
||||
abstract fun bindScheduledActivity(): ScheduledActivity
|
||||
|
||||
@ActivityScope
|
||||
@ContributesAndroidInjector(modules = [SettingsActivityModule::class])
|
||||
abstract fun bindSettingsActivity(): SettingsActivity
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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/>.
|
||||
-->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/toolbar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.QkTextView
|
||||
android:id="@+id/empty"
|
||||
style="@style/TextSecondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:gravity="center"
|
||||
android:padding="56dp"
|
||||
android:text="@string/scheduled_empty_text"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/messages"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
tools:listitem="@layout/blocked_list_item" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/ab_shadow"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -21,7 +21,6 @@
|
||||
<string name="app_name" translatable="false">QKSMS</string>
|
||||
|
||||
<string name="title_archived">Archived</string>
|
||||
<string name="title_scheduled">Scheduled</string>
|
||||
<string name="title_settings">Settings</string>
|
||||
<string name="title_notification_prefs">Notifications</string>
|
||||
<string name="title_theme">Theme</string>
|
||||
@@ -52,7 +51,6 @@
|
||||
<string name="inbox_empty_text">Your conversations will appear here</string>
|
||||
<string name="inbox_search_empty_text">No results</string>
|
||||
<string name="archived_empty_text">Your archived conversations will appear here</string>
|
||||
<string name="scheduled_empty_text">Your scheduled messages will appear here</string>
|
||||
<string name="main_fab_cd">Start new conversation</string>
|
||||
<string name="main_default_sms_title">Love texting again</string>
|
||||
<string name="main_default_sms_message">Make QKSMS your default SMS app</string>
|
||||
@@ -134,6 +132,9 @@
|
||||
|
||||
<string name="gallery_toast_saved">Saved to gallery</string>
|
||||
|
||||
<string name="scheduled_title">Scheduled</string>
|
||||
<string name="scheduled_empty_text">Your scheduled messages will appear here</string>
|
||||
|
||||
<string name="settings_category_appearance">Appearance</string>
|
||||
<string name="settings_category_general">General</string>
|
||||
<string name="settings_category_qkreply">QK Reply</string>
|
||||
|
||||
Reference in New Issue
Block a user