Skip to content

Commit

Permalink
add ui.
Browse files Browse the repository at this point in the history
  • Loading branch information
javaeryang committed Jul 4, 2018
1 parent 09f5442 commit f6890c4
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/.gradle/*
49 changes: 49 additions & 0 deletions app/src/main/java/aweme/AwemeUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package aweme;

import android.app.Activity;
import android.os.Bundle;
import android.widget.FrameLayout;

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

/**
* Created by javaer on 2018/7/5.
*/

public class AwemeUI {
public static Activity globalActivity;
public static void hookUI(ClassLoader classLoader){
XposedHelpers.findAndHookMethod(Activity.class,
"onResume",
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
globalActivity = (Activity) param.thisObject;
}
}
);
XposedHelpers.findAndHookMethod("com.douyin.baseshare.a.a",
classLoader,
"onCreate",
Bundle.class,
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Vlog.log("com.douyin.baseshare.a.a>>>>onCreate");
FrameLayout r = (FrameLayout)
XposedHelpers.getObjectField(param.thisObject, "r");
// TextView textView = new TextView(globalActivity);
// textView.setText("注入文字2");
// textView.setTextColor(Color.RED);
// r.addView(textView, 0);
// Vlog.log("注入完毕2");
MyLinear myLinear = new MyLinear(globalActivity);
r.addView(myLinear);
Vlog.log("add view success");
}
}
);
}
}
50 changes: 50 additions & 0 deletions app/src/main/java/aweme/MyLinear.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package aweme;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import log.Vlog;

/**
* Created by javaer on 2018/7/5.
*/

public class MyLinear extends LinearLayout{
private Context mContext;
public MyLinear(Context context) {
super(context);
this.mContext = context;
init();
}
private void init(){
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(dp2px(10), dp2px(5), dp2px(10), dp2px(5));
this.setLayoutParams(layoutParams);

LayoutParams tv_p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
tv_p.setMargins(dp2px(10), dp2px(10), dp2px(10), dp2px(0));
TextView textView = new TextView(mContext);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setTextColor(Color.RED);
textView.setText("抖音助手-小璇出品");
textView.setTextSize(18);
textView.setLayoutParams(tv_p);
textView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Vlog.log("抖音助手");
}
});

this.addView(textView);
}

private int dp2px(float value){
final float scale = mContext.getResources().getDisplayMetrics().density;
return (int) (scale * value + 0.5);
}
}
3 changes: 3 additions & 0 deletions app/src/main/java/xposed/MainHook.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xposed;

import aweme.AwemeUI;
import hook.Hook;

/**
Expand All @@ -10,5 +11,7 @@ public class MainHook {
public static void hookMain(ClassLoader classLoader){

Hook.hook(classLoader);

AwemeUI.hookUI(classLoader);
}
}

0 comments on commit f6890c4

Please sign in to comment.