Hello guys, I want to share my library XClasses. My idea was to see every XClass as an extension of the original class. My aim was to improve the user experience during the development. Also I wanted to increase the readability of xposed code. So it's nothing special. It's just my personal opinion how readable code should look like.
A small example:
Code:
public class XposedMain implements IXposedHookLoadPackage { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { if(lpparam.packageName.equals("com.android.systemui")) { XposedHelpers.findAndHookMethod(TextView.class, "setText", CharSequence.class, TextView.BufferType.class, boolean.class, int.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { TextView tv = (TextView)param.thisObject; CharSequence text = (CharSequence)param.args[0]; TextView.BufferType type = (TextView.BufferType)param.args[1]; boolean notifyBefore = (Boolean)param.args[2]; int oldlen = (Integer)param.args[3];
XposedBridge.log("setText "+text+" with size "+tv.getTextSize()); } }); } } }
The same code with XClasses:
Code:
// class 1 public class XposedMain implements IXposedHookLoadPackage { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { if(lpparam.packageName.equals("com.android.systemui")) { setup(lpparam.classLoader); hook(XTextView.class); } } } // class 2 public class XTextView extends AbstractXClass<TextView> { public static String getOriginalClassName() { return TextView.class.getCanonicalName(); }
public XTextView(TextView objectThis) { super(objectThis); }
No comments:
Post a Comment