Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
新增: 系统界面-其他-原生关机菜单
Browse files Browse the repository at this point in the history
  • Loading branch information
xing0meng committed Jun 2, 2024
1 parent ee106c5 commit 51e0b96
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
import android.content.pm.PackageManager;
import android.view.View;

import androidx.annotation.NonNull;

import com.sevtinge.hyperceiler.R;
import com.sevtinge.hyperceiler.ui.base.BaseSettingsActivity;
import com.sevtinge.hyperceiler.ui.fragment.base.SettingsPreferenceFragment;

import moralnorm.preference.DropDownPreference;
import moralnorm.preference.Preference;
import moralnorm.preference.PreferenceCategory;
import moralnorm.preference.SwitchPreference;

Expand All @@ -43,6 +46,7 @@ public class SystemUIOtherSettings extends SettingsPreferenceFragment {
SwitchPreference mMiuiMultiWinSwitchRemove;
SwitchPreference mBottomBar;
SwitchPreference mVolume;
SwitchPreference mPower;
SwitchPreference mDisableBluetoothRestrict; // 禁用蓝牙临时关闭
SwitchPreference mPctUseBlur;

Expand All @@ -54,8 +58,8 @@ public int getContentResId() {
@Override
public View.OnClickListener addRestartListener() {
return view -> ((BaseSettingsActivity) getActivity()).showRestartDialog(
getResources().getString(R.string.system_ui),
"com.android.systemui"
getResources().getString(R.string.system_ui),
"com.android.systemui"
);
}

Expand All @@ -68,6 +72,7 @@ public void initPrefs() {
mMiuiMultiWinSwitchRemove = findPreference("prefs_key_system_ui_remove_miui_multi_win_switch");
mBottomBar = findPreference("prefs_key_system_ui_disable_bottombar");
mVolume = findPreference("prefs_key_system_ui_disable_volume");
mPower = findPreference("prefs_key_system_ui_disable_power");
mPctUseBlur = findPreference("prefs_key_system_showpct_use_blur");

mChargeAnimationTitle.setVisible(!isMoreHyperOSVersion(1f));
Expand All @@ -80,19 +85,38 @@ public void initPrefs() {
mVolume.setOnPreferenceChangeListener(
(preference, o) -> {
ComponentName componentName = new ComponentName("miui.systemui.plugin",
"miui.systemui.volume.VolumeDialogPlugin");
"miui.systemui.volume.VolumeDialogPlugin");
PackageManager packageManager = getContext().getPackageManager();
if ((boolean) o) {
packageManager.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
} else {
packageManager.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
}
return true;
}
);

mPower.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(@NonNull Preference preference, Object o) {
ComponentName componentName = new ComponentName("miui.systemui.plugin",
"miui.systemui.globalactions.GlobalActionsPlugin");
PackageManager packageManager = getContext().getPackageManager();
if ((boolean) o) {
packageManager.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
} else {
packageManager.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
}
return true;
}
});
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,8 @@

<string name="system_ui_other_title">其他</string>
<string name="system_ui_disable_volume">原生音量条</string>
<string name="system_ui_disable_power">原生关机菜单</string>
<string name="system_ui_disable_power_desc">MIUI 为旧版菜单,Hyper 为原生菜单</string>
<string name="system_ui_disable_volume_desc">针对 MIUI/HyperOS 音量条的修改无法作用于原生音量条</string>
<string name="system_ui_unlock_clipboard">解锁原生剪切板编辑器</string>
<string name="system_ui_unlock_clipboard_desc">实验性功能,会导致 MIUI/HyperOS 的编辑器一并弹出</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@

<string name="system_ui_other_title">Other</string>
<string name="system_ui_disable_volume">Native volume bar</string>
<string name="system_ui_disable_power">Native shutdown menu</string>
<string name="system_ui_disable_power_desc">MIUI is the old menu, and Hyper is the native menu</string>
<string name="system_ui_disable_volume_desc">The modification of Xiaomi\'s volume bar does not apply to the native volume bar</string>
<string name="system_ui_unlock_clipboard">Unlock the AOSP clipboard editor</string>
<string name="system_ui_unlock_clipboard_desc">After unlocking, it will pop up together with the MIUI/HyperOS editor.</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/system_ui_other.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
android:summary="@string/system_ui_disable_volume_desc"
android:title="@string/system_ui_disable_volume" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_ui_disable_power"
android:summary="@string/system_ui_disable_power_desc"
android:title="@string/system_ui_disable_power" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_ui_unlock_clipboard"
Expand Down

0 comments on commit 51e0b96

Please sign in to comment.