fix: Only include transitionKind in intents for Pachli activities (#716)
Previous code always included the transitionKind enum as an extra, and could cause a crash if the activity launched by the intent was not a Pachli activity. Fixes #700.
This commit is contained in:
parent
61afde882c
commit
84fdf4abb7
|
@ -95,7 +95,11 @@ abstract class SFragment<T : IStatusViewData> : Fragment(), StatusActionListener
|
|||
private var serverCanTranslate = false
|
||||
|
||||
override fun startActivity(intent: Intent) {
|
||||
requireActivity().startActivityWithDefaultTransition(intent)
|
||||
if (intent.component?.className?.startsWith("app.pachli.") == true) {
|
||||
requireActivity().startActivityWithDefaultTransition(intent)
|
||||
} else {
|
||||
super.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
|
|
|
@ -27,8 +27,12 @@ import app.pachli.core.activity.BaseActivity
|
|||
import app.pachli.core.activity.BuildConfig
|
||||
|
||||
/**
|
||||
* Starts the activity in [intent] (which must be a subclass of [BaseActivity])
|
||||
* using [transitionKind] as the open/close transition.
|
||||
* Starts the activity in [intent]. Should only be called on subclasses of [BaseActivity].
|
||||
*
|
||||
* If the activity is a Pachli activity then [transitionKind] is included in the intent and
|
||||
* used as the open/close transition.
|
||||
*
|
||||
* See [BaseActivity.onCreate] for the other half of this code.
|
||||
*/
|
||||
fun Activity.startActivityWithTransition(intent: Intent, transitionKind: TransitionKind) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
|
@ -60,7 +64,7 @@ fun Activity.startActivityWithDefaultTransition(intent: Intent) = startActivityW
|
|||
fun Activity.setCloseTransition(transitionKind: TransitionKind) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (this !is BaseActivity) {
|
||||
throw IllegalStateException("startActivityWithTransition must be used with BaseActivity subclass")
|
||||
throw IllegalStateException("setCloseTransition must be used with BaseActivity subclass")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue