Skip to content

Commit

Permalink
1、跟随系统夜间模式
Browse files Browse the repository at this point in the history
2、修复高版本底部Tab变成发现/播客
3、修复推送
4、修复高版本播放页面黑胶无法隐藏
5、修复高版本广告拦截造成的阻塞
  • Loading branch information
nining377 committed Dec 3, 2021
1 parent 959c6ea commit 8b9bb04
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 18 deletions.
15 changes: 3 additions & 12 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/src/main/java/com/raincat/dolby_beta/Hook.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.raincat.dolby_beta.hook.HideTabHook;
import com.raincat.dolby_beta.hook.InternalDialogHook;
import com.raincat.dolby_beta.hook.MagiskFixHook;
import com.raincat.dolby_beta.hook.NightModeHook;
import com.raincat.dolby_beta.hook.PlayerActivityHook;
import com.raincat.dolby_beta.hook.ProxyHook;
import com.raincat.dolby_beta.hook.SettingHook;
Expand Down Expand Up @@ -106,6 +107,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
new EAPIHook(context);
//下载MD5校验
new DownloadMD5Hook(context);
//夜间模式
new NightModeHook(context, versionCode);
//精简tab
new HideTabHook(context, versionCode);
//精简侧边栏
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ public static Class<?> getClazz(Context context) {
try {
Pattern pattern = Pattern.compile("^com\\.netease\\.cloudmusic\\.module\\.[a-z]\\.[a-z]$");
Pattern pattern2 = Pattern.compile("^com\\.netease\\.cloudmusic\\.[a-z0-9]{1,2}\\.[a-z]\\.[a-z]$");
Pattern pattern3 = Pattern.compile("^com\\.netease\\.cloudmusic\\.module\\.main\\.[a-z]$");
List<String> list = ClassHelper.getFilteredClasses(pattern, Collections.reverseOrder());
list.addAll(ClassHelper.getFilteredClasses(pattern2, Collections.reverseOrder()));
list.addAll(ClassHelper.getFilteredClasses(pattern3, Collections.reverseOrder()));
clazz = Stream.of(list)
.map(s -> findClass(s, classLoader))
.filter(c -> Modifier.isPublic(c.getModifiers()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import android.content.Context;
import android.content.Intent;
import android.os.Build;

import com.raincat.dolby_beta.Hook;
import de.robv.android.xposed.XposedBridge;

/**
* <pre>
Expand All @@ -19,7 +20,7 @@ public class MessageHelper {
public static void sendNotification(Context context, int code) {
if (!SettingHelper.getInstance().isEnable(SettingHelper.warn_key))
return;
Intent intent = new Intent(Hook.msg_send_notification);
Intent intent = new Intent();
intent.putExtra("title", "错误");
switch (code) {
case cookieClassNotFoundCode:
Expand All @@ -43,7 +44,11 @@ public static void sendNotification(Context context, int code) {
intent.putExtra("message", sidebarClassNotFoundMessage);
break;
}
context.sendBroadcast(intent);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
NotificationHelper.getInstance(context).sendUnLockNotification(context, intent.getIntExtra("code", 0x10),
intent.getStringExtra("title"), intent.getStringExtra("title"), intent.getStringExtra("message"));
XposedBridge.log(intent.getStringExtra("title") + ":" + intent.getStringExtra("message"));
}

private final static String normalMessage = "请确保已使用官方版网易云。";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public class SettingHelper {
public static final String beauty_key = "β_beauty_key";
public static final String beauty_title = "美化设置";

public static final String beauty_night_mode_key = "β_beauty_night_mode_key";
public static final String beauty_night_mode_title = "跟随系统切换夜间模式";
public static final String beauty_night_mode_sub = "自动根据系统深色模式状态切换夜间/日间模式";

public static final String beauty_tab_hide_key = "β_beauty_tab_hide_key";
public static final String beauty_tab_hide_title = "精简Tab";
public static final String beauty_tab_hide_sub = "首页仅保留“我的”与“发现”,并默认显示“我的";
Expand Down Expand Up @@ -162,6 +166,7 @@ public void refreshSetting(Context context) {
settingMap.put(proxy_flac_key, sharedPreferences.getBoolean(proxy_flac_key, false));
settingMap.put(proxy_gray_key, sharedPreferences.getBoolean(proxy_gray_key, false));

settingMap.put(beauty_night_mode_key, sharedPreferences.getBoolean(beauty_night_mode_key, false));
settingMap.put(beauty_tab_hide_key, sharedPreferences.getBoolean(beauty_tab_hide_key, false));
settingMap.put(beauty_bubble_hide_key, sharedPreferences.getBoolean(beauty_bubble_hide_key, false));
settingMap.put(beauty_banner_hide_key, sharedPreferences.getBoolean(beauty_banner_hide_key, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Field url = urlObj.getClass().getDeclaredField(urlFieldString);
boolean urlAccessible = url.isAccessible();
url.setAccessible(true);
url.set(urlObj, "https://33.123.21.14/");
url.set(urlObj, "https://999.0.0.1/");
url.setAccessible(urlAccessible);
param.args[0] = request;
}
Expand Down
84 changes: 84 additions & 0 deletions app/src/main/java/com/raincat/dolby_beta/hook/NightModeHook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.raincat.dolby_beta.hook;

import android.content.Context;
import android.content.res.Configuration;
import android.util.Pair;

import com.raincat.dolby_beta.helper.SettingHelper;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;

import static de.robv.android.xposed.XposedHelpers.findClass;

/**
* <pre>
* author : RainCat
* e-mail : [email protected]
* time : 2021/12/03
* desc : 夜间模式
* version: 1.0
* </pre>
*/

public class NightModeHook {
private String resourceRouterInstanceMethodString = "getInstance";
private String resourceRouterIsNightThemeMethodString = "isNightTheme";
private String themeAgentInstanceMethodString = "getInstance";
private String themeAgentSwitchTheme = "switchTheme";

public NightModeHook(Context context, int versionCode) {
if (!SettingHelper.getInstance().isEnable(SettingHelper.beauty_night_mode_key))
return;
Class<?> superActivityClass = findClass("com.netease.cloudmusic.activity.MainActivity", context.getClassLoader());
while (superActivityClass != null && !superActivityClass.getName().contains("AppCompatActivity"))
superActivityClass = superActivityClass.getSuperclass();

String resourceRouterClassString = "com.netease.cloudmusic.theme.core.ResourceRouter";
String themeAgentClassString = "com.netease.cloudmusic.theme.core.ThemeAgent";
String themeConfigClassString = "com.netease.cloudmusic.theme.core.ThemeConfig";
String themeInfoClassString = "com.netease.cloudmusic.theme.core.ThemeInfo";

if (versionCode == 110) {
resourceRouterClassString = "com.netease.cloudmusic.theme.core.b";
themeAgentClassString = "com.netease.cloudmusic.theme.core.c";
themeConfigClassString = "com.netease.cloudmusic.theme.core.f";
resourceRouterInstanceMethodString = "a";
resourceRouterIsNightThemeMethodString = "d";
themeAgentInstanceMethodString = "a";
themeAgentSwitchTheme = "a";
}

final Class<?> resourceRouterClass = XposedHelpers.findClassIfExists(resourceRouterClassString, context.getClassLoader());
final Class<?> themeAgentClass = XposedHelpers.findClassIfExists(themeAgentClassString, context.getClassLoader());
final Class<?> themeConfigClass = XposedHelpers.findClassIfExists(themeConfigClassString, context.getClassLoader());
final Class<?> themeInfoClass = XposedHelpers.findClassIfExists(themeInfoClassString, context.getClassLoader());

XposedHelpers.findAndHookMethod(superActivityClass, "onStart", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Context c = (Context) param.thisObject;
Object resourceRouter = XposedHelpers.callStaticMethod(resourceRouterClass, resourceRouterInstanceMethodString);
boolean isNight = (boolean) XposedHelpers.callMethod(resourceRouter, resourceRouterIsNightThemeMethodString);
int nightModeFlags = c.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
if (nightModeFlags == Configuration.UI_MODE_NIGHT_YES && !isNight) {
Object themeAgent = XposedHelpers.callStaticMethod(themeAgentClass, themeAgentInstanceMethodString);
Object themeInfo = XposedHelpers.newInstance(themeInfoClass, -3);
XposedHelpers.callMethod(themeAgent, themeAgentSwitchTheme, c, themeInfo, true);
} else if (nightModeFlags == Configuration.UI_MODE_NIGHT_NO && isNight) {
Object themeAgent = XposedHelpers.callStaticMethod(themeAgentClass, themeAgentInstanceMethodString);
if (versionCode == 110) {
int prevThemeInfo = (int) XposedHelpers.callStaticMethod(themeConfigClass, "m");
Object themeInfo = XposedHelpers.newInstance(themeInfoClass, prevThemeInfo);
XposedHelpers.callMethod(themeAgent, themeAgentSwitchTheme, c, themeInfo, true);
} else {
Pair<Integer, Boolean> prevThemeInfo = (Pair<Integer, Boolean>) XposedHelpers.callStaticMethod(themeConfigClass, "getPrevThemeInfo");
Object themeInfo = XposedHelpers.newInstance(themeInfoClass, prevThemeInfo.first);
XposedHelpers.callMethod(themeAgent, themeAgentSwitchTheme, c, themeInfo, true);
}
}
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import de.robv.android.xposed.XposedHelpers;



/**
* <pre>
* author : RainCat
Expand Down Expand Up @@ -62,7 +61,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
View coverView = null, imageView = null;
RelativeLayout rotationRelativeLayout = (RelativeLayout) playerDiscViewFlipper.getChildAt(i);
for (int j = 0; j < rotationRelativeLayout.getChildCount(); j++) {
if (rotationRelativeLayout.getChildAt(j).getClass().getName().contains("ImageView"))
if (rotationRelativeLayout.getChildAt(j).getClass().getName().contains("ImageView")
&& rotationRelativeLayout.getChildAt(j).getClass().getName().contains("android"))
coverView = rotationRelativeLayout.getChildAt(j);
else {
imageView = rotationRelativeLayout.getChildAt(j);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.raincat.dolby_beta.view.beauty.BeautyBubbleHideView;
import com.raincat.dolby_beta.view.beauty.BeautyCommentHotView;
import com.raincat.dolby_beta.view.beauty.BeautyKSongHideView;
import com.raincat.dolby_beta.view.beauty.BeautyNightModeView;
import com.raincat.dolby_beta.view.beauty.BeautyRotationView;
import com.raincat.dolby_beta.view.beauty.BeautySidebarHideItem;
import com.raincat.dolby_beta.view.beauty.BeautySidebarHideView;
Expand Down Expand Up @@ -299,6 +300,7 @@ private void showBeautyDialog(final Context context) {
dialogBeautyRoot = new BaseDialogItem(context);
dialogBeautyRoot.setOrientation(LinearLayout.VERTICAL);
dialogBeautyRoot.addView(new BeautyTitleView(context));
dialogBeautyRoot.addView(new BeautyNightModeView(context));
dialogBeautyRoot.addView(new BeautyTabHideView(context));
dialogBeautyRoot.addView(new BeautyBannerHideView(context));
dialogBeautyRoot.addView(new BeautyBubbleHideView(context));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.raincat.dolby_beta.view.beauty;

import android.content.Context;
import android.util.AttributeSet;

import com.raincat.dolby_beta.helper.SettingHelper;
import com.raincat.dolby_beta.view.BaseDialogItem;

/**
* <pre>
* author : RainCat
* e-mail : [email protected]
* time : 2021/12/03
* desc : 夜间模式
* version: 1.0
* </pre>
*/

public class BeautyNightModeView extends BaseDialogItem {
public BeautyNightModeView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

public BeautyNightModeView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public BeautyNightModeView(Context context) {
super(context);
}

@Override
public void init(Context context, AttributeSet attrs) {
super.init(context, attrs);
title = SettingHelper.beauty_night_mode_title;
sub = SettingHelper.beauty_night_mode_sub;
key = SettingHelper.beauty_night_mode_key;
setData(true, SettingHelper.getInstance().getSetting(key));

setOnClickListener(view -> {
SettingHelper.getInstance().setSetting(key, !checkBox.isChecked());
sendBroadcast(SettingHelper.refresh_setting);
});
}
}

0 comments on commit 8b9bb04

Please sign in to comment.