Skip to content

Commit 163d652

Browse files
committed
Add enhancement status check
1 parent 33fbc25 commit 163d652

File tree

5 files changed

+83
-41
lines changed

5 files changed

+83
-41
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package top.trumeet.mipush.xmipushenhance.settings;
1+
package top.trumeet.mipush.settings;
22

33
import android.os.Bundle;
4+
45
import androidx.annotation.Nullable;
56
import androidx.fragment.app.FragmentActivity;
67

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
1-
package top.trumeet.mipush.xmipushenhance.settings;
1+
package top.trumeet.mipush.settings;
22

33
import android.app.AlertDialog;
44
import android.content.SharedPreferences;
5+
import android.os.Build;
56
import android.os.Bundle;
7+
import android.os.SystemProperties;
68
import android.text.Html;
79
import android.util.Log;
810
import android.util.Pair;
911
import android.view.Menu;
1012
import android.view.MenuInflater;
1113
import android.view.MenuItem;
14+
1215
import androidx.annotation.NonNull;
1316
import androidx.annotation.Nullable;
14-
import top.trumeet.mipush.xmipushenhance.R;
15-
import top.trumeet.mipush.xmipushenhance.settings.ini.IniConf;
16-
import top.trumeet.mipush.xmipushenhance.settings.ini.IniConstants;
17-
import top.trumeet.mipush.xmipushenhance.settings.ini.IniHelper;
18-
import moe.shizuku.preference.MultiSelectListPreference;
19-
import moe.shizuku.preference.SimpleMenuPreference;
17+
18+
import org.meowcat.xposed.mipush.R;
19+
import org.meowcat.xposed.mipush.Utils;
2020

2121
import java.io.IOException;
22-
import java.util.*;
22+
import java.util.ArrayList;
23+
import java.util.Collections;
24+
import java.util.Comparator;
25+
import java.util.HashSet;
26+
import java.util.List;
27+
import java.util.Objects;
2328
import java.util.stream.Collectors;
2429
import java.util.stream.Stream;
2530

31+
import moe.shizuku.preference.MultiSelectListPreference;
32+
import moe.shizuku.preference.Preference;
33+
import moe.shizuku.preference.SimpleMenuPreference;
34+
import top.trumeet.mipush.settings.ini.IniConf;
35+
import top.trumeet.mipush.settings.ini.IniConstants;
36+
import top.trumeet.mipush.settings.ini.IniUtils;
37+
38+
import static org.meowcat.xposed.mipush.Constants.TAG;
39+
2640
public class PreferenceFragment extends moe.shizuku.preference.PreferenceFragment implements
2741
SharedPreferences.OnSharedPreferenceChangeListener {
28-
private static final String TAG = "PreferenceFragment";
2942

3043
private IniConf mConf;
3144

@@ -48,11 +61,15 @@ public void onCreate(Bundle savedInstanceState) {
4861
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
4962
getPreferenceManager().setSharedPreferencesName("settings");
5063
addPreferencesFromResource(R.xml.preferences);
64+
Preference device_status = findPreference("device_status");
65+
String status = Utils.isEnhancementEnabled() ? getString(R.string.pref_enhancement_status_success) : getString(R.string.pref_enhancement_status_failed);
66+
status = String.format("%s\n\n%s", status, String.format(getString(R.string.pref_enhancement_status_summary), Build.MANUFACTURER, SystemProperties.get("ro.product.manufacturer", "failed"), SystemProperties.get("ro.product.vendor.manufacturer", "failed"), Build.BRAND, SystemProperties.get("ro.product.brand", "failed"), SystemProperties.get("ro.product.vendor.brand", "failed"), SystemProperties.get("ro.miui.ui.version.name", "failed"), SystemProperties.get("ro.miui.ui.version.code", "failed"), SystemProperties.get("ro.miui.version.code_time", "failed")));
67+
device_status.setSummary(status);
5168
}
5269

5370
/**
5471
* Render the content of ini to preferences.
55-
*
72+
* <p>
5673
* A set of well-known keys will be defined in preferences.xml.
5774
* For non-known keys, we will not show them through UI.
5875
*/
@@ -93,9 +110,9 @@ public void onResume() {
93110
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
94111
Log.d(TAG, "onSharedPreferenceChanged(): " + key);
95112
if (key.equals("module_blacklist") || key.equals("module_whitelist")) {
96-
mConf.putAll(IniHelper.convertKeyToIni(key), new ArrayList<>(sharedPreferences.getStringSet(key, Collections.emptySet())));
113+
mConf.putAll(IniUtils.convertKeyToIni(key), new ArrayList<>(Objects.requireNonNull(sharedPreferences.getStringSet(key, Collections.emptySet()))));
97114
} else {
98-
mConf.put(IniHelper.convertKeyToIni(key), sharedPreferences.getString(key, null));
115+
mConf.put(IniUtils.convertKeyToIni(key), sharedPreferences.getString(key, null));
99116
}
100117

101118
try {
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<string name="app_name">小米推送增强</string>
4-
<string name="xposed_description">小米推送机型伪装插件,如需使用请开启</string>
3+
<string name="app_name">小米推送框架增强</string>
4+
<string name="xposed_description">将设备制造商伪装成 Xiaomi 来启用小米推送服务\n需要安装小米推送相关组件</string>
55

6-
<string name="pref_menu_get_conf_path">查看配置地址</string>
6+
<string name="pref_menu_get_conf_path">查看配置文件路径</string>
77
<string name="pref_cat_module">模块</string>
88
<string name="pref_working_mode">工作模式</string>
9-
<string name="pref_working_mode_summary">决定模块工作模式。请注意:内置黑名单会一直起作用。</string>
9+
<string name="pref_working_mode_summary">决定模块的工作模式\n注意:内建的黑名单将会一直生效</string>
1010
<array name="pref_working_mode_entries">
1111
<item>黑名单</item>
1212
<item>白名单</item>
1313
</array>
1414
<string name="pref_blacklist">黑名单</string>
15-
<string name="pref_blacklist_summary">避免增强的应用</string>
15+
<string name="pref_blacklist_summary">选中的应用将不会生效</string>
1616
<string name="pref_whitelist">白名单</string>
17-
<string name="pref_whitelist_summary">仅增强的应用</string>
17+
<string name="pref_whitelist_summary">仅选中的应用生效</string>
18+
<string name="pref_hide_icon">隐藏图标</string>
19+
<string name="pref_hide_icon_summary">隐藏显示在桌面上的图标,可以在 Xposed 模块列表中打开\n打开后,您可能无法将模块添加到多用户环境中。如果出现问题,请关闭它</string>
20+
<string name="pref_enhancement_status">增强模式状态</string>
21+
<string name="pref_enhancement_status_summary">制造商: %s (%s / %s)\n品牌: %s (%s / %s)\nMIUI 版本名: %s\nMIUI 版本号: %s\nMIUI 版本日期: %s</string>
22+
<string name="pref_enhancement_status_failed">未生效</string>
23+
<string name="pref_enhancement_status_success">已生效</string>
1824
</resources>
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<resources>
2-
<string name="app_name">XMiPushEnhance</string>
3-
<string name="xposed_description">Fake XiaoMi Phone plugin, turn on if you need it.</string>
2+
<string name="app_name">MiPush Framework Enhancement</string>
3+
<string name="xposed_description">Fake equipment manufacturer into Xiaomi to enable mipush\nMiPush components need to be installed</string>
44

5-
<string name="pref_menu_get_conf_path">View Config Path</string>
5+
<string name="pref_menu_get_conf_path">View config file path</string>
66
<string name="pref_cat_module">Module</string>
7-
<string name="pref_working_mode">Working Mode</string>
8-
<string name="pref_working_mode_summary">Determines what apps to hack. Note: A built-in blacklist always applies.</string>
7+
<string name="pref_working_mode">Working mode</string>
8+
<string name="pref_working_mode_summary">Determine the working mode of the module\nNote: the built-in blacklist will always work</string>
99
<array name="pref_working_mode_entries">
1010
<item>Blacklist</item>
1111
<item>Whitelist</item>
@@ -15,7 +15,13 @@
1515
<item>whitelist</item>
1616
</array>
1717
<string name="pref_blacklist">Blacklist</string>
18-
<string name="pref_blacklist_summary">Apps that are never hacked.</string>
18+
<string name="pref_blacklist_summary">The selected apps will not take effect</string>
1919
<string name="pref_whitelist">Whitelist</string>
20-
<string name="pref_whitelist_summary">Only apps that will be hacked.</string>
20+
<string name="pref_whitelist_summary">Only the selected apps take effect</string>
21+
<string name="pref_hide_icon">Hide icon</string>
22+
<string name="pref_hide_icon_summary">Hide the icon displayed on the desktop, can be opened in Xposed modules list\nAfter opening, you may not be able to add module to multi-user environment. If there is a problem, please close it</string>
23+
<string name="pref_enhancement_status">Enhancement status</string>
24+
<string name="pref_enhancement_status_summary">Manufacturer: %s (%s / %s)\nBrand: %s (%s / %s)\nMIUI Version Name: %s\nMIUI Version Code: %s\nMIUI Version Time: %s</string>
25+
<string name="pref_enhancement_status_failed">Disabled</string>
26+
<string name="pref_enhancement_status_success">Enabled</string>
2127
</resources>
Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?><!--suppress AndroidElementNotAllowed -->
22
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
3-
<!-- The keys of preferences are converted to the ini section / options.
4-
Please refer to IniHelper.java for more details.
53

6-
This XML only describes known preferences, which are available through UI.
7-
Any keys that are present in the INI but not the UI will not be shown.
8-
-->
94
<PreferenceCategory
10-
android:title="@string/pref_cat_module">
5+
android:title="@string/pref_cat_module"
6+
android:key="pref_category">
7+
8+
<Preference
9+
android:key="device_status"
10+
android:title="@string/pref_enhancement_status"
11+
android:summary="@string/pref_enhancement_status_failed" />
12+
1113
<SimpleMenuPreference
12-
android:key="module_working_mode"
13-
android:title="@string/pref_working_mode"
14-
android:summary="@string/pref_working_mode_summary"
14+
android:defaultValue="blacklist"
1515
android:entries="@array/pref_working_mode_entries"
1616
android:entryValues="@array/pref_working_mode_entry_values"
17-
android:defaultValue="blacklist" />
17+
android:key="module_working_mode"
18+
android:summary="@string/pref_working_mode_summary"
19+
android:title="@string/pref_working_mode" />
20+
1821
<MultiSelectListPreference
1922
android:key="module_blacklist"
20-
android:title="@string/pref_blacklist"
21-
android:summary="@string/pref_blacklist_summary"/>
23+
android:summary="@string/pref_blacklist_summary"
24+
android:title="@string/pref_blacklist" />
25+
2226
<MultiSelectListPreference
2327
android:key="module_whitelist"
24-
android:title="@string/pref_whitelist"
25-
android:summary="@string/pref_whitelist_summary"/>
28+
android:summary="@string/pref_whitelist_summary"
29+
android:title="@string/pref_whitelist" />
30+
31+
<SwitchPreference
32+
android:key="hide_icon"
33+
android:defaultValue="false"
34+
android:summary="@string/pref_hide_icon_summary"
35+
android:title="@string/pref_hide_icon"/>
36+
2637
</PreferenceCategory>
38+
2739
</PreferenceScreen>

0 commit comments

Comments
 (0)