Skip to content

Commit

Permalink
Add no fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
shatyuka committed Apr 6, 2024
1 parent 4794f6b commit 74c640b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/shatyuka/zhiliao/Hooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.shatyuka.zhiliao.hooks.NavButton;
import com.shatyuka.zhiliao.hooks.NavRes;
import com.shatyuka.zhiliao.hooks.NextAnswer;
import com.shatyuka.zhiliao.hooks.FullScreen;
import com.shatyuka.zhiliao.hooks.RedDot;
import com.shatyuka.zhiliao.hooks.SearchAd;
import com.shatyuka.zhiliao.hooks.ShareAd;
Expand Down Expand Up @@ -66,6 +67,7 @@ public class Hooks {
new HeadZoneBanner(),
new MineHybridView(),
new FollowButton(),
new FullScreen(),
};

public static void init(final ClassLoader classLoader) {
Expand Down
37 changes: 37 additions & 0 deletions app/src/main/java/com/shatyuka/zhiliao/hooks/FullScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.shatyuka.zhiliao.hooks;

import com.shatyuka.zhiliao.Helper;

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

public class FullScreen implements IHook {
static Class<?> ClearScreenHelper_lambda;

@Override
public String getName() {
return "禁止进入全屏模式";
}

@Override
public void init(ClassLoader classLoader) throws Throwable {
try {
ClearScreenHelper_lambda = classLoader.loadClass("com.zhihu.android.feature.short_container_feature.ui.widget.toolbar.clearscreen.d$c");
} catch (ClassNotFoundException ignored) {
}
}

@Override
public void hook() throws Throwable {
if (ClearScreenHelper_lambda != null) {
XposedHelpers.findAndHookMethod(ClearScreenHelper_lambda, "invoke", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) {
if (Helper.prefs.getBoolean("switch_fullscreen", false)) {
param.setResult(null);
}
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
setIcon.invoke(findPreference.invoke(thisObject, "switch_colormode"), Helper.modRes.getDrawable(R.drawable.ic_color));
setIcon.invoke(switch_tag, Helper.modRes.getDrawable(R.drawable.ic_label));
setIcon.invoke(findPreference.invoke(thisObject, "switch_statusbar"), Helper.modRes.getDrawable(R.drawable.ic_fullscreen));
setIcon.invoke(findPreference.invoke(thisObject, "switch_fullscreen"), Helper.modRes.getDrawable(R.drawable.ic_fullscreen_exit));
setIcon.invoke(switch_thirdpartylogin, Helper.modRes.getDrawable(R.drawable.ic_login));
setIcon.invoke(switch_livebutton, Helper.modRes.getDrawable(R.drawable.ic_live_tv));
setIcon.invoke(switch_reddot, Helper.modRes.getDrawable(R.drawable.ic_mark_chat_unread));
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/drawable/ic_fullscreen_exit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#808080" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="@android:color/white" android:pathData="M5,16h3v3h2v-5L5,14v2zM8,8L5,8v2h5L10,5L8,5v3zM14,19h2v-3h3v-2h-5v5zM16,8L16,5h-2v5h5L19,8h-3z"/>
</vector>
6 changes: 6 additions & 0 deletions app/src/main/res/xml/preferences_zhihu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@
android:key="switch_statusbar"
android:title="状态栏沉浸"
android:summary="沉浸式状态栏"/>
<com.zhihu.android.app.ui.widget.SwitchPreference
android:defaultValue="false"
android:dependency="switch_mainswitch"
android:key="switch_fullscreen"
android:title="禁止进入全屏模式"
android:summary="看看时间"/>
<com.zhihu.android.app.ui.widget.SwitchPreference
android:defaultValue="false"
android:dependency="switch_mainswitch"
Expand Down
6 changes: 6 additions & 0 deletions app/src/test/java/com/shatyuka/zhiliao/HookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.shatyuka.zhiliao.hooks.FeedAd;
import com.shatyuka.zhiliao.hooks.FeedTopHotBanner;
import com.shatyuka.zhiliao.hooks.FollowButton;
import com.shatyuka.zhiliao.hooks.FullScreen;
import com.shatyuka.zhiliao.hooks.HeadZoneBanner;
import com.shatyuka.zhiliao.hooks.Horizontal;
import com.shatyuka.zhiliao.hooks.HotBanner;
Expand Down Expand Up @@ -206,4 +207,9 @@ public void mineHybridViewTest() {
public void followButtonTest() {
checkHook(new FollowButton());
}

@Test
public void fullScreen() {
checkHook(new FullScreen());
}
}

0 comments on commit 74c640b

Please sign in to comment.