Skip to content

Commit

Permalink
Fully support ColorQQ/QQ Theme
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit committed Jul 19, 2019
1 parent d7e1e39 commit 1694afe
Show file tree
Hide file tree
Showing 17 changed files with 2,031 additions and 94 deletions.
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>



<meta-data
android:name="xposedmodule"
android:value="true"/>
Expand Down
57 changes: 47 additions & 10 deletions app/src/main/java/nil/nadph/qnotified/ConfigActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import android.text.style.*;
import android.net.*;
import android.content.*;
import java.io.*;
import nil.nadph.qnotified.axml.*;
import android.content.res.*;
import org.xmlpull.v1.*;

public class ConfigActivity extends Activity implements Runnable{

Expand Down Expand Up @@ -83,6 +87,7 @@ protected void onCreate(Bundle savedInstanceState){
((TextView)findViewById(R.id.mainTextView)).setText(str);
statusTv=(TextView)findViewById(R.id.mainTextViewStatusA);
statusTvB=(TextView)findViewById(R.id.mainTextViewStatusB);

if(Utils.getActiveModuleVersion()==0){
statusTv.setText("!!! 错误:本模块没有激活 !!!");
statusTvB.setText("请在正确安装Xposed框架后,在Xposed Installer中(重新)勾选QNotified以激活本模块");
Expand All @@ -96,32 +101,64 @@ protected void onCreate(Bundle savedInstanceState){
try{
//tv.setMovementMethod(LinkMovementMethod.getInstance());
SpannableString ss = new SpannableString("QQ: 1041703712");
ss.setSpan(new URLSpan("http://wpa.qq.com/msgrd?v=3&uin=1041703712&site=qq&menu=yes"), 4, 14,
ss.setSpan(new URLSpan("http://wpa.qq.com/msgrd?v=3&uin=1041703712&site=qq&menu=yes"),4,14,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(ss);
tv.setClickable(true);
}catch(Throwable e){
tv.setText(""+e);
}

/*new Thread(new Runnable(){

InputStream in= ConfigActivity.class.getClassLoader().getResourceAsStream("assets/xposed_init");
byte buf[]=new byte[64];
String start="";
try{
int len=in.read(buf);
in.close();
start=new String(buf,0,len).replace("\n","").replace("\r","").replace(" ","");
}catch(IOException e){
start=e.toString();
}
TextView vtv=findViewById(R.id.mainTextViewVersion);
if(start.equals("nil.nadph.qnotified.HookLoader")){
vtv.setText("动态加载");
vtv.setTextColor(Color.BLUE);
}else
if(start.equals("nil.nadph.qnotified.HookEntry")){
vtv.setText("静态");
//vtv.setTextColor(Color.BLUE);
}else{
vtv.setText(start);
vtv.setTextColor(Color.RED);
}
/*
new Thread(new Runnable(){
@Override
public void run(){
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
final ColorStateList color_=QThemeKit.getStateColorInXml("/tmp/hyc.xml");
/*try{
FileInputStream is = new FileInputStream("/tmp/skin_black.xml");
/*byte[] buf = new byte[is.available()];
int bytesRead = is.read(buf);
is.close();*
AXmlResourceParser axml=new AXmlResourceParser();
axml.open(is);
final ColorStateList color=ResInflater.inflateColorFromXml(getResources(),axml,null);
}catch(XmlPullParserException e){}catch(IOException e){}*
runOnUiThread(new Runnable(){
@Override
public void run(){
Initiator it=new Initiator();
it.showPopup(getWindow().getDecorView());
TextView t=findViewById(R.id.mainTextViewStatusB);
t.setEnabled(true);
t.setClickable(true);
t.setTextColor(color_);
}
});
}
}).start();*/
}


public void onAddQqClick(View v){
Uri uri = Uri.parse("http://wpa.qq.com/msgrd?v=3&uin=1041703712&site=qq&menu=yes");
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
Expand Down
39 changes: 26 additions & 13 deletions app/src/main/java/nil/nadph/qnotified/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,45 @@ public class ConfigManager{
private static ConfigManager SELF;
private File file;
private HashMap <String,Object>config;

private ConfigManager() throws IOException{
file=new File(Utils.getApplication().getFilesDir().getAbsolutePath()+"/qnotified_config.dat");
if(!file.exists())file.createNewFile();
config=new HashMap<>();
reload();
}

public static ConfigManager get() throws IOException{
if(SELF==null)SELF=new ConfigManager();
return SELF;
}



public Object getOrDefault(String key,Object def){
if(!config.containsKey(key))return def;
return config.get(key);
}

public boolean getBooleanOrFalse(String key){
if(!config.containsKey(key))return false;
try{
return ((Boolean)config.get(key)).booleanValue();
}catch(ClassCastException e){
return false;
}
}

public String getString(String key){
return (String)config.get(key);
}

public void putString(String key,String val){
config.put(key,val);
}

public HashMap<String,Object>getAllConfig(){
return config;
}

public void reload() throws IOException{
FileInputStream fin = null;
fin=new FileInputStream(file);
Expand Down Expand Up @@ -97,8 +110,8 @@ public void reload() throws IOException{
}
}
}


public void save() throws IOException{
ByteArrayOutputStream baos=new ByteArrayOutputStream();
DataOutputStream out=new DataOutputStream(baos);
Expand Down Expand Up @@ -137,8 +150,8 @@ public void save() throws IOException{
out.close();
fout.close();
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ExfriendListAdapter(View listView,ExfriendManager m){
}catch(Throwable e){
log(e);
}
reload();
reload();MotionEvent n;
}

public void reload(){
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/nil/nadph/qnotified/ExfriendManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ private ExfriendManager(long uin){
dbg();
tableToFriend();
tableToEvents();
lastUpdateTimeSec=fileData.getOrDefault("lastUpdateFl",0l);
lastUpdateTimeSec=0l;
try{
lastUpdateTimeSec=fileData.get("lastUpdateFl");
}catch(Exception e){}
dbg();
}catch(IOException e){
log(e);
Expand Down
83 changes: 43 additions & 40 deletions app/src/main/java/nil/nadph/qnotified/QQMainHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public class QQMainHook <SlideDetectListView extends View,ContactsFPSPinnedHeade
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam _lpparam) throws Throwable{
try{
this.lpparam=_lpparam;
findAndHookMethod("com.tencent.common.app.QFixApplicationImpl",lpparam.classLoader,"isAndroidNPatchEnable",XC_MethodReplacement.returnConstant(500,false));
XposedHelpers.findAndHookMethod("com.tencent.mobileqq.app.InjectUtils",lpparam.classLoader,"injectExtraDexes",Application.class,boolean.class,new XC_MethodHook(51) {
protected void afterHookedMethod(MethodHookParam param) throws Throwable{
try{
Expand All @@ -73,6 +72,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable{
}
}
});
findAndHookMethod("com.tencent.common.app.QFixApplicationImpl",lpparam.classLoader,"isAndroidNPatchEnable",XC_MethodReplacement.returnConstant(500,false));
}catch(Throwable e){
log(e);
throw e;
Expand Down Expand Up @@ -157,14 +157,15 @@ private void performHook(ClassLoader classLoader){
/*try{
Thread.sleep(5000);
}catch(InterruptedException e){}*/
findAndHookMethod(load("com.tencent.mobileqq.activity.SplashActivity"),"doOnCreate",Bundle.class,new XC_MethodHook(200){
@Override
protected void afterHookedMethod(MethodHookParam param){
splashActivity=(Activity)param.thisObject;
new Thread(new SearchEntrance()).start();
}
});

try{
findAndHookMethod(load("com.tencent.mobileqq.activity.SplashActivity"),"doOnCreate",Bundle.class,new XC_MethodHook(200){
@Override
protected void afterHookedMethod(MethodHookParam param){
splashActivity=(Activity)param.thisObject;
new Thread(new SearchEntrance()).start();
}
});
}catch(Exception e){}
/*findAndHookMethod(load("com.tencent.mobileqq.data.MessageForQQWalletMsg"),"doParse",new XC_MethodHook(200){
@Override
protected void afterHookedMethod(MethodHookParam param){
Expand All @@ -183,8 +184,8 @@ protected void afterHookedMethod(MethodHookParam param){

Class clazz=load(".activity.contacts.fragment.FriendFragment");//".activity.Contacts");
/*findAndHookMethod(clazz,"i",pastEntry);
findAndHookMethod(clazz,"j",pastEntry);*/
XposedBridge.hookMethod(dump(XposedHelpers.findMethodBestMatch(load("com/tencent/mobileqq/activity/contacts/view/ContactsFPSPinnedHeaderExpandableListView"),"setAdapter",ExpandableListAdapter.class)),exfriendEntryHook);
findAndHookMethod(clazz,"j",pastEntry);*/
findAndHookMethod(load("com/tencent/widget/PinnedHeaderExpandableListView"),"setAdapter",ExpandableListAdapter.class,exfriendEntryHook);
clazz=load(ActProxyMgr.STUB_ACTIVITY);
findAndHookMethod(clazz,"onCreate",Bundle.class,proxyActivity_onCreate);
//findAndHookMethod(clazz,"doOnCreate",Bundle.class,proxyActivity_doOnCreate);
Expand All @@ -198,7 +199,7 @@ protected void afterHookedMethod(MethodHookParam param){
protected void afterHookedMethod(MethodHookParam param) throws Throwable{
try{
if(Utils.getLongAccountUin()>10000){
ExfriendManager ex=ExfriendManager.getCurrent();
ExfriendManager ex=ExfriendManager.getCurrent();
ex.timeToUpdateFl();
}
}catch(Throwable e){
Expand Down Expand Up @@ -289,14 +290,15 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable{
}
}
});

XposedBridge.hookAllConstructors(load("com/tencent/mobileqq/mini/entry/MiniAppEntryAdapter"),new XC_MethodHook(60){
@Override
protected void beforeHookedMethod(MethodHookParam param){
//param.setThrowable(new NullPointerException("mmp"));
}
});


try{
XposedBridge.hookAllConstructors(load("com/tencent/mobileqq/mini/entry/MiniAppEntryAdapter"),new XC_MethodHook(60){
@Override
protected void beforeHookedMethod(MethodHookParam param){
//param.setThrowable(new NullPointerException("mmp"));
}
});
}catch(Exception e){}
/*clazz=load("com.tencent.mobileqq.activity.Conversation");
if(clazz!=null){
try{
Expand Down Expand Up @@ -426,7 +428,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable{
iput_object(self,"mFlingHandler",exlist_mFlingHandler);
QThemeKit.initTheme(self);

SlideDetectListView sdlv=(SlideDetectListView)load("com.tencent.mobileqq.widget.SlideDetectListView").getConstructor(Context.class,AttributeSet.class).newInstance(self,null);
SlideDetectListView sdlv=(SlideDetectListView)load("com.tencent.widget.SwipListView").getConstructor(Context.class,AttributeSet.class).newInstance(self,null);
sdlv.setFocusable(true);
ViewGroup.LayoutParams mmlp=new ViewGroup.LayoutParams(MATCH_PARENT,MATCH_PARENT);
RelativeLayout.LayoutParams mwllp=new RelativeLayout.LayoutParams(MATCH_PARENT,WRAP_CONTENT);
Expand Down Expand Up @@ -486,7 +488,7 @@ public void run(){
}
});
//.addView(sdlv,lp);
invoke_virtual(sdlv,"setCanSlide",true,boolean.class);
//invoke_virtual(sdlv,"setCanSlide",true,boolean.class);
invoke_virtual(sdlv,"setDivider",null,Drawable.class);
long uin=Utils.getLongAccountUin();
ExfriendManager exm=ExfriendManager.get(uin);
Expand Down Expand Up @@ -521,7 +523,7 @@ else if(action==ACTION_ADV_SETTINGS)
__lp_r.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
__lp_r.addRule(RelativeLayout.CENTER_VERTICAL);

int _countm1=30;
int _countm1=1;
RelativeLayout _rl[]=new RelativeLayout[_countm1];
TextView _tv[]=new TextView[_countm1];
CompoundButton[] _sw=new CompoundButton[_countm1];
Expand All @@ -538,12 +540,13 @@ else if(action==ACTION_ADV_SETTINGS)
@Override
public void onCheckedChanged(CompoundButton v,boolean z){
try{
ExfriendManager.getCurrent().doNotifyDelFl(new Object[]{1,"sticker","通知","测试"});
Utils.showToastShort(self,v.getTag()+"->"+z);
}catch(Throwable e){}
}
});
_rl[i].addView(_sw[i],__lp_r);
_tv[i].setText("选项-Switch_"+i);
_tv[i].setText("设置暂不开放");
_tv[i].setTextSize(dip2sp(self,18));
_tv[i].setGravity(Gravity.CENTER_VERTICAL);
ll.addView(_rl[i],fixlp);
Expand Down Expand Up @@ -724,18 +727,18 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable{
}
}
};



/*private XC_MethodHook pastEntry=new XC_MethodHook(1200){
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable{
try{
*/
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable{
try{
*/
private XC_MethodHook exfriendEntryHook=new XC_MethodHook(1200){
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable{
Expand All @@ -759,15 +762,15 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable{
return;
}*/
//unusualContacts=(TextView)frameView.getChildAt(0);




layout_entrance=new LinearLayout(splashActivity);
RelativeLayout rell=new RelativeLayout(splashActivity);
//rell.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT,WRAP_CONTENT));

Object adapter=invoke_virtual(lv,"getAdapter",ListAdapter.class);
//Object adapter=invoke_virtual(lv,"getAdapter",ListAdapter.class);
//invoke_virtual(lv,"setAdapter",null,BaseAdapter.class);
/*try{
invoke_virtual(lv,"removeFooterView",layout,View.class);
Expand All @@ -777,7 +780,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable{
//log("fucking it!");
invoke_virtual_original(lv,"addFooterView",layout_entrance,View.class);
addedListView.add(lv);
invoke_static(XposedBridge.class,"dumpObjectNative",lv,Object.class);
//invoke_static(XposedBridge.class,"dumpObjectNative",lv,Object.class);
//lv.setVisibility(View.GONE);
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/nil/nadph/qnotified/QThemeKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static nil.nadph.qnotified.Initiator.load;
import java.lang.reflect.*;
import android.os.*;
import nil.nadph.qnotified.axml.*;

public class QThemeKit{

Expand Down
Loading

0 comments on commit 1694afe

Please sign in to comment.