Skip to content

Commit

Permalink
## 3.46.22
Browse files Browse the repository at this point in the history
- 增加 未激活时重启APP
- 适配 Android SDK 32
- 升级 Android SDK为32
- 修复 无法读取扩展列表
- 优化 增加歌词左右位置
- 优化 隐藏图标时去除间隔
- 优化 代码
---
- Added restart APP when inactive
- Adapt to Android SDK 32
- Upgrade Android SDK to 32
- Fixed unable to read the extension list
- Optimized to increase the left and right position of lyrics
- Optimized to remove the interval when hiding icons
- Optimize the code
  • Loading branch information
xiaowine authored Dec 31, 2021
2 parents ee08436 + 51f7f06 commit 029faa2
Show file tree
Hide file tree
Showing 15 changed files with 226 additions and 208 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ plugins {
}

android {
compileSdkVersion 30
compileSdkVersion 32
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "miui.statusbar.lyric"
minSdkVersion 26
//noinspection OldTargetApi
targetSdkVersion 29
versionCode 75
versionName "3.44.22"
targetSdkVersion 32
versionCode 77
versionName "3.46.22"
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage"/>
<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission"/>
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/AppName"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.SwitchPreference;
import android.provider.Settings;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.byyang.choose.ChooseFileUtils;
import com.microsoft.appcenter.AppCenter;
import com.microsoft.appcenter.analytics.Analytics;
Expand Down Expand Up @@ -55,16 +52,20 @@ protected void onCreate(Bundle savedInstanceState) {
addPreferencesFromResource(R.xml.root_preferences);
try {
config = new Config(ConfigUtils.getSP(activity, "Lyric_Config"));
setTitle(String.format("%s (%s)", getString(R.string.AppName), getString(R.string.SPConfigMode)));
setTitle(getString(R.string.AppName));
init();
} catch (SecurityException ignored) {
new AlertDialog.Builder(activity)
.setTitle(getString(R.string.Tips))
.setIcon(R.mipmap.ic_launcher)
.setMessage(getString(R.string.NotSupport))
.setPositiveButton(getString(R.string.Quit), (dialog, which) -> {
activity.finish();
System.exit(0);
.setPositiveButton(getString(R.string.ReStart), (dialog, which) -> {
final Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

//杀掉以前进程
android.os.Process.killProcess(android.os.Process.myPid());
})
.setCancelable(false)
.create()
Expand All @@ -75,7 +76,6 @@ protected void onCreate(Bundle savedInstanceState) {

@SuppressWarnings("deprecation")
public void init() {
ActivityUtils.checkPermissions(activity, config);
String tips = "Tips1";
SharedPreferences preferences = activity.getSharedPreferences(tips, MODE_PRIVATE);
if (!preferences.getBoolean(tips, false)) {
Expand Down Expand Up @@ -364,43 +364,6 @@ public void init() {
return true;
});

// 图标路径
Preference iconPath = findPreference("iconPath");
assert iconPath != null;
iconPath.setSummary(config.getIconPath());
if (config.getIconPath().equals(Utils.PATH)) {
iconPath.setSummary(getString(R.string.DefaultPath));
}
iconPath.setOnPreferenceClickListener(((preference) -> {
new AlertDialog.Builder(activity)
.setTitle(getString(R.string.IconPath))
.setNegativeButton(getString(R.string.RestoreDefaultPath), (dialog, which) -> {
iconPath.setSummary(getString(R.string.DefaultPath));
config.setIconPath(Utils.PATH);
ActivityUtils.initIcon(activity, config);
})
.setPositiveButton(getString(R.string.NewPath), (dialog, which) -> {
ChooseFileUtils chooseFileUtils = new ChooseFileUtils(activity);
chooseFileUtils.chooseFolder(new ChooseFileUtils.ChooseListener() {
@Override
public void onSuccess(String filePath, Uri uri, Intent intent) {
super.onSuccess(filePath, uri, intent);
config.setIconPath(filePath);
iconPath.setSummary(filePath);
if (config.getIconPath().equals(Utils.PATH)) {
iconPath.setSummary(getString(R.string.DefaultPath));
}
ActivityUtils.initIcon(activity, config);
}
});
})
.create()
.show();


return true;
}));


// 图标上下位置
EditTextPreference iconPosition = (EditTextPreference) findPreference("IconPosition");
Expand Down Expand Up @@ -619,43 +582,6 @@ public void onSuccess(String filePath, Uri uri, Intent intent) {
activity.registerReceiver(new HookReceiver(), HookSure);
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (config == null) {
config = ConfigUtils.getConfig(getApplicationContext());
}
if (grantResults[0] == 0) {
ActivityUtils.init();
ActivityUtils.initIcon(activity, config);
} else {
new AlertDialog.Builder(activity)
.setTitle(getString(R.string.GetStorageFailed))
.setMessage(getString(R.string.GetStorageFaildTips))
.setNegativeButton(getString(R.string.ReAppy), (dialog, which) -> ActivityUtils.checkPermissions(activity, config))
.setPositiveButton(getString(R.string.Quit), (dialog, which) -> finish())
.setNeutralButton(getString(R.string.GetPermission), (dialog, which) -> {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
.setData(Uri.fromParts("package", getPackageName(), null));
startActivityForResult(intent, 13131);
})
.setCancelable(false)
.create()
.show();
}

}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 13131) {
if (config == null) {
config = ConfigUtils.getConfig(getApplicationContext());
}
ActivityUtils.checkPermissions(activity, config);
}
}

public class HookReceiver extends BroadcastReceiver {
@Override
Expand Down
117 changes: 117 additions & 0 deletions app/src/main/java/miui/statusbar/lyric/config/IconConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package miui.statusbar.lyric.config;

import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import de.robv.android.xposed.XSharedPreferences;
import miui.statusbar.lyric.utils.ConfigUtils;

@SuppressLint("LongLogTag")
public class IconConfig {
private static final String KuGou = "UklGRmwCAABXRUJQVlA4WAoAAAAQAAAAHwAAHwAAQUxQSCACAAABP+SgbSRJOqdmH/6U745DROTHN8wEJcz/Mk3ndE7u3Hvgkg1ZXq67WLkYxfL4baNwgsQAEmzbNu3oxLZtm1Wx7ZQrtm07q99X76cHEf1n4LZtnBjemaTG6uwR4kBC9ejc/vn5/txodaL4gJyhCxy4HszyuorovsMDd90RTmbMG2Jul2cmJ2eWbw0R8xkOFhxpIRttpWFaRVhpy7rWcVRgMfsMeOiIEwdiOx6As2zRiFoEdsrEAyXbwGKUltAF7OaI+AcFBphP/INEcneALhHJVgs9qevAbz9meiI0s8Zmf40Elj7BnXo0oFZpF5Gwv7AUKSKFqv6+VqRd9RuQ+HPYihaR6FWYDRapVF/polwL2YLz+BpV2iYKifsw7id1d3BaJBptKrdmFO4MGelX0C8Nr3CQY1CKlMTROVgJ0Sry36C55Bk2U0xKyArM7cOMaBQDjX9gO0lszMC+ypwUjQoVY4fQ66BMwLmKCdGoh+fhE/jt7xGOm+9wV6a+/Ue3I/SNSlk2UjrhMiXvGl6bLBopqtGtbuQ/BnupUvsJj1UGzUb2vgRPw1qMSCtwk6Np7ou9r+H/4L/2pVqG42QRa19tX0StvTOl1Qb85IWFWLF8YfvKPyElzbChhKYlp2QGSZnlK9uXnsjZBcOXvvq6TJnP8rU9F7Guqzj3XIg1V+st9ly1bWgdjrmSr8+lfH2uFbIGr11Xl33Z4gMSXf+VBJcaVlA4ICYAAADQAgCdASogACAAP/3+/3+/uzayKAgD8D+JaQAAPaOgAP7lagAAAA==";
private static final String KuWo = "UklGRjYCAABXRUJQVlA4WAoAAAAQAAAAHwAAHwAAQUxQSOoBAAABN+WwbdtAesr9+/1nvrufISLy4ygimlzy2PFKRr+c7xgbWrEQFxKFYse/ueeVPJZXhjzyCpAgSbZpW/1s27ZtW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23D4VSwvIJuOcsF8415xOeguz6i2IfdUbLYJrJciNk6VkIO0StI2oRWRbc8B9X+j97gUHUj4V/4oZv7kZVmGtI16JWXDbqds/dy2X92mvW1v67HgDbzKiuQBlqEbz3dUUc6ZbqNWqT0MIm97fvvjRQ+ZC8gRjsPSiHYbOHOAon7YYOAmiBbErr4BFFug28aocor+ylkMrsouzB2B664sIr8DgamK466jcVw5/X6KuN1K/bMb++seUP6qIQP1CjRicnxVlhDuJGHnHd8rlyRa4k/b/leZRbbTaPQfzr5QBnt3gqJn4Yxfr4ntAcFTkmfYprNXDiy+FoEb2G4D";
private static final String QQMusic = "UklGRrgBAABXRUJQVlA4WAoAAAAQAAAAHwAAHwAAQUxQSGsBAAABv+OwbRvBzZVy7tGIiJ/UK6S60rrOC6a7KPl8pkrt/yZlkkh1Vtsz9S424wz1AIi2bRtbdq7fRv79Z9u2bdvc7z/uvefWG0T0fwIgjrS3trS0tkcAIBuGrXv0ieY94K3ewjVN6eMMOlkpy1H/cX0x3+cBnC9cFk2S5Fx5VW0I+jWSk4IpqusQjlKdMnRT32rKUT+iCf0a7ot1wzRXKwc0DyiFGxReAEhRGgXyzxT3AJuiOXg+KT+C61PENMYsGG2i/Ay4smibsuAQOizW120eS7D7P1xEXHZnxyjGRK9/cImyL8mJxc/5bPNxAu2S9UHRqgP6K8FEQvCZgTkpaCy4MTVBumV4d2DcsAFxwjAJBH90XTLc6OoAjOgiFqeaJajnmjaZ71t5qNAEvpUFWT/VNPQphQ0S76uSgjl6S5KNpsg9yY8aSItWSXLFq/jHSPKgFJbxQ5I/3N/nD8nDOP7Q27vzTpLv24MxCAEAVlA4ICYAAADQAgCdASogACAAP/3+/3+/uzayKAgD8D+JaQAAPaOgAP7lagAAAA==";
private static final String MiGu = "UklGRqwAAABXRUJQVlA4TJ8AAAAvIMAHEHdgIG2b+De97Tcx//OvIG0Dpnv+dc7FKoA86CDwPwiHACGSJMlN6/87BEFQBEEQDMVIDMFhRIpGUCR2ZuUPQET/J0B/GHiBcQokwQRoxE14E3ALnU8A3uEKZUCZoLQo4lQ8OlrHhTqaVJ8QBpTY6ImCpSCP+TABiQp7DjlGTei/Ky9YEuosNN7TXNWeK++7rxTvmtyEJ17N/L8A";
private static final String Myplayer = "UklGRqwBAABXRUJQVlA4TJ8BAAAvH8AHEP+ioG0bxuUPehfE/M+/47aRHGkj3fzf5mx3FYUESaTpDRw1QAB/ADwIgsUAAih8obgAC1gAwB8FAAQAMIAfgj8KCHoRgGIAQTGAooABDACCogigKIpi4S4QfLEIiuKC8h1OQIxk27S15tm28f3e+7Zt2z//PK7OjyCi/wzcNlKULB7DzD5Cjr6dbi4sbJ6+yZsfSyVslpY+3PkZhXA0NPpx4SoOkOgv7x+sjiUB4leO7AB072XzoQew41IzD9LDfKNSqc/dS49ZYNfGHdCWTorYLBxLHeDOwncEmtI0jk5JLYh8S9IQElINF6tSEoaSvgLwpElcndAzBL6kRWjpGgvF9Zub9SIWLzWARSkLL0pZWJXFVQs5HUJW7xDXCwBrsrkG4EsDvJ/AuGYB8nIwDxDrACcbsKI6wJYk/f1J0hbAmXywsQD7KgPcSNr//d2XdANEl7b7sGBA//X8Aha8T/y3e4PPAhveDwnOQL/CicGFKIWBd4P/ktERZM3/q3lcGMeVeVz+T1xLu57zwjivjPPSOK//bV0wXlcEAA==";
private static final String Default = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAZdJREFUWEftl69LBEEUxz/3D9hMJvGaQUFRRATFZDAJosEmWiwmg+VsWhS0mQRBg03sGkRQ8C8QQfDXH2AyKV+ZlWHudm9md/YWwQcbdm/e+37u8WbemxrFbRQYAA7zhKrlcbJ8FoBT834GzIfGKwpwAixaoltAIwSiKMAlMOkIKgvKhpeVASBhb4iyAASxB+wCL1mpiAmwDMwBM5bgm9kd2iHvrUBiAiSxDoA1R0wgm8CRC1EGgDRWzDPkCDbtkrIAEl2BqCCnzYcnoNeGKhsg0RoBbs3LFHCV/NApAOlpR6wDlQGMATdAHXisIgPSXAKOq6iB1LOokzXQEuIf4E9loBvoB55Nh/sE7Hkg15/xcdoxXa7PqaJX4MEaSHxiNRVillMPcAEMeo02EBVAY5bSG2JRAa6B8RB1ImfgK1D8A+gK9PlZnpa2c2A2IKAyNhGw/ndpGoDaptqnr63GvhmpZe47A2YazD0w7EvqrmtXuRvAdkbw4JtQKIDW6zzQBVSPRqs7M15pxNJhVMjaZaBQcB/nygG+AXMlQyFw9HwbAAAAAElFTkSuQmCC";
ConfigUtils config;

public IconConfig(XSharedPreferences xSharedPreferences) {
config = new ConfigUtils(xSharedPreferences);
}

public String getIcon(String str) {
String icon;
switch (str) {
case "KuGou":
icon = getKuGou();
break;
case "KuWo":
icon = getKuWo();
break;
case "Netease":
icon = getNetease();
break;
case "QQMusic":
icon = getQQMusic();
break;
case "MiGu":
icon = getMiGu();
break;
case "Myplayer":
icon = getMyplayer();
break;
default:
icon = getDefault();
break;
}
return icon;
}


public void update() {
config.update();
}


private String getKuGou() {
return config.optString("KuGou", KuGou);
}

public void setKuGou(String str) {
config.put("KuGou", str);
}


private String getKuWo() {
return config.optString("KuWo", KuWo);
}

public void setKuWo(String str) {
config.put("KuWo", str);
}


private String getNetease() {
return config.optString("Netease", Netease);
}

public void setNetease(String str) {
config.put("Netease", str);
}


private String getQQMusic() {
return config.optString("QQMusic", QQMusic);
}

public void setQQMusic(String str) {
config.put("QQMusic", str);
}


private String getMiGu() {
return config.optString("MiGu", MiGu);
}

public void setMiGu(String str) {
config.put("MiGu", str);
}


private String getMyplayer() {
return config.optString("Myplayer", Myplayer);
}

public void setMyplayer(String str) {
config.put("Myplayer", str);
}

private String getDefault() {
return config.optString("Default", Default);
}

public void setDefault(String str) {
config.put("Default", str);
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/miui/statusbar/lyric/hook/app/Kugou.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Thr
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Utils.log("酷狗音乐:" + ((HashMap) param.args[0]).values().toArray()[0]);
Utils.sendLyric(AndroidAppHelper.currentApplication(), "" + ((HashMap) param.args[0]).values().toArray()[0], "kugou");
Utils.sendLyric(AndroidAppHelper.currentApplication(), "" + ((HashMap) param.args[0]).values().toArray()[0], "KuGou");
}
});

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/miui/statusbar/lyric/hook/app/Kuwo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
String str = (String) param.args[0];
Utils.log("酷我音乐:" + str);
if (param.args[0] != null && !str.equals("")) {
Utils.sendLyric(AndroidAppHelper.currentApplication(), "" + str, "kuwo");
Utils.sendLyric(AndroidAppHelper.currentApplication(), "" + str, "KuWo");
}
param.setResult(replaceHookedMethod());
}
Expand Down
12 changes: 2 additions & 10 deletions app/src/main/java/miui/statusbar/lyric/hook/app/Myplayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,21 @@ public class Myplayer {
public static class Hook {
public Hook(XC_LoadPackage.LoadPackageParam lpparam) {
XposedHelpers.findAndHookMethod("remix.myplayer.util.p", lpparam.classLoader, "o", Context.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
}

@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
param.setResult(true);
}
});
XposedHelpers.findAndHookMethod("remix.myplayer.service.MusicService", lpparam.classLoader, "n1", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
}


@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Context context = (Context) param.thisObject;
super.afterHookedMethod(param);
Utils.log("myplayer: " + param.args[0].toString());
Utils.sendLyric(context, param.args[0].toString(), "myplayer");
Utils.sendLyric(context, param.args[0].toString(), "Myplayer");
}
});
}
Expand Down
Loading

0 comments on commit 029faa2

Please sign in to comment.