mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-20 11:15:02 +01:00
ConversationsListController: clean up a bit
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
929d6b3964
commit
f148c0e3c0
@ -27,7 +27,6 @@ import android.animation.AnimatorInflater
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.SearchManager
|
import android.app.SearchManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
@ -140,7 +139,6 @@ import org.greenrobot.eventbus.Subscribe
|
|||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
import org.parceler.Parcels
|
import org.parceler.Parcels
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.util.Collections
|
|
||||||
import java.util.Objects
|
import java.util.Objects
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -292,7 +290,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
|
|
||||||
private fun initSearchView() {
|
private fun initSearchView() {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
val searchManager = activity!!.getSystemService(Context.SEARCH_SERVICE) as SearchManager
|
val searchManager = activity!!.getSystemService(Context.SEARCH_SERVICE) as SearchManager?
|
||||||
if (searchItem != null) {
|
if (searchItem != null) {
|
||||||
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
|
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
|
||||||
viewThemeUtils.themeSearchView(searchView!!)
|
viewThemeUtils.themeSearchView(searchView!!)
|
||||||
@ -351,7 +349,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
showSearchView(activity, searchView, searchItem)
|
showSearchView(activity, searchView, searchItem)
|
||||||
searchView!!.setQuery(adapter!!.getFilter(String::class.java), false)
|
searchView!!.setQuery(adapter!!.getFilter(String::class.java), false)
|
||||||
}
|
}
|
||||||
activity.binding.searchText.setOnClickListener { v: View? ->
|
activity.binding.searchText.setOnClickListener {
|
||||||
showSearchView(activity, searchView, searchItem)
|
showSearchView(activity, searchView, searchItem)
|
||||||
viewThemeUtils.themeStatusBar(activity, searchView!!)
|
viewThemeUtils.themeStatusBar(activity, searchView!!)
|
||||||
}
|
}
|
||||||
@ -372,8 +370,8 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
adapter!!.setHeadersShown(true)
|
adapter!!.setHeadersShown(true)
|
||||||
adapter!!.updateDataSet(searchableConversationItems, false)
|
adapter!!.updateDataSet(searchableConversationItems, false)
|
||||||
adapter!!.showAllHeaders()
|
adapter!!.showAllHeaders()
|
||||||
if (binding.swipeRefreshLayoutView != null) {
|
withNullableControllerViewBinding {
|
||||||
binding.swipeRefreshLayoutView!!.isEnabled = false
|
binding.swipeRefreshLayoutView.isEnabled = false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -385,10 +383,10 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
if (searchHelper != null) {
|
if (searchHelper != null) {
|
||||||
// cancel any pending searches
|
// cancel any pending searches
|
||||||
searchHelper!!.cancelSearch()
|
searchHelper!!.cancelSearch()
|
||||||
binding.swipeRefreshLayoutView!!.isRefreshing = false
|
binding.swipeRefreshLayoutView.isRefreshing = false
|
||||||
}
|
}
|
||||||
if (binding.swipeRefreshLayoutView != null) {
|
withNullableControllerViewBinding {
|
||||||
binding.swipeRefreshLayoutView!!.isEnabled = true
|
binding.swipeRefreshLayoutView.isEnabled = true
|
||||||
}
|
}
|
||||||
searchView!!.onActionViewCollapsed()
|
searchView!!.onActionViewCollapsed()
|
||||||
val activity = getActivity() as MainActivity?
|
val activity = getActivity() as MainActivity?
|
||||||
@ -403,7 +401,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
viewThemeUtils.resetStatusBar(activity, activity.binding.searchToolbar)
|
viewThemeUtils.resetStatusBar(activity, activity.binding.searchToolbar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val layoutManager = binding.recyclerView!!.layoutManager as SmoothScrollLinearLayoutManager?
|
val layoutManager = binding.recyclerView.layoutManager as SmoothScrollLinearLayoutManager?
|
||||||
layoutManager?.scrollToPositionWithOffset(0, 0)
|
layoutManager?.scrollToPositionWithOffset(0, 0)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -491,21 +489,21 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
if (adapterWasNull) {
|
if (adapterWasNull) {
|
||||||
adapterWasNull = false
|
adapterWasNull = false
|
||||||
binding.loadingContent!!.visibility = View.GONE
|
binding.loadingContent.visibility = View.GONE
|
||||||
}
|
}
|
||||||
if (ocs!!.data!!.size > 0) {
|
if (ocs!!.data!!.isNotEmpty()) {
|
||||||
if (binding.emptyLayout!!.visibility != View.GONE) {
|
if (binding.emptyLayout.visibility != View.GONE) {
|
||||||
binding.emptyLayout!!.visibility = View.GONE
|
binding.emptyLayout.visibility = View.GONE
|
||||||
}
|
}
|
||||||
if (binding.swipeRefreshLayoutView!!.visibility != View.VISIBLE) {
|
if (binding.swipeRefreshLayoutView.visibility != View.VISIBLE) {
|
||||||
binding.swipeRefreshLayoutView!!.visibility = View.VISIBLE
|
binding.swipeRefreshLayoutView.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (binding.emptyLayout!!.visibility != View.VISIBLE) {
|
if (binding.emptyLayout.visibility != View.VISIBLE) {
|
||||||
binding.emptyLayout!!.visibility = View.VISIBLE
|
binding.emptyLayout.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
if (binding.swipeRefreshLayoutView!!.visibility != View.GONE) {
|
if (binding.swipeRefreshLayoutView.visibility != View.GONE) {
|
||||||
binding.swipeRefreshLayoutView!!.visibility = View.GONE
|
binding.swipeRefreshLayoutView.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (conversation in ocs.data!!) {
|
for (conversation in ocs.data!!) {
|
||||||
@ -515,8 +513,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
) {
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var headerTitle: String
|
val headerTitle: String = resources!!.getString(R.string.conversations)
|
||||||
headerTitle = resources!!.getString(R.string.conversations)
|
|
||||||
var genericTextHeaderItem: GenericTextHeaderItem
|
var genericTextHeaderItem: GenericTextHeaderItem
|
||||||
if (!callHeaderItems.containsKey(headerTitle)) {
|
if (!callHeaderItems.containsKey(headerTitle)) {
|
||||||
genericTextHeaderItem = GenericTextHeaderItem(headerTitle, viewThemeUtils)
|
genericTextHeaderItem = GenericTextHeaderItem(headerTitle, viewThemeUtils)
|
||||||
@ -547,31 +544,31 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
adapter!!.updateDataSet(conversationItems, false)
|
adapter!!.updateDataSet(conversationItems, false)
|
||||||
Handler().postDelayed({ checkToShowUnreadBubble() }, UNREAD_BUBBLE_DELAY.toLong())
|
Handler().postDelayed({ checkToShowUnreadBubble() }, UNREAD_BUBBLE_DELAY.toLong())
|
||||||
fetchOpenConversations(apiVersion)
|
fetchOpenConversations(apiVersion)
|
||||||
if (binding.swipeRefreshLayoutView != null) {
|
withNullableControllerViewBinding {
|
||||||
binding.swipeRefreshLayoutView!!.isRefreshing = false
|
binding.swipeRefreshLayoutView.isRefreshing = false
|
||||||
}
|
}
|
||||||
}, { throwable: Throwable ->
|
}, { throwable: Throwable ->
|
||||||
handleHttpExceptions(throwable)
|
handleHttpExceptions(throwable)
|
||||||
if (binding.swipeRefreshLayoutView != null) {
|
withNullableControllerViewBinding {
|
||||||
binding.swipeRefreshLayoutView!!.isRefreshing = false
|
binding.swipeRefreshLayoutView.isRefreshing = false
|
||||||
}
|
}
|
||||||
dispose(roomsQueryDisposable)
|
dispose(roomsQueryDisposable)
|
||||||
}) {
|
}) {
|
||||||
dispose(roomsQueryDisposable)
|
dispose(roomsQueryDisposable)
|
||||||
if (binding.swipeRefreshLayoutView != null) {
|
withNullableControllerViewBinding {
|
||||||
binding.swipeRefreshLayoutView!!.isRefreshing = false
|
binding.swipeRefreshLayoutView.isRefreshing = false
|
||||||
}
|
}
|
||||||
isRefreshing = false
|
isRefreshing = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sortConversations(conversationItems: List<AbstractFlexibleItem<*>>) {
|
private fun sortConversations(conversationItems: MutableList<AbstractFlexibleItem<*>>) {
|
||||||
Collections.sort(conversationItems) { o1: AbstractFlexibleItem<*>, o2: AbstractFlexibleItem<*> ->
|
conversationItems.sortWith { o1: AbstractFlexibleItem<*>, o2: AbstractFlexibleItem<*> ->
|
||||||
val (_, _, _, _, _, _, _, _, _, _, _, _, _, favorite, lastActivity) = (o1 as ConversationItem).model
|
val conversation1 = (o1 as ConversationItem).model
|
||||||
val (_, _, _, _, _, _, _, _, _, _, _, _, _, favorite1, lastActivity1) = (o2 as ConversationItem).model
|
val conversation2 = (o2 as ConversationItem).model
|
||||||
CompareToBuilder()
|
CompareToBuilder()
|
||||||
.append(favorite1, favorite)
|
.append(conversation2.favorite, conversation1.favorite)
|
||||||
.append(lastActivity1, lastActivity)
|
.append(conversation2.lastActivity, conversation1.lastActivity)
|
||||||
.toComparison()
|
.toComparison()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -643,10 +640,10 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun prepareViews() {
|
private fun prepareViews() {
|
||||||
layoutManager = SmoothScrollLinearLayoutManager(Objects.requireNonNull(activity))
|
layoutManager = SmoothScrollLinearLayoutManager(Objects.requireNonNull(activity))
|
||||||
binding.recyclerView!!.layoutManager = layoutManager
|
binding.recyclerView.layoutManager = layoutManager
|
||||||
binding.recyclerView!!.setHasFixedSize(true)
|
binding.recyclerView.setHasFixedSize(true)
|
||||||
binding.recyclerView!!.adapter = adapter
|
binding.recyclerView.adapter = adapter
|
||||||
binding.recyclerView!!.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||||
super.onScrollStateChanged(recyclerView, newState)
|
super.onScrollStateChanged(recyclerView, newState)
|
||||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||||
@ -654,24 +651,24 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
binding.recyclerView!!.setOnTouchListener { v: View, event: MotionEvent? ->
|
binding.recyclerView.setOnTouchListener { v: View, _: MotionEvent? ->
|
||||||
if (isAttached && (!isBeingDestroyed || !isDestroyed)) {
|
if (isAttached && (!isBeingDestroyed || !isDestroyed)) {
|
||||||
val imm = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
val imm = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
imm.hideSoftInputFromWindow(v.windowToken, 0)
|
imm.hideSoftInputFromWindow(v.windowToken, 0)
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
binding.swipeRefreshLayoutView!!.setOnRefreshListener { fetchData() }
|
binding.swipeRefreshLayoutView.setOnRefreshListener { fetchData() }
|
||||||
viewThemeUtils.themeSwipeRefreshLayout(binding.swipeRefreshLayoutView!!)
|
viewThemeUtils.themeSwipeRefreshLayout(binding.swipeRefreshLayoutView)
|
||||||
binding.emptyLayout!!.setOnClickListener { v: View? -> showNewConversationsScreen() }
|
binding.emptyLayout.setOnClickListener { showNewConversationsScreen() }
|
||||||
binding.floatingActionButton!!.setOnClickListener { v: View? ->
|
binding.floatingActionButton.setOnClickListener {
|
||||||
run(context)
|
run(context)
|
||||||
showNewConversationsScreen()
|
showNewConversationsScreen()
|
||||||
}
|
}
|
||||||
viewThemeUtils.themeFAB(binding.floatingActionButton!!)
|
viewThemeUtils.themeFAB(binding.floatingActionButton)
|
||||||
if (activity != null && activity is MainActivity) {
|
if (activity != null && activity is MainActivity) {
|
||||||
val activity = activity as MainActivity?
|
val activity = activity as MainActivity?
|
||||||
activity!!.binding.switchAccountButton.setOnClickListener { v: View? ->
|
activity!!.binding.switchAccountButton.setOnClickListener {
|
||||||
if (resources != null && resources!!.getBoolean(R.bool.multiaccount_support)) {
|
if (resources != null && resources!!.getBoolean(R.bool.multiaccount_support)) {
|
||||||
val newFragment: DialogFragment = ChooseAccountDialogFragment.newInstance()
|
val newFragment: DialogFragment = ChooseAccountDialogFragment.newInstance()
|
||||||
newFragment.show(
|
newFragment.show(
|
||||||
@ -687,13 +684,13 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.newMentionPopupBubble!!.hide()
|
binding.newMentionPopupBubble.hide()
|
||||||
binding.newMentionPopupBubble!!.setPopupBubbleListener {
|
binding.newMentionPopupBubble.setPopupBubbleListener {
|
||||||
binding.recyclerView!!.smoothScrollToPosition(
|
binding.recyclerView.smoothScrollToPosition(
|
||||||
nextUnreadConversationScrollPosition
|
nextUnreadConversationScrollPosition
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.newMentionPopupBubble!!)
|
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.newMentionPopupBubble)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkToShowUnreadBubble() {
|
private fun checkToShowUnreadBubble() {
|
||||||
@ -709,14 +706,14 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
) && position > lastVisibleItem
|
) && position > lastVisibleItem
|
||||||
) {
|
) {
|
||||||
nextUnreadConversationScrollPosition = position
|
nextUnreadConversationScrollPosition = position
|
||||||
if (!binding.newMentionPopupBubble!!.isShown) {
|
if (!binding.newMentionPopupBubble.isShown) {
|
||||||
binding.newMentionPopupBubble!!.show()
|
binding.newMentionPopupBubble.show()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextUnreadConversationScrollPosition = 0
|
nextUnreadConversationScrollPosition = 0
|
||||||
binding.newMentionPopupBubble!!.hide()
|
binding.newMentionPopupBubble.hide()
|
||||||
} catch (e: NullPointerException) {
|
} catch (e: NullPointerException) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
@ -738,10 +735,8 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun dispose(disposable: Disposable?) {
|
private fun dispose(disposable: Disposable?) {
|
||||||
var disposable = disposable
|
|
||||||
if (disposable != null && !disposable.isDisposed) {
|
if (disposable != null && !disposable.isDisposed) {
|
||||||
disposable.dispose()
|
disposable.dispose()
|
||||||
disposable = null
|
|
||||||
} else if (disposable == null && roomsQueryDisposable != null && !roomsQueryDisposable!!.isDisposed) {
|
} else if (disposable == null && roomsQueryDisposable != null && !roomsQueryDisposable!!.isDisposed) {
|
||||||
roomsQueryDisposable!!.dispose()
|
roomsQueryDisposable!!.dispose()
|
||||||
roomsQueryDisposable = null
|
roomsQueryDisposable = null
|
||||||
@ -776,7 +771,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onQueryTextChange(newText: String?) {
|
private fun onQueryTextChange(newText: String?) {
|
||||||
if (!TextUtils.isEmpty(searchQuery)) {
|
if (!TextUtils.isEmpty(searchQuery)) {
|
||||||
val filter = searchQuery
|
val filter = searchQuery
|
||||||
searchQuery = ""
|
searchQuery = ""
|
||||||
@ -817,8 +812,8 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
|
|
||||||
@SuppressLint("CheckResult") // handled by helper
|
@SuppressLint("CheckResult") // handled by helper
|
||||||
private fun startMessageSearch(search: String?) {
|
private fun startMessageSearch(search: String?) {
|
||||||
if (binding.swipeRefreshLayoutView != null) {
|
withNullableControllerViewBinding {
|
||||||
binding.swipeRefreshLayoutView!!.isRefreshing = true
|
binding.swipeRefreshLayoutView.isRefreshing = true
|
||||||
}
|
}
|
||||||
searchHelper?.startMessageSearch(search!!)
|
searchHelper?.startMessageSearch(search!!)
|
||||||
?.subscribeOn(Schedulers.io())
|
?.subscribeOn(Schedulers.io())
|
||||||
@ -832,7 +827,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
|
|
||||||
@SuppressLint("CheckResult") // handled by helper
|
@SuppressLint("CheckResult") // handled by helper
|
||||||
private fun loadMoreMessages() {
|
private fun loadMoreMessages() {
|
||||||
binding.swipeRefreshLayoutView!!.isRefreshing = true
|
binding.swipeRefreshLayoutView.isRefreshing = true
|
||||||
val observable = searchHelper!!.loadMore()
|
val observable = searchHelper!!.loadMore()
|
||||||
observable?.observeOn(AndroidSchedulers.mainThread())
|
observable?.observeOn(AndroidSchedulers.mainThread())
|
||||||
?.subscribe({ results: MessageSearchResults -> onMessageSearchResult(results) }) { throwable: Throwable ->
|
?.subscribe({ results: MessageSearchResults -> onMessageSearchResult(results) }) { throwable: Throwable ->
|
||||||
@ -906,9 +901,9 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
|
|
||||||
private fun handleSharedData() {
|
private fun handleSharedData() {
|
||||||
collectDataFromIntent()
|
collectDataFromIntent()
|
||||||
if (!textToPaste!!.isEmpty()) {
|
if (textToPaste!!.isNotEmpty()) {
|
||||||
openConversation(textToPaste)
|
openConversation(textToPaste)
|
||||||
} else if (filesToShare != null && !filesToShare!!.isEmpty()) {
|
} else if (filesToShare != null && filesToShare!!.isNotEmpty()) {
|
||||||
showSendFilesConfirmDialog()
|
showSendFilesConfirmDialog()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(context, context.resources.getString(R.string.nc_common_error_sorry), Toast.LENGTH_LONG)
|
Toast.makeText(context, context.resources.getString(R.string.nc_common_error_sorry), Toast.LENGTH_LONG)
|
||||||
@ -923,8 +918,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
val filename = getFileName(Uri.parse(file), context)
|
val filename = getFileName(Uri.parse(file), context)
|
||||||
fileNamesWithLineBreaks.append(filename).append("\n")
|
fileNamesWithLineBreaks.append(filename).append("\n")
|
||||||
}
|
}
|
||||||
val confirmationQuestion: String
|
val confirmationQuestion: String = if (filesToShare!!.size == 1) {
|
||||||
confirmationQuestion = if (filesToShare!!.size == 1) {
|
|
||||||
String.format(
|
String.format(
|
||||||
resources!!.getString(R.string.nc_upload_confirm_send_single),
|
resources!!.getString(R.string.nc_upload_confirm_send_single),
|
||||||
selectedConversation!!.displayName
|
selectedConversation!!.displayName
|
||||||
@ -935,19 +929,19 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
selectedConversation!!.displayName
|
selectedConversation!!.displayName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton!!.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.upload))
|
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.upload))
|
||||||
.setTitle(confirmationQuestion)
|
.setTitle(confirmationQuestion)
|
||||||
.setMessage(fileNamesWithLineBreaks.toString())
|
.setMessage(fileNamesWithLineBreaks.toString())
|
||||||
.setPositiveButton(R.string.nc_yes) { dialog: DialogInterface?, which: Int ->
|
.setPositiveButton(R.string.nc_yes) { _, _ ->
|
||||||
upload()
|
upload()
|
||||||
openConversation()
|
openConversation()
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.nc_no) { dialog: DialogInterface?, which: Int ->
|
.setNegativeButton(R.string.nc_no) { _, _ ->
|
||||||
Log.d(TAG, "sharing files aborted, going back to share-to screen")
|
Log.d(TAG, "sharing files aborted, going back to share-to screen")
|
||||||
showShareToScreen = true
|
showShareToScreen = true
|
||||||
}
|
}
|
||||||
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton!!.context, dialogBuilder)
|
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.colorTextButtons(
|
viewThemeUtils.colorTextButtons(
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
||||||
@ -1037,7 +1031,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var filesToShareArray: Array<String?>? = arrayOfNulls(filesToShare!!.size)
|
var filesToShareArray: Array<String?> = arrayOfNulls(filesToShare!!.size)
|
||||||
filesToShareArray = filesToShare!!.toArray(filesToShareArray)
|
filesToShareArray = filesToShare!!.toArray(filesToShareArray)
|
||||||
val data = Data.Builder()
|
val data = Data.Builder()
|
||||||
.putStringArray(UploadAndShareFilesWorker.DEVICE_SOURCEFILES, filesToShareArray)
|
.putStringArray(UploadAndShareFilesWorker.DEVICE_SOURCEFILES, filesToShareArray)
|
||||||
@ -1125,11 +1119,11 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
) {
|
) {
|
||||||
val conversation = Parcels.unwrap<Conversation>(conversationMenuBundle!!.getParcelable(KEY_ROOM))
|
val conversation = Parcels.unwrap<Conversation>(conversationMenuBundle!!.getParcelable(KEY_ROOM))
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton!!.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
||||||
.setTitle(R.string.nc_delete_call)
|
.setTitle(R.string.nc_delete_call)
|
||||||
.setMessage(R.string.nc_delete_conversation_more)
|
.setMessage(R.string.nc_delete_conversation_more)
|
||||||
.setPositiveButton(R.string.nc_delete) { dialog: DialogInterface?, which: Int ->
|
.setPositiveButton(R.string.nc_delete) { _, _ ->
|
||||||
val data = Data.Builder()
|
val data = Data.Builder()
|
||||||
data.putLong(
|
data.putLong(
|
||||||
KEY_INTERNAL_USER_ID,
|
KEY_INTERNAL_USER_ID,
|
||||||
@ -1139,10 +1133,10 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
conversationMenuBundle = null
|
conversationMenuBundle = null
|
||||||
deleteConversation(data.build())
|
deleteConversation(data.build())
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.nc_cancel) { dialog: DialogInterface?, which: Int ->
|
.setNegativeButton(R.string.nc_cancel) { _, _ ->
|
||||||
conversationMenuBundle = null
|
conversationMenuBundle = null
|
||||||
}
|
}
|
||||||
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton!!.context, dialogBuilder)
|
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.colorTextButtons(
|
viewThemeUtils.colorTextButtons(
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
||||||
@ -1154,12 +1148,12 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
|
|
||||||
private fun showUnauthorizedDialog() {
|
private fun showUnauthorizedDialog() {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton!!.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
||||||
.setTitle(R.string.nc_dialog_invalid_password)
|
.setTitle(R.string.nc_dialog_invalid_password)
|
||||||
.setMessage(R.string.nc_dialog_reauth_or_delete)
|
.setMessage(R.string.nc_dialog_reauth_or_delete)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton(R.string.nc_delete) { dialog: DialogInterface?, which: Int ->
|
.setPositiveButton(R.string.nc_delete) { _, _ ->
|
||||||
val otherUserExists = userManager
|
val otherUserExists = userManager
|
||||||
.scheduleUserForDeletionWithId(currentUser!!.id!!)
|
.scheduleUserForDeletionWithId(currentUser!!.id!!)
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
@ -1178,7 +1172,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.nc_settings_reauthorize) { dialog: DialogInterface?, which: Int ->
|
.setNegativeButton(R.string.nc_settings_reauthorize) { _, _ ->
|
||||||
router.pushController(
|
router.pushController(
|
||||||
RouterTransaction.with(
|
RouterTransaction.with(
|
||||||
WebViewLoginController(currentUser!!.baseUrl, true)
|
WebViewLoginController(currentUser!!.baseUrl, true)
|
||||||
@ -1187,7 +1181,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
.popChangeHandler(VerticalChangeHandler())
|
.popChangeHandler(VerticalChangeHandler())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton!!.context, dialogBuilder)
|
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.colorTextButtons(
|
viewThemeUtils.colorTextButtons(
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
||||||
@ -1197,12 +1191,12 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showServerEOLDialog() {
|
private fun showServerEOLDialog() {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton!!.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_warning_white))
|
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_warning_white))
|
||||||
.setTitle(R.string.nc_settings_server_eol_title)
|
.setTitle(R.string.nc_settings_server_eol_title)
|
||||||
.setMessage(R.string.nc_settings_server_eol)
|
.setMessage(R.string.nc_settings_server_eol)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton(R.string.nc_settings_remove_account) { dialog: DialogInterface?, which: Int ->
|
.setPositiveButton(R.string.nc_settings_remove_account) { _, _ ->
|
||||||
val otherUserExists = userManager
|
val otherUserExists = userManager
|
||||||
.scheduleUserForDeletionWithId(currentUser!!.id!!)
|
.scheduleUserForDeletionWithId(currentUser!!.id!!)
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
@ -1221,15 +1215,15 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.nc_cancel) { dialog: DialogInterface?, which: Int ->
|
.setNegativeButton(R.string.nc_cancel) { _, _ ->
|
||||||
if (userManager.users.blockingGet().size > 0) {
|
if (userManager.users.blockingGet().isNotEmpty()) {
|
||||||
router.pushController(RouterTransaction.with(SwitchAccountController()))
|
router.pushController(RouterTransaction.with(SwitchAccountController()))
|
||||||
} else {
|
} else {
|
||||||
activity!!.finishAffinity()
|
activity!!.finishAffinity()
|
||||||
activity!!.finish()
|
activity!!.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton!!.context, dialogBuilder)
|
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.colorTextButtons(
|
viewThemeUtils.colorTextButtons(
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
||||||
@ -1243,11 +1237,11 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
WorkManager.getInstance().enqueue(deleteConversationWorker)
|
WorkManager.getInstance().enqueue(deleteConversationWorker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onMessageSearchResult(results: MessageSearchResults) {
|
private fun onMessageSearchResult(results: MessageSearchResults) {
|
||||||
if (searchView!!.query.length > 0) {
|
if (searchView!!.query.isNotEmpty()) {
|
||||||
clearMessageSearchResults()
|
clearMessageSearchResults()
|
||||||
val entries = results.messages
|
val entries = results.messages
|
||||||
if (entries.size > 0) {
|
if (entries.isNotEmpty()) {
|
||||||
val adapterItems: MutableList<AbstractFlexibleItem<*>> = ArrayList(entries.size + 1)
|
val adapterItems: MutableList<AbstractFlexibleItem<*>> = ArrayList(entries.size + 1)
|
||||||
for (i in entries.indices) {
|
for (i in entries.indices) {
|
||||||
val showHeader = i == 0
|
val showHeader = i == 0
|
||||||
@ -1265,18 +1259,18 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
adapterItems.add(LoadMoreResultsItem)
|
adapterItems.add(LoadMoreResultsItem)
|
||||||
}
|
}
|
||||||
adapter!!.addItems(0, adapterItems)
|
adapter!!.addItems(0, adapterItems)
|
||||||
binding.recyclerView!!.scrollToPosition(0)
|
binding.recyclerView.scrollToPosition(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (binding.swipeRefreshLayoutView != null) {
|
withNullableControllerViewBinding {
|
||||||
binding.swipeRefreshLayoutView!!.isRefreshing = false
|
binding.swipeRefreshLayoutView.isRefreshing = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onMessageSearchError(throwable: Throwable) {
|
private fun onMessageSearchError(throwable: Throwable) {
|
||||||
handleHttpExceptions(throwable)
|
handleHttpExceptions(throwable)
|
||||||
if (binding.swipeRefreshLayoutView != null) {
|
withNullableControllerViewBinding {
|
||||||
binding.swipeRefreshLayoutView!!.isRefreshing = false
|
binding.swipeRefreshLayoutView.isRefreshing = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user