mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Fix crash on logout
This commit is contained in:
parent
9224fcabfa
commit
8fefdc1019
2 changed files with 13 additions and 12 deletions
|
@ -34,9 +34,7 @@ import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceCategory
|
import androidx.preference.PreferenceCategory
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
import im.vector.matrix.android.api.Matrix
|
|
||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
import im.vector.riotredesign.core.di.ActiveSessionHolder
|
|
||||||
import im.vector.riotredesign.core.extensions.showPassword
|
import im.vector.riotredesign.core.extensions.showPassword
|
||||||
import im.vector.riotredesign.core.platform.SimpleTextWatcher
|
import im.vector.riotredesign.core.platform.SimpleTextWatcher
|
||||||
import im.vector.riotredesign.core.preference.UserAvatarPreference
|
import im.vector.riotredesign.core.preference.UserAvatarPreference
|
||||||
|
@ -46,20 +44,16 @@ import im.vector.riotredesign.core.utils.allGranted
|
||||||
import im.vector.riotredesign.core.utils.copyToClipboard
|
import im.vector.riotredesign.core.utils.copyToClipboard
|
||||||
import im.vector.riotredesign.core.utils.toast
|
import im.vector.riotredesign.core.utils.toast
|
||||||
import im.vector.riotredesign.features.MainActivity
|
import im.vector.riotredesign.features.MainActivity
|
||||||
import im.vector.riotredesign.features.notifications.NotificationDrawerManager
|
|
||||||
import im.vector.riotredesign.features.themes.ThemeUtils
|
import im.vector.riotredesign.features.themes.ThemeUtils
|
||||||
import im.vector.riotredesign.features.workers.signout.SignOutUiWorker
|
import im.vector.riotredesign.features.workers.signout.SignOutUiWorker
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
||||||
|
|
||||||
override var titleRes = R.string.settings_general_title
|
override var titleRes = R.string.settings_general_title
|
||||||
override val preferenceXmlRes = R.xml.vector_settings_general
|
override val preferenceXmlRes = R.xml.vector_settings_general
|
||||||
|
|
||||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
|
||||||
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
|
||||||
|
|
||||||
private var mDisplayedEmails = ArrayList<String>()
|
private var mDisplayedEmails = ArrayList<String>()
|
||||||
private var mDisplayedPhoneNumber = ArrayList<String>()
|
private var mDisplayedPhoneNumber = ArrayList<String>()
|
||||||
|
@ -239,8 +233,8 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
||||||
findPreference("SETTINGS_SIGN_OUT_KEY")
|
findPreference("SETTINGS_SIGN_OUT_KEY")
|
||||||
.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
activity?.let {
|
activity?.let {
|
||||||
SignOutUiWorker(requireActivity(), notificationDrawerManager)
|
SignOutUiWorker(requireActivity())
|
||||||
.perform(activeSessionHolder.getActiveSession())
|
.perform(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
false
|
false
|
||||||
|
|
|
@ -16,17 +16,24 @@
|
||||||
|
|
||||||
package im.vector.riotredesign.features.workers.signout
|
package im.vector.riotredesign.features.workers.signout
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import im.vector.matrix.android.api.session.Session
|
|
||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
|
import im.vector.riotredesign.core.di.ActiveSessionHolder
|
||||||
|
import im.vector.riotredesign.core.extensions.vectorComponent
|
||||||
import im.vector.riotredesign.features.MainActivity
|
import im.vector.riotredesign.features.MainActivity
|
||||||
import im.vector.riotredesign.features.notifications.NotificationDrawerManager
|
import im.vector.riotredesign.features.notifications.NotificationDrawerManager
|
||||||
|
|
||||||
class SignOutUiWorker(private val activity: FragmentActivity,
|
class SignOutUiWorker(private val activity: FragmentActivity) {
|
||||||
private val notificationDrawerManager: NotificationDrawerManager) {
|
|
||||||
|
|
||||||
fun perform(session: Session) {
|
lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||||
|
lateinit var activeSessionHolder: ActiveSessionHolder
|
||||||
|
|
||||||
|
fun perform(context: Context) {
|
||||||
|
notificationDrawerManager = context.vectorComponent().notificationDrawerManager()
|
||||||
|
activeSessionHolder = context.vectorComponent().activeSessionHolder()
|
||||||
|
val session = activeSessionHolder.getActiveSession()
|
||||||
if (SignOutViewModel.doYouNeedToBeDisplayed(session)) {
|
if (SignOutViewModel.doYouNeedToBeDisplayed(session)) {
|
||||||
val signOutDialog = SignOutBottomSheetDialogFragment.newInstance(session.sessionParams.credentials.userId)
|
val signOutDialog = SignOutBottomSheetDialogFragment.newInstance(session.sessionParams.credentials.userId)
|
||||||
signOutDialog.onSignOut = Runnable {
|
signOutDialog.onSignOut = Runnable {
|
||||||
|
|
Loading…
Reference in a new issue