From b636d415c4a996870dc3b66f762a1de16891f354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=8C=E5=A0=86=E5=B0=8F=E9=80=8F=E6=98=8E?= Date: Thu, 10 Mar 2022 13:45:34 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E5=A4=A9=E6=B0=94=E5=90=AF=E5=8A=A8APP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hook/app/systemui/ControlCenterWeather.kt | 16 ++++++++++++++ .../hook/app/systemui/NotificationWeather.kt | 22 ++++++++++++++++++- .../app/systemui/OldNotificationWeather.kt | 16 ++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) 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 d7a80999..987bdf88 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 @@ -1,8 +1,11 @@ package com.lt2333.simplicitytools.hook.app.systemui +import android.content.ComponentName +import android.content.Intent import android.view.View import android.view.ViewGroup import android.widget.TextView +import android.widget.Toast import com.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.view.WeatherView import de.robv.android.xposed.IXposedHookLoadPackage @@ -76,6 +79,19 @@ class ControlCenterWeather : IXposedHookLoadPackage { } viewGroup.addView(mWeatherView) + (mWeatherView as WeatherView).setOnClickListener { + try { + val intent = Intent() + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + intent.component = ComponentName( + "com.miui.weather2", + "com.miui.weather2.ActivityWeatherMain" + ) + viewGroup.context.startActivity(intent) + } catch (e: Exception) { + Toast.makeText(viewGroup.context, "启动失败,可能是不支持", Toast.LENGTH_LONG).show() + } + } } }) //解决横屏重叠 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 4d63b52e..44b80bdf 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 @@ -1,8 +1,11 @@ package com.lt2333.simplicitytools.hook.app.systemui +import android.content.ComponentName +import android.content.Intent import android.view.View import android.view.ViewGroup import android.widget.TextView +import android.widget.Toast import com.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.view.WeatherView import de.robv.android.xposed.IXposedHookLoadPackage @@ -64,7 +67,7 @@ class NotificationWeather : IXposedHookLoadPackage { ) ) - mWeatherView = WeatherView(viewGroup.context,isDisplayCity).also { + mWeatherView = WeatherView(viewGroup.context, isDisplayCity).also { it.setTextAppearance( viewGroup.context.resources.getIdentifier( "TextAppearance.QSControl.Date", @@ -75,6 +78,20 @@ class NotificationWeather : IXposedHookLoadPackage { it.layoutParams = layout } viewGroup.addView(mWeatherView) + + (mWeatherView as WeatherView).setOnClickListener { + try { + val intent = Intent() + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + intent.component = ComponentName( + "com.miui.weather2", + "com.miui.weather2.ActivityWeatherMain" + ) + viewGroup.context.startActivity(intent) + } catch (e: Exception) { + Toast.makeText(viewGroup.context, "启动失败", Toast.LENGTH_LONG).show() + } + } } }) //解决横屏重叠 @@ -90,6 +107,9 @@ class NotificationWeather : IXposedHookLoadPackage { } } }) + + } + } diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/OldNotificationWeather.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/OldNotificationWeather.kt index f982311b..ab0d49af 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/OldNotificationWeather.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/OldNotificationWeather.kt @@ -1,8 +1,11 @@ package com.lt2333.simplicitytools.hook.app.systemui +import android.content.ComponentName +import android.content.Intent import android.view.View import android.view.ViewGroup import android.widget.TextView +import android.widget.Toast import com.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.view.WeatherView import de.robv.android.xposed.IXposedHookLoadPackage @@ -77,6 +80,19 @@ class OldNotificationWeather : IXposedHookLoadPackage { it.layoutParams = layout } viewGroup.addView(mWeatherView) + (mWeatherView as WeatherView).setOnClickListener { + try { + val intent = Intent() + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + intent.component = ComponentName( + "com.miui.weather2", + "com.miui.weather2.ActivityWeatherMain" + ) + viewGroup.context.startActivity(intent) + } catch (e: Exception) { + Toast.makeText(viewGroup.context, "启动失败,可能是不支持", Toast.LENGTH_LONG).show() + } + } } }) //解决横屏重叠 From e2adf4e9346d7de5945b4db86f26a1697039909e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=8C=E5=A0=86=E5=B0=8F=E9=80=8F=E6=98=8E?= Date: Thu, 10 Mar 2022 13:46:21 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`SettingsActivity.kt`?= =?UTF-8?q?=E4=B8=BACRLF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/SettingsActivity.kt | 1018 ++++++++++++++++- 1 file changed, 1017 insertions(+), 1 deletion(-) 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 cb33a9a9..91e438b2 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt @@ -1 +1,1017 @@ -@file:Suppress("DEPRECATION") package com.lt2333.simplicitytools.activity import android.annotation.SuppressLint import android.content.ComponentName import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Bundle import android.view.View import android.widget.Switch import android.widget.Toast import cn.fkj233.ui.activity.MIUIActivity import cn.fkj233.ui.activity.view.* import cn.fkj233.ui.dialog.MIUIDialog import com.lt2333.simplicitytools.BuildConfig import com.lt2333.simplicitytools.R import com.lt2333.simplicitytools.util.SPUtils import com.lt2333.simplicitytools.util.ShellUtils import com.microsoft.appcenter.AppCenter import com.microsoft.appcenter.analytics.Analytics import com.microsoft.appcenter.crashes.Crashes 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() super.onCreate(savedInstanceState) } //检测LSPosed是否激活 @SuppressLint("WorldReadableFiles") private fun checkLSPosed() { try { setSP(getSharedPreferences("config", MODE_WORLD_READABLE)) } catch (exception: SecurityException) { isLoad = false MIUIDialog(this).apply { setTitle(R.string.Tips) setMessage(R.string.not_support) setCancelable(false) setRButton(R.string.Done) { exitProcess(0) } show() } } } //主页标题 override fun mainName(): String { return getString(R.string.app_name) } //菜单标题 override fun menuName(): String { return getString(R.string.menu) } //主页面 override fun mainItems(): ArrayList { return arrayListOf().apply { add( TextWithSwitchV( TextV(resId = R.string.main_switch, colorId = R.color.purple_700), SwitchV("main_switch", true) ) ) add( TextWithSwitchV( TextV(resId = 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 ) }) ) ) add( TextSummaryArrowV( TextSummaryV( textId = R.string.matters_needing_attention, colorId = R.color.red, onClickListener = { MIUIDialog(activity).apply { setTitle(R.string.matters_needing_attention) setMessage( R.string.matters_needing_attention_context ) setRButton(R.string.Done) { dismiss() } show() } }) ) ) add(LineV()) add(TitleTextV(resId = R.string.scope)) add( TextSummaryArrowV( TextSummaryV( textId = R.string.scope_systemui, tipsId = R.string.scope_systemui_summary, onClickListener = { showFragment(getString(R.string.scope_systemui)) } ) ) ) add( TextSummaryArrowV( TextSummaryV( textId = R.string.scope_android, tipsId = R.string.scope_android_summary, onClickListener = { showFragment(getString(R.string.scope_android)) } ) ) ) add( TextSummaryArrowV( TextSummaryV( textId = R.string.scope_other, tipsId = R.string.scope_other_summary, onClickListener = { showFragment(getString(R.string.scope_other)) } ) ) ) add(LineV()) add(TitleTextV(resId = R.string.about)) add( TextSummaryArrowV( TextSummaryV( textId = R.string.about_module, tips = getString(R.string.about_module_summary), onClickListener = { showFragment(getString(R.string.about_module)) } ) ) ) } } //菜单页面 override fun menuItems(): ArrayList { return ArrayList().apply { add( TextSummaryArrowV( TextSummaryV(textId = R.string.reboot, onClickListener = { MIUIDialog(activity).apply { 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() } }) ) ) add( TextSummaryArrowV( TextSummaryV(textId = R.string.reboot_host, onClickListener = { MIUIDialog(activity).apply { 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.miui.home", "killall com.miui.securitycenter ", "killall com.miui.powerkeeper", "killall com.miui.mediaeditor", "killall com.android.systemui", "killall com.android.updater", "killall com.android.settings" ) ShellUtils.execCommand(command, true) dismiss() } show() } }) ) ) } } //关于页面 fun aboutItems(): ArrayList { return ArrayList().apply { add( AuthorV( authorHead = getDrawable(R.drawable.app_icon)!!, authorName = getString(R.string.app_name), authorTips = BuildConfig.VERSION_NAME + "(" + BuildConfig.BUILD_TYPE + ")", onClick = { 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) } }) ) add(LineV()) add( TitleTextV(text = getString(R.string.developer)) ) add( AuthorV( authorHead = getDrawable(R.drawable.lt)!!, authorName = "乌堆小透明", authorTips = "LittleTurtle2333", onClick = { 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) } }) ) add(LineV()) add( TitleTextV(text = getString(R.string.thank_list)) ) add( TextSummaryArrowV( 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() } }) ) ) add( TextSummaryArrowV( 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() } }) ) ) add(LineV()) add( TitleTextV(text = getString(R.string.discussions)) ) add(TextSummaryArrowV(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() } }))) add( TextSummaryArrowV( 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) } }) ) ) add( TextSummaryArrowV( 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() } }) ) ) add(LineV()) add( TitleTextV(text = getString(R.string.other)) ) add( TextSummaryArrowV( 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() } }) ) ) add( TextSummaryArrowV( 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() } }) ) ) } } //系统框架页面 fun androidItems(): ArrayList { return ArrayList().apply { add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.disable_flag_secure, tipsId = R.string.disable_flag_secure_summary ), SwitchV("disable_flag_secure") ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.corepacth, tipsId = R.string.corepacth_summary ), SwitchV("corepatch") ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.delete_on_post_notification, tipsId = R.string.delete_on_post_notification_summary ), SwitchV("delete_on_post_notification") ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.remove_small_window_restrictions, tipsId = R.string.remove_small_window_restrictions_summary ), SwitchV("remove_small_window_restrictions") ) ) } } //系统界面页面 fun systemuiItems(): ArrayList { return ArrayList().apply { add(TitleTextV(resId = R.string.statusbar)) add( TextSummaryWithSwitchV( 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") ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.hide_battery_percentage_icon, tipsId = R.string.hide_battery_percentage_icon_summary ), SwitchV("hide_battery_percentage_icon") ) ) add( TextSummaryWithSwitchV( 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") ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.remove_the_maximum_number_of_notification_icons, tipsId = R.string.remove_the_maximum_number_of_notification_icons_summary ), SwitchV("remove_the_maximum_number_of_notification_icons") ) ) add(LineV()) add(TitleTextV(resId = R.string.status_bar_layout)) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.status_bar_time_center, tipsId = R.string.status_bar_layout_summary ), SwitchV("status_bar_time_center") ) ) val layout_compatibility_mode_binding = getDataBinding( SPUtils.getBoolean( activity, "layout_compatibility_mode", 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 } } add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.layout_compatibility_mode, tipsId = R.string.layout_compatibility_mode_summary ), SwitchV( "layout_compatibility_mode", dataBindingSend = layout_compatibility_mode_binding.bindingSend ) ) ) add( TextV( resId = R.string.left_margin, dataBindingRecv = layout_compatibility_mode_binding.binding.getRecv(2) ) ) add( SeekBarWithTextV( "status_bar_left_margin", 0, 300, 0, dataBindingRecv = layout_compatibility_mode_binding.binding.getRecv(2) ) ) add( TextV( resId = R.string.right_margin, dataBindingRecv = layout_compatibility_mode_binding.binding.getRecv(2) ) ) add( SeekBarWithTextV( "status_bar_right_margin", 0, 300, 0, dataBindingRecv = layout_compatibility_mode_binding.binding.getRecv(2) ) ) add(LineV()) add(TitleTextV(resId = R.string.status_bar_clock_format)) val custom_clock_binding = getDataBinding( SPUtils.getBoolean( activity, "custom_clock_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 } } add( TextWithSwitchV( TextV(resId = R.string.custom_clock_switch, colorId = R.color.purple_700), SwitchV( "custom_clock_switch", dataBindingSend = custom_clock_binding.bindingSend ) ) ) add( TextWithSwitchV( TextV(resId = R.string.status_bar_time_year), SwitchV("status_bar_time_year"), dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextWithSwitchV( TextV(resId = R.string.status_bar_time_month), SwitchV("status_bar_time_month"), dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextWithSwitchV( TextV(resId = R.string.status_bar_time_day), SwitchV("status_bar_time_day"), dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextWithSwitchV( TextV(resId = R.string.status_bar_time_week), SwitchV("status_bar_time_week"), dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextWithSwitchV( TextV(resId = R.string.status_bar_time_double_hour), SwitchV("status_bar_time_double_hour"), dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextWithSwitchV( TextV(resId = R.string.status_bar_time_period), SwitchV("status_bar_time_period", true), dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextWithSwitchV( TextV(resId = R.string.status_bar_time_seconds), SwitchV("status_bar_time_seconds"), dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextWithSwitchV( TextV(resId = R.string.status_bar_time_hide_space), SwitchV("status_bar_time_hide_space"), dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextWithSwitchV( TextV(resId = R.string.status_bar_time_double_line), SwitchV("status_bar_time_double_line"), dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextV( resId = R.string.status_bar_clock_size, dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( SeekBarWithTextV( "status_bar_clock_size", 0, 18, 0, dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( TextV( resId = R.string.status_bar_clock_double_line_size, dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add( SeekBarWithTextV( "status_bar_clock_double_line_size", 0, 8, 0, dataBindingRecv = custom_clock_binding.binding.getRecv(2) ) ) add(LineV()) add(TitleTextV(resId = R.string.status_bar_icon)) add( TextWithSwitchV( TextV(resId = R.string.hide_battery_icon), SwitchV("hide_battery_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_battery_charging_icon), SwitchV("hide_battery_charging_icon") ) ) add(TextWithSwitchV(TextV(resId = R.string.hide_gps_icon), SwitchV("hide_gps_icon"))) add( TextWithSwitchV( TextV(resId = R.string.hide_bluetooth_icon), SwitchV("hide_bluetooth_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_bluetooth_battery_icon), SwitchV("hide_bluetooth_battery_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_small_hd_icon), SwitchV("hide_small_hd_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_big_hd_icon), SwitchV("hide_big_hd_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_hd_no_service_icon), SwitchV("hide_hd_no_service_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_sim_one_icon), SwitchV("hide_sim_one_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_sim_two_icon), SwitchV("hide_sim_two_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_mobile_activity_icon), SwitchV("hide_mobile_activity_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_mobile_type_icon), SwitchV("hide_mobile_type_icon") ) ) add(TextWithSwitchV(TextV(resId = R.string.hide_wifi_icon), SwitchV("hide_wifi_icon"))) add( TextWithSwitchV( TextV(resId = R.string.hide_wifi_activity_icon), SwitchV("hide_wifi_activity_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_wifi_standard_icon), SwitchV("hide_wifi_standard_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_slave_wifi_icon), SwitchV("hide_slave_wifi_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_hotspot_icon), SwitchV("hide_hotspot_icon") ) ) add(TextWithSwitchV(TextV(resId = R.string.hide_vpn_icon), SwitchV("hide_vpn_icon"))) add( TextWithSwitchV( TextV(resId = R.string.hide_airplane_icon), SwitchV("hide_airplane_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_alarm_icon), SwitchV("hide_alarm_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_headset_icon), SwitchV("hide_headset_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_volume_zen_icon), SwitchV("hide_volume_zen_icon") ) ) add( TextWithSwitchV( TextV(resId = R.string.hide_network_speed_splitter), SwitchV("hide_network_speed_splitter") ) ) add(LineV()) add(TitleTextV(resId = R.string.notification_center)) val show_weather_main_switch_binding = getDataBinding( SPUtils.getBoolean( activity, "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 } } add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.show_weather_main_switch, colorId = R.color.purple_700 ), SwitchV( "notification_weather", dataBindingSend = show_weather_main_switch_binding.bindingSend ) ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.show_city, ), SwitchV("notification_weather_city"), dataBindingRecv = show_weather_main_switch_binding.binding.getRecv(2) ) ) add(LineV()) add(TitleTextV(resId = R.string.control_center)) val control_center_weather_binding = getDataBinding( SPUtils.getBoolean( activity, "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 } } add( TextSummaryWithSwitchV( 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 = control_center_weather_binding.bindingSend ) ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.show_city, ), SwitchV("control_center_weather_city"), dataBindingRecv = control_center_weather_binding.binding.getRecv(2) ) ) add(LineV()) add(TitleTextV(resId = R.string.lock_screen)) add( TextSummaryWithSwitchV( 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") ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.remove_lock_screen_camera, tipsId = R.string.only_official_default_themes_are_supported ), SwitchV("remove_lock_screen_camera") ) ) } } //其他页面 fun otherItems(): ArrayList { return ArrayList().apply { add(TitleTextV(resId = R.string.scope_miuihome)) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.home_time, tipsId = R.string.home_time_summary ), SwitchV("home_time") ) ) add(LineV()) add(TitleTextV(resId = R.string.scope_powerkeeper)) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.lock_max_fps, tipsId = R.string.lock_max_fps_summary ), SwitchV("lock_max_fps") ) ) add( TextSummaryWithSwitchV( 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") ) ) add( TextSummaryArrowV( 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() } }) ) ) add(LineV()) add(TitleTextV(resId = R.string.scope_securitycenter)) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.skip_waiting_time, tipsId = R.string.skip_waiting_time_summary ), SwitchV("skip_waiting_time") ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.lock_one_hundred, tipsId = R.string.lock_one_hundred_summary ), SwitchV("lock_one_hundred") ) ) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.remove_macro_blacklist ), SwitchV("remove_macro_blacklist") ) ) add(LineV()) add(TitleTextV(resId = R.string.scope_mediaeditor)) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.unlock_unlimited_cropping, tipsId = R.string.unlock_unlimited_cropping_summary ), SwitchV("unlock_unlimited_cropping") ) ) add(LineV()) add(TitleTextV(resId = R.string.updater)) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.remove_ota_validate, tipsId = R.string.remove_ota_validate_summary ), SwitchV("remove_ota_validate") ) ) add(LineV()) add(TitleTextV(resId = R.string.settings)) add( TextSummaryWithSwitchV( TextSummaryV( textId = R.string.show_notification_importance, tipsId = R.string.show_notification_importance_summary ), SwitchV("show_notification_importance") ) ) } } override fun getItems(item: String): ArrayList { return when (item) { getString(R.string.scope_android) -> androidItems() getString(R.string.scope_systemui) -> systemuiItems() getString(R.string.scope_other) -> otherItems() getString(R.string.about_module) -> aboutItems() menuName() -> menuItems() else -> mainItems() } } } \ No newline at end of file +@file:Suppress("DEPRECATION") + +package com.lt2333.simplicitytools.activity + +import android.annotation.SuppressLint +import android.content.ComponentName +import android.content.Intent +import android.content.pm.PackageManager +import android.net.Uri +import android.os.Bundle +import android.view.View +import android.widget.Switch +import android.widget.Toast +import cn.fkj233.ui.activity.MIUIActivity +import cn.fkj233.ui.activity.view.* +import cn.fkj233.ui.dialog.MIUIDialog +import com.lt2333.simplicitytools.BuildConfig +import com.lt2333.simplicitytools.R +import com.lt2333.simplicitytools.util.SPUtils +import com.lt2333.simplicitytools.util.ShellUtils +import com.microsoft.appcenter.AppCenter +import com.microsoft.appcenter.analytics.Analytics +import com.microsoft.appcenter.crashes.Crashes +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() + super.onCreate(savedInstanceState) + } + + //检测LSPosed是否激活 + @SuppressLint("WorldReadableFiles") + private fun checkLSPosed() { + try { + setSP(getSharedPreferences("config", MODE_WORLD_READABLE)) + } catch (exception: SecurityException) { + isLoad = false + MIUIDialog(this).apply { + setTitle(R.string.Tips) + setMessage(R.string.not_support) + setCancelable(false) + setRButton(R.string.Done) { + exitProcess(0) + } + show() + } + } + } + + //主页标题 + override fun mainName(): String { + return getString(R.string.app_name) + } + + //菜单标题 + override fun menuName(): String { + return getString(R.string.menu) + } + + //主页面 + override fun mainItems(): ArrayList { + return arrayListOf().apply { + add( + TextWithSwitchV( + TextV(resId = R.string.main_switch, colorId = R.color.purple_700), + SwitchV("main_switch", true) + ) + ) + add( + TextWithSwitchV( + TextV(resId = 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 + ) + }) + ) + ) + add( + TextSummaryArrowV( + TextSummaryV( + textId = R.string.matters_needing_attention, + colorId = R.color.red, + onClickListener = { + MIUIDialog(activity).apply { + setTitle(R.string.matters_needing_attention) + setMessage( + R.string.matters_needing_attention_context + ) + setRButton(R.string.Done) { + dismiss() + } + show() + } + }) + ) + ) + + + add(LineV()) + add(TitleTextV(resId = R.string.scope)) + add( + TextSummaryArrowV( + TextSummaryV( + textId = R.string.scope_systemui, tipsId = R.string.scope_systemui_summary, + onClickListener = { showFragment(getString(R.string.scope_systemui)) } + ) + ) + ) + add( + TextSummaryArrowV( + TextSummaryV( + textId = R.string.scope_android, tipsId = R.string.scope_android_summary, + onClickListener = { showFragment(getString(R.string.scope_android)) } + ) + ) + ) + add( + TextSummaryArrowV( + TextSummaryV( + textId = R.string.scope_other, tipsId = R.string.scope_other_summary, + onClickListener = { showFragment(getString(R.string.scope_other)) } + ) + ) + ) + add(LineV()) + add(TitleTextV(resId = R.string.about)) + add( + TextSummaryArrowV( + TextSummaryV( + textId = R.string.about_module, + tips = getString(R.string.about_module_summary), + onClickListener = { showFragment(getString(R.string.about_module)) } + ) + ) + ) + } + } + + //菜单页面 + override fun menuItems(): ArrayList { + return ArrayList().apply { + add( + TextSummaryArrowV( + TextSummaryV(textId = R.string.reboot, onClickListener = { + MIUIDialog(activity).apply { + 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() + } + }) + ) + ) + add( + TextSummaryArrowV( + TextSummaryV(textId = R.string.reboot_host, onClickListener = { + MIUIDialog(activity).apply { + 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.miui.home", + "killall com.miui.securitycenter ", + "killall com.miui.powerkeeper", + "killall com.miui.mediaeditor", + "killall com.android.systemui", + "killall com.android.updater", + "killall com.android.settings" + ) + ShellUtils.execCommand(command, true) + dismiss() + } + show() + } + }) + ) + ) + + } + } + + //关于页面 + fun aboutItems(): ArrayList { + return ArrayList().apply { + add( + AuthorV( + authorHead = getDrawable(R.drawable.app_icon)!!, + authorName = getString(R.string.app_name), + authorTips = BuildConfig.VERSION_NAME + "(" + BuildConfig.BUILD_TYPE + ")", + onClick = { + 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) + } + }) + ) + add(LineV()) + add( + TitleTextV(text = getString(R.string.developer)) + ) + add( + AuthorV( + authorHead = getDrawable(R.drawable.lt)!!, + authorName = "乌堆小透明", + authorTips = "LittleTurtle2333", + onClick = { + 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) + } + }) + ) + add(LineV()) + add( + TitleTextV(text = getString(R.string.thank_list)) + ) + add( + TextSummaryArrowV( + 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() + } + }) + ) + ) + add( + TextSummaryArrowV( + 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() + } + }) + ) + ) + add(LineV()) + add( + TitleTextV(text = getString(R.string.discussions)) + ) + add(TextSummaryArrowV(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() + } + }))) + add( + TextSummaryArrowV( + 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) + } + }) + ) + ) + add( + TextSummaryArrowV( + 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() + } + }) + ) + ) + add(LineV()) + add( + TitleTextV(text = getString(R.string.other)) + ) + add( + TextSummaryArrowV( + 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() + } + }) + ) + ) + add( + TextSummaryArrowV( + 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() + } + }) + ) + ) + } + } + + //系统框架页面 + fun androidItems(): ArrayList { + return ArrayList().apply { + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.disable_flag_secure, + tipsId = R.string.disable_flag_secure_summary + ), + SwitchV("disable_flag_secure") + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.corepacth, + tipsId = R.string.corepacth_summary + ), + SwitchV("corepatch") + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.delete_on_post_notification, + tipsId = R.string.delete_on_post_notification_summary + ), + SwitchV("delete_on_post_notification") + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.remove_small_window_restrictions, + tipsId = R.string.remove_small_window_restrictions_summary + ), + SwitchV("remove_small_window_restrictions") + ) + ) + } + } + + //系统界面页面 + fun systemuiItems(): ArrayList { + return ArrayList().apply { + add(TitleTextV(resId = R.string.statusbar)) + add( + TextSummaryWithSwitchV( + 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") + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.hide_battery_percentage_icon, + tipsId = R.string.hide_battery_percentage_icon_summary + ), + SwitchV("hide_battery_percentage_icon") + ) + ) + add( + TextSummaryWithSwitchV( + 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") + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.remove_the_maximum_number_of_notification_icons, + tipsId = R.string.remove_the_maximum_number_of_notification_icons_summary + ), + SwitchV("remove_the_maximum_number_of_notification_icons") + ) + ) + + add(LineV()) + add(TitleTextV(resId = R.string.status_bar_layout)) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.status_bar_time_center, + tipsId = R.string.status_bar_layout_summary + ), + SwitchV("status_bar_time_center") + ) + ) + val layout_compatibility_mode_binding = getDataBinding( + SPUtils.getBoolean( + activity, + "layout_compatibility_mode", + 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 + } + } + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.layout_compatibility_mode, + tipsId = R.string.layout_compatibility_mode_summary + ), + SwitchV( + "layout_compatibility_mode", + dataBindingSend = layout_compatibility_mode_binding.bindingSend + ) + ) + ) + + + add( + TextV( + resId = R.string.left_margin, + dataBindingRecv = layout_compatibility_mode_binding.binding.getRecv(2) + ) + ) + add( + SeekBarWithTextV( + "status_bar_left_margin", + 0, + 300, + 0, + dataBindingRecv = layout_compatibility_mode_binding.binding.getRecv(2) + ) + ) + + add( + TextV( + resId = R.string.right_margin, + dataBindingRecv = layout_compatibility_mode_binding.binding.getRecv(2) + ) + ) + add( + SeekBarWithTextV( + "status_bar_right_margin", + 0, + 300, + 0, + dataBindingRecv = layout_compatibility_mode_binding.binding.getRecv(2) + ) + ) + + + add(LineV()) + add(TitleTextV(resId = R.string.status_bar_clock_format)) + + val custom_clock_binding = getDataBinding( + SPUtils.getBoolean( + activity, + "custom_clock_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 + } + } + + + add( + TextWithSwitchV( + TextV(resId = R.string.custom_clock_switch, colorId = R.color.purple_700), + SwitchV( + "custom_clock_switch", + dataBindingSend = custom_clock_binding.bindingSend + ) + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.status_bar_time_year), + SwitchV("status_bar_time_year"), + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.status_bar_time_month), + SwitchV("status_bar_time_month"), + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.status_bar_time_day), + SwitchV("status_bar_time_day"), + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.status_bar_time_week), + SwitchV("status_bar_time_week"), + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.status_bar_time_double_hour), + SwitchV("status_bar_time_double_hour"), + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.status_bar_time_period), + SwitchV("status_bar_time_period", true), + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.status_bar_time_seconds), + SwitchV("status_bar_time_seconds"), + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.status_bar_time_hide_space), + SwitchV("status_bar_time_hide_space"), + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.status_bar_time_double_line), + SwitchV("status_bar_time_double_line"), + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextV( + resId = R.string.status_bar_clock_size, + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + SeekBarWithTextV( + "status_bar_clock_size", 0, 18, 0, + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + TextV( + resId = R.string.status_bar_clock_double_line_size, + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add( + SeekBarWithTextV( + "status_bar_clock_double_line_size", 0, 8, 0, + dataBindingRecv = custom_clock_binding.binding.getRecv(2) + ) + ) + add(LineV()) + add(TitleTextV(resId = R.string.status_bar_icon)) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_battery_icon), + SwitchV("hide_battery_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_battery_charging_icon), + SwitchV("hide_battery_charging_icon") + ) + ) + add(TextWithSwitchV(TextV(resId = R.string.hide_gps_icon), SwitchV("hide_gps_icon"))) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_bluetooth_icon), + SwitchV("hide_bluetooth_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_bluetooth_battery_icon), + SwitchV("hide_bluetooth_battery_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_small_hd_icon), + SwitchV("hide_small_hd_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_big_hd_icon), + SwitchV("hide_big_hd_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_hd_no_service_icon), + SwitchV("hide_hd_no_service_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_sim_one_icon), + SwitchV("hide_sim_one_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_sim_two_icon), + SwitchV("hide_sim_two_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_mobile_activity_icon), + SwitchV("hide_mobile_activity_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_mobile_type_icon), + SwitchV("hide_mobile_type_icon") + ) + ) + add(TextWithSwitchV(TextV(resId = R.string.hide_wifi_icon), SwitchV("hide_wifi_icon"))) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_wifi_activity_icon), + SwitchV("hide_wifi_activity_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_wifi_standard_icon), + SwitchV("hide_wifi_standard_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_slave_wifi_icon), + SwitchV("hide_slave_wifi_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_hotspot_icon), + SwitchV("hide_hotspot_icon") + ) + ) + add(TextWithSwitchV(TextV(resId = R.string.hide_vpn_icon), SwitchV("hide_vpn_icon"))) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_airplane_icon), + SwitchV("hide_airplane_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_alarm_icon), + SwitchV("hide_alarm_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_headset_icon), + SwitchV("hide_headset_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_volume_zen_icon), + SwitchV("hide_volume_zen_icon") + ) + ) + add( + TextWithSwitchV( + TextV(resId = R.string.hide_network_speed_splitter), + SwitchV("hide_network_speed_splitter") + ) + ) + + add(LineV()) + add(TitleTextV(resId = R.string.notification_center)) + val show_weather_main_switch_binding = getDataBinding( + SPUtils.getBoolean( + activity, + "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 + } + } + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.show_weather_main_switch, colorId = R.color.purple_700 + ), + SwitchV( + "notification_weather", + dataBindingSend = show_weather_main_switch_binding.bindingSend + ) + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.show_city, + ), + SwitchV("notification_weather_city"), + dataBindingRecv = show_weather_main_switch_binding.binding.getRecv(2) + ) + ) + + add(LineV()) + add(TitleTextV(resId = R.string.control_center)) + val control_center_weather_binding = getDataBinding( + SPUtils.getBoolean( + activity, + "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 + } + } + add( + TextSummaryWithSwitchV( + 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 = control_center_weather_binding.bindingSend + ) + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.show_city, + ), + SwitchV("control_center_weather_city"), + dataBindingRecv = control_center_weather_binding.binding.getRecv(2) + ) + ) + + add(LineV()) + add(TitleTextV(resId = R.string.lock_screen)) + + add( + TextSummaryWithSwitchV( + 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") + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.remove_lock_screen_camera, + tipsId = R.string.only_official_default_themes_are_supported + ), + SwitchV("remove_lock_screen_camera") + ) + ) + } + } + + //其他页面 + fun otherItems(): ArrayList { + return ArrayList().apply { + add(TitleTextV(resId = R.string.scope_miuihome)) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.home_time, + tipsId = R.string.home_time_summary + ), SwitchV("home_time") + ) + ) + add(LineV()) + add(TitleTextV(resId = R.string.scope_powerkeeper)) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.lock_max_fps, + tipsId = R.string.lock_max_fps_summary + ), + SwitchV("lock_max_fps") + ) + ) + + add( + TextSummaryWithSwitchV( + 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") + ) + ) + add( + TextSummaryArrowV( + 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() + } + }) + ) + ) + add(LineV()) + add(TitleTextV(resId = R.string.scope_securitycenter)) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.skip_waiting_time, + tipsId = R.string.skip_waiting_time_summary + ), + SwitchV("skip_waiting_time") + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.lock_one_hundred, + tipsId = R.string.lock_one_hundred_summary + ), + SwitchV("lock_one_hundred") + ) + ) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.remove_macro_blacklist + ), + SwitchV("remove_macro_blacklist") + ) + ) + add(LineV()) + add(TitleTextV(resId = R.string.scope_mediaeditor)) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.unlock_unlimited_cropping, + tipsId = R.string.unlock_unlimited_cropping_summary + ), + SwitchV("unlock_unlimited_cropping") + ) + ) + + add(LineV()) + add(TitleTextV(resId = R.string.updater)) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.remove_ota_validate, + tipsId = R.string.remove_ota_validate_summary + ), + SwitchV("remove_ota_validate") + ) + ) + + add(LineV()) + add(TitleTextV(resId = R.string.settings)) + add( + TextSummaryWithSwitchV( + TextSummaryV( + textId = R.string.show_notification_importance, + tipsId = R.string.show_notification_importance_summary + ), + SwitchV("show_notification_importance") + ) + ) + } + } + + override fun getItems(item: String): ArrayList { + return when (item) { + getString(R.string.scope_android) -> androidItems() + getString(R.string.scope_systemui) -> systemuiItems() + getString(R.string.scope_other) -> otherItems() + getString(R.string.about_module) -> aboutItems() + menuName() -> menuItems() + else -> mainItems() + } + } +} \ No newline at end of file From b64f67079897b463c277e7c23110610c5b4ed84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=8C=E5=A0=86=E5=B0=8F=E9=80=8F=E6=98=8E?= Date: Thu, 10 Mar 2022 13:50:21 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8C=96=E5=AD=94?= =?UTF-8?q?=E5=B1=8F=E5=B1=85=E4=B8=AD,=E5=90=91=E9=A1=BA=E6=97=B6?= =?UTF-8?q?=E9=92=88=E6=97=8B=E8=BD=AC90=C2=B0,=E6=A8=AA=E5=B1=8F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=BA=A2=E5=87=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hook/app/systemui/StatusBarLayout.kt | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) 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 22c8c2de..cb891e12 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 @@ -1,6 +1,7 @@ package com.lt2333.simplicitytools.hook.app.systemui import android.content.Context +import android.content.res.Configuration import android.content.res.Resources import android.os.Bundle import android.view.Gravity @@ -165,7 +166,7 @@ class StatusBarLayout : IXposedHookLoadPackage { if (custom_right_margin != 0) { status_bar_right = custom_right_margin } - updateLayout() + updateLayout(context) } } @@ -182,7 +183,8 @@ class StatusBarLayout : IXposedHookLoadPackage { object : XC_MethodHook() { override fun afterHookedMethod(param: MethodHookParam) { if (XSPUtils.getBoolean("layout_compatibility_mode", false)) { - updateLayout() + val context = (param.thisObject as ViewGroup).context + updateLayout(context) } } } @@ -190,10 +192,19 @@ class StatusBarLayout : IXposedHookLoadPackage { } - fun updateLayout() { - mLeftLayout!!.setPadding(status_bar_left, 0, 0, 0) - mRightLayout!!.setPadding(0, 0, status_bar_right, 0) - status_bar!!.setPadding(0, status_bar_top, 0, status_bar_bottom) + fun updateLayout(context: Context) { + //判断屏幕方向 + val mConfiguration: Configuration = context.resources.configuration + if (mConfiguration.orientation == Configuration.ORIENTATION_PORTRAIT) { + mLeftLayout!!.setPadding(status_bar_left, 0, 0, 0) + mRightLayout!!.setPadding(0, 0, status_bar_right, 0) + status_bar!!.setPadding(0, status_bar_top, 0, status_bar_bottom) + } else { + //横屏状态 + mLeftLayout!!.setPadding(175, 0, 0, 0) + mRightLayout!!.setPadding(0, 0, 175, 0) + status_bar!!.setPadding(0, status_bar_top, 0, status_bar_bottom) + } } } \ No newline at end of file From 88f216f91f2a5ed8bfd29073ee337baa9b6faa27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=8C=E5=A0=86=E5=B0=8F=E9=80=8F=E6=98=8E?= Date: Thu, 10 Mar 2022 13:51:10 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9A=90=E8=97=8FWIFI?= =?UTF-8?q?=E6=A0=87=E5=87=86=E5=90=8E=E5=81=B6=E7=8E=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hook/app/systemui/HideWifiActivityIcon.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/HideWifiActivityIcon.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/HideWifiActivityIcon.kt index ca86e621..014246a8 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/HideWifiActivityIcon.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/HideWifiActivityIcon.kt @@ -45,12 +45,22 @@ class HideWifiActivityIcon : IXposedHookLoadPackage { "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState", object : XC_MethodHook() { override fun afterHookedMethod(param: MethodHookParam) { + //隐藏WIFI箭头 if (XSPUtils.getBoolean("hide_wifi_activity_icon", false)) { (XposedHelpers.getObjectField( param.thisObject, "mWifiActivityView" ) as ImageView).visibility = View.INVISIBLE } + + //隐藏WIFI标准图标 + if (XSPUtils.getBoolean("hide_wifi_standard_icon", false)) { + (XposedHelpers.getObjectField( + param.thisObject, + "mWifiStandardView" + ) as TextView).visibility = View.INVISIBLE + } + } }) From 48c913888e9bdf17166f3138a282b9001ba6d9de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=8C=E5=A0=86=E5=B0=8F=E9=80=8F=E6=98=8E?= Date: Thu, 10 Mar 2022 13:53:05 +0800 Subject: [PATCH 5/5] Update version to 1.3.9 --- app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6703ce58..b7e6927f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -12,8 +12,8 @@ android { applicationId = "com.lt2333.simplicitytools" minSdk = 31 targetSdk = 32 - versionCode = 39 - versionName = "1.3.8" + versionCode = 40 + versionName = "1.3.9" } buildTypes {