Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
shatyuka committed Mar 9, 2024
1 parent aef8941 commit 7b83473
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 20 deletions.
3 changes: 1 addition & 2 deletions app/src/main/java/com/shatyuka/zhiliao/Hooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class Hooks {
new FeedTopHotBanner(),
new HeadZoneBanner(),
new MineHybridView(),
new FollowButton()
new FollowButton(),
};

public static void init(final ClassLoader classLoader) {
Expand All @@ -76,7 +76,6 @@ public static void init(final ClassLoader classLoader) {
} catch (Throwable e) {
Helper.toast(hook.getName() + "功能加载失败,可能不支持当前版本知乎: " + Helper.packageInfo.versionName, Toast.LENGTH_LONG);
XposedBridge.log("[Zhiliao] " + e);
XposedBridge.log(e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@
*/
public class FollowButton implements IHook {
static Class<?> followWithAvatarView;

static Class<?> bottomReactionView;

static Class<?> followPeopleButton;

static Class<?> zHAuthorInfoView;

static Field followWithAvatarViewField;

static Field followPeopleButtonField;

@Override
Expand All @@ -48,7 +44,6 @@ public void init(ClassLoader classLoader) throws Throwable {

@Override
public void hook() throws Throwable {

XposedBridge.hookAllMethods(bottomReactionView, "setData", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import de.robv.android.xposed.XposedBridge;

public class MineHybridView implements IHook {

static Class<?> mineTabFragment;

static Class<?> mineHybridView;

static Field mineHybridViewField;
Expand All @@ -30,12 +28,10 @@ public void init(ClassLoader classLoader) throws Throwable {

mineHybridViewField = Arrays.stream(mineTabFragment.getDeclaredFields()).filter(field -> field.getType() == mineHybridView).findFirst().get();
mineHybridViewField.setAccessible(true);

}

@Override
public void hook() throws Throwable {

XposedBridge.hookAllMethods(mineTabFragment, "onCreateView", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Expand All @@ -47,7 +43,5 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
}
});


}
}
3 changes: 0 additions & 3 deletions app/src/main/java/com/shatyuka/zhiliao/hooks/NavButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@ public String getName() {
public void init(ClassLoader classLoader) throws Throwable {
BottomNavMenuView = classLoader.loadClass("com.zhihu.android.bottomnav.core.BottomNavMenuView");


Class<?> tabLayoutTabClass = classLoader.loadClass("com.google.android.material.tabs.TabLayout$Tab");
IMenuItem = Arrays.stream(BottomNavMenuView.getDeclaredMethods())
.filter(method -> method.getReturnType() == tabLayoutTabClass)
.map(method -> method.getParameterTypes()[0]).findFirst().get();


getItemId = Arrays.stream(IMenuItem.getDeclaredMethods())
.filter(method -> method.getReturnType() == String.class).findFirst().get();


Tab_tabView = tabLayoutTabClass.getField("view");
}

Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/shatyuka/zhiliao/hooks/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
} else {
((ViewGroup.MarginLayoutParams) author.getLayoutParams()).leftMargin = (int) (Helper.scale * 40 + 0.5 + baseX);
}

}
});
}
Expand All @@ -134,7 +133,6 @@ private void postProcessTag(RelativeLayout relativeLayout, TextView tag, String
} else {
relativeLayout.setY(0);
}

}

static String getType(String type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ protected Object replaceHookedMethod(MethodHookParam param) {
}

XposedBridge.hookAllMethods(MoreVipData, "isLegal", XC_MethodReplacement.returnConstant(Boolean.FALSE));

}
}
}
1 change: 0 additions & 1 deletion app/src/main/java/com/shatyuka/zhiliao/hooks/WebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void init(ClassLoader classLoader) throws Throwable {

@Override
public void hook() throws Throwable {

if (Helper.prefs.getBoolean("switch_subscribe", false)) {
// 禁用, 使用pre render时, js会失效
XposedBridge.hookAllMethods(answerAppView, "canPreRender", XC_MethodReplacement.returnConstant(false));
Expand Down

0 comments on commit 7b83473

Please sign in to comment.