forked from upstream-mirrors/quik
Created new Activity for Settings
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.moez.QKSMS.presentation.messages.MessagesActivity" />
|
<activity android:name="com.moez.QKSMS.presentation.messages.MessagesActivity" />
|
||||||
|
<activity android:name=".presentation.settings.SettingActivity" />
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".receiver.SmsReceiver"
|
android:name=".receiver.SmsReceiver"
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import android.content.Intent
|
|||||||
import com.moez.QKSMS.presentation.conversations.ConversationsViewModel
|
import com.moez.QKSMS.presentation.conversations.ConversationsViewModel
|
||||||
import com.moez.QKSMS.presentation.messages.MessagesActivity
|
import com.moez.QKSMS.presentation.messages.MessagesActivity
|
||||||
import com.moez.QKSMS.presentation.messages.MessagesViewModel
|
import com.moez.QKSMS.presentation.messages.MessagesViewModel
|
||||||
|
import com.moez.QKSMS.presentation.settings.SettingActivity
|
||||||
|
import com.moez.QKSMS.presentation.settings.SettingsViewModel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@@ -24,6 +26,11 @@ class Navigator @Inject constructor(val context: Context) {
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showSettings() {
|
||||||
|
val intent = Intent(context, SettingActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
class ViewModelFactory(private val intent: Intent) : ViewModelProvider.Factory {
|
class ViewModelFactory(private val intent: Intent) : ViewModelProvider.Factory {
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@@ -39,6 +46,10 @@ class Navigator @Inject constructor(val context: Context) {
|
|||||||
MessagesViewModel(threadId)
|
MessagesViewModel(threadId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsViewModel::class.java -> {
|
||||||
|
SettingsViewModel()
|
||||||
|
}
|
||||||
|
|
||||||
else -> throw IllegalArgumentException("Invalid ViewModel class. If this is a new ViewModel, please add it to Navigator.kt")
|
else -> throw IllegalArgumentException("Invalid ViewModel class. If this is a new ViewModel, please add it to Navigator.kt")
|
||||||
} as T
|
} as T
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -5,12 +5,14 @@ import com.moez.QKSMS.data.model.Message
|
|||||||
import com.moez.QKSMS.data.repository.MessageRepository
|
import com.moez.QKSMS.data.repository.MessageRepository
|
||||||
import com.moez.QKSMS.domain.interactor.MarkAllSeen
|
import com.moez.QKSMS.domain.interactor.MarkAllSeen
|
||||||
import com.moez.QKSMS.domain.interactor.SyncConversations
|
import com.moez.QKSMS.domain.interactor.SyncConversations
|
||||||
|
import com.moez.QKSMS.presentation.Navigator
|
||||||
import com.moez.QKSMS.presentation.base.QkViewModel
|
import com.moez.QKSMS.presentation.base.QkViewModel
|
||||||
import io.realm.RealmResults
|
import io.realm.RealmResults
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ConversationsViewModel : QkViewModel<ConversationsView, ConversationsState>(ConversationsState()) {
|
class ConversationsViewModel : QkViewModel<ConversationsView, ConversationsState>(ConversationsState()) {
|
||||||
|
|
||||||
|
@Inject lateinit var navigator: Navigator
|
||||||
@Inject lateinit var messageRepo: MessageRepository
|
@Inject lateinit var messageRepo: MessageRepository
|
||||||
@Inject lateinit var syncConversations: SyncConversations
|
@Inject lateinit var syncConversations: SyncConversations
|
||||||
@Inject lateinit var markAllSeen: MarkAllSeen
|
@Inject lateinit var markAllSeen: MarkAllSeen
|
||||||
@@ -33,7 +35,7 @@ class ConversationsViewModel : QkViewModel<ConversationsView, ConversationsState
|
|||||||
view.archivedIntent.subscribe()
|
view.archivedIntent.subscribe()
|
||||||
view.scheduledIntent.subscribe()
|
view.scheduledIntent.subscribe()
|
||||||
view.blockedIntent.subscribe()
|
view.blockedIntent.subscribe()
|
||||||
view.settingsIntent.subscribe()
|
view.settingsIntent.subscribe { navigator.showSettings() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onRefresh() {
|
fun onRefresh() {
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.moez.QKSMS.presentation.settings
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import com.moez.QKSMS.R
|
||||||
|
import com.moez.QKSMS.presentation.base.QkActivity
|
||||||
|
|
||||||
|
class SettingActivity : QkActivity<SettingsViewModel, SettingsState>(), SettingsView {
|
||||||
|
|
||||||
|
override val viewModelClass = SettingsViewModel::class
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.settings_activity)
|
||||||
|
setTitle(R.string.title_settings)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
viewModel.setView(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(state: SettingsState) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.moez.QKSMS.presentation.settings
|
||||||
|
|
||||||
|
data class SettingsState(
|
||||||
|
val ignored: String = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.moez.QKSMS.presentation.settings
|
||||||
|
|
||||||
|
import com.moez.QKSMS.presentation.base.QkView
|
||||||
|
|
||||||
|
interface SettingsView : QkView<SettingsState> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.moez.QKSMS.presentation.settings
|
||||||
|
|
||||||
|
import com.moez.QKSMS.presentation.base.QkViewModel
|
||||||
|
|
||||||
|
class SettingsViewModel : QkViewModel<SettingsView, SettingsState>(SettingsState()) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/toolbar" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:background="@drawable/ab_shadow" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
<string name="app_name">QKSMS</string>
|
<string name="app_name">QKSMS</string>
|
||||||
|
|
||||||
|
<string name="title_settings">Settings</string>
|
||||||
|
|
||||||
<string name="compose_hint">Write a message</string>
|
<string name="compose_hint">Write a message</string>
|
||||||
|
|
||||||
<string name="drawer_archived">Archived</string>
|
<string name="drawer_archived">Archived</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user