Merge pull request #4526 from vector-im/feature/bma/setarguments
Some cleanup on Fragment argument
This commit is contained in:
		
						commit
						72360104fb
					
				| @ -16,9 +16,7 @@ | ||||
| 
 | ||||
| package im.vector.app.core.extensions | ||||
| 
 | ||||
| import android.os.Bundle | ||||
| import android.util.Patterns | ||||
| import androidx.fragment.app.Fragment | ||||
| import com.google.i18n.phonenumbers.NumberParseException | ||||
| import com.google.i18n.phonenumbers.PhoneNumberUtil | ||||
| import org.matrix.android.sdk.api.extensions.ensurePrefix | ||||
| @ -27,11 +25,6 @@ fun Boolean.toOnOff() = if (this) "ON" else "OFF" | ||||
| 
 | ||||
| inline fun <T> T.ooi(block: (T) -> Unit): T = also(block) | ||||
| 
 | ||||
| /** | ||||
|  * Apply argument to a Fragment | ||||
|  */ | ||||
| fun <T : Fragment> T.withArgs(block: Bundle.() -> Unit) = apply { arguments = Bundle().apply(block) } | ||||
| 
 | ||||
| /** | ||||
|  * Check if a CharSequence is an email | ||||
|  */ | ||||
|  | ||||
| @ -22,6 +22,7 @@ import android.content.Context | ||||
| import android.content.res.Configuration | ||||
| import android.os.Build | ||||
| import android.os.Bundle | ||||
| import android.os.Parcelable | ||||
| import android.view.Menu | ||||
| import android.view.MenuItem | ||||
| import android.view.View | ||||
| @ -60,6 +61,7 @@ import im.vector.app.core.extensions.registerStartForActivityResult | ||||
| import im.vector.app.core.extensions.restart | ||||
| import im.vector.app.core.extensions.setTextOrHide | ||||
| import im.vector.app.core.extensions.singletonEntryPoint | ||||
| import im.vector.app.core.extensions.toMvRxBundle | ||||
| import im.vector.app.core.flow.throttleFirst | ||||
| import im.vector.app.core.utils.toast | ||||
| import im.vector.app.features.MainActivity | ||||
| @ -385,9 +387,9 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver | ||||
|         bugReporter.inMultiWindowMode = isInMultiWindowMode | ||||
|     } | ||||
| 
 | ||||
|     protected fun createFragment(fragmentClass: Class<out Fragment>, args: Bundle?): Fragment { | ||||
|     protected fun createFragment(fragmentClass: Class<out Fragment>, argsParcelable: Parcelable? = null): Fragment { | ||||
|         return fragmentFactory.instantiate(classLoader, fragmentClass.name).apply { | ||||
|             arguments = args | ||||
|             arguments = argsParcelable?.toMvRxBundle() | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -28,13 +28,13 @@ import androidx.annotation.CallSuper | ||||
| import androidx.lifecycle.ViewModelProvider | ||||
| import androidx.lifecycle.lifecycleScope | ||||
| import androidx.viewbinding.ViewBinding | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.MavericksView | ||||
| import com.google.android.material.bottomsheet.BottomSheetBehavior | ||||
| import com.google.android.material.bottomsheet.BottomSheetDialog | ||||
| import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||||
| import dagger.hilt.android.EntryPointAccessors | ||||
| import im.vector.app.core.di.ActivityEntryPoint | ||||
| import im.vector.app.core.extensions.toMvRxBundle | ||||
| import im.vector.app.core.flow.throttleFirst | ||||
| import im.vector.app.core.utils.DimensionConverter | ||||
| import kotlinx.coroutines.flow.launchIn | ||||
| @ -159,7 +159,7 @@ abstract class VectorBaseBottomSheetDialogFragment<VB : ViewBinding> : BottomShe | ||||
|     } | ||||
| 
 | ||||
|     protected fun setArguments(args: Parcelable? = null) { | ||||
|         arguments = args?.let { Bundle().apply { putParcelable(Mavericks.KEY_ARG, it) } } | ||||
|         arguments = args.toMvRxBundle() | ||||
|     } | ||||
| 
 | ||||
|     /* ========================================================================================== | ||||
|  | ||||
| @ -38,6 +38,7 @@ import im.vector.app.R | ||||
| import im.vector.app.core.extensions.commitTransaction | ||||
| import im.vector.app.core.extensions.exhaustive | ||||
| import im.vector.app.core.extensions.registerStartForActivityResult | ||||
| import im.vector.app.core.extensions.toMvRxBundle | ||||
| import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment | ||||
| import im.vector.app.databinding.BottomSheetBootstrapBinding | ||||
| import im.vector.app.features.auth.ReAuthActivity | ||||
| @ -154,48 +155,48 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetBoot | ||||
|             is BootstrapStep.CheckingMigration           -> { | ||||
|                 views.bootstrapIcon.isVisible = false | ||||
|                 views.bootstrapTitleText.text = getString(R.string.bottom_sheet_setup_secure_backup_title) | ||||
|                 showFragment(BootstrapWaitingFragment::class, Bundle()) | ||||
|                 showFragment(BootstrapWaitingFragment::class) | ||||
|             } | ||||
|             is BootstrapStep.FirstForm                   -> { | ||||
|                 views.bootstrapIcon.isVisible = false | ||||
|                 views.bootstrapTitleText.text = getString(R.string.bottom_sheet_setup_secure_backup_title) | ||||
|                 showFragment(BootstrapSetupRecoveryKeyFragment::class, Bundle()) | ||||
|                 showFragment(BootstrapSetupRecoveryKeyFragment::class) | ||||
|             } | ||||
|             is BootstrapStep.SetupPassphrase             -> { | ||||
|                 views.bootstrapIcon.isVisible = true | ||||
|                 views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_phrase_24dp)) | ||||
|                 views.bootstrapTitleText.text = getString(R.string.set_a_security_phrase_title) | ||||
|                 showFragment(BootstrapEnterPassphraseFragment::class, Bundle()) | ||||
|                 showFragment(BootstrapEnterPassphraseFragment::class) | ||||
|             } | ||||
|             is BootstrapStep.ConfirmPassphrase           -> { | ||||
|                 views.bootstrapIcon.isVisible = true | ||||
|                 views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_phrase_24dp)) | ||||
|                 views.bootstrapTitleText.text = getString(R.string.set_a_security_phrase_title) | ||||
|                 showFragment(BootstrapConfirmPassphraseFragment::class, Bundle()) | ||||
|                 showFragment(BootstrapConfirmPassphraseFragment::class) | ||||
|             } | ||||
|             is BootstrapStep.AccountReAuth               -> { | ||||
|                 views.bootstrapIcon.isVisible = true | ||||
|                 views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_user)) | ||||
|                 views.bootstrapTitleText.text = getString(R.string.re_authentication_activity_title) | ||||
|                 showFragment(BootstrapReAuthFragment::class, Bundle()) | ||||
|                 showFragment(BootstrapReAuthFragment::class) | ||||
|             } | ||||
|             is BootstrapStep.Initializing                -> { | ||||
|                 views.bootstrapIcon.isVisible = true | ||||
|                 views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp)) | ||||
|                 views.bootstrapTitleText.text = getString(R.string.bootstrap_loading_title) | ||||
|                 showFragment(BootstrapWaitingFragment::class, Bundle()) | ||||
|                 showFragment(BootstrapWaitingFragment::class) | ||||
|             } | ||||
|             is BootstrapStep.SaveRecoveryKey             -> { | ||||
|                 views.bootstrapIcon.isVisible = true | ||||
|                 views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp)) | ||||
|                 views.bootstrapTitleText.text = getString(R.string.bottom_sheet_save_your_recovery_key_title) | ||||
|                 showFragment(BootstrapSaveRecoveryKeyFragment::class, Bundle()) | ||||
|                 showFragment(BootstrapSaveRecoveryKeyFragment::class) | ||||
|             } | ||||
|             is BootstrapStep.DoneSuccess                 -> { | ||||
|                 views.bootstrapIcon.isVisible = true | ||||
|                 views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp)) | ||||
|                 views.bootstrapTitleText.text = getString(R.string.bootstrap_finish_title) | ||||
|                 showFragment(BootstrapConclusionFragment::class, Bundle()) | ||||
|                 showFragment(BootstrapConclusionFragment::class) | ||||
|             } | ||||
|             is BootstrapStep.GetBackupSecretForMigration -> { | ||||
|                 val isKey = state.step.useKey() | ||||
| @ -206,7 +207,7 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetBoot | ||||
|                         drawableRes) | ||||
|                 ) | ||||
|                 views.bootstrapTitleText.text = getString(R.string.upgrade_security) | ||||
|                 showFragment(BootstrapMigrateBackupFragment::class, Bundle()) | ||||
|                 showFragment(BootstrapMigrateBackupFragment::class) | ||||
|             } | ||||
|         }.exhaustive | ||||
|         super.invalidate() | ||||
| @ -214,26 +215,22 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetBoot | ||||
| 
 | ||||
|     companion object { | ||||
| 
 | ||||
|         const val EXTRA_ARGS = "EXTRA_ARGS" | ||||
| 
 | ||||
|         fun show(fragmentManager: FragmentManager, mode: SetupMode): BootstrapBottomSheet { | ||||
|             return BootstrapBottomSheet().apply { | ||||
|                 isCancelable = false | ||||
|                 arguments = Bundle().apply { | ||||
|                     this.putParcelable(EXTRA_ARGS, Args(setUpMode = mode)) | ||||
|                 } | ||||
|                 setArguments(Args(setUpMode = mode)) | ||||
|             }.also { | ||||
|                 it.show(fragmentManager, "BootstrapBottomSheet") | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private fun showFragment(fragmentClass: KClass<out Fragment>, bundle: Bundle) { | ||||
|     private fun showFragment(fragmentClass: KClass<out Fragment>, argsParcelable: Parcelable? = null) { | ||||
|         if (childFragmentManager.findFragmentByTag(fragmentClass.simpleName) == null) { | ||||
|             childFragmentManager.commitTransaction { | ||||
|                 replace(R.id.bottomSheetFragmentContainer, | ||||
|                         fragmentClass.java, | ||||
|                         bundle, | ||||
|                         argsParcelable?.toMvRxBundle(), | ||||
|                         fragmentClass.simpleName | ||||
|                 ) | ||||
|             } | ||||
|  | ||||
| @ -24,7 +24,6 @@ import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import androidx.fragment.app.Fragment | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.fragmentViewModel | ||||
| import com.airbnb.mvrx.withState | ||||
| import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||||
| @ -33,6 +32,7 @@ import im.vector.app.R | ||||
| import im.vector.app.core.extensions.commitTransaction | ||||
| import im.vector.app.core.extensions.exhaustive | ||||
| import im.vector.app.core.extensions.registerStartForActivityResult | ||||
| import im.vector.app.core.extensions.toMvRxBundle | ||||
| import im.vector.app.core.platform.VectorBaseActivity | ||||
| import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment | ||||
| import im.vector.app.databinding.BottomSheetVerificationBinding | ||||
| @ -178,36 +178,37 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV | ||||
|         } | ||||
| 
 | ||||
|         if (state.quadSHasBeenReset) { | ||||
|             showFragment(VerificationConclusionFragment::class, Bundle().apply { | ||||
|                 putParcelable(Mavericks.KEY_ARG, VerificationConclusionFragment.Args( | ||||
|                         isSuccessFull = true, | ||||
|                         isMe = true, | ||||
|                         cancelReason = null | ||||
|                 )) | ||||
|             }) | ||||
|             showFragment( | ||||
|                     VerificationConclusionFragment::class, | ||||
|                     VerificationConclusionFragment.Args( | ||||
|                             isSuccessFull = true, | ||||
|                             isMe = true, | ||||
|                             cancelReason = null | ||||
|                     )) | ||||
|             return@withState | ||||
|         } | ||||
| 
 | ||||
|         if (state.userThinkItsNotHim) { | ||||
|             views.otherUserNameText.text = getString(R.string.dialog_title_warning) | ||||
|             showFragment(VerificationNotMeFragment::class, Bundle()) | ||||
|             showFragment(VerificationNotMeFragment::class) | ||||
|             return@withState | ||||
|         } | ||||
| 
 | ||||
|         if (state.userWantsToCancel) { | ||||
|             views.otherUserNameText.text = getString(R.string.are_you_sure) | ||||
|             showFragment(VerificationCancelFragment::class, Bundle()) | ||||
|             showFragment(VerificationCancelFragment::class) | ||||
|             return@withState | ||||
|         } | ||||
| 
 | ||||
|         if (state.selfVerificationMode && state.verifyingFrom4S) { | ||||
|             showFragment(QuadSLoadingFragment::class, Bundle()) | ||||
|             showFragment(QuadSLoadingFragment::class) | ||||
|             return@withState | ||||
|         } | ||||
|         if (state.selfVerificationMode && state.verifiedFromPrivateKeys) { | ||||
|             showFragment(VerificationConclusionFragment::class, Bundle().apply { | ||||
|                 putParcelable(Mavericks.KEY_ARG, VerificationConclusionFragment.Args(true, null, state.isMe)) | ||||
|             }) | ||||
|             showFragment( | ||||
|                     VerificationConclusionFragment::class, | ||||
|                     VerificationConclusionFragment.Args(true, null, state.isMe) | ||||
|             ) | ||||
|             return@withState | ||||
|         } | ||||
| 
 | ||||
| @ -229,23 +230,27 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV | ||||
|                 is VerificationTxState.SendingMac, | ||||
|                 is VerificationTxState.MacSent, | ||||
|                 is VerificationTxState.Verifying -> { | ||||
|                     showFragment(VerificationEmojiCodeFragment::class, Bundle().apply { | ||||
|                         putParcelable(Mavericks.KEY_ARG, VerificationArgs( | ||||
|                                 state.otherUserMxItem?.id ?: "", | ||||
|                                 // If it was outgoing it.transaction id would be null, but the pending request | ||||
|                                 // would be updated (from localId to txId) | ||||
|                                 state.pendingRequest.invoke()?.transactionId ?: state.transactionId)) | ||||
|                     }) | ||||
|                     showFragment( | ||||
|                             VerificationEmojiCodeFragment::class, | ||||
|                             VerificationArgs( | ||||
|                                     state.otherUserMxItem?.id ?: "", | ||||
|                                     // If it was outgoing it.transaction id would be null, but the pending request | ||||
|                                     // would be updated (from localId to txId) | ||||
|                                     state.pendingRequest.invoke()?.transactionId ?: state.transactionId | ||||
|                             ) | ||||
|                     ) | ||||
|                 } | ||||
|                 is VerificationTxState.Verified  -> { | ||||
|                     showFragment(VerificationConclusionFragment::class, Bundle().apply { | ||||
|                         putParcelable(Mavericks.KEY_ARG, VerificationConclusionFragment.Args(true, null, state.isMe)) | ||||
|                     }) | ||||
|                     showFragment( | ||||
|                             VerificationConclusionFragment::class, | ||||
|                             VerificationConclusionFragment.Args(true, null, state.isMe) | ||||
|                     ) | ||||
|                 } | ||||
|                 is VerificationTxState.Cancelled -> { | ||||
|                     showFragment(VerificationConclusionFragment::class, Bundle().apply { | ||||
|                         putParcelable(Mavericks.KEY_ARG, VerificationConclusionFragment.Args(false, state.sasTransactionState.cancelCode.value, state.isMe)) | ||||
|                     }) | ||||
|                     showFragment( | ||||
|                             VerificationConclusionFragment::class, | ||||
|                             VerificationConclusionFragment.Args(false, state.sasTransactionState.cancelCode.value, state.isMe) | ||||
|                     ) | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
| @ -254,29 +259,32 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV | ||||
| 
 | ||||
|         when (state.qrTransactionState) { | ||||
|             is VerificationTxState.QrScannedByOther               -> { | ||||
|                 showFragment(VerificationQrScannedByOtherFragment::class, Bundle()) | ||||
|                 showFragment(VerificationQrScannedByOtherFragment::class) | ||||
|                 return@withState | ||||
|             } | ||||
|             is VerificationTxState.Started, | ||||
|             is VerificationTxState.WaitingOtherReciprocateConfirm -> { | ||||
|                 showFragment(VerificationQRWaitingFragment::class, Bundle().apply { | ||||
|                     putParcelable(Mavericks.KEY_ARG, VerificationQRWaitingFragment.Args( | ||||
|                             isMe = state.isMe, | ||||
|                             otherUserName = state.otherUserMxItem?.getBestName() ?: "" | ||||
|                     )) | ||||
|                 }) | ||||
|                 showFragment( | ||||
|                         VerificationQRWaitingFragment::class, | ||||
|                         VerificationQRWaitingFragment.Args( | ||||
|                                 isMe = state.isMe, | ||||
|                                 otherUserName = state.otherUserMxItem?.getBestName() ?: "" | ||||
|                         ) | ||||
|                 ) | ||||
|                 return@withState | ||||
|             } | ||||
|             is VerificationTxState.Verified                       -> { | ||||
|                 showFragment(VerificationConclusionFragment::class, Bundle().apply { | ||||
|                     putParcelable(Mavericks.KEY_ARG, VerificationConclusionFragment.Args(true, null, state.isMe)) | ||||
|                 }) | ||||
|                 showFragment( | ||||
|                         VerificationConclusionFragment::class, | ||||
|                         VerificationConclusionFragment.Args(true, null, state.isMe) | ||||
|                 ) | ||||
|                 return@withState | ||||
|             } | ||||
|             is VerificationTxState.Cancelled                      -> { | ||||
|                 showFragment(VerificationConclusionFragment::class, Bundle().apply { | ||||
|                     putParcelable(Mavericks.KEY_ARG, VerificationConclusionFragment.Args(false, state.qrTransactionState.cancelCode.value, state.isMe)) | ||||
|                 }) | ||||
|                 showFragment( | ||||
|                         VerificationConclusionFragment::class, | ||||
|                         VerificationConclusionFragment.Args(false, state.qrTransactionState.cancelCode.value, state.isMe) | ||||
|                 ) | ||||
|                 return@withState | ||||
|             } | ||||
|             else                                                  -> Unit | ||||
| @ -288,12 +296,14 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV | ||||
|         if (state.pendingRequest.invoke()?.cancelConclusion != null) { | ||||
|             // The request has been declined, we should dismiss | ||||
|             views.otherUserNameText.text = getString(R.string.verification_cancelled) | ||||
|             showFragment(VerificationConclusionFragment::class, Bundle().apply { | ||||
|                 putParcelable(Mavericks.KEY_ARG, VerificationConclusionFragment.Args( | ||||
|                         false, | ||||
|                         state.pendingRequest.invoke()?.cancelConclusion?.value ?: CancelCode.User.value, | ||||
|                         state.isMe)) | ||||
|             }) | ||||
|             showFragment( | ||||
|                     VerificationConclusionFragment::class, | ||||
|                     VerificationConclusionFragment.Args( | ||||
|                             isSuccessFull = false, | ||||
|                             cancelReason = state.pendingRequest.invoke()?.cancelConclusion?.value ?: CancelCode.User.value, | ||||
|                             isMe = state.isMe | ||||
|                     ) | ||||
|             ) | ||||
|             return@withState | ||||
|         } | ||||
| 
 | ||||
| @ -303,36 +313,44 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV | ||||
|             if (state.pendingRequest.invoke()?.isReady == true) { | ||||
|                 Timber.v("## SAS show bottom sheet for outgoing and ready request") | ||||
|                 // Show choose method fragment with waiting | ||||
|                 showFragment(VerificationChooseMethodFragment::class, Bundle().apply { | ||||
|                     putParcelable(Mavericks.KEY_ARG, VerificationArgs(state.otherUserMxItem?.id | ||||
|                             ?: "", state.pendingRequest.invoke()?.transactionId)) | ||||
|                 }) | ||||
|                 showFragment( | ||||
|                         VerificationChooseMethodFragment::class, | ||||
|                         VerificationArgs( | ||||
|                                 otherUserId = state.otherUserMxItem?.id ?: "", | ||||
|                                 verificationId = state.pendingRequest.invoke()?.transactionId | ||||
|                         ) | ||||
|                 ) | ||||
|             } else { | ||||
|                 // Stay on the start fragment | ||||
|                 showFragment(VerificationRequestFragment::class, Bundle().apply { | ||||
|                     putParcelable(Mavericks.KEY_ARG, VerificationArgs( | ||||
|                             state.otherUserMxItem?.id ?: "", | ||||
|                             state.pendingRequest.invoke()?.transactionId, | ||||
|                             state.roomId)) | ||||
|                 }) | ||||
|                 showFragment( | ||||
|                         VerificationRequestFragment::class, | ||||
|                         VerificationArgs( | ||||
|                                 otherUserId = state.otherUserMxItem?.id ?: "", | ||||
|                                 verificationId = state.pendingRequest.invoke()?.transactionId, | ||||
|                                 verificationLocalId = state.roomId | ||||
|                         ) | ||||
|                 ) | ||||
|             } | ||||
|         } else if (state.pendingRequest.invoke()?.isIncoming == true) { | ||||
|             Timber.v("## SAS show bottom sheet for Incoming request") | ||||
|             // For incoming we can switch to choose method because ready is being sent or already sent | ||||
|             showFragment(VerificationChooseMethodFragment::class, Bundle().apply { | ||||
|                 putParcelable(Mavericks.KEY_ARG, VerificationArgs(state.otherUserMxItem?.id | ||||
|                         ?: "", state.pendingRequest.invoke()?.transactionId)) | ||||
|             }) | ||||
|             showFragment( | ||||
|                     VerificationChooseMethodFragment::class, | ||||
|                     VerificationArgs( | ||||
|                             otherUserId = state.otherUserMxItem?.id ?: "", | ||||
|                             verificationId = state.pendingRequest.invoke()?.transactionId | ||||
|                     ) | ||||
|             ) | ||||
|         } | ||||
|         super.invalidate() | ||||
|     } | ||||
| 
 | ||||
|     private fun showFragment(fragmentClass: KClass<out Fragment>, bundle: Bundle) { | ||||
|     private fun showFragment(fragmentClass: KClass<out Fragment>, argsParcelable: Parcelable? = null) { | ||||
|         if (childFragmentManager.findFragmentByTag(fragmentClass.simpleName) == null) { | ||||
|             childFragmentManager.commitTransaction { | ||||
|                 replace(R.id.bottomSheetFragmentContainer, | ||||
|                         fragmentClass.java, | ||||
|                         bundle, | ||||
|                         argsParcelable?.toMvRxBundle(), | ||||
|                         fragmentClass.simpleName | ||||
|                 ) | ||||
|             } | ||||
| @ -342,37 +360,31 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV | ||||
|     companion object { | ||||
|         fun withArgs(roomId: String?, otherUserId: String, transactionId: String? = null): VerificationBottomSheet { | ||||
|             return VerificationBottomSheet().apply { | ||||
|                 arguments = Bundle().apply { | ||||
|                     putParcelable(Mavericks.KEY_ARG, VerificationArgs( | ||||
|                             otherUserId = otherUserId, | ||||
|                             roomId = roomId, | ||||
|                             verificationId = transactionId, | ||||
|                             selfVerificationMode = false | ||||
|                     )) | ||||
|                 } | ||||
|                 setArguments(VerificationArgs( | ||||
|                         otherUserId = otherUserId, | ||||
|                         roomId = roomId, | ||||
|                         verificationId = transactionId, | ||||
|                         selfVerificationMode = false | ||||
|                 )) | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         fun forSelfVerification(session: Session): VerificationBottomSheet { | ||||
|             return VerificationBottomSheet().apply { | ||||
|                 arguments = Bundle().apply { | ||||
|                     putParcelable(Mavericks.KEY_ARG, VerificationArgs( | ||||
|                             otherUserId = session.myUserId, | ||||
|                             selfVerificationMode = true | ||||
|                     )) | ||||
|                 } | ||||
|                 setArguments(VerificationArgs( | ||||
|                         otherUserId = session.myUserId, | ||||
|                         selfVerificationMode = true | ||||
|                 )) | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         fun forSelfVerification(session: Session, outgoingRequest: String): VerificationBottomSheet { | ||||
|             return VerificationBottomSheet().apply { | ||||
|                 arguments = Bundle().apply { | ||||
|                     putParcelable(Mavericks.KEY_ARG, VerificationArgs( | ||||
|                             otherUserId = session.myUserId, | ||||
|                             selfVerificationMode = true, | ||||
|                             verificationId = outgoingRequest | ||||
|                     )) | ||||
|                 } | ||||
|                 setArguments(VerificationArgs( | ||||
|                         otherUserId = session.myUserId, | ||||
|                         selfVerificationMode = true, | ||||
|                         verificationId = outgoingRequest | ||||
|                 )) | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -18,7 +18,6 @@ package im.vector.app.features.devtools | ||||
| 
 | ||||
| import android.content.Context | ||||
| import android.content.Intent | ||||
| import android.os.Bundle | ||||
| import android.os.Parcelable | ||||
| import android.view.Menu | ||||
| import android.view.MenuItem | ||||
| @ -37,7 +36,6 @@ import dagger.hilt.android.AndroidEntryPoint | ||||
| import im.vector.app.R | ||||
| import im.vector.app.core.extensions.exhaustive | ||||
| import im.vector.app.core.extensions.replaceFragment | ||||
| import im.vector.app.core.extensions.toMvRxBundle | ||||
| import im.vector.app.core.platform.SimpleFragmentActivity | ||||
| import im.vector.app.core.resources.ColorProvider | ||||
| import im.vector.app.core.utils.createJSonViewerStyleProvider | ||||
| @ -109,15 +107,15 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac | ||||
|                 } | ||||
|                 RoomDevToolViewState.Mode.StateEventList, | ||||
|                 RoomDevToolViewState.Mode.StateEventListByType -> { | ||||
|                     val frag = createFragment(RoomDevToolStateEventListFragment::class.java, Bundle().toMvRxBundle()) | ||||
|                     val frag = createFragment(RoomDevToolStateEventListFragment::class.java) | ||||
|                     navigateTo(frag) | ||||
|                 } | ||||
|                 RoomDevToolViewState.Mode.EditEventContent     -> { | ||||
|                     val frag = createFragment(RoomDevToolEditFragment::class.java, Bundle().toMvRxBundle()) | ||||
|                     val frag = createFragment(RoomDevToolEditFragment::class.java) | ||||
|                     navigateTo(frag) | ||||
|                 } | ||||
|                 is RoomDevToolViewState.Mode.SendEventForm     -> { | ||||
|                     val frag = createFragment(RoomDevToolSendFormFragment::class.java, Bundle().toMvRxBundle()) | ||||
|                     val frag = createFragment(RoomDevToolSendFormFragment::class.java) | ||||
|                     navigateTo(frag) | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @ -62,7 +62,6 @@ import com.airbnb.epoxy.EpoxyModel | ||||
| import com.airbnb.epoxy.OnModelBuildFinishedListener | ||||
| import com.airbnb.epoxy.addGlidePreloader | ||||
| import com.airbnb.epoxy.glidePreloader | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.args | ||||
| import com.airbnb.mvrx.fragmentViewModel | ||||
| import com.airbnb.mvrx.withState | ||||
| @ -1635,10 +1634,11 @@ class RoomDetailFragment @Inject constructor( | ||||
|             is RoomDetailAction.ResumeVerification        -> { | ||||
|                 val otherUserId = data.otherUserId ?: return | ||||
|                 VerificationBottomSheet().apply { | ||||
|                     arguments = Bundle().apply { | ||||
|                         putParcelable(Mavericks.KEY_ARG, VerificationBottomSheet.VerificationArgs( | ||||
|                                 otherUserId, data.transactionId, roomId = roomDetailArgs.roomId)) | ||||
|                     } | ||||
|                     setArguments(VerificationBottomSheet.VerificationArgs( | ||||
|                             otherUserId = otherUserId, | ||||
|                             verificationId = data.transactionId, | ||||
|                             roomId = roomDetailArgs.roomId | ||||
|                     )) | ||||
|                 }.show(parentFragmentManager, "REQ") | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -21,7 +21,6 @@ import android.os.Parcelable | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.args | ||||
| import dagger.hilt.android.AndroidEntryPoint | ||||
| import im.vector.app.R | ||||
| @ -81,12 +80,9 @@ class DisplayReadReceiptsBottomSheet : | ||||
| 
 | ||||
|     companion object { | ||||
|         fun newInstance(readReceipts: List<ReadReceiptData>): DisplayReadReceiptsBottomSheet { | ||||
|             val args = Bundle() | ||||
|             val parcelableArgs = DisplayReadReceiptArgs( | ||||
|                     readReceipts | ||||
|             ) | ||||
|             args.putParcelable(Mavericks.KEY_ARG, parcelableArgs) | ||||
|             return DisplayReadReceiptsBottomSheet().apply { arguments = args } | ||||
|             return DisplayReadReceiptsBottomSheet().apply { | ||||
|                 setArguments(DisplayReadReceiptArgs(readReceipts = readReceipts)) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -19,7 +19,6 @@ import android.os.Bundle | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.fragmentViewModel | ||||
| import com.airbnb.mvrx.withState | ||||
| import dagger.hilt.android.AndroidEntryPoint | ||||
| @ -68,14 +67,13 @@ class ViewEditHistoryBottomSheet : | ||||
| 
 | ||||
|     companion object { | ||||
|         fun newInstance(roomId: String, informationData: MessageInformationData): ViewEditHistoryBottomSheet { | ||||
|             val args = Bundle() | ||||
|             val parcelableArgs = TimelineEventFragmentArgs( | ||||
|                     informationData.eventId, | ||||
|                     roomId, | ||||
|                     informationData | ||||
|             ) | ||||
|             args.putParcelable(Mavericks.KEY_ARG, parcelableArgs) | ||||
|             return ViewEditHistoryBottomSheet().apply { arguments = args } | ||||
|             return ViewEditHistoryBottomSheet().apply { | ||||
|                 setArguments(TimelineEventFragmentArgs( | ||||
|                         eventId = informationData.eventId, | ||||
|                         roomId = roomId, | ||||
|                         informationData = informationData | ||||
|                 )) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -20,7 +20,6 @@ import android.os.Bundle | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.fragmentViewModel | ||||
| import com.airbnb.mvrx.withState | ||||
| import dagger.hilt.android.AndroidEntryPoint | ||||
| @ -82,14 +81,13 @@ class ViewReactionsBottomSheet : | ||||
| 
 | ||||
|     companion object { | ||||
|         fun newInstance(roomId: String, informationData: MessageInformationData): ViewReactionsBottomSheet { | ||||
|             val args = Bundle() | ||||
|             val parcelableArgs = TimelineEventFragmentArgs( | ||||
|                     informationData.eventId, | ||||
|                     roomId, | ||||
|                     informationData | ||||
|             ) | ||||
|             args.putParcelable(Mavericks.KEY_ARG, parcelableArgs) | ||||
|             return ViewReactionsBottomSheet().apply { arguments = args } | ||||
|             return ViewReactionsBottomSheet().apply { | ||||
|                 setArguments(TimelineEventFragmentArgs( | ||||
|                         eventId = informationData.eventId, | ||||
|                         roomId = roomId, | ||||
|                         informationData = informationData | ||||
|                 )) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -24,7 +24,6 @@ import android.view.ViewGroup | ||||
| import androidx.core.view.isVisible | ||||
| import androidx.fragment.app.Fragment | ||||
| import com.airbnb.mvrx.Incomplete | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.fragmentViewModel | ||||
| import com.airbnb.mvrx.withState | ||||
| import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||||
| @ -66,15 +65,15 @@ class MatrixToBottomSheet : | ||||
|     override fun invalidate() = withState(viewModel) { state -> | ||||
|         super.invalidate() | ||||
|         when (state.linkType) { | ||||
|             is PermalinkData.RoomLink -> { | ||||
|             is PermalinkData.RoomLink     -> { | ||||
|                 views.matrixToCardContentLoading.isVisible = state.roomPeekResult is Incomplete | ||||
|                 showFragment(MatrixToRoomSpaceFragment::class, Bundle()) | ||||
|             } | ||||
|             is PermalinkData.UserLink -> { | ||||
|             is PermalinkData.UserLink     -> { | ||||
|                 views.matrixToCardContentLoading.isVisible = state.matrixItem is Incomplete | ||||
|                 showFragment(MatrixToUserFragment::class, Bundle()) | ||||
|             } | ||||
|             is PermalinkData.GroupLink -> { | ||||
|             is PermalinkData.GroupLink    -> { | ||||
|             } | ||||
|             is PermalinkData.FallbackLink -> { | ||||
|             } | ||||
| @ -98,16 +97,16 @@ class MatrixToBottomSheet : | ||||
| 
 | ||||
|         viewModel.observeViewEvents { | ||||
|             when (it) { | ||||
|                 is MatrixToViewEvents.NavigateToRoom -> { | ||||
|                 is MatrixToViewEvents.NavigateToRoom  -> { | ||||
|                     interactionListener?.mxToBottomSheetNavigateToRoom(it.roomId) | ||||
|                     dismiss() | ||||
|                 } | ||||
|                 MatrixToViewEvents.Dismiss -> dismiss() | ||||
|                 MatrixToViewEvents.Dismiss            -> dismiss() | ||||
|                 is MatrixToViewEvents.NavigateToSpace -> { | ||||
|                     interactionListener?.mxToBottomSheetSwitchToSpace(it.spaceId) | ||||
|                     dismiss() | ||||
|                 } | ||||
|                 is MatrixToViewEvents.ShowModalError -> { | ||||
|                 is MatrixToViewEvents.ShowModalError  -> { | ||||
|                     MaterialAlertDialogBuilder(requireContext()) | ||||
|                             .setMessage(it.error) | ||||
|                             .setPositiveButton(getString(R.string.ok), null) | ||||
| @ -120,11 +119,7 @@ class MatrixToBottomSheet : | ||||
|     companion object { | ||||
|         fun withLink(matrixToLink: String): MatrixToBottomSheet { | ||||
|             return MatrixToBottomSheet().apply { | ||||
|                 arguments = Bundle().apply { | ||||
|                     putParcelable(Mavericks.KEY_ARG, MatrixToArgs( | ||||
|                             matrixToLink = matrixToLink | ||||
|                     )) | ||||
|                 } | ||||
|                 setArguments(MatrixToArgs(matrixToLink = matrixToLink)) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -24,7 +24,6 @@ import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import androidx.fragment.app.Fragment | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.fragmentViewModel | ||||
| import com.airbnb.mvrx.withState | ||||
| import dagger.hilt.android.AndroidEntryPoint | ||||
| @ -115,9 +114,9 @@ class DeviceListBottomSheet : | ||||
| 
 | ||||
|     companion object { | ||||
|         fun newInstance(userId: String, allowDeviceAction: Boolean = true): DeviceListBottomSheet { | ||||
|             val args = Bundle() | ||||
|             args.putParcelable(Mavericks.KEY_ARG, Args(userId, allowDeviceAction)) | ||||
|             return DeviceListBottomSheet().apply { arguments = args } | ||||
|             return DeviceListBottomSheet().apply { | ||||
|                 setArguments(Args(userId, allowDeviceAction)) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -21,7 +21,6 @@ import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import androidx.core.view.isVisible | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.fragmentViewModel | ||||
| import com.airbnb.mvrx.parentFragmentViewModel | ||||
| import com.airbnb.mvrx.withState | ||||
| @ -76,10 +75,9 @@ class DeviceVerificationInfoBottomSheet : | ||||
| 
 | ||||
|     companion object { | ||||
|         fun newInstance(userId: String, deviceId: String): DeviceVerificationInfoBottomSheet { | ||||
|             val args = Bundle() | ||||
|             val parcelableArgs = DeviceVerificationInfoArgs(userId, deviceId) | ||||
|             args.putParcelable(Mavericks.KEY_ARG, parcelableArgs) | ||||
|             return DeviceVerificationInfoBottomSheet().apply { arguments = args } | ||||
|             return DeviceVerificationInfoBottomSheet().apply { | ||||
|                 setArguments(DeviceVerificationInfoArgs(userId, deviceId)) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -26,7 +26,6 @@ import com.airbnb.mvrx.withState | ||||
| import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||||
| import dagger.hilt.android.AndroidEntryPoint | ||||
| import im.vector.app.R | ||||
| import im.vector.app.core.extensions.toMvRxBundle | ||||
| import im.vector.app.core.platform.SimpleFragmentActivity | ||||
| import im.vector.app.features.spaces.create.ChoosePrivateSpaceTypeFragment | ||||
| import im.vector.app.features.spaces.create.ChooseSpaceTypeFragment | ||||
| @ -121,7 +120,7 @@ class SpaceCreationActivity : SimpleFragmentActivity() { | ||||
|     } | ||||
| 
 | ||||
|     private fun navigateToFragment(fragmentClass: Class<out Fragment>) { | ||||
|         val frag = supportFragmentManager.findFragmentByTag(fragmentClass.name) ?: createFragment(fragmentClass, Bundle().toMvRxBundle()) | ||||
|         val frag = supportFragmentManager.findFragmentByTag(fragmentClass.name) ?: createFragment(fragmentClass) | ||||
|         supportFragmentManager.beginTransaction() | ||||
|                 .setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out) | ||||
|                 .replace(R.id.container, | ||||
|  | ||||
| @ -23,12 +23,10 @@ import android.text.style.BulletSpan | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import com.airbnb.mvrx.Mavericks | ||||
| import com.airbnb.mvrx.activityViewModel | ||||
| import com.airbnb.mvrx.withState | ||||
| import dagger.hilt.android.AndroidEntryPoint | ||||
| import im.vector.app.R | ||||
| import im.vector.app.core.extensions.withArgs | ||||
| import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment | ||||
| import im.vector.app.databinding.BottomSheetRoomWidgetPermissionBinding | ||||
| import im.vector.app.features.home.AvatarRenderer | ||||
| @ -111,8 +109,10 @@ class RoomWidgetPermissionBottomSheet : | ||||
| 
 | ||||
|     companion object { | ||||
| 
 | ||||
|         fun newInstance(widgetArgs: WidgetArgs) = RoomWidgetPermissionBottomSheet().withArgs { | ||||
|             putParcelable(Mavericks.KEY_ARG, widgetArgs) | ||||
|         fun newInstance(widgetArgs: WidgetArgs): RoomWidgetPermissionBottomSheet { | ||||
|             return RoomWidgetPermissionBottomSheet().apply { | ||||
|                 setArguments(widgetArgs) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -35,6 +35,7 @@ | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:imeOptions="actionDone" | ||||
|             android:inputType="textPassword" | ||||
|             android:maxLines="3" | ||||
|             android:singleLine="false" | ||||
|             tools:hint="@string/passphrase_enter_passphrase" /> | ||||
|  | ||||
| @ -33,6 +33,7 @@ | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:imeOptions="actionDone" | ||||
|             android:inputType="textPassword" | ||||
|             android:maxLines="3" | ||||
|             android:singleLine="false" | ||||
|             tools:hint="@string/passphrase_enter_passphrase" /> | ||||
|  | ||||
| @ -35,6 +35,7 @@ | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:imeOptions="actionDone" | ||||
|             android:inputType="textPassword" | ||||
|             android:maxLines="3" | ||||
|             android:singleLine="false" | ||||
|             tools:hint="@string/keys_backup_restore_key_enter_hint" /> | ||||
|  | ||||
| @ -56,6 +56,7 @@ | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:hint="@string/passphrase_enter_passphrase" | ||||
|                 android:inputType="textPassword" | ||||
|                 android:maxLines="3" | ||||
|                 android:singleLine="false" /> | ||||
| 
 | ||||
|  | ||||
| @ -58,6 +58,7 @@ | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:hint="@string/passphrase_create_passphrase" | ||||
|                 android:inputType="textPassword" | ||||
|                 android:maxLines="3" /> | ||||
| 
 | ||||
|         </com.google.android.material.textfield.TextInputLayout> | ||||
| @ -86,6 +87,7 @@ | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:hint="@string/passphrase_confirm_passphrase" | ||||
|                 android:inputType="textPassword" | ||||
|                 android:maxLines="3" /> | ||||
| 
 | ||||
|         </com.google.android.material.textfield.TextInputLayout> | ||||
|  | ||||
| @ -70,9 +70,9 @@ | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:hint="@string/passphrase_enter_passphrase" | ||||
|                 android:imeOptions="actionDone" | ||||
|                 android:inputType="textPassword" | ||||
|                 android:maxLines="3" | ||||
|                 android:singleLine="false" | ||||
|                 tools:inputType="textPassword" /> | ||||
|                 android:singleLine="false" /> | ||||
| 
 | ||||
|         </com.google.android.material.textfield.TextInputLayout> | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user