From 37066e3c29c12d634e7214609640de2ac4052396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E5=9D=97=E5=90=9B?= Date: Fri, 18 Feb 2022 20:40:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 + app/build.gradle | 49 ---- app/build.gradle.kts | 63 +++++ app/proguard-rules.pro | 2 +- app/src/main/AndroidManifest.xml | 3 +- .../activity/SettingsActivity.kt | 236 +++++++++++------- app/src/main/res/layout/settings_activity.xml | 9 - app/src/main/res/menu/main.xml | 9 - app/src/main/res/values-night/themes.xml | 17 +- app/src/main/res/values/strings.xml | 2 + app/src/main/res/values/themes.xml | 24 +- app/src/main/res/xml/root_preferences.xml | 171 ------------- blockmiui | 1 + build.gradle => build.gradle.kts | 10 +- settings.gradle => settings.gradle.kts | 5 +- 15 files changed, 221 insertions(+), 383 deletions(-) create mode 100644 .gitmodules delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 app/src/main/res/layout/settings_activity.xml delete mode 100644 app/src/main/res/menu/main.xml delete mode 100644 app/src/main/res/xml/root_preferences.xml create mode 160000 blockmiui rename build.gradle => build.gradle.kts (52%) rename settings.gradle => settings.gradle.kts (64%) diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..5f60ba22 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "blockmiui"] + path = blockmiui + url = https://github.com/577fkj/blockmiui.git diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 5432d1dd..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' -} - -android { - compileSdk 31 - - defaultConfig { - applicationId "com.lt2333.simplicitytools" - minSdk 30 - targetSdk 32 - versionCode 10 - versionName '1.0.9' - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - buildFeatures { - viewBinding true - } - packagingOptions { - dex { - useLegacyPackaging true - } - } - android.applicationVariants.all { - variant -> - variant.outputs.all { - outputFileName = "Simplicity_Tools_Xposed-${variant.versionName}-${variant.name}.apk" - } - } -} - -dependencies { - compileOnly 'de.robv.android.xposed:api:82' - implementation 'androidx.preference:preference-ktx:1.2.0' - implementation 'com.google.android.material:material:1.5.0' -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..d619b027 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,63 @@ +import com.android.build.gradle.internal.api.BaseVariantOutputImpl + +plugins { + id("com.android.application") + id("kotlin-android") +} + +android { + compileSdk = 31 + + defaultConfig { + applicationId = "com.lt2333.simplicitytools" + minSdk = 30 + targetSdk = 32 + versionCode = 10 + versionName = "1.0.9" + } + + buildTypes { + release { + isMinifyEnabled = true + isZipAlignEnabled = true + isShrinkResources = true + setProguardFiles( + listOf( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.majorVersion + } + packagingOptions { + resources { + excludes += "/META-INF/**" + excludes += "/kotlin/**" + excludes += "/*.txt" + excludes += "/*.bin" + } + dex { + useLegacyPackaging = true + } + } + applicationVariants.all { + outputs.all { + (this as BaseVariantOutputImpl).outputFileName = + "Simplicity_Tools_Xposed-${versionName}-${name}.apk" + } + } +} + +dependencies { + //API + compileOnly("de.robv.android.xposed:api:82") + //UI + implementation(project(":blockmiui")) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 7018289e..6102543f 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1929e001..612ac5b4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,8 +7,7 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:label="@string/app_name" - android:supportsRtl="true" - android:theme="@style/Theme.MyApplication"> + android:supportsRtl="true" > - android.os.Process.killProcess(android.os.Process.myPid()) - }) - .show() - + isLoad = false + MIUIDialog(this).apply { + setTitle(R.string.Tips) + setMessage("您似乎正在使用过时的 LSPosed 版本或 LSPosed 未激活,请更新 LSPosed 或者激活后再试。") + setCancelable(false) + setRButton("确定") { + exitProcess(0) + } + show() + } } } - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.reboot -> { - AlertDialog.Builder(this) - .setMessage("确定重启?") - .setPositiveButton( - "是", - DialogInterface.OnClickListener { dialogInterface, i -> - val commad = arrayOf("reboot") - ShellUtils.execCommand(commad, true) - }) - .setNegativeButton("否", null) - .show() - } - R.id.reboot_ui -> { - val commad = arrayOf("killall com.android.systemui") - ShellUtils.execCommand(commad, true) - } - } - return super.onOptionsItemSelected(item) + override fun mainName(): String { + return getString(R.string.app_name) } - class SettingsFragment : PreferenceFragmentCompat() { - override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - preferenceManager.sharedPreferencesName = "config" - setPreferencesFromResource(R.xml.root_preferences, rootKey) - findPreference("verison")!!.summary = - BuildConfig.VERSION_NAME + "(" + BuildConfig.BUILD_TYPE + ")" - } - - override fun onPreferenceTreeClick(preference: Preference): Boolean { - - when (preference.key) { - "opensource" -> { - try { - val uri = - Uri.parse("https://github.com/LittleTurtle2333/Simplicity_Tools_Xposed") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } catch (e: Exception) { - Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() - } + override fun mainItems(): ArrayList { + return arrayListOf().apply { + add(TitleTextV(resId = R.string.ui)) + add(TextWithSwitchV(TextV(resId = R.string.delete_on_post_notification), SwitchV("delete_on_post_notification"))) + add(LineV()) + add(TitleTextV(resId = R.string.statusbar)) + add(TextWithSwitchV(TextV(resId = R.string.status_bar_time_seconds), SwitchV("status_bar_time_seconds"))) + add(TextWithSwitchV(TextV(resId = R.string.status_bar_network_speed_refresh_speed), SwitchV("status_bar_network_speed_refresh_speed"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_status_bar_network_speed_second), SwitchV("hide_status_bar_network_speed_second"))) + add(TextWithSwitchV(TextV(resId = R.string.remove_the_maximum_number_of_notification_icons), SwitchV("remove_the_maximum_number_of_notification_icons"))) + add(LineV()) + add(TitleTextV(resId = R.string.status_bar_icon)) + add(TextWithSwitchV(TextV(resId = R.string.hide_gps_icon), SwitchV("hide_gps_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_bluetooth_icon), SwitchV("hide_bluetooth_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_bluetooth_battery_icon), SwitchV("hide_bluetooth_battery_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_small_hd_icon), SwitchV("hide_small_hd_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_big_hd_icon), SwitchV("hide_big_hd_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_hd_no_service_icon), SwitchV("hide_hd_no_service_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_sim_one_icon), SwitchV("hide_sim_one_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_sim_two_icon), SwitchV("hide_sim_two_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_no_sim_icon), SwitchV("hide_no_sim_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_wifi_icon), SwitchV("hide_wifi_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_hotspot_icon), SwitchV("hide_hotspot_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_vpn_icon), SwitchV("hide_vpn_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_airplane_icon), SwitchV("hide_airplane_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_alarm_icon), SwitchV("hide_alarm_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_headset_icon), SwitchV("hide_headset_icon"))) + add(TextWithSwitchV(TextV(resId = R.string.hide_volume_zen_icon), SwitchV("hide_volume_zen_icon"))) + add(LineV()) + add(TitleTextV(resId = R.string.home)) + add(TextWithSwitchV(TextV(resId = R.string.home_time), SwitchV("home_time"))) + add(LineV()) + add(TitleTextV(resId = R.string.performance)) + add(TextWithSwitchV(TextV(resId = R.string.lock_max_fps), SwitchV("lock_max_fps"))) + add(LineV()) + add(TitleTextV(resId = R.string.other)) + add(TextWithSwitchV(TextV(resId = R.string.disable_flag_secure), SwitchV("disable_flag_secure"))) + add(LineV()) + add(TitleTextV(resId = R.string.about)) + add(TextSummaryV(textId = R.string.opensource, tipsId = R.string.github_url, onClickListener = { + try { + val uri = + Uri.parse("https://github.com/LittleTurtle2333/Simplicity_Tools_Xposed") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } catch (e: Exception) { + Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() } - "issues" -> { - try { - val uri = - Uri.parse("https://github.com/LittleTurtle2333/Simplicity_Tools_Xposed/issues") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } catch (e: Exception) { - Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() - } + })) + add(TextSummaryV(textId = R.string.issues, tipsId = R.string.issues_url, onClickListener = { + try { + val uri = + Uri.parse("https://github.com/LittleTurtle2333/Simplicity_Tools_Xposed/issues") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } catch (e: Exception) { + Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() } - "dev_coolapk" -> { - try { - startActivity( - Intent( - Intent.ACTION_VIEW, - Uri.parse("coolmarket://u/883441") - ) + })) + add(TextSummaryV(textId = R.string.dev_coolapk, tipsId = R.string.dev_coolapk_name, onClickListener = { + try { + startActivity( + Intent( + Intent.ACTION_VIEW, + Uri.parse("coolmarket://u/883441") ) - Toast.makeText(activity, "乌堆小透明:靓仔,点个关注吧!", Toast.LENGTH_SHORT).show() - } catch (e: Exception) { - Toast.makeText(activity, "本机未安装酷安应用", Toast.LENGTH_SHORT).show() - val uri = Uri.parse("http://www.coolapk.com/u/883441") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } + ) + Toast.makeText(activity, "乌堆小透明:靓仔,点个关注吧!", Toast.LENGTH_SHORT).show() + } catch (e: Exception) { + Toast.makeText(activity, "本机未安装酷安应用", Toast.LENGTH_SHORT).show() + val uri = Uri.parse("http://www.coolapk.com/u/883441") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) } - } - return super.onPreferenceTreeClick(preference) + })) + add(TextSummaryV(textId = R.string.verison, tips = "${BuildConfig.VERSION_NAME}(${BuildConfig.BUILD_TYPE})")) + } + } + + override fun menuName(): String { + return getString(R.string.menu) + } + + override fun menuItems(): ArrayList { + return ArrayList().apply { + add(TextSummaryV(textId = R.string.reboot_ui, onClickListener = { + MIUIDialog(activity).apply { + setTitle(R.string.Tips) + setMessage("确定重启系统界面?") + setLButton("取消") { + dismiss() + } + setRButton("确定") { + val command = arrayOf("killall com.android.systemui") + ShellUtils.execCommand(command, true) + dismiss() + } + show() + } + })) + add(TextSummaryV(textId = R.string.reboot, onClickListener = { + MIUIDialog(activity).apply { + setTitle(R.string.Tips) + setMessage("确定重启系统?") + setLButton("取消") { + dismiss() + } + setRButton("确定") { + val command = arrayOf("reboot") + ShellUtils.execCommand(command, true) + dismiss() + } + show() + } + })) + } + } + + override fun getItems(item: String): ArrayList { + return when (item) { + /** 必须写这两个 不然会出错 */ + menuName() -> menuItems() + else -> mainItems() } } } \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity.xml b/app/src/main/res/layout/settings_activity.xml deleted file mode 100644 index de6591a2..00000000 --- a/app/src/main/res/layout/settings_activity.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml deleted file mode 100644 index 9f9fc769..00000000 --- a/app/src/main/res/menu/main.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 203e2191..6a6931e9 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,16 +1 @@ - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8e240920..7373d4ba 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -51,5 +51,7 @@ 总开关 隐藏 GPS 图标 隐藏网速(/s)单位 + 菜单 + 提示 \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index f50294a3..6a6931e9 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,23 +1 @@ - - - - -