菜单新增重启系统(2)

This commit is contained in:
LittleTurtle2333
2022-02-16 15:56:02 +08:00
parent 6632b4aa75
commit 183a3bd77d
5 changed files with 37 additions and 14 deletions

View File

@@ -10,8 +10,8 @@ android {
applicationId "com.lt2333.simplicitytools" applicationId "com.lt2333.simplicitytools"
minSdk 30 minSdk 30
targetSdk 32 targetSdk 32
versionCode 2 versionCode 3
versionName "1.0.1" versionName "1.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@@ -22,9 +22,9 @@ class SettingsActivity : AppCompatActivity() {
setContentView(R.layout.settings_activity) setContentView(R.layout.settings_activity)
if (savedInstanceState == null) { if (savedInstanceState == null) {
supportFragmentManager supportFragmentManager
.beginTransaction() .beginTransaction()
.replace(R.id.settings, SettingsFragment()) .replace(R.id.settings, SettingsFragment())
.commit() .commit()
} }
supportActionBar?.setDisplayHomeAsUpEnabled(false) supportActionBar?.setDisplayHomeAsUpEnabled(false)
checkLSPosed() checkLSPosed()
@@ -41,13 +41,17 @@ class SettingsActivity : AppCompatActivity() {
getSharedPreferences("config", MODE_WORLD_READABLE) getSharedPreferences("config", MODE_WORLD_READABLE)
} catch (exception: SecurityException) { } catch (exception: SecurityException) {
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setMessage("您似乎正在使用过时的 LSPosed 版本或 LSPosed 未激活,请更新 LSPosed 或者激活后再试。") .setMessage("您似乎正在使用过时的 LSPosed 版本或 LSPosed 未激活,请更新 LSPosed 或者激活后再试。")
.show() .show()
} }
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.reboot -> {
val commad = arrayOf("reboot")
ShellUtils.execCommand(commad, true)
}
R.id.reboot_ui -> { R.id.reboot_ui -> {
val commad = arrayOf("killall com.android.systemui") val commad = arrayOf("killall com.android.systemui")
ShellUtils.execCommand(commad, true) ShellUtils.execCommand(commad, true)
@@ -61,7 +65,7 @@ class SettingsActivity : AppCompatActivity() {
preferenceManager.sharedPreferencesName = "config" preferenceManager.sharedPreferencesName = "config"
setPreferencesFromResource(R.xml.root_preferences, rootKey) setPreferencesFromResource(R.xml.root_preferences, rootKey)
findPreference<Preference>("verison")!!.summary = findPreference<Preference>("verison")!!.summary =
BuildConfig.VERSION_NAME + "(" + BuildConfig.BUILD_TYPE + ")" BuildConfig.VERSION_NAME + "(" + BuildConfig.BUILD_TYPE + ")"
} }
override fun onPreferenceTreeClick(preference: Preference?): Boolean { override fun onPreferenceTreeClick(preference: Preference?): Boolean {
@@ -70,7 +74,7 @@ class SettingsActivity : AppCompatActivity() {
"opensource" -> { "opensource" -> {
try { try {
val uri = val uri =
Uri.parse("https://github.com/LittleTurtle2333/Simplicity_Tools_Xposed") Uri.parse("https://github.com/LittleTurtle2333/Simplicity_Tools_Xposed")
val intent = Intent(Intent.ACTION_VIEW, uri) val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent) startActivity(intent)
} catch (e: Exception) { } catch (e: Exception) {
@@ -90,10 +94,10 @@ class SettingsActivity : AppCompatActivity() {
"dev_coolapk" -> { "dev_coolapk" -> {
try { try {
startActivity( startActivity(
Intent( Intent(
Intent.ACTION_VIEW, Intent.ACTION_VIEW,
Uri.parse("coolmarket://u/883441") Uri.parse("coolmarket://u/883441")
) )
) )
Toast.makeText(activity, "乌堆小透明:靓仔,点个关注吧!", Toast.LENGTH_SHORT).show() Toast.makeText(activity, "乌堆小透明:靓仔,点个关注吧!", Toast.LENGTH_SHORT).show()
} catch (e: Exception) { } catch (e: Exception) {

View File

@@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/reboot_ui" android:title="@string/reboot_ui"/> <item
android:id="@+id/reboot"
android:title="@string/reboot" />
<item
android:id="@+id/reboot_ui"
android:title="@string/reboot_ui" />
</menu> </menu>

View File

@@ -39,5 +39,7 @@
<string name="issues">反馈/提议</string> <string name="issues">反馈/提议</string>
<string name="issues_url">点击查看GitHub Issues</string> <string name="issues_url">点击查看GitHub Issues</string>
<string name="xposeddescription">基于 MIUI13(Android 12) 适配的自定义工具</string> <string name="xposeddescription">基于 MIUI13(Android 12) 适配的自定义工具</string>
<string name="reboot">重启</string>
<string name="hide_hd_icon">隐藏 HD 图标</string>
</resources> </resources>

View File

@@ -57,6 +57,11 @@
app:key="hide_vpn_icon" app:key="hide_vpn_icon"
app:title="@string/hide_vpn_icon" /> app:title="@string/hide_vpn_icon" />
<SwitchPreference
app:iconSpaceReserved="false"
app:key="hide_hd_icon"
app:title="@string/hide_hd_icon" />
<SwitchPreference <SwitchPreference
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:key="hide_sim_one_icon" app:key="hide_sim_one_icon"
@@ -112,6 +117,13 @@
app:title="@string/opensource"> app:title="@string/opensource">
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen
app:key="issues"
app:iconSpaceReserved="false"
app:summary="@string/issues_url"
app:title="@string/issues">
</PreferenceScreen>
<PreferenceScreen <PreferenceScreen
app:key="dev_coolapk" app:key="dev_coolapk"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"