forked from upstream-mirrors/quik
add new 'rename conversation' menu option on main activity when 1 convo selected that allows changing conversation name/title
removed restriction on renaming only group conversations on conversationinfo screen
This commit is contained in:
-1
@@ -94,7 +94,6 @@ class ConversationInfoAdapter @Inject constructor(
|
||||
}
|
||||
|
||||
is ConversationInfoSettings -> {
|
||||
holder.groupName.isVisible = item.recipients.size > 1
|
||||
holder.groupName.summary = item.name
|
||||
|
||||
holder.notifications.isEnabled = !item.blocked
|
||||
|
||||
@@ -61,6 +61,7 @@ import dev.octoshrimpy.quik.repository.SyncRepository
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.common.widget.TextInputDialog
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
@@ -111,6 +112,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
override val rateIntent by lazy { rateOkay.clicks() }
|
||||
override val conversationsSelectedIntent by lazy { conversationsAdapter.selectionChanges }
|
||||
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
|
||||
override val renameConversationIntent: Subject<String> = PublishSubject.create()
|
||||
override val swipeConversationIntent by lazy { itemTouchCallback.swipes }
|
||||
override val changelogMoreIntent by lazy { changelogDialog.moreClicks }
|
||||
override val undoArchiveIntent: Subject<Unit> = PublishSubject.create()
|
||||
@@ -234,6 +236,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
toolbar.menu.findItem(R.id.read)?.isVisible = markRead && selectedConversations != 0
|
||||
toolbar.menu.findItem(R.id.unread)?.isVisible = !markRead && selectedConversations != 0
|
||||
toolbar.menu.findItem(R.id.block)?.isVisible = selectedConversations != 0
|
||||
toolbar.menu.findItem(R.id.rename)?.isVisible = selectedConversations == 1
|
||||
|
||||
listOf(plusBadge1, plusBadge2).forEach { badge ->
|
||||
badge.isVisible = drawerBadgesExperiment.variant && !state.upgraded
|
||||
@@ -398,6 +401,14 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun showRenameDialog(conversationName: String) {
|
||||
TextInputDialog(
|
||||
this,
|
||||
getString(R.string.info_name),
|
||||
renameConversationIntent::onNext
|
||||
).setText(conversationName).show()
|
||||
}
|
||||
|
||||
override fun showChangelog(changelog: ChangelogManager.CumulativeChangelog) {
|
||||
changelogDialog.show(changelog)
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ interface MainView : QkView<MainState> {
|
||||
val rateIntent: Observable<*>
|
||||
val conversationsSelectedIntent: Observable<List<Long>>
|
||||
val confirmDeleteIntent: Observable<List<Long>>
|
||||
val renameConversationIntent: Observable<String>
|
||||
val swipeConversationIntent: Observable<Pair<Long, Int>>
|
||||
val changelogMoreIntent: Observable<*>
|
||||
val undoArchiveIntent: Observable<Unit>
|
||||
@@ -50,6 +51,7 @@ interface MainView : QkView<MainState> {
|
||||
fun themeChanged()
|
||||
fun showBlockingDialog(conversations: List<Long>, block: Boolean)
|
||||
fun showDeleteDialog(conversations: List<Long>)
|
||||
fun showRenameDialog(conversationName: String)
|
||||
fun showChangelog(changelog: ChangelogManager.CumulativeChangelog)
|
||||
fun showArchivedSnackbar()
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.feature.main
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.Settings
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.Navigator
|
||||
@@ -420,6 +417,13 @@ class MainViewModel @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
view.optionsItemIntent
|
||||
.filter { itemId -> itemId == R.id.rename }
|
||||
.withLatestFrom(view.conversationsSelectedIntent) { _, conversationIds -> conversationIds.first() }
|
||||
.mapNotNull { conversationId -> conversationRepo.getConversation(conversationId) }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { conversation -> view.showRenameDialog(conversation.name) }
|
||||
|
||||
// view.plusBannerIntent
|
||||
// .autoDisposable(view.scope())
|
||||
// .subscribe {
|
||||
@@ -476,6 +480,23 @@ class MainViewModel @Inject constructor(
|
||||
view.clearSelection()
|
||||
}
|
||||
|
||||
view.renameConversationIntent
|
||||
.withLatestFrom(view.conversationsSelectedIntent) { newConversationName, selectedConversationIds ->
|
||||
Pair(newConversationName, selectedConversationIds.first())
|
||||
}
|
||||
.doOnNext { view.clearSelection() }
|
||||
.map { newNameAndConversationId ->
|
||||
conversationRepo.setConversationName(
|
||||
newNameAndConversationId.second,
|
||||
newNameAndConversationId.first
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
.flatMapCompletable { it }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
view.swipeConversationIntent
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { (threadId, direction) ->
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
android:id="@+id/groupName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_people_black_24dp"
|
||||
app:title="@string/info_name" />
|
||||
|
||||
|
||||
@@ -29,5 +29,4 @@
|
||||
android:padding="24dp"
|
||||
android:singleLine="true"
|
||||
android:textStyle="bold"
|
||||
app:textSize="dialog"
|
||||
tools:hint="Enter something" />
|
||||
app:textSize="dialog" />
|
||||
|
||||
@@ -83,4 +83,11 @@
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/rename"
|
||||
android:icon="@drawable/ic_people_black_24dp"
|
||||
android:title="@string/main_menu_rename_conversation"
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
||||
@@ -53,6 +53,7 @@
|
||||
<string name="main_menu_read">Mark read</string>
|
||||
<string name="main_menu_unread">Mark unread</string>
|
||||
<string name="main_menu_block">Block</string>
|
||||
<string name="main_menu_rename_conversation">Rename conversation</string>
|
||||
<string name="main_syncing">Syncing messages…</string>
|
||||
<string name="main_sender_you">You: %s</string>
|
||||
<string name="main_draft">Draft</string>
|
||||
|
||||
Reference in New Issue
Block a user