From 1dd31af54b390207e77b08fef6fc0d53b05b5de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=83=E6=9F=92=E6=9F=92?= Date: Sun, 29 Dec 2024 01:10:31 +0800 Subject: [PATCH] opt: move some func --- .../module/app/SystemUI/Pad/SystemUiU.java | 2 - .../module/app/SystemUI/Pad/SystemUiV.java | 2 - .../module/app/SystemUI/Phone/SystemUiU.java | 2 - .../module/app/SystemUI/Phone/SystemUiV.java | 2 - .../controlcenter/NotificationWeatherNew.kt | 63 +------ .../controlcenter/NotificationWeatherOld.kt | 1 + .../hook/systemui/plugin/PluginHelper.java | 3 + .../app/systemui/ControlCenterSettings.java | 96 ++-------- .../fragment/app/systemui/TileSettings.java | 115 ++++++++++++ .../ui/fragment/app/various/AOSPSettings.java | 18 +- .../hyperceiler/utils/devicesdk/SystemSDK.kt | 76 ++++---- app/src/main/res/values-ar-rSA/strings.xml | 4 +- app/src/main/res/values-es-rES/strings.xml | 4 +- app/src/main/res/values-in-rID/strings.xml | 4 +- app/src/main/res/values-it-rIT/strings.xml | 4 +- app/src/main/res/values-ja-rJP/strings.xml | 4 +- app/src/main/res/values-pl-rPL/strings.xml | 4 +- app/src/main/res/values-pt-rBR/strings.xml | 4 +- app/src/main/res/values-ru-rRU/strings.xml | 4 +- app/src/main/res/values-tr-rTR/strings.xml | 4 +- app/src/main/res/values-vi-rVN/strings.xml | 4 +- app/src/main/res/values-zh-rCN/strings.xml | 4 +- app/src/main/res/values-zh-rHK/strings.xml | 4 +- app/src/main/res/values-zh-rTW/strings.xml | 4 +- app/src/main/res/values/strings.xml | 4 +- .../main/res/xml/system_ui_control_center.xml | 155 +--------------- .../xml/system_ui_control_center_tiles.xml | 166 ++++++++++++++++++ 27 files changed, 384 insertions(+), 373 deletions(-) create mode 100644 app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/TileSettings.java create mode 100644 app/src/main/res/xml/system_ui_control_center_tiles.xml diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiU.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiU.java index 7f362e6b95..667e049cf1 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiU.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiU.java @@ -304,8 +304,6 @@ public void handleLoadPackage() { initHook(new SwitchCCAndNotification(), mPrefsMap.getBoolean("system_ui_control_center_switch_cc_and_notification")); initHook(QSControlDetailBackgroundAlpha.INSTANCE, mPrefsMap.getInt("system_ui_control_center_control_detail_background_alpha", 255) != 255); initHook(NotificationWeather.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); - initHook(NotificationWeatherOld.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); - initHook(NotificationWeatherNew.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); initHook(CompactNotificationsHook.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_compact_notice")); /*initHook(CCGridOld.INSTANCE, mPrefsMap.getInt("system_control_center_cc_rows", 4) > 4 || mPrefsMap.getInt("system_control_center_cc_columns", 4) > 4 || diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiV.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiV.java index bdafe12884..9d30e76cdd 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiV.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiV.java @@ -226,8 +226,6 @@ public void handleLoadPackage() { initHook(new SwitchCCAndNotification(), mPrefsMap.getBoolean("system_ui_control_center_switch_cc_and_notification")); initHook(QSControlDetailBackgroundAlpha.INSTANCE, mPrefsMap.getInt("system_ui_control_center_control_detail_background_alpha", 255) != 255); initHook(NotificationWeather.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); - initHook(NotificationWeatherOld.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); - initHook(NotificationWeatherNew.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); initHook(CompactNotificationsHook.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_compact_notice")); /*initHook(CCGridOld.INSTANCE, mPrefsMap.getInt("system_control_center_cc_rows", 4) > 4 || mPrefsMap.getInt("system_control_center_cc_columns", 4) > 4 || diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiU.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiU.java index e314b125b2..4a37e0a937 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiU.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiU.java @@ -301,8 +301,6 @@ public void handleLoadPackage() { initHook(new SwitchCCAndNotification(), mPrefsMap.getBoolean("system_ui_control_center_switch_cc_and_notification")); initHook(QSControlDetailBackgroundAlpha.INSTANCE, mPrefsMap.getInt("system_ui_control_center_control_detail_background_alpha", 255) != 255); initHook(NotificationWeather.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); - initHook(NotificationWeatherOld.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); - initHook(NotificationWeatherNew.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); initHook(CompactNotificationsHook.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_compact_notice")); /*initHook(CCGridOld.INSTANCE, mPrefsMap.getInt("system_control_center_cc_rows", 4) > 4 || mPrefsMap.getInt("system_control_center_cc_columns", 4) > 4 || diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiV.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiV.java index 7e888e19ad..f30ac4e3b6 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiV.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiV.java @@ -244,8 +244,6 @@ public void handleLoadPackage() { initHook(new SwitchCCAndNotification(), mPrefsMap.getBoolean("system_ui_control_center_switch_cc_and_notification")); initHook(QSControlDetailBackgroundAlpha.INSTANCE, mPrefsMap.getInt("system_ui_control_center_control_detail_background_alpha", 255) != 255); initHook(NotificationWeather.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); - initHook(NotificationWeatherOld.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); - initHook(NotificationWeatherNew.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_show_weather")); initHook(CompactNotificationsHook.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_compact_notice")); initHook(new CCGrid(), (mPrefsMap.getInt("system_control_center_cc_rows", 4) > 4 || mPrefsMap.getInt("system_control_center_cc_columns", 4) > 4 || diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherNew.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherNew.kt index fabbcb0d40..0037ead162 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherNew.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherNew.kt @@ -19,23 +19,22 @@ package com.sevtinge.hyperceiler.module.hook.systemui.controlcenter import android.annotation.SuppressLint -import android.content.pm.ApplicationInfo import android.widget.TextView import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder import com.sevtinge.hyperceiler.module.base.BaseHook import com.sevtinge.hyperceiler.utils.api.invokeMethod -import com.sevtinge.hyperceiler.utils.devicesdk.isAndroidVersion import com.sevtinge.hyperceiler.utils.devicesdk.isMoreHyperOSVersion import com.sevtinge.hyperceiler.utils.getObjectFieldOrNullAs import com.sevtinge.hyperceiler.view.WeatherData @SuppressLint("StaticFieldLeak") +// 控制中心添加天气信息 object NotificationWeatherNew : BaseHook() { lateinit var weather: WeatherData - var clockId: Int = -2 + private var clockId: Int = -2 @SuppressLint("DiscouragedApi", "ClickableViewAccessibility") override fun init() { @@ -44,7 +43,7 @@ object NotificationWeatherNew : BaseHook() { mControlCenterDateViewClass.methodFinder().findSuper() .filterByName("onDetachedFromWindow") - .single().createHook { + .first().createHook { before { if ((it.thisObject as TextView).id == clockId && this@NotificationWeatherNew::weather.isInitialized) { weather.onDetachedFromWindow() @@ -53,7 +52,7 @@ object NotificationWeatherNew : BaseHook() { } mControlCenterDateViewClass.methodFinder().findSuper() .filterByName("setText") - .single().createHook { + .first().createHook { before { val time = it.args[0]?.toString() val view = it.thisObject as TextView @@ -65,61 +64,9 @@ object NotificationWeatherNew : BaseHook() { } } } - - val pluginLoaderClass = - if (isAndroidVersion(34)) "com.android.systemui.shared.plugins.PluginInstance\$Factory\$\$ExternalSyntheticLambda0" - else "com.android.systemui.shared.plugins.PluginInstance\$Factory" - - var appInfo: ApplicationInfo? - - if (isAndroidVersion(34) && !isMoreHyperOSVersion(1f)) { - hookAllMethods("com.android.systemui.shared.plugins.PluginInstance\$Factory", - "create", object : MethodHook() { - override fun before(param: MethodHookParam) { - appInfo = param.args[1] as ApplicationInfo? - - loadClass(pluginLoaderClass, lpparam.classLoader).methodFinder().first { - name == "get" - }.createHook { - after { getClassLoader -> - val classLoader = getClassLoader.result as ClassLoader - if (appInfo != null) { - if ("miui.systemui.plugin" == appInfo!!.packageName) { - mainPanelHeader(classLoader) - logW(TAG, "com.android.systemui", "im get ClassLoader: $classLoader") - } else { - logW(TAG, "com.android.systemui", "Au get classloader miui.systemui.plugin error: $classLoader") - } - } else { - if ( - classLoader.toString().contains("MIUISystemUIPlugin") || - classLoader.toString().contains("miui.systemui.plugin") - ) { - mainPanelHeader(classLoader) - } else { - logW(TAG, "com.android.systemui", "Au get classloader miui.systemui.plugin error & appInfo is null") - } - } - } - } - } - } - ) - } else { - loadClass(pluginLoaderClass, lpparam.classLoader).methodFinder() - .filterByName("getClassLoader") - .first().createHook { - after { getClassLoader -> - appInfo = getClassLoader.args[0] as ApplicationInfo - if (appInfo!!.packageName == "miui.systemui.plugin") { - val classLoader = getClassLoader.result as ClassLoader - mainPanelHeader(classLoader) - } - } - } - } } + @JvmStatic fun mainPanelHeader(pluginClassLoader: ClassLoader) { if (isMoreHyperOSVersion(1f)) return val isDisplayCity = mPrefsMap.getBoolean("system_ui_control_center_show_weather_city") diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherOld.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherOld.kt index 11105608e2..6290872415 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherOld.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherOld.kt @@ -31,6 +31,7 @@ import com.sevtinge.hyperceiler.module.base.BaseHook import com.sevtinge.hyperceiler.utils.setObjectField import com.sevtinge.hyperceiler.view.WeatherView +// 控制中心添加天气信息 object NotificationWeatherOld : BaseHook() { @SuppressLint("DiscouragedApi") diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/PluginHelper.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/PluginHelper.java index d1cde1b06c..b4e4b40164 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/PluginHelper.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/PluginHelper.java @@ -29,6 +29,7 @@ import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.CCGrid; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.CCGridForHyperOS; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.CustomCardTiles; +import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationWeatherNew; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.QSColor; import java.util.ArrayList; @@ -74,6 +75,8 @@ public void setClassLoader(ClassLoader classLoader) { EnableVolumeBlur.initEnableVolumeBlur(classLoader); if (mPrefsMap.getStringAsInt("system_ui_control_center_mi_smart_hub_entry", 0) != 0) HideMiSmartHubEntry.initHideMiSmartHubEntry(classLoader); + if (mPrefsMap.getBoolean("system_ui_control_center_show_weather")) + NotificationWeatherNew.mainPanelHeader(classLoader); if (mPrefsMap.getStringAsInt("system_ui_control_center_mi_play_entry", 0) != 0) HideMiPlayEntry.initHideMiPlayEntry(classLoader); if (mPrefsMap.getStringAsInt("system_ui_control_center_device_ctrl_entry", 0) != 0) diff --git a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/ControlCenterSettings.java b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/ControlCenterSettings.java index d77fef8a64..5c6d8d7cc0 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/ControlCenterSettings.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/ControlCenterSettings.java @@ -18,19 +18,15 @@ */ package com.sevtinge.hyperceiler.ui.fragment.app.systemui; -import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.getWhoAmI; import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreAndroidVersion; import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreHyperOSVersion; -import static com.sevtinge.hyperceiler.utils.shell.ShellUtils.rootExecCmd; import android.content.Intent; import android.os.Bundle; -import android.os.Handler; import android.provider.Settings; import android.view.View; import android.widget.SeekBar; -import androidx.annotation.NonNull; import androidx.preference.Preference; import androidx.preference.PreferenceCategory; import androidx.preference.SwitchPreference; @@ -41,44 +37,29 @@ import com.sevtinge.hyperceiler.ui.activity.base.BaseSettingsActivity; import com.sevtinge.hyperceiler.ui.fragment.dashboard.DashboardFragment; import com.sevtinge.hyperceiler.ui.fragment.sub.AppPicker; -import com.sevtinge.hyperceiler.utils.KillApp; -import com.sevtinge.hyperceiler.utils.ThreadPoolManager; -import com.sevtinge.hyperceiler.utils.devicesdk.TelephonyManager; import com.sevtinge.hyperceiler.utils.log.AndroidLogUtils; -import com.sevtinge.hyperceiler.utils.prefs.PrefsUtils; -import fan.preference.ColorPickerPreference; import fan.preference.DropDownPreference; import fan.preference.SeekBarPreferenceCompat; -public class ControlCenterSettings extends DashboardFragment implements Preference.OnPreferenceChangeListener { +public class ControlCenterSettings extends DashboardFragment { Preference mExpandNotification; Preference mMusic; PreferenceCategory mCard; + PreferenceCategory mOldCCGrid; SwitchPreference mNotice; SwitchPreference mNoticex; + SwitchPreference mSwitchCCAN; + SwitchPreference mSpotlightNotifColorMix; SeekBarPreferenceCompat mNewCCGrid; SeekBarPreferenceCompat mNewCCGridColumns; - SwitchPreference mNewCCGridLabel; - DropDownPreference mFiveG; DropDownPreference mBluetoothSytle; - SwitchPreference mRoundedRect; - SeekBarPreferenceCompat mRoundedRectRadius; SwitchPreference mThemeBlur; SwitchPreference mRedirectNotice; SwitchPreference mShadeHeaderBlur; - DropDownPreference mSunshineMode; - DropDownPreference mSunshineModeHigh; - SeekBarPreferenceCompat mSunshineModeHighBrightness; - SwitchPreference mSpotlightNotifColorMix; - - SwitchPreference mTaplus; SwitchPreference mNotifrowmenu; RecommendPreference mRecommend; - Handler handler; - - int mMaxBrightness = 0; @Override public int getPreferenceScreenResId() { @@ -97,30 +78,19 @@ public View.OnClickListener addRestartListener() { public void initPrefs() { mMusic = findPreference("prefs_key_system_ui_control_center_media_control_media_custom"); mCard = findPreference("prefs_key_system_ui_controlcenter_card"); + mOldCCGrid = findPreference("prefs_key_system_ui_controlcenter_old"); mExpandNotification = findPreference("prefs_key_system_ui_control_center_expand_notification"); mNewCCGrid = findPreference("prefs_key_system_control_center_cc_rows"); mNewCCGridColumns = findPreference("prefs_key_system_control_center_cc_columns"); - mNewCCGridLabel = findPreference("prefs_key_system_control_center_qs_tile_label"); mNotice = findPreference("prefs_key_n_enable"); mNoticex = findPreference("prefs_key_n_enable_fix"); + mSwitchCCAN = findPreference("prefs_key_system_ui_control_center_switch_cc_and_notification"); mBluetoothSytle = findPreference("prefs_key_system_ui_control_center_cc_bluetooth_tile_style"); - mFiveG = findPreference("prefs_key_system_control_center_5g_new_tile"); - mRoundedRect = findPreference("prefs_key_system_ui_control_center_rounded_rect"); - mRoundedRectRadius = findPreference("prefs_key_system_ui_control_center_rounded_rect_radius"); - mTaplus = findPreference("prefs_key_security_center_taplus"); mThemeBlur = findPreference("prefs_key_system_ui_control_center_unlock_blur_supported"); mNotifrowmenu = findPreference("prefs_key_system_ui_control_center_notifrowmenu"); mRedirectNotice = findPreference("prefs_key_system_ui_control_center_redirect_notice"); - mShadeHeaderBlur = findPreference("prefs_key_system_ui_shade_header_gradient_blur"); - mSunshineMode = findPreference("prefs_key_system_control_center_sunshine_new_mode"); - mSunshineModeHigh = findPreference("prefs_key_system_control_center_sunshine_new_mode_high"); - mSunshineModeHighBrightness = findPreference("prefs_key_system_control_center_sunshine_mode_brightness"); mSpotlightNotifColorMix = findPreference("prefs_key_system_ui_control_center_opt_notification_element_background_color"); - handler = new Handler(); - - try { - mMaxBrightness = Integer.parseInt(rootExecCmd("cat /sys/class/backlight/panel0-backlight/max_brightness")); - } catch (Exception ignore) {} + mShadeHeaderBlur = findPreference("prefs_key_system_ui_shade_header_gradient_blur"); mExpandNotification.setOnPreferenceClickListener( preference -> { @@ -132,54 +102,31 @@ public void initPrefs() { } ); - mTaplus.setOnPreferenceChangeListener( - (preference, o) -> { - killTaplus(); - return true; - } - ); - - if (getWhoAmI().equals("root") && mMaxBrightness > 2048) { - mSunshineModeHigh.setVisible(true); - mSunshineMode.setVisible(false); - mSunshineModeHigh.setOnPreferenceChangeListener(this); - mSunshineModeHighBrightness.setMaxValue(mMaxBrightness); - } else { - mSunshineMode.setVisible(true); - mSunshineModeHigh.setVisible(false); - mSunshineModeHighBrightness.setVisible(false); - } - if (isMoreHyperOSVersion(1f)) { mNewCCGrid.setVisible(false); mCard.setVisible(false); mNewCCGridColumns.setVisible(false); - mNewCCGridLabel.setVisible(false); + mNotice.setVisible(false); mBluetoothSytle.setVisible(false); mNotifrowmenu.setVisible(false); mMusic.setVisible(true); mThemeBlur.setVisible(true); - mRoundedRectRadius.setVisible(PrefsUtils.getSharedBoolPrefs(getContext(), "prefs_key_system_ui_control_center_rounded_rect", false)); } else { mNewCCGrid.setVisible(true); mCard.setVisible(true); mNewCCGridColumns.setVisible(true); - mNewCCGridLabel.setVisible(true); mNotice.setVisible(true); mBluetoothSytle.setVisible(true); mNotifrowmenu.setVisible(true); mMusic.setVisible(false); mThemeBlur.setVisible(false); - mRoundedRectRadius.setVisible(false); } + mOldCCGrid.setVisible(!isMoreHyperOSVersion(2f)); + mSwitchCCAN.setVisible(!isMoreHyperOSVersion(2f)); mRedirectNotice.setVisible(!isMoreAndroidVersion(35)); mSpotlightNotifColorMix.setVisible(isMoreHyperOSVersion(2f) && isMoreAndroidVersion(35)); mShadeHeaderBlur.setVisible(isMoreHyperOSVersion(2f) && isMoreAndroidVersion(35)); - mFiveG.setVisible(TelephonyManager.getDefault().isFiveGCapable()); - mSunshineModeHighBrightness.setVisible(Integer.parseInt(PrefsUtils.mSharedPreferences.getString("prefs_key_system_control_center_sunshine_new_mode_high", "0")) == 3);; - - mRoundedRect.setOnPreferenceChangeListener(this); ((SeekBarPreferenceCompat) findPreference("prefs_key_system_control_center_old_qs_grid_columns")).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override @@ -217,27 +164,4 @@ public void onStopTrackingTouch(SeekBar seekBar) { ); } - - public void killTaplus() { - ThreadPoolManager.getInstance().submit(() -> handler.post(() -> - KillApp.killApps("com.miui.contentextension"))); - } - - @Override - public boolean onPreferenceChange(@NonNull Preference preference, Object o) { - if (preference == mRoundedRect) { - setCanBeVisibleRoundedRect((Boolean) o); - } else if (preference == mSunshineModeHigh) { - setCanBeVisibleSunshineBrightness(Integer.parseInt((String) o)); - } - return true; - } - - private void setCanBeVisibleRoundedRect(boolean mode) { - mRoundedRectRadius.setVisible(mode && isMoreHyperOSVersion(1f)); - } - - private void setCanBeVisibleSunshineBrightness(int mode) { - mSunshineModeHighBrightness.setVisible(mode == 3); - } } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/TileSettings.java b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/TileSettings.java new file mode 100644 index 0000000000..3bdd4fc579 --- /dev/null +++ b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/TileSettings.java @@ -0,0 +1,115 @@ +package com.sevtinge.hyperceiler.ui.fragment.app.systemui; + +import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.getWhoAmI; +import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreAndroidVersion; +import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreHyperOSVersion; +import static com.sevtinge.hyperceiler.utils.shell.ShellUtils.rootExecCmd; + +import android.os.Handler; +import android.os.Looper; + +import androidx.annotation.NonNull; +import androidx.preference.Preference; +import androidx.preference.SwitchPreference; + +import com.sevtinge.hyperceiler.R; +import com.sevtinge.hyperceiler.ui.fragment.dashboard.DashboardFragment; +import com.sevtinge.hyperceiler.utils.KillApp; +import com.sevtinge.hyperceiler.utils.ThreadPoolManager; +import com.sevtinge.hyperceiler.utils.devicesdk.TelephonyManager; +import com.sevtinge.hyperceiler.utils.prefs.PrefsUtils; + +import fan.preference.DropDownPreference; +import fan.preference.SeekBarPreferenceCompat; + +public class TileSettings extends DashboardFragment implements Preference.OnPreferenceChangeListener { + SwitchPreference mTaplus; + SwitchPreference mNewCCGridLabel; + SwitchPreference mRoundedRect; + SeekBarPreferenceCompat mRoundedRectRadius; + SeekBarPreferenceCompat mSunshineModeHighBrightness; + DropDownPreference mFiveG; + DropDownPreference mSunshineMode; + DropDownPreference mSunshineModeHigh; + Handler handler; + + int mMaxBrightness = 0; + + @Override + public int getPreferenceScreenResId() { + return R.xml.system_ui_control_center_tiles; + } + + @Override + public void initPrefs() { + mFiveG = findPreference("prefs_key_system_control_center_5g_new_tile"); + mRoundedRect = findPreference("prefs_key_system_ui_control_center_rounded_rect"); + mRoundedRectRadius = findPreference("prefs_key_system_ui_control_center_rounded_rect_radius"); + mTaplus = findPreference("prefs_key_security_center_taplus"); + mNewCCGridLabel = findPreference("prefs_key_system_control_center_qs_tile_label"); + mSunshineMode = findPreference("prefs_key_system_control_center_sunshine_new_mode"); + mSunshineModeHigh = findPreference("prefs_key_system_control_center_sunshine_new_mode_high"); + mSunshineModeHighBrightness = findPreference("prefs_key_system_control_center_sunshine_mode_brightness"); + handler = new Handler(Looper.getMainLooper()); + + try { + mMaxBrightness = Integer.parseInt(rootExecCmd("cat /sys/class/backlight/panel0-backlight/max_brightness")); + } catch (Exception ignore) {} + + mTaplus.setOnPreferenceChangeListener( + (preference, o) -> { + killTaplus(); + return true; + } + ); + + if (getWhoAmI().equals("root") && mMaxBrightness > 2048) { + mSunshineModeHigh.setVisible(true); + mSunshineMode.setVisible(false); + mSunshineModeHigh.setOnPreferenceChangeListener(this); + mSunshineModeHighBrightness.setMaxValue(mMaxBrightness); + } else { + mSunshineMode.setVisible(true); + mSunshineModeHigh.setVisible(false); + mSunshineModeHighBrightness.setVisible(false); + } + + if (isMoreHyperOSVersion(1f)) { + mRoundedRectRadius.setVisible(PrefsUtils.getSharedBoolPrefs(getContext(), "prefs_key_system_ui_control_center_rounded_rect", false)); + mNewCCGridLabel.setVisible(false); + } else { + mRoundedRectRadius.setVisible(false); + mNewCCGridLabel.setVisible(true); + } + + mFiveG.setVisible(TelephonyManager.getDefault().isFiveGCapable()); + mSunshineModeHighBrightness.setVisible(Integer.parseInt(PrefsUtils.mSharedPreferences.getString("prefs_key_system_control_center_sunshine_new_mode_high", "0")) == 3);; + + mRoundedRect.setOnPreferenceChangeListener(this); + + } + + @Override + public boolean onPreferenceChange(@NonNull Preference preference, Object o) { + if (preference == mRoundedRect) { + setCanBeVisibleRoundedRect((Boolean) o); + } else if (preference == mSunshineModeHigh) { + setCanBeVisibleSunshineBrightness(Integer.parseInt((String) o)); + } + return true; + } + + public void killTaplus() { + ThreadPoolManager.getInstance().submit(() -> handler.post(() -> + KillApp.killApps("com.miui.contentextension"))); + } + + private void setCanBeVisibleRoundedRect(boolean mode) { + mRoundedRectRadius.setVisible(mode && isMoreHyperOSVersion(1f)); + } + + private void setCanBeVisibleSunshineBrightness(int mode) { + mSunshineModeHighBrightness.setVisible(mode == 3); + } + +} diff --git a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/various/AOSPSettings.java b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/various/AOSPSettings.java index 2adca90c35..9a7ed14f0f 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/various/AOSPSettings.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/various/AOSPSettings.java @@ -18,14 +18,16 @@ */ package com.sevtinge.hyperceiler.ui.fragment.app.various; +import android.content.ComponentName; import android.content.Intent; +import android.os.Bundle; + import androidx.preference.Preference; import com.sevtinge.hyperceiler.R; import com.sevtinge.hyperceiler.ui.fragment.base.SettingsPreferenceFragment; -import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreAndroidVersion; public class AOSPSettings extends SettingsPreferenceFragment { - private Preference mBattery; + Preference mBattery; @Override public int getPreferenceScreenResId() { @@ -38,11 +40,13 @@ public void initPrefs() { if (mBattery != null) { mBattery.setOnPreferenceClickListener(preference -> { - Intent intent = new Intent(); - String className = isMoreAndroidVersion(35) ? - "com.android.settings.Settings$AppBatteryUsageActivity" : - "com.android.settings.Settings$HighPowerApplicationsActivity"; - intent.setClassName("com.android.settings", className); + Intent intent = new Intent("android.intent.action.MAIN"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.SubSettings")); + intent.putExtra(":settings:show_fragment", "com.android.settings.applications.manageapplications.ManageApplications"); + Bundle bundle = new Bundle(); + bundle.putString("classname", "com.android.settings.Settings$HighPowerApplicationsActivity"); + intent.putExtra(":settings:show_fragment_args", bundle); startActivity(intent); return true; }); diff --git a/app/src/main/java/com/sevtinge/hyperceiler/utils/devicesdk/SystemSDK.kt b/app/src/main/java/com/sevtinge/hyperceiler/utils/devicesdk/SystemSDK.kt index 04af03323b..ca0ff42d12 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/utils/devicesdk/SystemSDK.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/utils/devicesdk/SystemSDK.kt @@ -21,53 +21,57 @@ package com.sevtinge.hyperceiler.utils.devicesdk import android.os.* import com.sevtinge.hyperceiler.utils.PropUtils.* import com.sevtinge.hyperceiler.utils.shell.ShellUtils.* -import java.util.* // 设备信息相关 -fun getSystemVersionIncremental(): String = if (getProp("ro.mi.os.version.incremental") != "") getProp("ro.mi.os.version.incremental") else getProp("ro.system.build.version.incremental") +fun getSystemVersionIncremental(): String = getProp("ro.mi.os.version.incremental").ifEmpty { getProp("ro.system.build.version.incremental") } fun getBuildDate(): String = getProp("ro.system.build.date") fun getHost(): String = Build.HOST fun getBuilder(): String = getProp("ro.build.user") -fun getBaseOs(): String = if (getProp("ro.build.version.base_os") != "") getProp("ro.build.version.base_os") else "null" +fun getBaseOs(): String = getProp("ro.build.version.base_os").ifEmpty { "null" } fun getRomAuthor(): String = getProp("ro.rom.author") + getProp("ro.romid") fun getWhoAmI(): String = rootExecCmd("whoami") fun getCurrentUserId(): Int = Process.myUserHandle().hashCode() - -/** - * 获取设备 Android 版本 - * @return 一个 Int 值 - */ -fun getAndroidVersion(): Int = Build.VERSION.SDK_INT - -/** - * 获取小米设备 MIUI 版本 - * 将获取到的字符串转换为浮点,以提供判断 - * @return 一个 Float 值 - * HyperOS 2.0 已弃用 - */ -fun getMiuiVersion(): Float = if (getProp("ro.miui.ui.version.name") == "V125") 12.5f else try { getProp("ro.miui.ui.version.code").toFloat() } catch (_: Exception) { -1f } - -/** - * 获取小米设备 HyperOS 版本 - * 将获取到的字符串转换为浮点,以提供判断 - * @return 一个 Float 值 - */ -fun getHyperOSVersion(): Float = if (getProp("ro.mi.os.version.code") != null) try { getProp("ro.mi.os.version.code").toFloat() } catch (_: Exception) { -1f } else 0f +// 仅获取设备信息,不要用于判断 +fun getAndroidVersion(): Int = androidSDK +fun getMiuiVersion(): Float = miuiSDK +fun getHyperOSVersion(): Float = hyperOSSDK + +private val androidSDK: Int by lazy { + Build.VERSION.SDK_INT +} +private val miuiSDK: Float by lazy { + when (getProp("ro.miui.ui.version.name")) { + "V125" -> 12.5f + else -> getProp("ro.miui.ui.version.code").toFloatOrNull() ?: -1f + } +} +private val hyperOSSDK: Float by lazy { + getProp("ro.mi.os.version.code").toFloatOrNull() ?: 0f +} +private val mSupportMiuiVersion: List by lazy { + mutableListOf(13.0f, 14.0f, 816.0f, 818.0f) +} +private val mSupportHyperOsVersion: List by lazy { + mutableListOf(-1.0f, 1.0f, 2.0f) +} +private val mSupportAndroidVersion: List by lazy { + mutableListOf(33, 34, 35) +} /** * 判断是否为指定某个 Android 版本 * @param code 传入的 Android SDK Int 数值 * @return 一个 Boolean 值 */ -fun isAndroidVersion(code: Int): Boolean = getAndroidVersion() == code +fun isAndroidVersion(code: Int): Boolean = androidSDK == code /** * 判断是否大于某个 Android 版本 * @param code 传入的 Android SDK Int 数值 * @return 一个 Boolean 值 */ -fun isMoreAndroidVersion(code: Int): Boolean = getAndroidVersion() >= code +fun isMoreAndroidVersion(code: Int): Boolean = androidSDK >= code /** * 判断是否为指定某个 MIUI 版本 @@ -75,7 +79,7 @@ fun isMoreAndroidVersion(code: Int): Boolean = getAndroidVersion() >= code * @return 一个 Boolean 值 * HyperOS 2.0 已弃用 */ -fun isMiuiVersion(code: Float): Boolean = getMiuiVersion() == code +fun isMiuiVersion(code: Float): Boolean = miuiSDK == code /** * 判断是否大于某个 MIUI 版本 @@ -83,14 +87,14 @@ fun isMiuiVersion(code: Float): Boolean = getMiuiVersion() == code * @return 一个 Boolean 值 * HyperOS 2.0 已弃用 */ -fun isMoreMiuiVersion(code: Float): Boolean = getMiuiVersion() >= code +fun isMoreMiuiVersion(code: Float): Boolean = miuiSDK >= code /** * 判断是否为指定某个 HyperOS 版本 * @param code 传入的 HyperOS 版本 Float 数值 * @return 一个 Boolean 值 */ -fun isHyperOSVersion(code: Float): Boolean = getHyperOSVersion() == code +fun isHyperOSVersion(code: Float): Boolean = hyperOSSDK == code /** @@ -98,17 +102,11 @@ fun isHyperOSVersion(code: Float): Boolean = getHyperOSVersion() == code * @param code 传入的 HyperOS 版本 Float 数值 * @return 一个 Boolean 值 */ -fun isMoreHyperOSVersion(code: Float): Boolean = getHyperOSVersion() >= code - - -private val mSupportMiuiVersion: List = mutableListOf(13.0f, 14.0f, 816.0f, 818.0f) -private val mSupportHyperOsVersion: List = mutableListOf(-1.0f, 1.0f, 2.0f) -private val mSupportAndroidVersion: List = mutableListOf(33, 34, 35) - +fun isMoreHyperOSVersion(code: Float): Boolean = hyperOSSDK >= code fun isFullSupport(): Boolean { - val isMiuiVersionSupport = mSupportMiuiVersion.contains(getMiuiVersion()) - val isHyperOsVersionSupport = mSupportHyperOsVersion.contains(getHyperOSVersion()) - val isAndroidVersionSupport = mSupportAndroidVersion.contains(getAndroidVersion()) + val isMiuiVersionSupport = mSupportMiuiVersion.contains(miuiSDK) + val isHyperOsVersionSupport = mSupportHyperOsVersion.contains(hyperOSSDK) + val isAndroidVersionSupport = mSupportAndroidVersion.contains(androidSDK) return isMiuiVersionSupport && isHyperOsVersionSupport && isAndroidVersionSupport } \ No newline at end of file diff --git a/app/src/main/res/values-ar-rSA/strings.xml b/app/src/main/res/values-ar-rSA/strings.xml index 92cc98cacf..cf3c363bb9 100644 --- a/app/src/main/res/values-ar-rSA/strings.xml +++ b/app/src/main/res/values-ar-rSA/strings.xml @@ -904,8 +904,8 @@ مركز التحكم بطاقة بطاقة إشعار الوسائط - مغناطيس - الإشعارات + مغناطيس + الإشعارات شفافية الخلفية للبطاقة %1$s مفعل %1$s غير مفعل diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index e5dc22b7e6..d0a904f7fc 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -775,8 +775,8 @@ aplicaciones del sistema Este es un largo texto que será salida en forma de desplazamiento Centro de control Tarjeta - Pegatinas - Notificación + Pegatinas + Notificación Transparencia del fondo de tarjeta %1$s está activado %1$s está desactivado diff --git a/app/src/main/res/values-in-rID/strings.xml b/app/src/main/res/values-in-rID/strings.xml index 94d3a08e41..e1357a0df8 100644 --- a/app/src/main/res/values-in-rID/strings.xml +++ b/app/src/main/res/values-in-rID/strings.xml @@ -753,8 +753,8 @@ Pusat kendali Kartu Kartu Pemberitahuan Media - magnet - Pemberitahuan + magnet + Pemberitahuan Transparansi latar belakang kartu %1$s aktif %1$s tidak aktif diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index 0e3f2dd233..d1e8e63dcb 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -746,8 +746,8 @@ Centro di Controllo Scheda Scheda Notifiche Media - Magnet - Notifica + Magnet + Notifica Trasparenza sfondo carta %1$s è attivo %1$s è spento diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index ffa8a80532..4fa5eeb050 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -885,8 +885,8 @@ コントロールセンター カード メディア通知カード - 便利ツール - 通知 + 便利ツール + 通知 カード背景の透明度 %1$s はオンです %1$s はオフです diff --git a/app/src/main/res/values-pl-rPL/strings.xml b/app/src/main/res/values-pl-rPL/strings.xml index 98e23ebf5f..d3ca0a8f64 100644 --- a/app/src/main/res/values-pl-rPL/strings.xml +++ b/app/src/main/res/values-pl-rPL/strings.xml @@ -904,8 +904,8 @@ Centrum sterowania Karta Karta powiadomienia multimedialnego - Magnet - Powiadomienie + Magnet + Powiadomienie Przezroczystość tła karty %1$s jest wł. %1$s jest wył. diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 9b3b358677..2d2767d26b 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -904,8 +904,8 @@ Centro de controle Cartão Cartão de notificação de mídia - Magnético - Notificação + Magnético + Notificação Transparência do fundo do cartão %1$s está ativado %1$s está desativado diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index c068ca01d9..56a3b54d47 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -904,8 +904,8 @@ Центр управления Карта Карточка мультимедийного уведомления - Магнит - Уведомления + Магнит + Уведомления Прозрачность фона карты %1$s вкл. %1$s выкл. diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml index f379317211..ef5293cf07 100644 --- a/app/src/main/res/values-tr-rTR/strings.xml +++ b/app/src/main/res/values-tr-rTR/strings.xml @@ -773,8 +773,8 @@ Bu, kaydırma biçiminde çıktısı alınacak uzun bir metin parçasıdır Kontrol merkezi Kart - Mıknatıs - Bildirim + Mıknatıs + Bildirim Kart arka plan saydamlığı %1$s açık %1$s kapalı diff --git a/app/src/main/res/values-vi-rVN/strings.xml b/app/src/main/res/values-vi-rVN/strings.xml index b20e2c7dec..691c417ada 100644 --- a/app/src/main/res/values-vi-rVN/strings.xml +++ b/app/src/main/res/values-vi-rVN/strings.xml @@ -906,8 +906,8 @@ Chức năng này là chức năng thử nghiệm có độ ổn định caoTrung tâm điều khiển Độ trong suốt nền thẻ bổ sung Thẻ thông báo phương tiện - Bảng điều khiển - Thông báo + Bảng điều khiển + Thông báo Độ trong suốt nền thẻ bổ sung %1$s đang bật %1$s đang tắt diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 8d934a9bc4..63d176aa94 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -972,8 +972,8 @@ 通知与控制中心 卡片 媒体通知卡片 - 磁贴 - 通知 + 磁贴 + 通知中心 卡片背景透明度 %1$s已开启 %1$s已关闭 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 35c8198475..36b1f81a8d 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -800,8 +800,8 @@ 通知與控制中心 卡片 媒體通知卡片 - 磁貼 - 通知 + 磁貼 + 通知中心 卡片背景透明度 %1$s已開啟 %1$s已關閉 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index adfc0b1935..dd66500b6a 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -904,8 +904,8 @@ 通知與控制中心 卡片 媒體通知卡片 - 磁貼 - 通知 + 磁貼 + 通知中心 卡片背景透明度 %1$s已開啟 %1$s已關閉 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 38f897f460..cbacabdf79 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -972,8 +972,8 @@ Control center Card Media notification card - Magnet - Notification + Magnet + Notification center Card background transparency %1$s is on %1$s is off diff --git a/app/src/main/res/xml/system_ui_control_center.xml b/app/src/main/res/xml/system_ui_control_center.xml index 5ecf00f2f8..2aac7d4cba 100644 --- a/app/src/main/res/xml/system_ui_control_center.xml +++ b/app/src/main/res/xml/system_ui_control_center.xml @@ -44,7 +44,7 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file