Prevent exported settings activity from honoring caller-supplied navigation graph.

This commit is contained in:
Cody Henthorne
2026-06-10 15:33:50 -04:00
parent 3e92fca26d
commit 2389279cfd
2 changed files with 10 additions and 6 deletions
@@ -25,12 +25,12 @@ open class DSLSettingsActivity : PassphraseRequiredActivity() {
setContentView(R.layout.dsl_settings_activity)
if (savedInstanceState == null) {
val navGraphId = intent.getIntExtra(ARG_NAV_GRAPH, -1)
val navGraphId = resolveNavGraphId()
if (navGraphId == -1) {
throw IllegalStateException("No navgraph id was passed to activity")
}
val fragment: NavHostFragment = NavHostFragment.create(navGraphId, intent.getBundleExtra(ARG_START_BUNDLE))
val fragment: NavHostFragment = NavHostFragment.create(navGraphId, resolveStartBundle())
supportFragmentManager.beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
@@ -64,6 +64,10 @@ open class DSLSettingsActivity : PassphraseRequiredActivity() {
protected open fun onWillFinish() {}
protected open fun resolveNavGraphId(): Int = intent.getIntExtra(ARG_NAV_GRAPH, -1)
protected open fun resolveStartBundle(): Bundle? = intent.getBundleExtra(ARG_START_BUNDLE)
companion object {
const val ARG_NAV_GRAPH = "nav_graph"
const val ARG_START_BUNDLE = "start_bundle"
@@ -45,10 +45,6 @@ class AppSettingsActivity : DSLSettingsActivity(), GooglePayComponent {
override val googlePayResultPublisher: Subject<GooglePayComponent.GooglePayResult> = PublishSubject.create()
override fun onCreate(savedInstanceState: Bundle?, ready: Boolean) {
if (intent?.hasExtra(ARG_NAV_GRAPH) != true) {
intent?.putExtra(ARG_NAV_GRAPH, R.navigation.app_settings_with_change_number)
}
super.onCreate(savedInstanceState, ready)
val startingAction: NavDirections? = if (intent?.categories?.contains(NOTIFICATION_CATEGORY) == true) {
@@ -152,6 +148,10 @@ class AppSettingsActivity : DSLSettingsActivity(), GooglePayComponent {
}
}
override fun resolveNavGraphId(): Int = R.navigation.app_settings_with_change_number
override fun resolveStartBundle(): Bundle? = null
@Suppress("DEPRECATION")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)