diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 311368cef..aa809b3b2 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,16 @@
+
+
+
+
+
+
+
+
RedesignActivity::class.java
else -> MainActivity::class.java
}
- val intent = Intent(context, ClassMap[destination])
- intent.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
- context.startActivity(intent)
+ Intent(context, ClassMap[destination])
+ .putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
+ .putExtra(
+ Const.Key.OPEN_SETTINGS,
+ launchIntent.action == ACTION_APPLICATION_PREFERENCES
+ )
+ .also { context.startActivity(it) }
}
object Main {
const val OPEN_NAV = 1
}
+
+ private val ACTION_APPLICATION_PREFERENCES
+ get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ Intent.ACTION_APPLICATION_PREFERENCES
+ } else {
+ "cannot be null, cannot be empty"
+ }
}
diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt
index 9ccdaca87..d92bd0134 100644
--- a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt
+++ b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt
@@ -4,6 +4,7 @@ import android.graphics.Insets
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.ncapdevi.fragnav.FragNavController
+import com.topjohnwu.magisk.Const
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.ActivityMainMd2Binding
import com.topjohnwu.magisk.model.navigation.Navigation
@@ -44,9 +45,13 @@ open class MainActivity : CompatActivity(
R.id.logFragment -> Navigation.log()
R.id.settingsFragment -> Navigation.settings()
else -> throw NotImplementedError("Id ${it.itemId} is not defined as selectable")
- }.also { onEventDispatched(it) }
+ }.dispatchOnSelf()
true
}
+
+ if (intent.getBooleanExtra(Const.Key.OPEN_SETTINGS, false)) {
+ binding.mainNavigation.selectedItemId = R.id.settingsFragment
+ }
}
override fun onTabTransaction(fragment: Fragment?, index: Int) {
diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatActivity.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatActivity.kt
index 4ba995450..a10b51e8e 100644
--- a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatActivity.kt
+++ b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatActivity.kt
@@ -31,4 +31,6 @@ abstract class CompatActivity