新增重启系统对话框

This commit is contained in:
LittleTurtle2333
2022-02-17 01:45:49 +08:00
parent d9e503fe13
commit e13a1ddf47

View File

@@ -1,6 +1,7 @@
package com.lt2333.simplicitytools.activity package com.lt2333.simplicitytools.activity
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
@@ -22,9 +23,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,16 +42,24 @@ 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 -> { R.id.reboot -> {
val commad = arrayOf("reboot") AlertDialog.Builder(this)
ShellUtils.execCommand(commad, true) .setMessage("确定重启?")
.setPositiveButton(
"",
DialogInterface.OnClickListener { dialogInterface, i ->
val commad = arrayOf("reboot")
ShellUtils.execCommand(commad, true)
})
.setNegativeButton("", null)
.show()
} }
R.id.reboot_ui -> { R.id.reboot_ui -> {
val commad = arrayOf("killall com.android.systemui") val commad = arrayOf("killall com.android.systemui")
@@ -65,7 +74,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 {
@@ -74,7 +83,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) {
@@ -84,7 +93,7 @@ class SettingsActivity : AppCompatActivity() {
"issues" -> { "issues" -> {
try { try {
val uri = val uri =
Uri.parse("https://github.com/LittleTurtle2333/Simplicity_Tools_Xposed/issues") Uri.parse("https://github.com/LittleTurtle2333/Simplicity_Tools_Xposed/issues")
val intent = Intent(Intent.ACTION_VIEW, uri) val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent) startActivity(intent)
} catch (e: Exception) { } catch (e: Exception) {
@@ -94,10 +103,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) {