mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 10:07:38 +00:00
Added in-app settings shortcut from system settings
This commit is contained in:
parent
8024089bde
commit
8999a57f06
@ -36,6 +36,16 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity-alias
|
||||
android:name="a.s"
|
||||
android:targetActivity="a.c">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<activity
|
||||
android:name="a.f"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
|
@ -59,6 +59,7 @@ object Const {
|
||||
const val ETAG_KEY = "ETag"
|
||||
// intents
|
||||
const val OPEN_SECTION = "section"
|
||||
const val OPEN_SETTINGS = "settings"
|
||||
const val INTENT_SET_APP = "app_json"
|
||||
const val FLASH_ACTION = "action"
|
||||
const val FLASH_DATA = "additional_data"
|
||||
|
@ -2,6 +2,7 @@ package com.topjohnwu.magisk.model.navigation
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import com.topjohnwu.magisk.ClassMap
|
||||
import com.topjohnwu.magisk.Config
|
||||
import com.topjohnwu.magisk.Const
|
||||
@ -74,12 +75,23 @@ object Navigation {
|
||||
Config.redesign -> 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"
|
||||
}
|
||||
}
|
||||
|
@ -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<MainViewModel, ActivityMainMd2Binding>(
|
||||
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) {
|
||||
|
@ -31,4 +31,6 @@ abstract class CompatActivity<ViewModel : CompatViewModel, Binding : ViewDataBin
|
||||
delegate.onEventExecute(event, this)
|
||||
}
|
||||
|
||||
protected fun ViewEvent.dispatchOnSelf() = onEventDispatched(this)
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user