diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5cc47e14..b43dbc46 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,6 +14,7 @@ android { targetSdk = 33 versionCode = 68 versionName = "1.6.7" + buildConfigField("String", "BUILD_TIME", "\"${System.currentTimeMillis()}\"") } buildTypes { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ca92f31a..b3aac5b9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,6 +16,10 @@ android:launchMode="singleTop"> + + + + diff --git a/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt b/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt index bed32308..a0433bca 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt @@ -10,7 +10,6 @@ import android.view.View import android.widget.Switch import android.widget.Toast import cn.fkj233.ui.activity.MIUIActivity -import cn.fkj233.ui.activity.data.DefValue import cn.fkj233.ui.activity.view.SpinnerV import cn.fkj233.ui.activity.view.SwitchV import cn.fkj233.ui.activity.view.TextSummaryV @@ -22,28 +21,27 @@ import com.lt2333.simplicitytools.util.ShellUtils import com.microsoft.appcenter.AppCenter import com.microsoft.appcenter.analytics.Analytics import com.microsoft.appcenter.crashes.Crashes +import java.text.SimpleDateFormat +import java.util.* import kotlin.system.exitProcess class SettingsActivity : MIUIActivity() { private val activity = this override fun onCreate(savedInstanceState: Bundle?) { - if (BuildConfig.BUILD_TYPE != "debug") { - AppCenter.start( - application, "ae2037d3-9914-4e0c-b02b-f9b2bb2574e5", - Analytics::class.java, Crashes::class.java - ) - } - checkLSPosed() + if (!checkLSPosed()) isLoad = false super.onCreate(savedInstanceState) + if (isLoad && BuildConfig.BUILD_TYPE != "debug") { + AppCenter.start(application, "ae2037d3-9914-4e0c-b02b-f9b2bb2574e5", Analytics::class.java, Crashes::class.java) + } } //检测LSPosed是否激活 @SuppressLint("WorldReadableFiles") - private fun checkLSPosed() { + private fun checkLSPosed(): Boolean { try { setSP(getSharedPreferences("config", MODE_WORLD_READABLE)) + return true } catch (exception: SecurityException) { - isLoad = false MIUIDialog(this) { setTitle(R.string.Tips) setMessage(R.string.not_support) @@ -53,86 +51,42 @@ class SettingsActivity : MIUIActivity() { } }.show() } + return false } init { initView { registerMain(getString(R.string.app_name), false) { - TextSummaryWithSwitch( - TextSummaryV(textId = R.string.main_switch, colorId = R.color.purple_700), - SwitchV("main_switch", true) - ) - TextSummaryWithSwitch( - TextSummaryV(textId = R.string.HideLauncherIcon), - SwitchV("hLauncherIcon", customOnCheckedChangeListener = { - packageManager.setComponentEnabledSetting( - ComponentName(activity, "${BuildConfig.APPLICATION_ID}.launcher"), - if (it) { - PackageManager.COMPONENT_ENABLED_STATE_DISABLED - } else { - PackageManager.COMPONENT_ENABLED_STATE_ENABLED - }, - PackageManager.DONT_KILL_APP - ) - }) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.matters_needing_attention, - colorId = R.color.red, - onClickListener = { - MIUIDialog(activity) { - setTitle(R.string.matters_needing_attention) - setMessage( - R.string.matters_needing_attention_context - ) - setRButton(R.string.Done) { - dismiss() - } - }.show() - }) - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.main_switch, colorId = R.color.purple_700), SwitchV("main_switch", true)) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.HideLauncherIcon), SwitchV("hLauncherIcon", onClickListener = { + packageManager.setComponentEnabledSetting(ComponentName(activity, "${BuildConfig.APPLICATION_ID}.launcher"), if (it) { + PackageManager.COMPONENT_ENABLED_STATE_DISABLED + } else { + PackageManager.COMPONENT_ENABLED_STATE_ENABLED + }, PackageManager.DONT_KILL_APP) + })) + TextSummaryArrow(TextSummaryV(textId = R.string.matters_needing_attention, colorId = R.color.red, onClickListener = { + MIUIDialog(activity) { + setTitle(R.string.matters_needing_attention) + setMessage(R.string.matters_needing_attention_context) + setRButton(R.string.Done) { + dismiss() + } + }.show() + })) Line() TitleText(textId = R.string.scope) - TextSummaryArrow( - TextSummaryV( - textId = R.string.scope_systemui, - tipsId = R.string.scope_systemui_summary, - onClickListener = { showFragment("scope_systemui") } - ) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.scope_android, - tipsId = R.string.scope_android_summary, - onClickListener = { showFragment("scope_android") } - ) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.scope_other, - tipsId = R.string.scope_other_summary, - onClickListener = { showFragment("scope_other") } - ) - ) + TextSummaryArrow(TextSummaryV(textId = R.string.scope_systemui, tipsId = R.string.scope_systemui_summary, onClickListener = { showFragment("scope_systemui") })) + TextSummaryArrow(TextSummaryV(textId = R.string.scope_android, tipsId = R.string.scope_android_summary, onClickListener = { showFragment("scope_android") })) + TextSummaryArrow(TextSummaryV(textId = R.string.scope_other, tipsId = R.string.scope_other_summary, onClickListener = { showFragment("scope_other") })) Line() TitleText(textId = R.string.about) - TextSummaryArrow( - TextSummaryV( - textId = R.string.about_module, - tips = getString(R.string.about_module_summary), - onClickListener = { showFragment("about_module") } - ) - ) + TextSummaryArrow(TextSummaryV(textId = R.string.about_module, tips = getString(R.string.about_module_summary), onClickListener = { showFragment("about_module") })) } register("scope_systemui", getString(R.string.scope_systemui), false) { TitleText(textId = R.string.statusbar) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.double_tap_to_sleep - ), SwitchV("status_bar_double_tap_to_sleep") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.double_tap_to_sleep), SwitchV("status_bar_double_tap_to_sleep")) Line() TitleText(textId = R.string.status_bar_layout) val statusBarLayoutMode: HashMap = hashMapOf().also { @@ -141,36 +95,22 @@ class SettingsActivity : MIUIActivity() { it[2] = getString(R.string.clock_right) it[3] = getString(R.string.clock_center_and_icon_left) } - TextWithSpinner( - TextV(textId = R.string.status_bar_layout_mode), - SpinnerV( - statusBarLayoutMode[safeSP.getInt( - "status_bar_layout_mode", - 0 - )].toString() - ) { - add(statusBarLayoutMode[0].toString()) { - safeSP.putAny("status_bar_layout_mode", 0) - } - add(statusBarLayoutMode[1].toString()) { - safeSP.putAny("status_bar_layout_mode", 1) - } - add(statusBarLayoutMode[2].toString()) { - safeSP.putAny("status_bar_layout_mode", 2) - } - add(statusBarLayoutMode[3].toString()) { - safeSP.putAny("status_bar_layout_mode", 3) - } + TextWithSpinner(TextV(textId = R.string.status_bar_layout_mode), SpinnerV(statusBarLayoutMode[safeSP.getInt("status_bar_layout_mode", 0)].toString()) { + add(statusBarLayoutMode[0].toString()) { + safeSP.putAny("status_bar_layout_mode", 0) } - ) + add(statusBarLayoutMode[1].toString()) { + safeSP.putAny("status_bar_layout_mode", 1) + } + add(statusBarLayoutMode[2].toString()) { + safeSP.putAny("status_bar_layout_mode", 2) + } + add(statusBarLayoutMode[3].toString()) { + safeSP.putAny("status_bar_layout_mode", 3) + } + }) - val layoutCompatibilityModeBinding = GetDataBinding( - object : DefValue { - override fun getValue(): Any { - return safeSP.getInt("screen_hole_location", 0)==2 - } - } - ) { view, flags, data -> + val layoutCompatibilityModeBinding = GetDataBinding({ safeSP.getInt("screen_hole_location", 0) == 2 }) { view, flags, data -> when (flags) { 1 -> (view as Switch).isEnabled = data as Boolean 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE @@ -182,71 +122,39 @@ class SettingsActivity : MIUIActivity() { it[1] = getString(R.string.center) it[2] = getString(R.string.left_or_right) } - TextSummaryWithSpinner( - TextSummaryV(textId = R.string.layout_compatibility_mode, tipsId = R.string.screen_hole_location), - SpinnerV( - screenHoleLocation[safeSP.getInt( - "screen_hole_location", - 0 - )].toString() - ) { - add(screenHoleLocation[0].toString()) { - safeSP.putAny("screen_hole_location", 0) - layoutCompatibilityModeBinding.binding.Send().send(false) - } - add(screenHoleLocation[1].toString()) { - safeSP.putAny("screen_hole_location", 1) - layoutCompatibilityModeBinding.binding.Send().send(false) - } - add(screenHoleLocation[2].toString()) { - safeSP.putAny("screen_hole_location", 2) - layoutCompatibilityModeBinding.binding.Send().send(true) - } + TextSummaryWithSpinner(TextSummaryV(textId = R.string.layout_compatibility_mode, tipsId = R.string.screen_hole_location), SpinnerV(screenHoleLocation[safeSP.getInt("screen_hole_location", 0)].toString()) { + add(screenHoleLocation[0].toString()) { + safeSP.putAny("screen_hole_location", 0) + layoutCompatibilityModeBinding.binding.Send().send(false) } - ) + add(screenHoleLocation[1].toString()) { + safeSP.putAny("screen_hole_location", 1) + layoutCompatibilityModeBinding.binding.Send().send(false) + } + add(screenHoleLocation[2].toString()) { + safeSP.putAny("screen_hole_location", 2) + layoutCompatibilityModeBinding.binding.Send().send(true) + } + }) - Text( - textId = R.string.left_margin, - dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2) - ) - SeekBarWithText( - "status_bar_left_margin", - 0, - 300, - 0, - dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2) - ) - Text( - textId = R.string.right_margin, - dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2) - ) - SeekBarWithText( - "status_bar_right_margin", - 0, - 300, - 0, - dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2) - ) + Text(textId = R.string.left_margin, dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2)) + SeekBarWithText("status_bar_left_margin", 0, 300, 0, dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2)) + Text(textId = R.string.right_margin, dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2)) + SeekBarWithText("status_bar_right_margin", 0, 300, 0, dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2)) Line() TitleText(textId = R.string.status_bar_clock_format) - val customClockPresetBinding = GetDataBinding(object : DefValue { - override fun getValue(): Any { - return safeSP.getInt("custom_clock_mode", 0)==1 - } - }) { view, flags, data -> + val customClockPresetBinding = GetDataBinding({ safeSP.getInt("custom_clock_mode", 0) == 1 }) { view, flags, data -> when (flags) { 1 -> (view as Switch).isEnabled = data as Boolean 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE } } - val customClockGeekBinding = GetDataBinding(object : DefValue { - override fun getValue(): Any { - return safeSP.getInt("custom_clock_mode", 0)==2 - } - }) { view, flags, data -> + val customClockGeekBinding = GetDataBinding({ safeSP.getInt("custom_clock_mode", 0) == 2 } + + ) { view, flags, data -> when (flags) { 1 -> (view as Switch).isEnabled = data as Boolean 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE @@ -258,538 +166,251 @@ class SettingsActivity : MIUIActivity() { it[1] = getString(R.string.preset) it[2] = getString(R.string.geek) } - TextWithSpinner( - TextV(textId = R.string.custom_clock_mode), - SpinnerV( - customClockMode[safeSP.getInt( - "custom_clock_mode", - 0 - )].toString() - ) { - add(customClockMode[0].toString()) { - safeSP.putAny("custom_clock_mode", 0) - customClockPresetBinding.binding.Send().send(false) - customClockGeekBinding.binding.Send().send(false) - } - add(customClockMode[1].toString()) { - safeSP.putAny("custom_clock_mode", 1) - customClockPresetBinding.binding.Send().send(true) - customClockGeekBinding.binding.Send().send(false) - } - add(customClockMode[2].toString()) { - safeSP.putAny("custom_clock_mode", 2) - customClockPresetBinding.binding.Send().send(false) - customClockGeekBinding.binding.Send().send(true) - } + TextWithSpinner(TextV(textId = R.string.custom_clock_mode), SpinnerV(customClockMode[safeSP.getInt("custom_clock_mode", 0)].toString()) { + add(customClockMode[0].toString()) { + safeSP.putAny("custom_clock_mode", 0) + customClockPresetBinding.binding.Send().send(false) + customClockGeekBinding.binding.Send().send(false) } - ) + add(customClockMode[1].toString()) { + safeSP.putAny("custom_clock_mode", 1) + customClockPresetBinding.binding.Send().send(true) + customClockGeekBinding.binding.Send().send(false) + } + add(customClockMode[2].toString()) { + safeSP.putAny("custom_clock_mode", 2) + customClockPresetBinding.binding.Send().send(false) + customClockGeekBinding.binding.Send().send(true) + } + }) //预设模式起始 - TextWithSwitch( - TextV(textId = R.string.status_bar_time_year), - SwitchV("status_bar_time_year"), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_month), - SwitchV("status_bar_time_month"), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_day), - SwitchV("status_bar_time_day"), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_week), - SwitchV("status_bar_time_week"), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_double_hour), - SwitchV("status_bar_time_double_hour"), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_period), - SwitchV("status_bar_time_period", true), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_seconds), - SwitchV("status_bar_time_seconds"), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_hide_space), - SwitchV("status_bar_time_hide_space"), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_double_line), - SwitchV("status_bar_time_double_line"), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_double_line_center_align), - SwitchV("status_bar_time_double_line_center_align"), - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - Text( - textId = R.string.status_bar_clock_size, - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - SeekBarWithText( - "status_bar_clock_size", 0, 18, 0, - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - Text( - textId = R.string.status_bar_clock_double_line_size, - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) - SeekBarWithText( - "status_bar_clock_double_line_size", 0, 9, 0, - dataBindingRecv = customClockPresetBinding.binding.getRecv(2) - ) + TextWithSwitch(TextV(textId = R.string.status_bar_time_year), SwitchV("status_bar_time_year"), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_month), SwitchV("status_bar_time_month"), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_day), SwitchV("status_bar_time_day"), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_week), SwitchV("status_bar_time_week"), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_double_hour), SwitchV("status_bar_time_double_hour"), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_period), SwitchV("status_bar_time_period", true), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_seconds), SwitchV("status_bar_time_seconds"), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_hide_space), SwitchV("status_bar_time_hide_space"), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_double_line), SwitchV("status_bar_time_double_line"), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_double_line_center_align), SwitchV("status_bar_time_double_line_center_align"), dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + Text(textId = R.string.status_bar_clock_size, dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + SeekBarWithText("status_bar_clock_size", 0, 18, 0, dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + Text(textId = R.string.status_bar_clock_double_line_size, dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) + SeekBarWithText("status_bar_clock_double_line_size", 0, 9, 0, dataBindingRecv = customClockPresetBinding.binding.getRecv(2)) //预设模式结束 //极客模式起始 - TextSummaryArrow( - TextSummaryV( - textId = R.string.custom_clock_format_geek - ) { - MIUIDialog(activity) { - setTitle(R.string.custom_clock_format_geek) - setEditText( - safeSP.getString( - "custom_clock_format_geek", "HH:mm:ss" - ), - "" - ) - setLButton(textId = R.string.cancel) { - dismiss() - } - setRButton(textId = R.string.Done) { - if (getEditText().isNotEmpty()) { - try { - safeSP.putAny("custom_clock_format_geek", getEditText()) - dismiss() - return@setRButton - } catch (_: Throwable) { - } + TextSummaryArrow(TextSummaryV(textId = R.string.custom_clock_format_geek) { + MIUIDialog(activity) { + setTitle(R.string.custom_clock_format_geek) + setEditText(safeSP.getString("custom_clock_format_geek", "HH:mm:ss"), "") + setLButton(textId = R.string.cancel) { + dismiss() + } + setRButton(textId = R.string.Done) { + if (getEditText().isNotEmpty()) { + try { + safeSP.putAny("custom_clock_format_geek", getEditText()) + dismiss() + return@setRButton + } catch (_: Throwable) { } - Toast.makeText( - activity, - R.string.input_error, - Toast.LENGTH_SHORT - ).show() } - }.show() - }, dataBindingRecv = customClockGeekBinding.binding.getRecv(2) - ) - TextWithSwitch( - TextV(textId = R.string.status_bar_time_double_line_center_align), - SwitchV("status_bar_time_center_align_geek"), - dataBindingRecv = customClockGeekBinding.binding.getRecv(2) - ) - Text( - textId = R.string.status_bar_clock_size, - dataBindingRecv = customClockGeekBinding.binding.getRecv(2) - ) - SeekBarWithText( - "status_bar_clock_size_geek", 0, 18, 0, - dataBindingRecv = customClockGeekBinding.binding.getRecv(2) - ) + Toast.makeText(activity, R.string.input_error, Toast.LENGTH_SHORT).show() + } + }.show() + }, dataBindingRecv = customClockGeekBinding.binding.getRecv(2)) + TextWithSwitch(TextV(textId = R.string.status_bar_time_double_line_center_align), SwitchV("status_bar_time_center_align_geek"), dataBindingRecv = customClockGeekBinding.binding.getRecv(2)) + Text(textId = R.string.status_bar_clock_size, dataBindingRecv = customClockGeekBinding.binding.getRecv(2)) + SeekBarWithText("status_bar_clock_size_geek", 0, 18, 0, dataBindingRecv = customClockGeekBinding.binding.getRecv(2)) //极客模式结束 Line() TitleText(textId = R.string.status_bar_icon) - TextSummaryArrow( - TextSummaryV( - textId = R.string.hide_icon, - onClickListener = { showFragment("hide_icon") } - ) - ) - TextWithSwitch( - TextV(textId = R.string.show_wifi_standard), - SwitchV("show_wifi_standard") - ) - val customMobileTypeTextBinding = GetDataBinding(object : DefValue { - override fun getValue(): Any { - return safeSP.getBoolean("custom_mobile_type_text_switch", false) - } - }) { view, flags, data -> + TextSummaryArrow(TextSummaryV(textId = R.string.hide_icon, onClickListener = { showFragment("hide_icon") })) + TextWithSwitch(TextV(textId = R.string.show_wifi_standard), SwitchV("show_wifi_standard")) + val customMobileTypeTextBinding = GetDataBinding({ safeSP.getBoolean("custom_mobile_type_text_switch", false) }) { view, flags, data -> when (flags) { 1 -> (view as Switch).isEnabled = data as Boolean 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE } } - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.custom_mobile_type_text_switch - ), - SwitchV( - "custom_mobile_type_text_switch", - dataBindingSend = customMobileTypeTextBinding.bindingSend - ) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.custom_mobile_type_text - ) { - MIUIDialog(activity) { - setTitle(R.string.custom_mobile_type_text) - setEditText( - safeSP.getString( - "custom_mobile_type_text", "5G" - ), - "" - ) - setLButton(textId = R.string.cancel) { - dismiss() + TextSummaryWithSwitch(TextSummaryV(textId = R.string.custom_mobile_type_text_switch), SwitchV("custom_mobile_type_text_switch", dataBindingSend = customMobileTypeTextBinding.bindingSend)) + TextSummaryArrow(TextSummaryV(textId = R.string.custom_mobile_type_text) { + MIUIDialog(activity) { + setTitle(R.string.custom_mobile_type_text) + setEditText(safeSP.getString("custom_mobile_type_text", "5G"), "") + setLButton(textId = R.string.cancel) { + dismiss() + } + setRButton(textId = R.string.Done) { + if (getEditText().isNotEmpty()) { + try { + safeSP.putAny("custom_mobile_type_text", getEditText()) + dismiss() + return@setRButton + } catch (_: Throwable) { + } } - setRButton(textId = R.string.Done) { - if (getEditText().isNotEmpty()) { - try { - safeSP.putAny("custom_mobile_type_text", getEditText()) + Toast.makeText(activity, R.string.input_error, Toast.LENGTH_SHORT).show() + } + }.show() + }, dataBindingRecv = customMobileTypeTextBinding.binding.getRecv(2)) + val bigMobileTypeIconBinding = GetDataBinding({ safeSP.getBoolean("big_mobile_type_icon", false) }) { view, flags, data -> + when (flags) { + 1 -> (view as Switch).isEnabled = data as Boolean + 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + } + } + TextSummaryWithSwitch(TextSummaryV(textId = R.string.big_mobile_type_icon), SwitchV("big_mobile_type_icon", dataBindingSend = bigMobileTypeIconBinding.bindingSend)) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.big_mobile_type_icon_bold), SwitchV("big_mobile_type_icon_bold", true), dataBindingRecv = bigMobileTypeIconBinding.binding.getRecv(2)) + TextSummaryArrow(TextSummaryV(textId = R.string.big_mobile_type_icon_size, onClickListener = { + MIUIDialog(activity) { + setTitle(R.string.big_mobile_type_icon_size) + setEditText("", "${activity.getString(R.string.def)}12.5, ${activity.getString(R.string.current)}${ + safeSP.getFloat("big_mobile_type_icon_size", 12.5f) + }") + setLButton(textId = R.string.cancel) { + dismiss() + } + setRButton(textId = R.string.Done) { + if (getEditText() != "") { + safeSP.putAny("big_mobile_type_icon_size", getEditText().toFloat()) + } + dismiss() + } + }.show() + }), dataBindingRecv = bigMobileTypeIconBinding.binding.getRecv(2)) + TextSummaryArrow(TextSummaryV(textId = R.string.big_mobile_type_icon_up_and_down_position) { + MIUIDialog(activity) { + setTitle(R.string.big_mobile_type_icon_up_and_down_position) + setMessage("${activity.getString(R.string.range)} -15~15") + setEditText("", "${activity.getString(R.string.def)}0, ${activity.getString(R.string.current)}${ + safeSP.getInt("big_mobile_type_icon_up_and_down_position", 0) + }") + setLButton(textId = R.string.cancel) { + dismiss() + } + setRButton(textId = R.string.Done) { + if (getEditText().isNotEmpty()) { + try { + val value = getEditText().toInt() + if (value in (-15..15)) { + safeSP.putAny("big_mobile_type_icon_up_and_down_position", value) dismiss() return@setRButton - } catch (_: Throwable) { } + } catch (_: Throwable) { } - Toast.makeText( - activity, - R.string.input_error, - Toast.LENGTH_SHORT - ).show() } - }.show() - }, dataBindingRecv = customMobileTypeTextBinding.binding.getRecv(2) - ) - val bigMobileTypeIconBinding = GetDataBinding(object : DefValue { - override fun getValue(): Any { - return safeSP.getBoolean("big_mobile_type_icon", false) - } - }) { view, flags, data -> - when (flags) { - 1 -> (view as Switch).isEnabled = data as Boolean - 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE - } - } - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.big_mobile_type_icon - ), - SwitchV( - "big_mobile_type_icon", - dataBindingSend = bigMobileTypeIconBinding.bindingSend - ) - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.big_mobile_type_icon_bold - ), - SwitchV("big_mobile_type_icon_bold", true), - dataBindingRecv = bigMobileTypeIconBinding.binding.getRecv(2) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.big_mobile_type_icon_size, - onClickListener = { - MIUIDialog(activity) { - setTitle(R.string.big_mobile_type_icon_size) - setEditText( - "", - "${activity.getString(R.string.def)}12.5, ${activity.getString(R.string.current)}${ - safeSP.getFloat( - "big_mobile_type_icon_size", - 12.5f - ) - }" - ) - setLButton(textId = R.string.cancel) { - dismiss() - } - setRButton(textId = R.string.Done) { - if (getEditText() != "") { - safeSP.putAny( - "big_mobile_type_icon_size", - getEditText().toFloat() - ) + Toast.makeText(activity, R.string.input_error, Toast.LENGTH_SHORT).show() + } + }.show() + }, dataBindingRecv = bigMobileTypeIconBinding.binding.getRecv(2)) + TextSummaryArrow(TextSummaryV(textId = R.string.big_mobile_type_icon_left_and_right_margins) { + MIUIDialog(activity) { + setTitle(R.string.big_mobile_type_icon_left_and_right_margins) + setMessage("${activity.getString(R.string.range)} 0~30") + setEditText("", "${activity.getString(R.string.def)}0, ${activity.getString(R.string.current)}${ + safeSP.getInt("big_mobile_type_icon_left_and_right_margins", 0) + }") + setLButton(textId = R.string.cancel) { + dismiss() + } + setRButton(textId = R.string.Done) { + if (getEditText().isNotEmpty()) { + try { + val value = getEditText().toInt() + if (value in (0..30)) { + safeSP.putAny("big_mobile_type_icon_left_and_right_margins", value) + dismiss() + return@setRButton } - dismiss() + } catch (_: Throwable) { } - }.show() - }), dataBindingRecv = bigMobileTypeIconBinding.binding.getRecv(2) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.big_mobile_type_icon_up_and_down_position - ) { - MIUIDialog(activity) { - setTitle(R.string.big_mobile_type_icon_up_and_down_position) - setMessage("${activity.getString(R.string.range)} -15~15") - setEditText( - "", - "${activity.getString(R.string.def)}0, ${activity.getString(R.string.current)}${ - safeSP.getInt( - "big_mobile_type_icon_up_and_down_position", - 0 - ) - }" - ) - setLButton(textId = R.string.cancel) { - dismiss() } - setRButton(textId = R.string.Done) { - if (getEditText().isNotEmpty()) { - try { - val value = getEditText().toInt() - if (value in (-15..15)) { - safeSP.putAny( - "big_mobile_type_icon_up_and_down_position", - value - ) - dismiss() - return@setRButton - } - } catch (_: Throwable) { - } - } - Toast.makeText( - activity, - R.string.input_error, - Toast.LENGTH_SHORT - ).show() + Toast.makeText(activity, R.string.input_error, Toast.LENGTH_SHORT).show() + } + }.show() + }, dataBindingRecv = bigMobileTypeIconBinding.binding.getRecv(2)) + Text(textId = R.string.maximum_number_of_notification_icons) + SeekBarWithText("maximum_number_of_notification_icons", 1, 30, 3) + Text(textId = R.string.maximum_number_of_notification_dots) + SeekBarWithText("maximum_number_of_notification_dots", 0, 4, 3) + TextSummaryArrow(TextSummaryV(textId = R.string.battery_percentage_font_size, onClickListener = { + MIUIDialog(activity) { + setTitle(R.string.battery_percentage_font_size) + setMessage(R.string.zero_do_no_change) + setEditText("", "${activity.getString(R.string.current)}${ + safeSP.getFloat("battery_percentage_font_size", 0f) + }") + setLButton(textId = R.string.cancel) { + dismiss() + } + setRButton(textId = R.string.Done) { + if (getEditText() != "") { + safeSP.putAny("battery_percentage_font_size", getEditText().toFloat()) } - }.show() - }, dataBindingRecv = bigMobileTypeIconBinding.binding.getRecv(2) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.big_mobile_type_icon_left_and_right_margins - ) { - MIUIDialog(activity) { - setTitle(R.string.big_mobile_type_icon_left_and_right_margins) - setMessage("${activity.getString(R.string.range)} 0~30") - setEditText( - "", - "${activity.getString(R.string.def)}0, ${activity.getString(R.string.current)}${ - safeSP.getInt( - "big_mobile_type_icon_left_and_right_margins", - 0 - ) - }" - ) - setLButton(textId = R.string.cancel) { - dismiss() - } - setRButton(textId = R.string.Done) { - if (getEditText().isNotEmpty()) { - try { - val value = getEditText().toInt() - if (value in (0..30)) { - safeSP.putAny( - "big_mobile_type_icon_left_and_right_margins", - value - ) - dismiss() - return@setRButton - } - } catch (_: Throwable) { - } - } - Toast.makeText( - activity, - R.string.input_error, - Toast.LENGTH_SHORT - ).show() - } - }.show() - }, dataBindingRecv = bigMobileTypeIconBinding.binding.getRecv(2) - ) - Text( - textId = R.string.maximum_number_of_notification_icons - ) - SeekBarWithText( - "maximum_number_of_notification_icons", - 1, - 30, - 3 - ) - Text( - textId = R.string.maximum_number_of_notification_dots - ) - SeekBarWithText( - "maximum_number_of_notification_dots", - 0, - 4, - 3 - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.battery_percentage_font_size, - onClickListener = { - MIUIDialog(activity) { - setTitle(R.string.battery_percentage_font_size) - setMessage(R.string.zero_do_no_change) - setEditText( - "", - "${activity.getString(R.string.current)}${ - safeSP.getFloat( - "battery_percentage_font_size", - 0f - ) - }" - ) - setLButton(textId = R.string.cancel) { - dismiss() - } - setRButton(textId = R.string.Done) { - if (getEditText() != "") { - safeSP.putAny( - "battery_percentage_font_size", - getEditText().toFloat() - ) - } - dismiss() - } - }.show() - }) - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.hide_battery_percentage_icon, - tipsId = R.string.hide_battery_percentage_icon_summary - ), - SwitchV("hide_battery_percentage_icon") - ) + dismiss() + } + }.show() + })) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.hide_battery_percentage_icon, tipsId = R.string.hide_battery_percentage_icon_summary), SwitchV("hide_battery_percentage_icon")) Line() TitleText(textId = R.string.status_bar_network_speed) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.status_bar_network_speed_refresh_speed, - tipsId = R.string.status_bar_network_speed_refresh_speed_summary - ), - SwitchV("status_bar_network_speed_refresh_speed") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.hide_status_bar_network_speed_second, - tipsId = R.string.hide_status_bar_network_speed_second_summary - ), - SwitchV("hide_status_bar_network_speed_second") - ) - TextWithSwitch( - TextV(textId = R.string.hide_network_speed_splitter), - SwitchV("hide_network_speed_splitter") - ) - val statusBarDualRowNetworkSpeedBinding = GetDataBinding(object : DefValue { - override fun getValue(): Any { - return safeSP.getBoolean("status_bar_dual_row_network_speed", false) - } - }) { view, flags, data -> + TextSummaryWithSwitch(TextSummaryV(textId = R.string.status_bar_network_speed_refresh_speed, tipsId = R.string.status_bar_network_speed_refresh_speed_summary), SwitchV("status_bar_network_speed_refresh_speed")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.hide_status_bar_network_speed_second, tipsId = R.string.hide_status_bar_network_speed_second_summary), SwitchV("hide_status_bar_network_speed_second")) + TextWithSwitch(TextV(textId = R.string.hide_network_speed_splitter), SwitchV("hide_network_speed_splitter")) + val statusBarDualRowNetworkSpeedBinding = GetDataBinding({ safeSP.getBoolean("status_bar_dual_row_network_speed", false) }) { view, flags, data -> when (flags) { 1 -> (view as Switch).isEnabled = data as Boolean 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE } } - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.status_bar_dual_row_network_speed, - tipsId = R.string.status_bar_dual_row_network_speed_summary - ), - SwitchV( - "status_bar_dual_row_network_speed", - dataBindingSend = statusBarDualRowNetworkSpeedBinding.bindingSend - ) - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.status_bar_dual_row_network_speed, tipsId = R.string.status_bar_dual_row_network_speed_summary), SwitchV("status_bar_dual_row_network_speed", dataBindingSend = statusBarDualRowNetworkSpeedBinding.bindingSend)) val align: HashMap = hashMapOf() align[0] = getString(R.string.left) align[1] = getString(R.string.right) - TextWithSpinner( - TextV(textId = R.string.status_bar_network_speed_dual_row_gravity), - SpinnerV( - align[safeSP.getInt( - "status_bar_network_speed_dual_row_gravity", - 0 - )].toString() - ) { - add(align[0].toString()) { - safeSP.putAny("status_bar_network_speed_dual_row_gravity", 0) - } - add(align[1].toString()) { - safeSP.putAny("status_bar_network_speed_dual_row_gravity", 1) - - } - }, - dataBindingRecv = statusBarDualRowNetworkSpeedBinding.binding.getRecv(2) - ) - TextWithSpinner( - TextV(textId = R.string.status_bar_network_speed_dual_row_icon), - SpinnerV( - safeSP.getString( - "status_bar_network_speed_dual_row_icon", - getString(R.string.none) - ) - ) { - add(getString(R.string.none)) { - safeSP.putAny( - "status_bar_network_speed_dual_row_icon", - getString(R.string.none) - ) - } - add("▲▼") { - safeSP.putAny("status_bar_network_speed_dual_row_icon", "▲▼") - } - add("△▽") { - safeSP.putAny("status_bar_network_speed_dual_row_icon", "△▽") - } - add("↑↓") { - safeSP.putAny("status_bar_network_speed_dual_row_icon", "↑↓") - } + TextWithSpinner(TextV(textId = R.string.status_bar_network_speed_dual_row_gravity), SpinnerV(align[safeSP.getInt("status_bar_network_speed_dual_row_gravity", 0)].toString()) { + add(align[0].toString()) { + safeSP.putAny("status_bar_network_speed_dual_row_gravity", 0) } - ) - Text( - textId = R.string.status_bar_network_speed_dual_row_size, - dataBindingRecv = statusBarDualRowNetworkSpeedBinding.binding.getRecv(2) - ) - SeekBarWithText( - "status_bar_network_speed_dual_row_size", - 0, - 9, - 0, - dataBindingRecv = statusBarDualRowNetworkSpeedBinding.binding.getRecv(2) - ) + add(align[1].toString()) { + safeSP.putAny("status_bar_network_speed_dual_row_gravity", 1) + + } + }, dataBindingRecv = statusBarDualRowNetworkSpeedBinding.binding.getRecv(2)) + TextWithSpinner(TextV(textId = R.string.status_bar_network_speed_dual_row_icon), SpinnerV(safeSP.getString("status_bar_network_speed_dual_row_icon", getString(R.string.none))) { + add(getString(R.string.none)) { + safeSP.putAny("status_bar_network_speed_dual_row_icon", getString(R.string.none)) + } + add("▲▼") { + safeSP.putAny("status_bar_network_speed_dual_row_icon", "▲▼") + } + add("△▽") { + safeSP.putAny("status_bar_network_speed_dual_row_icon", "△▽") + } + add("↑↓") { + safeSP.putAny("status_bar_network_speed_dual_row_icon", "↑↓") + } + }) + Text(textId = R.string.status_bar_network_speed_dual_row_size, dataBindingRecv = statusBarDualRowNetworkSpeedBinding.binding.getRecv(2)) + SeekBarWithText("status_bar_network_speed_dual_row_size", 0, 9, 0, dataBindingRecv = statusBarDualRowNetworkSpeedBinding.binding.getRecv(2)) Line() TitleText(textId = R.string.notification_center) - val showWeatherMainSwitchBinding = GetDataBinding(object : DefValue { - override fun getValue(): Any { - return safeSP.getBoolean("notification_weather", false) - } - }) { view, flags, data -> + val showWeatherMainSwitchBinding = GetDataBinding({ safeSP.getBoolean("notification_weather", false) }) { view, flags, data -> when (flags) { 1 -> (view as Switch).isEnabled = data as Boolean 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE } } - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.show_weather_main_switch, colorId = R.color.purple_700 - ), - SwitchV( - "notification_weather", - dataBindingSend = showWeatherMainSwitchBinding.bindingSend - ) - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.show_city, - ), - SwitchV("notification_weather_city"), - dataBindingRecv = showWeatherMainSwitchBinding.binding.getRecv(2) - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.show_weather_main_switch, colorId = R.color.purple_700), SwitchV("notification_weather", dataBindingSend = showWeatherMainSwitchBinding.bindingSend)) + TextSummaryWithSwitch(TextSummaryV( + textId = R.string.show_city, + ), SwitchV("notification_weather_city"), dataBindingRecv = showWeatherMainSwitchBinding.binding.getRecv(2)) TextSummaryWithSwitch( TextSummaryV( textId = R.string.can_notification_slide, @@ -799,736 +420,304 @@ class SettingsActivity : MIUIActivity() { ) Line() TitleText(textId = R.string.control_center) - val controlCenterWeatherBinding = GetDataBinding(object : DefValue { - override fun getValue(): Any { - return safeSP.getBoolean("control_center_weather", false) - } - }) { view, flags, data -> + val controlCenterWeatherBinding = GetDataBinding({ safeSP.getBoolean("control_center_weather", false) }) { view, flags, data -> when (flags) { 1 -> (view as Switch).isEnabled = data as Boolean 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE } } - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.show_weather_main_switch, - colorId = R.color.purple_700, - tipsId = R.string.control_center_weather_summary - ), - SwitchV( - "control_center_weather", - dataBindingSend = controlCenterWeatherBinding.bindingSend - ) - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.show_city, - ), - SwitchV("control_center_weather_city"), - dataBindingRecv = controlCenterWeatherBinding.binding.getRecv(2) - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.show_weather_main_switch, colorId = R.color.purple_700, tipsId = R.string.control_center_weather_summary), SwitchV("control_center_weather", dataBindingSend = controlCenterWeatherBinding.bindingSend)) + TextSummaryWithSwitch(TextSummaryV( + textId = R.string.show_city, + ), SwitchV("control_center_weather_city"), dataBindingRecv = controlCenterWeatherBinding.binding.getRecv(2)) Line() TitleText(textId = R.string.lock_screen) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.lock_screen_clock_display_seconds, - tipsId = R.string.only_official_default_themes_are_supported - ), - SwitchV("lock_screen_clock_display_seconds") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.remove_the_left_side_of_the_lock_screen, - tipsId = R.string.only_official_default_themes_are_supported - ), - SwitchV("remove_the_left_side_of_the_lock_screen") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.remove_lock_screen_camera, - tipsId = R.string.only_official_default_themes_are_supported - ), - SwitchV("remove_lock_screen_camera") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.enable_wave_charge_animation - ), - SwitchV("enable_wave_charge_animation") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.lock_screen_charging_current, - tipsId = R.string.only_official_default_themes_are_supported - ), - SwitchV("lock_screen_charging_current") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.double_tap_to_sleep, - tipsId = R.string.home_double_tap_to_sleep_summary - ), SwitchV("lock_screen_double_tap_to_sleep") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.lock_screen_clock_display_seconds, tipsId = R.string.only_official_default_themes_are_supported), SwitchV("lock_screen_clock_display_seconds")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.remove_the_left_side_of_the_lock_screen, tipsId = R.string.only_official_default_themes_are_supported), SwitchV("remove_the_left_side_of_the_lock_screen")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.remove_lock_screen_camera, tipsId = R.string.only_official_default_themes_are_supported), SwitchV("remove_lock_screen_camera")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.enable_wave_charge_animation), SwitchV("enable_wave_charge_animation")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.lock_screen_charging_current, tipsId = R.string.only_official_default_themes_are_supported), SwitchV("lock_screen_charging_current")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.double_tap_to_sleep, tipsId = R.string.home_double_tap_to_sleep_summary), SwitchV("lock_screen_double_tap_to_sleep")) Line() TitleText(textId = R.string.old_quick_settings_panel) - val oldQSCustomSwitchBinding = GetDataBinding(object : DefValue { - override fun getValue(): Any { - return safeSP.getBoolean("old_qs_custom_switch", false) - } - }) { view, flags, data -> + val oldQSCustomSwitchBinding = GetDataBinding({ safeSP.getBoolean("old_qs_custom_switch", false) }) { view, flags, data -> when (flags) { 1 -> (view as Switch).isEnabled = data as Boolean 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE } } - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.old_qs_custom_switch, - colorId = R.color.purple_700 - ), - SwitchV( - "old_qs_custom_switch", - dataBindingSend = oldQSCustomSwitchBinding.bindingSend - ) - ) - Text( - textId = R.string.qs_custom_rows, - dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2) - ) - SeekBarWithText( - "qs_custom_rows", - 1, - 6, - 3, - dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2) - ) - Text( - textId = R.string.qs_custom_rows_horizontal, - dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2) - ) - SeekBarWithText( - "qs_custom_rows_horizontal", - 1, - 3, - 2, - dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2) - ) - Text( - textId = R.string.qs_custom_columns, - dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2) - ) - SeekBarWithText( - "qs_custom_columns", - 1, - 7, - 4, - dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2) - ) - Text( - textId = R.string.qs_custom_columns_unexpanded, - dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2) - ) - SeekBarWithText( - "qs_custom_columns_unexpanded", - 1, - 7, - 5, - dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2) - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.old_qs_custom_switch, colorId = R.color.purple_700), SwitchV("old_qs_custom_switch", dataBindingSend = oldQSCustomSwitchBinding.bindingSend)) + Text(textId = R.string.qs_custom_rows, dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2)) + SeekBarWithText("qs_custom_rows", 1, 6, 3, dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2)) + Text(textId = R.string.qs_custom_rows_horizontal, dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2)) + SeekBarWithText("qs_custom_rows_horizontal", 1, 3, 2, dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2)) + Text(textId = R.string.qs_custom_columns, dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2)) + SeekBarWithText("qs_custom_columns", 1, 7, 4, dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2)) + Text(textId = R.string.qs_custom_columns_unexpanded, dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2)) + SeekBarWithText("qs_custom_columns_unexpanded", 1, 7, 5, dataBindingRecv = oldQSCustomSwitchBinding.binding.getRecv(2)) } register("scope_android", getString(R.string.scope_android), false) { TitleText(textId = R.string.corepacth) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.downgr, - tipsId = R.string.downgr_summary - ), - SwitchV("downgrade") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.authcreak, - tipsId = R.string.authcreak_summary - ), - SwitchV("authcreak") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.digestCreak, - tipsId = R.string.digestCreak_summary - ), - SwitchV("digestCreak") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.UsePreSig, - tipsId = R.string.UsePreSig_summary - ), - SwitchV("UsePreSig") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.enhancedMode, - tipsId = R.string.enhancedMode_summary - ), - SwitchV("enhancedMode") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.downgr, tipsId = R.string.downgr_summary), SwitchV("downgrade")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.authcreak, tipsId = R.string.authcreak_summary), SwitchV("authcreak")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.digestCreak, tipsId = R.string.digestCreak_summary), SwitchV("digestCreak")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.UsePreSig, tipsId = R.string.UsePreSig_summary), SwitchV("UsePreSig")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.enhancedMode, tipsId = R.string.enhancedMode_summary), SwitchV("enhancedMode")) Line() - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.disable_flag_secure, - tipsId = R.string.disable_flag_secure_summary - ), - SwitchV("disable_flag_secure") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.delete_on_post_notification, - tipsId = R.string.delete_on_post_notification_summary - ), - SwitchV("delete_on_post_notification") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.remove_small_window_restrictions, - tipsId = R.string.remove_small_window_restrictions_summary - ), - SwitchV("remove_small_window_restrictions") - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.max_wallpaper_scale, - onClickListener = { - MIUIDialog(activity) { - setTitle(R.string.max_wallpaper_scale) - setEditText( - "", - "${activity.getString(R.string.def)}1.1, ${activity.getString(R.string.current)}${ - safeSP.getFloat( - "max_wallpaper_scale", - 1.1f - ) - }" - ) - setLButton(textId = R.string.cancel) { - dismiss() - } - setRButton(textId = R.string.Done) { - if (getEditText() != "") { - safeSP.putAny( - "max_wallpaper_scale", - getEditText().toFloat() - ) - } - dismiss() - } - }.show() - }) - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.allow_untrusted_touches, - tipsId = R.string.take_effect_after_reboot - ), - SwitchV("allow_untrusted_touches") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.disable_flag_secure, tipsId = R.string.disable_flag_secure_summary), SwitchV("disable_flag_secure")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.delete_on_post_notification, tipsId = R.string.delete_on_post_notification_summary), SwitchV("delete_on_post_notification")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.remove_small_window_restrictions, tipsId = R.string.remove_small_window_restrictions_summary), SwitchV("remove_small_window_restrictions")) + TextSummaryArrow(TextSummaryV(textId = R.string.max_wallpaper_scale, onClickListener = { + MIUIDialog(activity) { + setTitle(R.string.max_wallpaper_scale) + setEditText("", "${activity.getString(R.string.def)}1.1, ${activity.getString(R.string.current)}${ + safeSP.getFloat("max_wallpaper_scale", 1.1f) + }") + setLButton(textId = R.string.cancel) { + dismiss() + } + setRButton(textId = R.string.Done) { + if (getEditText() != "") { + safeSP.putAny("max_wallpaper_scale", getEditText().toFloat()) + } + dismiss() + } + }.show() + })) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.allow_untrusted_touches, tipsId = R.string.take_effect_after_reboot), SwitchV("allow_untrusted_touches")) Line() TitleText(textId = R.string.sound) - val mediaVolumeStepsSwitchBinding = GetDataBinding( - object : DefValue { - override fun getValue(): Any { - return safeSP.getBoolean("media_volume_steps_switch", false) - } - } - ) { view, flags, data -> + val mediaVolumeStepsSwitchBinding = GetDataBinding({ safeSP.getBoolean("media_volume_steps_switch", false) }) { view, flags, data -> when (flags) { 1 -> (view as Switch).isEnabled = data as Boolean 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE } } - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.media_volume_steps_switch, - tips = "${getString(R.string.take_effect_after_reboot)}\n${getString(R.string.media_volume_steps_summary)}" - ), - SwitchV( - "media_volume_steps_switch", - dataBindingSend = mediaVolumeStepsSwitchBinding.bindingSend - ) - ) - SeekBarWithText( - "media_volume_steps", - 15, - 29, - 15, dataBindingRecv = mediaVolumeStepsSwitchBinding.binding.getRecv(2) - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.media_volume_steps_switch, tips = "${getString(R.string.take_effect_after_reboot)}\n${getString(R.string.media_volume_steps_summary)}"), SwitchV("media_volume_steps_switch", dataBindingSend = mediaVolumeStepsSwitchBinding.bindingSend)) + SeekBarWithText("media_volume_steps", 15, 29, 15, dataBindingRecv = mediaVolumeStepsSwitchBinding.binding.getRecv(2)) } register("scope_other", getString(R.string.scope_other), false) { TitleText(textId = R.string.scope_miuihome) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.home_time, - tipsId = R.string.home_time_summary - ), SwitchV("home_time") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.double_tap_to_sleep, - tipsId = R.string.home_double_tap_to_sleep_summary - ), SwitchV("double_tap_to_sleep") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.home_time, tipsId = R.string.home_time_summary), SwitchV("home_time")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.double_tap_to_sleep, tipsId = R.string.home_double_tap_to_sleep_summary), SwitchV("double_tap_to_sleep")) Line() TitleText(textId = R.string.scope_powerkeeper) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.lock_max_fps, - tipsId = R.string.lock_max_fps_summary - ), - SwitchV("lock_max_fps") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.prevent_recovery_of_battery_optimization_white_list, - tipsId = R.string.failed_after_restart - ), - SwitchV("prevent_recovery_of_battery_optimization_white_list") - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.battery_optimization, - tipsId = R.string.battery_optimization_summary, - onClickListener = { - try { - val intent = Intent() - val comp = ComponentName( - "com.android.settings", - "com.android.settings.Settings\$HighPowerApplicationsActivity" - ) - intent.component = comp - startActivity(intent) - } catch (e: Exception) { - Toast.makeText(activity, "启动失败,可能是不支持", Toast.LENGTH_LONG) - .show() - } - }) - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.lock_max_fps, tipsId = R.string.lock_max_fps_summary), SwitchV("lock_max_fps")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.prevent_recovery_of_battery_optimization_white_list, tipsId = R.string.failed_after_restart), SwitchV("prevent_recovery_of_battery_optimization_white_list")) + TextSummaryArrow(TextSummaryV(textId = R.string.battery_optimization, tipsId = R.string.battery_optimization_summary, onClickListener = { + try { + val intent = Intent() + val comp = ComponentName("com.android.settings", "com.android.settings.Settings\$HighPowerApplicationsActivity") + intent.component = comp + startActivity(intent) + } catch (e: Exception) { + Toast.makeText(activity, "启动失败,可能是不支持", Toast.LENGTH_LONG).show() + } + })) Line() TitleText(textId = R.string.scope_securitycenter) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.skip_waiting_time, - tipsId = R.string.skip_waiting_time_summary - ), - SwitchV("skip_waiting_time") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.remove_open_app_confirmation_popup, - tipsId = R.string.remove_open_app_confirmation_popup_summary - ), - SwitchV("remove_open_app_confirmation_popup") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.lock_one_hundred, - tipsId = R.string.lock_one_hundred_summary - ), - SwitchV("lock_one_hundred") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.remove_macro_blacklist - ), - SwitchV("remove_macro_blacklist") - ) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.battery_life_function - ), - SwitchV("battery_life_function") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.skip_waiting_time, tipsId = R.string.skip_waiting_time_summary), SwitchV("skip_waiting_time")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.remove_open_app_confirmation_popup, tipsId = R.string.remove_open_app_confirmation_popup_summary), SwitchV("remove_open_app_confirmation_popup")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.lock_one_hundred, tipsId = R.string.lock_one_hundred_summary), SwitchV("lock_one_hundred")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.remove_macro_blacklist), SwitchV("remove_macro_blacklist")) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.battery_life_function), SwitchV("battery_life_function")) Line() TitleText(textId = R.string.scope_mediaeditor) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.unlock_unlimited_cropping, - tipsId = R.string.unlock_unlimited_cropping_summary - ), - SwitchV("unlock_unlimited_cropping") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.unlock_unlimited_cropping, tipsId = R.string.unlock_unlimited_cropping_summary), SwitchV("unlock_unlimited_cropping")) Line() TitleText(textId = R.string.updater) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.remove_ota_validate, - tipsId = R.string.remove_ota_validate_summary - ), - SwitchV("remove_ota_validate") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.remove_ota_validate, tipsId = R.string.remove_ota_validate_summary), SwitchV("remove_ota_validate")) Line() TitleText(textId = R.string.settings) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.show_notification_importance, - tipsId = R.string.show_notification_importance_summary - ), - SwitchV("show_notification_importance") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.show_notification_importance, tipsId = R.string.show_notification_importance_summary), SwitchV("show_notification_importance")) Line() TitleText(textId = R.string.cast) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.force_support_send_app, - ), - SwitchV("force_support_send_app") - ) + TextSummaryWithSwitch(TextSummaryV( + textId = R.string.force_support_send_app, + ), SwitchV("force_support_send_app")) Line() TitleText(textId = R.string.rear_display) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.show_weather_main_switch, - ), - SwitchV("rear_show_weather") - ) + TextSummaryWithSwitch(TextSummaryV( + textId = R.string.show_weather_main_switch, + ), SwitchV("rear_show_weather")) Line() TitleText(textId = R.string.remove_ad) - TextSummaryWithSwitch( - TextSummaryV( - textId = R.string.remove_thememanager_ads - ), - SwitchV("remove_thememanager_ads") - ) + TextSummaryWithSwitch(TextSummaryV(textId = R.string.remove_thememanager_ads), SwitchV("remove_thememanager_ads")) } register("hide_icon", getString(R.string.hide_icon), false) { TitleText(textId = R.string.status_bar_icon) - TextWithSwitch( - TextV(textId = R.string.hide_battery_icon), - SwitchV("hide_battery_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_battery_charging_icon), - SwitchV("hide_battery_charging_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_gps_icon), - SwitchV("hide_gps_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_bluetooth_icon), - SwitchV("hide_bluetooth_icon") - ) + TextWithSwitch(TextV(textId = R.string.hide_battery_icon), SwitchV("hide_battery_icon")) + TextWithSwitch(TextV(textId = R.string.hide_battery_charging_icon), SwitchV("hide_battery_charging_icon")) + TextWithSwitch(TextV(textId = R.string.hide_gps_icon), SwitchV("hide_gps_icon")) + TextWithSwitch(TextV(textId = R.string.hide_bluetooth_icon), SwitchV("hide_bluetooth_icon")) - TextWithSwitch( - TextV(textId = R.string.hide_nfc_icon), - SwitchV("hide_nfc_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_bluetooth_battery_icon), - SwitchV("hide_bluetooth_battery_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_small_hd_icon), - SwitchV("hide_small_hd_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_big_hd_icon), - SwitchV("hide_big_hd_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_hd_no_service_icon), - SwitchV("hide_hd_no_service_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_no_sim_icon), - SwitchV("hide_no_sim_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_sim_one_icon), - SwitchV("hide_sim_one_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_sim_two_icon), - SwitchV("hide_sim_two_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_mobile_activity_icon), - SwitchV("hide_mobile_activity_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_mobile_type_icon), - SwitchV("hide_mobile_type_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_wifi_icon), - SwitchV("hide_wifi_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_wifi_activity_icon), - SwitchV("hide_wifi_activity_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_wifi_standard_icon), - SwitchV("hide_wifi_standard_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_slave_wifi_icon), - SwitchV("hide_slave_wifi_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_hotspot_icon), - SwitchV("hide_hotspot_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_vpn_icon), - SwitchV("hide_vpn_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_airplane_icon), - SwitchV("hide_airplane_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_alarm_icon), - SwitchV("hide_alarm_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_headset_icon), - SwitchV("hide_headset_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_volume_icon), - SwitchV("hide_volume_icon") - ) - TextWithSwitch( - TextV(textId = R.string.hide_zen_icon), - SwitchV("hide_zen_icon") - ) + TextWithSwitch(TextV(textId = R.string.hide_nfc_icon), SwitchV("hide_nfc_icon")) + TextWithSwitch(TextV(textId = R.string.hide_bluetooth_battery_icon), SwitchV("hide_bluetooth_battery_icon")) + TextWithSwitch(TextV(textId = R.string.hide_small_hd_icon), SwitchV("hide_small_hd_icon")) + TextWithSwitch(TextV(textId = R.string.hide_big_hd_icon), SwitchV("hide_big_hd_icon")) + TextWithSwitch(TextV(textId = R.string.hide_hd_no_service_icon), SwitchV("hide_hd_no_service_icon")) + TextWithSwitch(TextV(textId = R.string.hide_no_sim_icon), SwitchV("hide_no_sim_icon")) + TextWithSwitch(TextV(textId = R.string.hide_sim_one_icon), SwitchV("hide_sim_one_icon")) + TextWithSwitch(TextV(textId = R.string.hide_sim_two_icon), SwitchV("hide_sim_two_icon")) + TextWithSwitch(TextV(textId = R.string.hide_mobile_activity_icon), SwitchV("hide_mobile_activity_icon")) + TextWithSwitch(TextV(textId = R.string.hide_mobile_type_icon), SwitchV("hide_mobile_type_icon")) + TextWithSwitch(TextV(textId = R.string.hide_wifi_icon), SwitchV("hide_wifi_icon")) + TextWithSwitch(TextV(textId = R.string.hide_wifi_activity_icon), SwitchV("hide_wifi_activity_icon")) + TextWithSwitch(TextV(textId = R.string.hide_wifi_standard_icon), SwitchV("hide_wifi_standard_icon")) + TextWithSwitch(TextV(textId = R.string.hide_slave_wifi_icon), SwitchV("hide_slave_wifi_icon")) + TextWithSwitch(TextV(textId = R.string.hide_hotspot_icon), SwitchV("hide_hotspot_icon")) + TextWithSwitch(TextV(textId = R.string.hide_vpn_icon), SwitchV("hide_vpn_icon")) + TextWithSwitch(TextV(textId = R.string.hide_airplane_icon), SwitchV("hide_airplane_icon")) + TextWithSwitch(TextV(textId = R.string.hide_alarm_icon), SwitchV("hide_alarm_icon")) + TextWithSwitch(TextV(textId = R.string.hide_headset_icon), SwitchV("hide_headset_icon")) + TextWithSwitch(TextV(textId = R.string.hide_volume_icon), SwitchV("hide_volume_icon")) + TextWithSwitch(TextV(textId = R.string.hide_zen_icon), SwitchV("hide_zen_icon")) } register("about_module", getString(R.string.about_module), true) { - Author( - authorHead = getDrawable(R.drawable.app_icon)!!, - authorName = getString(R.string.app_name), - authorTips = BuildConfig.VERSION_NAME + "(" + BuildConfig.BUILD_TYPE + ")", - onClickListener = { - try { - startActivity( - Intent( - Intent.ACTION_VIEW, - Uri.parse("coolmarket://apk/com.lt2333.simplicitytools") - ) - ) - Toast.makeText(activity, "恳求一个五星好评,Thanks♪(・ω・)ノ", Toast.LENGTH_LONG) - .show() - } catch (e: Exception) { - val uri = - Uri.parse("https://github.com/Xposed-Modules-Repo/com.lt2333.simplicitytools/releases") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } - }) + Author(authorHead = getDrawable(R.drawable.app_icon)!!, authorName = getString(R.string.app_name), authorTips = "${SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(BuildConfig.BUILD_TIME.toLong())} ${BuildConfig.VERSION_NAME}(${BuildConfig.BUILD_TYPE})", onClickListener = { + try { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("coolmarket://apk/com.lt2333.simplicitytools"))) + Toast.makeText(activity, "恳求一个五星好评,Thanks♪(・ω・)ノ", Toast.LENGTH_LONG).show() + } catch (e: Exception) { + val uri = Uri.parse("https://github.com/Xposed-Modules-Repo/com.lt2333.simplicitytools/releases") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } + }) Line() TitleText(text = getString(R.string.developer)) - Author( - authorHead = getDrawable(R.drawable.lt)!!, - authorName = "乌堆小透明", - authorTips = "LittleTurtle2333", - 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) - } - }) + Author(authorHead = getDrawable(R.drawable.lt)!!, authorName = "乌堆小透明", authorTips = "LittleTurtle2333", 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("https://www.coolapk.com/u/883441") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } + }) Line() TitleText(text = getString(R.string.thank_list)) - TextSummaryArrow( - TextSummaryV( - textId = R.string.contributor_list, - onClickListener = { - try { - val uri = - Uri.parse("https://github.com/LittleTurtle2333/SimplicityTools/graphs/contributors") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } catch (e: Exception) { - Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() - } - }) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.third_party_open_source_statement, - onClickListener = { - try { - val uri = - Uri.parse("https://github.com/LittleTurtle2333/SimplicityTools#%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BC%80%E6%BA%90%E5%BC%95%E7%94%A8") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } catch (e: Exception) { - Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() - } - }) - ) - Line() - TitleText(text = getString(R.string.discussions)) - TextSummaryArrow(TextSummaryV(textId = R.string.qq_channel, onClickListener = { + TextSummaryArrow(TextSummaryV(textId = R.string.contributor_list, onClickListener = { try { - val uri = - Uri.parse("https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&inviteCode=29Mu64&from=246610&biz=ka") + val uri = Uri.parse("https://github.com/LittleTurtle2333/SimplicityTools/graphs/contributors") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } catch (e: Exception) { + Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() + } + })) + TextSummaryArrow(TextSummaryV(textId = R.string.third_party_open_source_statement, onClickListener = { + try { + val uri = Uri.parse("https://github.com/LittleTurtle2333/SimplicityTools#%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BC%80%E6%BA%90%E5%BC%95%E7%94%A8") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } catch (e: Exception) { + Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() + } + })) + Line() + TitleText(text = getString(R.string.discussions)) + TextSummaryArrow(TextSummaryV(textId = R.string.qq_channel, onClickListener = { + try { + val uri = Uri.parse("https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&inviteCode=29Mu64&from=246610&biz=ka") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } catch (e: Exception) { + Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() + } + })) + TextSummaryArrow(TextSummaryV(textId = R.string.tg_channel, tipsId = R.string.tg_channel_summary, onClickListener = { + try { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("tg://resolve?domain=simplicityrom"))) + } catch (e: Exception) { + Toast.makeText(activity, "本机未安装Telegram应用", Toast.LENGTH_SHORT).show() + val uri = Uri.parse("https://t.me/simplicityrom") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } + })) + TextSummaryArrow(TextSummaryV(textId = R.string.issues, tipsId = R.string.issues_url, onClickListener = { + try { + val uri = Uri.parse("https://github.com/LittleTurtle2333/SimplicityTools/issues") val intent = Intent(Intent.ACTION_VIEW, uri) startActivity(intent) } catch (e: Exception) { Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() } })) - TextSummaryArrow( - TextSummaryV( - textId = R.string.tg_channel, - tipsId = R.string.tg_channel_summary, - onClickListener = { - try { - startActivity( - Intent( - Intent.ACTION_VIEW, - Uri.parse("tg://resolve?domain=simplicityrom") - ) - ) - } catch (e: Exception) { - Toast.makeText(activity, "本机未安装Telegram应用", Toast.LENGTH_SHORT) - .show() - val uri = - Uri.parse("https://t.me/simplicityrom") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } - }) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.issues, - tipsId = R.string.issues_url, - onClickListener = { - try { - val uri = - Uri.parse("https://github.com/LittleTurtle2333/SimplicityTools/issues") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } catch (e: Exception) { - Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() - } - }) - ) Line() TitleText(getString(R.string.other)) - TextSummaryArrow( - TextSummaryV( - textId = R.string.app_coolapk_url, - tipsId = R.string.app_coolapk_url_summary, - onClickListener = { - try { - startActivity( - Intent( - Intent.ACTION_VIEW, - Uri.parse("coolmarket://apk/com.lt2333.simplicitytools") - ) - ) - Toast.makeText( - activity, - "恳求一个五星好评,Thanks♪(・ω・)ノ", - Toast.LENGTH_LONG - ).show() - } catch (e: Exception) { - Toast.makeText(activity, "本机未安装酷安应用", Toast.LENGTH_SHORT) - .show() - } - }) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.opensource, - tipsId = R.string.github_url, - onClickListener = { - try { - val uri = - Uri.parse("https://github.com/LittleTurtle2333/SimplicityTools") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } catch (e: Exception) { - Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() - } - }) - ) - TextSummaryArrow( - TextSummaryV( - textId = R.string.participate_in_translation, - tipsId = R.string.participate_in_translation_summary, - onClickListener = { - try { - val uri = - Uri.parse("https://crowdin.com/project/simplicitytools") - val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) - } catch (e: Exception) { - Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() - } - }) - ) + TextSummaryArrow(TextSummaryV(textId = R.string.app_coolapk_url, tipsId = R.string.app_coolapk_url_summary, onClickListener = { + try { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("coolmarket://apk/com.lt2333.simplicitytools"))) + Toast.makeText(activity, "恳求一个五星好评,Thanks♪(・ω・)ノ", Toast.LENGTH_LONG).show() + } catch (e: Exception) { + Toast.makeText(activity, "本机未安装酷安应用", Toast.LENGTH_SHORT).show() + } + })) + TextSummaryArrow(TextSummaryV(textId = R.string.opensource, tipsId = R.string.github_url, onClickListener = { + try { + val uri = Uri.parse("https://github.com/LittleTurtle2333/SimplicityTools") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } catch (e: Exception) { + Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() + } + })) + TextSummaryArrow(TextSummaryV(textId = R.string.participate_in_translation, tipsId = R.string.participate_in_translation_summary, onClickListener = { + try { + val uri = Uri.parse("https://crowdin.com/project/simplicitytools") + val intent = Intent(Intent.ACTION_VIEW, uri) + startActivity(intent) + } catch (e: Exception) { + Toast.makeText(activity, "访问失败", Toast.LENGTH_SHORT).show() + } + })) } registerMenu(getString(R.string.menu)) { - TextSummaryArrow( - TextSummaryV(textId = R.string.reboot, onClickListener = { - MIUIDialog(activity) { - setTitle(R.string.Tips) - setMessage(R.string.are_you_sure_reboot) - setLButton(R.string.cancel) { - dismiss() - } - setRButton(R.string.Done) { - val command = arrayOf("reboot") - ShellUtils.execCommand(command, true) - dismiss() - } - }.show() - }) - ) + TextSummaryArrow(TextSummaryV(textId = R.string.reboot, onClickListener = { + MIUIDialog(activity) { + setTitle(R.string.Tips) + setMessage(R.string.are_you_sure_reboot) + setLButton(R.string.cancel) { + dismiss() + } + setRButton(R.string.Done) { + val command = arrayOf("reboot") + ShellUtils.execCommand(command, true) + dismiss() + } + }.show() + })) - TextSummaryArrow( - TextSummaryV(textId = R.string.reboot_host, onClickListener = { - MIUIDialog(activity) { - setTitle(R.string.Tips) - setMessage(R.string.are_you_sure_reboot_scope) - setLButton(R.string.cancel) { - dismiss() - } - setRButton(R.string.Done) { - val command = arrayOf( - "killall com.android.systemui", - "killall com.miui.home", - "killall com.miui.securitycenter ", - "killall com.android.settings", - "killall com.miui.powerkeeper", - "killall com.android.updater", - "killall com.miui.mediaeditor", - "killall com.miui.screenshot", - "killall com.milink.service", - "killall com.xiaomi.misubscreenui", - ) - ShellUtils.execCommand(command, true) - dismiss() - } - }.show() - }) - ) + TextSummaryArrow(TextSummaryV(textId = R.string.reboot_host, onClickListener = { + MIUIDialog(activity) { + setTitle(R.string.Tips) + setMessage(R.string.are_you_sure_reboot_scope) + setLButton(R.string.cancel) { + dismiss() + } + setRButton(R.string.Done) { + val command = arrayOf( + "killall com.android.systemui", + "killall com.miui.home", + "killall com.miui.securitycenter ", + "killall com.android.settings", + "killall com.miui.powerkeeper", + "killall com.android.updater", + "killall com.miui.mediaeditor", + "killall com.miui.screenshot", + "killall com.milink.service", + "killall com.xiaomi.misubscreenui", + ) + ShellUtils.execCommand(command, true) + dismiss() + } + }.show() + })) } } } diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/Updater.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/Updater.kt index 11fa964f..8251166f 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/Updater.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/Updater.kt @@ -15,7 +15,7 @@ object Updater : AppRegister() { hasEnable("remove_ota_validate") { Array(26) { "com.android.updater.common.utils.${'a' + it}" } .mapNotNull { loadClassOrNull(it) } - .firstOrNull() { it.declaredFields.size >= 9 && it.declaredMethods.size > 60 } + .firstOrNull { it.declaredFields.size >= 9 && it.declaredMethods.size > 60 } ?.findMethod { name == "T" && returnType == Boolean::class.java } ?.hookReturnConstant(false) } diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/corepatch/CorePatch.java b/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/corepatch/CorePatch.java index 1e565b1e..c1ea7ceb 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/corepatch/CorePatch.java +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/corepatch/CorePatch.java @@ -20,6 +20,7 @@ import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.zip.ZipEntry; import de.robv.android.xposed.IXposedHookLoadPackage; @@ -133,7 +134,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage, I if(prefs.getBoolean("UsePreSig", false)) { PackageManager PM = AndroidAppHelper.currentApplication().getPackageManager(); if(PM == null){ - XposedBridge.log("E: " + BuildConfig.APPLICATION_ID + " Cannot get the Package Manager... Are you using MiUI?"); + XposedBridge.log("E: ${}" + BuildConfig.APPLICATION_ID + " Cannot get the Package Manager... Are you using MiUI?"); }else { PackageInfo pI = PM.getPackageArchiveInfo((String) methodHookParam.args[0], 0); PackageInfo InstpI = PM.getPackageInfo(pI.packageName, PackageManager.GET_SIGNATURES); @@ -147,11 +148,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage, I lastSigs = (Signature[]) XposedHelpers.callStaticMethod(ASV, "convertToSignatures", (Object) lastCerts); } } - if (lastSigs != null) { - signingDetailsArgs[0] = lastSigs; - } else { - signingDetailsArgs[0] = new Signature[]{new Signature(SIGNATURE)}; - } + signingDetailsArgs[0] = Objects.requireNonNullElseGet(lastSigs, () -> new Signature[]{new Signature(SIGNATURE)}); Object newInstance = findConstructorExact.newInstance(signingDetailsArgs); //修复 java.lang.ClassCastException: Cannot cast android.content.pm.PackageParser$SigningDetails to android.util.apk.ApkSignatureVerifier$SigningDetailsWithDigests @@ -159,7 +156,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage, I if (signingDetailsWithDigests != null) { Constructor signingDetailsWithDigestsConstructorExact = XposedHelpers.findConstructorExact(signingDetailsWithDigests, signingDetails, Map.class); signingDetailsWithDigestsConstructorExact.setAccessible(true); - newInstance = signingDetailsWithDigestsConstructorExact.newInstance(new Object[]{newInstance, null}); + newInstance = signingDetailsWithDigestsConstructorExact.newInstance(newInstance, null); } Throwable cause = throwable.getCause(); @@ -211,7 +208,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage, I Class pPClass = findClass("com.android.server.pm.parsing.pkg.ParsedPackage", loadPackageParam.classLoader); XposedHelpers.findAndHookMethod(pmClass, "doesSignatureMatchForPermissions", String.class, pPClass, int.class, new XC_MethodHook() { @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { + protected void afterHookedMethod(MethodHookParam param) { //If we decide to crack this then at least make sure they are same apks, avoid another one that tries to impersonate. if (param.getResult().equals(false)) { String pPname = (String) XposedHelpers.callMethod(param.args[1], "getPackageName"); diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/settings/ShowNotificationImportance.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/settings/ShowNotificationImportance.kt index 3fb0b44c..5cc2206b 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/settings/ShowNotificationImportance.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/settings/ShowNotificationImportance.kt @@ -9,38 +9,26 @@ import de.robv.android.xposed.XposedHelpers object ShowNotificationImportance : HookRegister() { override fun init() { - findMethod("com.android.settings.notification.ChannelNotificationSettings"){ + findMethod("com.android.settings.notification.ChannelNotificationSettings") { name == "removeDefaultPrefs" }.hookBefore { if (!XSPUtils.getBoolean("show_notification_importance", false)) return@hookBefore - val importance = - it.thisObject.invokeMethodAuto("findPreference", "importance") ?: return@hookBefore + val importance = it.thisObject.invokeMethodAuto("findPreference", "importance") ?: return@hookBefore val mChannel = it.thisObject.getObject("mChannel") as NotificationChannel - val index = importance.invokeMethodAutoAs( - "findSpinnerIndexOfValue", - mChannel.importance.toString() - ) as Int + val index = importance.invokeMethodAutoAs("findSpinnerIndexOfValue", mChannel.importance.toString())!! if (index < 0) return@hookBefore importance.invokeMethodAuto("setValueIndex", index) - XposedHelpers.setAdditionalInstanceField( - importance, - "channelNotificationSettings", - it.thisObject - ) + XposedHelpers.setAdditionalInstanceField(importance, "channelNotificationSettings", it.thisObject) it.result = null } - findMethod("androidx.preference.Preference"){ + findMethod("androidx.preference.Preference") { name == "callChangeListener" && parameterTypes[0] == Any::class.java }.hookAfter { - val channelNotificationSettings = XposedHelpers.getAdditionalInstanceField( - it.thisObject, - "channelNotificationSettings" - ) ?: return@hookAfter + val channelNotificationSettings = XposedHelpers.getAdditionalInstanceField(it.thisObject, "channelNotificationSettings") ?: return@hookAfter val mChannel = channelNotificationSettings.getObject("mChannel") as NotificationChannel mChannel.invokeMethodAuto("setImportance", (it.args[0] as String).toInt()) - val mBackend = - channelNotificationSettings.getObjectOrNull("mBackend") ?: return@hookAfter + val mBackend = channelNotificationSettings.getObjectOrNull("mBackend") ?: return@hookAfter val mPkg = channelNotificationSettings.getObjectAs("mPkg") val mUid = channelNotificationSettings.getObjectAs("mUid") mBackend.invokeMethodAuto("updateChannel", mPkg, mUid, mChannel) diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt index e5d302a7..2e5e0ad1 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt @@ -33,13 +33,13 @@ object ControlCenterWeather : HookRegister() { !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM") ) { //获取原组件 - val big_time_ID = + val bigTimeId = context.resources.getIdentifier("big_time", "id", context.packageName) - val big_time: TextView = viewGroup.findViewById(big_time_ID) + val big_time: TextView = viewGroup.findViewById(bigTimeId) - val date_time_ID = + val dateTimeId = context.resources.getIdentifier("date_time", "id", context.packageName) - val date_time: TextView = viewGroup.findViewById(date_time_ID) + val dateTime: TextView = viewGroup.findViewById(dateTimeId) //创建新布局 val mConstraintLayoutLp = LinearLayout.LayoutParams( @@ -62,18 +62,18 @@ object ControlCenterWeather : HookRegister() { //从原布局中删除组件 (big_time.parent as ViewGroup).removeView(big_time) - (date_time.parent as ViewGroup).removeView(date_time) + (dateTime.parent as ViewGroup).removeView(dateTime) //添加组件至新布局 mConstraintLayout!!.addView(big_time) - mConstraintLayout!!.addView(date_time) + mConstraintLayout!!.addView(dateTime) //组件属性 - val date_time_LP = ConstraintLayout.LayoutParams( + val dateTimeLp = ConstraintLayout.LayoutParams( ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT ).also { - it.startToEnd = big_time_ID + it.startToEnd = bigTimeId it.bottomToBottom = 0 it.marginStart = context.resources.getDimensionPixelSize( context.resources.getIdentifier( @@ -84,7 +84,7 @@ object ControlCenterWeather : HookRegister() { ) it.bottomMargin = dp2px(context, 5f) } - date_time.layoutParams = date_time_LP + dateTime.layoutParams = dateTimeLp //创建天气组件 @@ -100,12 +100,12 @@ object ControlCenterWeather : HookRegister() { } mConstraintLayout!!.addView(mWeatherView) - val mWeatherView_LP = ConstraintLayout.LayoutParams( + val mweatherviewLp = ConstraintLayout.LayoutParams( ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT ).also { - it.startToEnd = big_time_ID - it.bottomToTop = date_time_ID + it.startToEnd = bigTimeId + it.bottomToTop = dateTimeId it.marginStart = context.resources.getDimensionPixelSize( context.resources.getIdentifier( "notification_panel_time_date_space", @@ -115,7 +115,7 @@ object ControlCenterWeather : HookRegister() { ) } - (mWeatherView as WeatherView).layoutParams = mWeatherView_LP + (mWeatherView as WeatherView).layoutParams = mweatherviewLp } else { val layoutParam = diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/DoubleLineNetworkSpeed.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/DoubleLineNetworkSpeed.kt index 75b49800..a9f1e8bc 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/DoubleLineNetworkSpeed.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/DoubleLineNetworkSpeed.kt @@ -35,10 +35,8 @@ object DoubleLineNetworkSpeed : HookRegister() { val none = InitFields.moduleRes.getString(R.string.none) if (XSPUtils.getString("status_bar_network_speed_dual_row_icon", none) != none) { - upIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none) - ?.firstOrNull().toString() - downIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none) - ?.lastOrNull().toString() + upIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)?.firstOrNull().toString() + downIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)?.lastOrNull().toString() } findConstructor("com.android.systemui.statusbar.views.NetworkSpeedView") { @@ -62,17 +60,13 @@ object DoubleLineNetworkSpeed : HookRegister() { name == "formatSpeed" && parameterCount == 2 }.hookBefore { if (getDualAlign == 0) { - it.result = - "$upIcon ${getTotalUpSpeed(it.args[0] as Context)}\n${downIcon} ${ - getTotalDownloadSpeed(it.args[0] as Context) - }" + it.result = "$upIcon ${getTotalUpSpeed(it.args[0] as Context)}\n${downIcon} ${ + getTotalDownloadSpeed(it.args[0] as Context) + }" } else { - it.result = - "${getTotalUpSpeed(it.args[0] as Context)} ${upIcon}\n${ - getTotalDownloadSpeed( - it.args[0] as Context - ) - } $downIcon" + it.result = "${getTotalUpSpeed(it.args[0] as Context)} ${upIcon}\n${ + getTotalDownloadSpeed(it.args[0] as Context) + } $downIcon" } } } @@ -85,30 +79,15 @@ object DoubleLineNetworkSpeed : HookRegister() { val nowTimeStampTotalUp = System.currentTimeMillis() //计算上传速度 - val bytes = - (currentTotalTxBytes - mLastTotalUp) * 1000 / (nowTimeStampTotalUp - lastTimeStampTotalUp).toFloat() + val bytes = (currentTotalTxBytes - mLastTotalUp) * 1000 / (nowTimeStampTotalUp - lastTimeStampTotalUp).toFloat() val unit: String if (bytes >= 1048576) { - totalUpSpeed = - DecimalFormat("0.0").format(bytes / 1048576).toFloat() - unit = context.resources.getString( - context.resources.getIdentifier( - "megabyte_per_second", - "string", - context.packageName - ) - ) + totalUpSpeed = DecimalFormat("0.0").format(bytes / 1048576).toFloat() + unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second", "string", context.packageName)) } else { - totalUpSpeed = - DecimalFormat("0.0").format(bytes / 1024).toFloat() - unit = context.resources.getString( - context.resources.getIdentifier( - "kilobyte_per_second", - "string", - context.packageName - ) - ) + totalUpSpeed = DecimalFormat("0.0").format(bytes / 1024).toFloat() + unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second", "string", context.packageName)) } //保存当前的流量总和和上次的时间戳 @@ -116,9 +95,9 @@ object DoubleLineNetworkSpeed : HookRegister() { lastTimeStampTotalUp = nowTimeStampTotalUp return if (totalUpSpeed >= 100) { - "" + totalUpSpeed.toInt() + unit + "${totalUpSpeed.toInt()}$unit" } else { - "" + totalUpSpeed + unit + "${totalUpSpeed}$unit" } } @@ -129,40 +108,25 @@ object DoubleLineNetworkSpeed : HookRegister() { val nowTimeStampTotalDown = System.currentTimeMillis() //计算下行速度 - val bytes = - (currentTotalRxBytes - mLastTotalDown) * 1000 / (nowTimeStampTotalDown - lastTimeStampTotalDown).toFloat() + val bytes = (currentTotalRxBytes - mLastTotalDown) * 1000 / (nowTimeStampTotalDown - lastTimeStampTotalDown).toFloat() val unit: String if (bytes >= 1048576) { - totalDownSpeed = - DecimalFormat("0.0").format(bytes / 1048576).toFloat() - unit = context.resources.getString( - context.resources.getIdentifier( - "megabyte_per_second", - "string", - context.packageName - ) - ) + totalDownSpeed = DecimalFormat("0.0").format(bytes / 1048576).toFloat() + unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second", "string", context.packageName)) } else { - totalDownSpeed = - DecimalFormat("0.0").format(bytes / 1024).toFloat() - unit = context.resources.getString( - context.resources.getIdentifier( - "kilobyte_per_second", - "string", - context.packageName - ) - ) + totalDownSpeed = DecimalFormat("0.0").format(bytes / 1024).toFloat() + unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second", "string", context.packageName)) } //保存当前的流量总和和上次的时间戳 mLastTotalDown = currentTotalRxBytes lastTimeStampTotalDown = nowTimeStampTotalDown return if (totalDownSpeed >= 100) { - "" + totalDownSpeed.toInt() + unit + "${totalDownSpeed.toInt()}$unit" } else { - "" + totalDownSpeed + unit + "${totalDownSpeed}$unit" } } diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/LockScreenClockDisplaySeconds.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/LockScreenClockDisplaySeconds.kt index 91fe5b81..428611cf 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/LockScreenClockDisplaySeconds.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/LockScreenClockDisplaySeconds.kt @@ -62,14 +62,8 @@ object LockScreenClockDisplaySeconds : HookRegister() { val textV = it.thisObject.getObjectAs("mTimeText") val c: Context = textV.context - Log.d( - "lock_screen_clock_display_seconds", - "updateTime: " + it.thisObject.javaClass.simpleName - ) - val is24 = Settings.System.getString( - c.contentResolver, - Settings.System.TIME_12_24 - ) == "24" + Log.d("lock_screen_clock_display_seconds", "updateTime: ${it.thisObject.javaClass.simpleName}") + val is24 = Settings.System.getString(c.contentResolver, Settings.System.TIME_12_24) == "24" nowTime = Calendar.getInstance().time diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/LockScreenCurrent.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/LockScreenCurrent.kt index 79ed47cb..79435179 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/LockScreenCurrent.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/LockScreenCurrent.kt @@ -1,6 +1,9 @@ package com.lt2333.simplicitytools.hook.app.systemui -import android.annotation.SuppressLint + +import android.app.AndroidAppHelper +import android.content.Context +import android.os.BatteryManager import android.widget.TextView import com.github.kyuubiran.ezxhelper.init.InitFields import com.github.kyuubiran.ezxhelper.utils.findMethod @@ -11,8 +14,7 @@ import com.lt2333.simplicitytools.util.hasEnable import com.lt2333.simplicitytools.util.xposed.base.HookRegister import java.io.BufferedReader import java.io.FileReader -import java.lang.reflect.Method -import kotlin.math.roundToInt +import kotlin.math.abs object LockScreenCurrent : HookRegister() { @@ -20,43 +22,22 @@ object LockScreenCurrent : HookRegister() { findMethod("com.android.keyguard.charge.ChargeUtils") { name == "getChargingHintText" && parameterCount == 3 }.hookAfter { - it.result = getCurrent() + "\n" + it.result + it.result = "${getCurrent()}\n${it.result}" } findMethod("com.android.systemui.statusbar.phone.KeyguardBottomAreaView") { name == "onFinishInflate" }.hookAfter { - (it.thisObject.getObject( - "mIndicationText" - ) as TextView).isSingleLine = false + (it.thisObject.getObject("mIndicationText") as TextView).isSingleLine = false } } - /** - * 原始代码来自 CSDN - * https://blog.csdn.net/zhangyongfeiyong/article/details/53641809 - */ - @SuppressLint("PrivateApi") + + private fun getCurrent(): String { - var result = "" - try { - val systemProperties = Class.forName("android.os.SystemProperties") - val get = systemProperties.getDeclaredMethod("get", String::class.java) as Method - val platName = get.invoke(null, "ro.hardware") as String - if (platName.startsWith("mt") || platName.startsWith("MT")) { - val filePath = - "/sys/class/power_supply/battery/device/FG_Battery_CurrentConsumption" - val current = (-getMeanCurrentVal(filePath, 5, 0) / 1000.0f).roundToInt() - result = "${InitFields.moduleRes.getString(R.string.current_current)} ${current}mA" - } else if (platName.startsWith("qcom")) { - val filePath = "/sys/class/power_supply/battery/current_now" - val current = (-getMeanCurrentVal(filePath, 5, 0) / 1000.0f).roundToInt() - result = "${InitFields.moduleRes.getString(R.string.current_current)} ${current}mA" - } - } catch (e: Exception) { - e.printStackTrace() - } - return result + val batteryManager = AndroidAppHelper.currentApplication().getSystemService(Context.BATTERY_SERVICE) as BatteryManager + val current = abs(batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW) / 1000) + return "${InitFields.moduleRes.getString(R.string.current_current)} ${current}mA" } /** diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/NotificationWeather.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/NotificationWeather.kt index 51516e11..8d00bc5c 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/NotificationWeather.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/NotificationWeather.kt @@ -29,17 +29,17 @@ object NotificationWeather : HookRegister() { val context = viewGroup.context // MIUI编译时间大于 2022-03-12 00:00:00 且为内测版 - if (SystemProperties[context, "ro.build.date.utc"]!!.toInt() >= 1647014400 && - !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM") + if (SystemProperties[context, "ro.build.date.utc"].toInt() >= 1647014400 && + !SystemProperties[context, "ro.build.version.incremental"].endsWith("XM") ) { //获取原组件 - val big_time_ID = + val bigTimeId = context.resources.getIdentifier("big_time", "id", context.packageName) - val big_time: TextView = viewGroup.findViewById(big_time_ID) + val bigTime: TextView = viewGroup.findViewById(bigTimeId) - val date_time_ID = + val dateTimeId = context.resources.getIdentifier("date_time", "id", context.packageName) - val date_time: TextView = viewGroup.findViewById(date_time_ID) + val dateTime: TextView = viewGroup.findViewById(dateTimeId) //创建新布局 val mConstraintLayoutLp = LinearLayout.LayoutParams( @@ -58,25 +58,25 @@ object NotificationWeather : HookRegister() { mConstraintLayout = ConstraintLayout(context).also { it.layoutParams = mConstraintLayoutLp } - (big_time.parent as ViewGroup).addView(mConstraintLayout, 0) + (bigTime.parent as ViewGroup).addView(mConstraintLayout, 0) //从原布局中删除组件 - (big_time.parent as ViewGroup).removeView(big_time) - (date_time.parent as ViewGroup).removeView(date_time) + (bigTime.parent as ViewGroup).removeView(bigTime) + (dateTime.parent as ViewGroup).removeView(dateTime) //添加组件至新布局 - mConstraintLayout!!.addView(big_time) - mConstraintLayout!!.addView(date_time) + mConstraintLayout!!.addView(bigTime) + mConstraintLayout!!.addView(dateTime) //组件属性 - val date_time_LP = ConstraintLayout.LayoutParams( + val dateTimeLp = ConstraintLayout.LayoutParams( ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT ).also { - it.startToEnd = big_time_ID + it.startToEnd = bigTimeId it.bottomToBottom = 0 it.marginStart = context.resources.getDimensionPixelSize( context.resources.getIdentifier( @@ -87,7 +87,7 @@ object NotificationWeather : HookRegister() { ) it.bottomMargin = dp2px(context, 5f) } - date_time.layoutParams = date_time_LP + dateTime.layoutParams = dateTimeLp //创建天气组件 @@ -103,12 +103,12 @@ object NotificationWeather : HookRegister() { } mConstraintLayout!!.addView(mWeatherView) - val mWeatherView_LP = ConstraintLayout.LayoutParams( + val mweatherviewLp = ConstraintLayout.LayoutParams( ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT ).also { - it.startToEnd = big_time_ID - it.bottomToTop = date_time_ID + it.startToEnd = bigTimeId + it.bottomToTop = dateTimeId it.marginStart = context.resources.getDimensionPixelSize( context.resources.getIdentifier( "notification_panel_time_date_space", @@ -118,7 +118,7 @@ object NotificationWeather : HookRegister() { ) } - (mWeatherView as WeatherView).layoutParams = mWeatherView_LP + (mWeatherView as WeatherView).layoutParams = mweatherviewLp } else { val layoutParam = diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/StatusBarLayout.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/StatusBarLayout.kt index bf644c4b..ac01d346 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/StatusBarLayout.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/StatusBarLayout.kt @@ -118,12 +118,12 @@ object StatusBarLayout : HookRegister() { mConstraintLayout.addView(notificationIconAreaInner) - val fullscreen_notification_icon_area_lp = LinearLayout.LayoutParams( + val fullscreenNotificationIconAreaLp = LinearLayout.LayoutParams( ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT ) - notificationIconAreaInner.layoutParams = fullscreen_notification_icon_area_lp + notificationIconAreaInner.layoutParams = fullscreenNotificationIconAreaLp //增加一个左对齐布局 mLeftLayout = LinearLayout(context) @@ -404,16 +404,16 @@ object StatusBarLayout : HookRegister() { }.hookAfter { val miuiPhoneStatusBarView = it.thisObject.getObjectAs("mStatusBar") val res = miuiPhoneStatusBarView.resources - val status_bar_ID = + val statusBarId = res.getIdentifier("status_bar", "id", "com.android.systemui") - val status_bar = miuiPhoneStatusBarView.findViewById(status_bar_ID) + val statusBar1 = miuiPhoneStatusBarView.findViewById(statusBarId) //非锁屏下整个状态栏布局 val keyguardMgr = - status_bar.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager + statusBar1.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager if (keyguardMgr.isKeyguardLocked) { - status_bar!!.visibility = View.GONE + statusBar1!!.visibility = View.GONE } else { - status_bar!!.visibility = View.VISIBLE + statusBar1!!.visibility = View.VISIBLE } } } diff --git a/app/src/main/java/com/lt2333/simplicitytools/tile/AllowScreenshots.kt b/app/src/main/java/com/lt2333/simplicitytools/tile/AllowScreenshots.kt index 9516abe7..0589115b 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/tile/AllowScreenshots.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/tile/AllowScreenshots.kt @@ -4,7 +4,7 @@ import android.service.quicksettings.Tile import android.service.quicksettings.TileService class AllowScreenshots : TileService() { - val key = "disable_flag_secure" + private val key = "disable_flag_secure" override fun onClick() { super.onClick() diff --git a/app/src/main/java/com/lt2333/simplicitytools/tile/LockMaxFpsTile.kt b/app/src/main/java/com/lt2333/simplicitytools/tile/LockMaxFpsTile.kt index ef3dcfee..62b90f09 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/tile/LockMaxFpsTile.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/tile/LockMaxFpsTile.kt @@ -5,7 +5,7 @@ import android.service.quicksettings.TileService class LockMaxFpsTile : TileService() { - val key = "lock_max_fps" + private val key = "lock_max_fps" override fun onClick() { super.onClick() diff --git a/app/src/main/java/com/lt2333/simplicitytools/util/SystemProperties.kt b/app/src/main/java/com/lt2333/simplicitytools/util/SystemProperties.kt index fadb237e..f4b433ad 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/util/SystemProperties.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/util/SystemProperties.kt @@ -5,7 +5,7 @@ import android.content.Context object SystemProperties { @SuppressLint("PrivateApi") - operator fun get(context: Context, key: String?): String? { + operator fun get(context: Context, key: String?): String { var ret = "" try { val cl = context.classLoader diff --git a/app/src/main/java/com/lt2333/simplicitytools/util/xposed/EasyXposedInit.kt b/app/src/main/java/com/lt2333/simplicitytools/util/xposed/EasyXposedInit.kt index f37f0ce5..aaed2448 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/util/xposed/EasyXposedInit.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/util/xposed/EasyXposedInit.kt @@ -5,7 +5,6 @@ import com.github.kyuubiran.ezxhelper.utils.Log.logexIfThrow import com.lt2333.simplicitytools.util.xposed.base.AppRegister import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.IXposedHookZygoteInit -import de.robv.android.xposed.XposedBridge import de.robv.android.xposed.callbacks.XC_LoadPackage abstract class EasyXposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit { diff --git a/app/src/main/java/com/lt2333/simplicitytools/view/WeatherView.kt b/app/src/main/java/com/lt2333/simplicitytools/view/WeatherView.kt index e03d9b1d..307c3414 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/view/WeatherView.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/view/WeatherView.kt @@ -14,7 +14,7 @@ import android.widget.TextView class WeatherView(context: Context?, private val showCity: Boolean) : TextView(context) { private val mContext: Context - private val WEATHER_URI = Uri.parse("content://weather/weather") + private val weatherUri = Uri.parse("content://weather/weather") private val mHandler: Handler private val mWeatherObserver: ContentObserver? private val mWeatherRunnable: WeatherRunnable @@ -30,7 +30,7 @@ class WeatherView(context: Context?, private val showCity: Boolean) : TextView(c mWeatherObserver = WeatherContentObserver(mHandler) mContext = context!! mWeatherRunnable = WeatherRunnable() - context.contentResolver.registerContentObserver(WEATHER_URI, true, mWeatherObserver) + context.contentResolver.registerContentObserver(weatherUri, true, mWeatherObserver) updateWeatherInfo() } @@ -44,19 +44,13 @@ class WeatherView(context: Context?, private val showCity: Boolean) : TextView(c override fun run() { var str = "" try { - val query = mContext.contentResolver.query(WEATHER_URI, null, null, null, null) + val query = mContext.contentResolver.query(weatherUri, null, null, null, null) if (query != null) { if (query.moveToFirst()) { - if (showCity) { - str = - query.getString(query.getColumnIndexOrThrow("city_name")) + " " + query.getString( - query.getColumnIndexOrThrow("description") - ) + " " + query.getString(query.getColumnIndexOrThrow("temperature")) + str = if (showCity) { + query.getString(query.getColumnIndexOrThrow("city_name")) + " " + query.getString(query.getColumnIndexOrThrow("description")) + " " + query.getString(query.getColumnIndexOrThrow("temperature")) } else { - str = - query.getString( - query.getColumnIndexOrThrow("description") - ) + " " + query.getString(query.getColumnIndexOrThrow("temperature")) + query.getString(query.getColumnIndexOrThrow("description")) + " " + query.getString(query.getColumnIndexOrThrow("temperature")) } } query.close() diff --git a/blockmiui b/blockmiui index fbaed7f8..63e7817f 160000 --- a/blockmiui +++ b/blockmiui @@ -1 +1 @@ -Subproject commit fbaed7f8ed752bf2488aef9e6e2c29531f7d944d +Subproject commit 63e7817f3f3fa73a4049f2cf227943d2454e7e5e