Skip to content

Commit

Permalink
QNotified 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit committed Sep 12, 2019
1 parent da38429 commit 713e2ab
Show file tree
Hide file tree
Showing 14 changed files with 955 additions and 597 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ QNotified is a Xposed module that automatically refreshes friend list and tell(n

- **其他功能**
1. 可以设置隐藏消息列表上方小程序入口
2. 可屏蔽 \@全体成员 或者 群红包 的通知(不影响接收消息,不影响某些插件抢红包功能)

- **在建功能** (未必一次更新全部到位)
1. 语音转发 _向前兼容_
2. _用户建议_ 左划删除历史好友记录
3. 转发的消息记录点击用户头像打开个人资料卡
4. 屏蔽 \@全体成员 或 群红包 的消息通知(可设置,不影响接收消息或抢红包插件)
5. 适配TIM,QQ轻聊版
6. (待确认)是否已修复偶发性的莫名其妙好友全部被标记为删除的bug
4. 适配TIM,QQ轻聊版
5. (待确认)是否已修复偶发性的莫名其妙好友全部被标记为删除的bug

- **考虑中功能**
1. 后期适配QQ国际版
Expand All @@ -25,4 +24,4 @@ QNotified is a Xposed module that automatically refreshes friend list and tell(n
**如发现bug或好的建议请在Issue区留言**


# 高考惨败,继续更新
# 高考惨败,继续更新
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="nil.nadph.qnotified"
android:versionName="0.2.0概念版"
android:versionCode="9">
android:versionName="0.2.0"
android:versionCode="10">

<uses-sdk
android:targetSdkVersion="27"
Expand Down
124 changes: 63 additions & 61 deletions app/src/main/java/nil/nadph/qnotified/ActProxyMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,67 +56,69 @@ protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Th
//ActProxyMgr.set(id,self);
ActivityAdapter aa;
Method method = (Method) param.method;

if (method.getName().equals("onCreate") && param.args.length == 1) {
Method m = load("mqq/app/AppActivity").getDeclaredMethod("onCreate", Bundle.class);
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m, param.args);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa = createActivityAdapter(action, self);
Object exlist_mFlingHandler = new_instance(load("com/tencent/mobileqq/activity/fling/FlingGestureHandler"), self, Activity.class);
iput_object(self, "mFlingHandler", exlist_mFlingHandler);
QThemeKit.initTheme(self);
aa.doOnPostCreate((Bundle) param.args[0]);
self.getWindow().getDecorView().setTag(aa);
} else {
aa = (ActivityAdapter) self.getWindow().getDecorView().getTag();
switch (method.getName()) {
case "doOnDestroy":
Method m = self.getClass().getSuperclass().getSuperclass().getDeclaredMethod("doOnDestroy");
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa.doOnPostDestory();
break;
case "doOnPause":
m = self.getClass().getSuperclass().getSuperclass().getDeclaredMethod("doOnPause");
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa.doOnPostPause();
break;
case "doOnResume":
m = self.getClass().getSuperclass().getSuperclass().getDeclaredMethod("doOnResume");
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa.doOnPostResume();
break;
case "doOnActivityResult":
m = self.getClass().getSuperclass().getSuperclass().getDeclaredMethod("doOnActivityResult", int.class, int.class, Intent.class);
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m, param.args);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa.doOnPostActivityResult((int) param.args[0], (int) param.args[1], (Intent) param.args[2]);
break;
case "isWrapContent":
param.setResult(aa.isWrapContent());
break;
default:
throw new UnsupportedOperationException("Unexpected method: " + method.getName());
}
}

try {
if (method.getName().equals("onCreate") && param.args.length == 1) {
Method m = load("mqq/app/AppActivity").getDeclaredMethod("onCreate", Bundle.class);
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m, param.args);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa = createActivityAdapter(action, self);
Object exlist_mFlingHandler = new_instance(load("com/tencent/mobileqq/activity/fling/FlingGestureHandler"), self, Activity.class);
iput_object(self, "mFlingHandler", exlist_mFlingHandler);
QThemeKit.initTheme(self);
aa.doOnPostCreate((Bundle) param.args[0]);
self.getWindow().getDecorView().setTag(aa);
} else {
aa = (ActivityAdapter) self.getWindow().getDecorView().getTag();
switch (method.getName()) {
case "doOnDestroy":
Method m = self.getClass().getSuperclass().getSuperclass().getDeclaredMethod("doOnDestroy");
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa.doOnPostDestory();
break;
case "doOnPause":
m = self.getClass().getSuperclass().getSuperclass().getDeclaredMethod("doOnPause");
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa.doOnPostPause();
break;
case "doOnResume":
m = self.getClass().getSuperclass().getSuperclass().getDeclaredMethod("doOnResume");
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa.doOnPostResume();
break;
case "doOnActivityResult":
m = self.getClass().getSuperclass().getSuperclass().getDeclaredMethod("doOnActivityResult", int.class, int.class, Intent.class);
m.setAccessible(true);
try {
ActProxyMgr.invokeSuper(self, m, param.args);
} catch (ActProxyMgr.BreakUnaughtException e) {
}
aa.doOnPostActivityResult((int) param.args[0], (int) param.args[1], (Intent) param.args[2]);
break;
case "isWrapContent":
param.setResult(aa.isWrapContent());
break;
default:
throw new UnsupportedOperationException("Unexpected method: " + method.getName());
}
}
} catch (Throwable th) {
param.setThrowable(th);
}
}

private ActivityAdapter createActivityAdapter(int action, Activity activity) {
Expand Down
153 changes: 85 additions & 68 deletions app/src/main/java/nil/nadph/qnotified/ExfriendManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ExfriendManager {
private ConfigManager fileData;//Back compatibility

private ConcurrentHashMap mStdRemarks;
private ArrayList<FriendChunk> cachedFriendChunks = new ArrayList<>();
private ArrayList<FriendChunk> cachedFriendChunks;


private boolean dirtyFlag;
Expand Down Expand Up @@ -88,60 +88,77 @@ public void run() {
};

private ExfriendManager(long uin) {
mUin = uin;
persons = new HashMap<>();
events = new HashMap();
if (tp == null) {
tp = Executors.newCachedThreadPool();
tp.execute(asyncUpdateAwaitingTask);
}
//persons=loadSavedPersonsInfo();
try {
loadSavedPersonsInfo();
dbg();
try {
mStdRemarks = getFriendsConcurrentHashMap(getFriendsManager());
} catch (Throwable e) {
}
if (persons.size() == 0 && mStdRemarks != null) {
dbg();
log("WARNING:INIT FROM THE INTERNAL");
//Here we try to copy friendlist
Object fr;
Field fuin, fremark, fnick;
Class clz_fr = load("com/tencent/mobileqq/data/Friends");
fuin = clz_fr.getField("uin");//long!!!
fuin.setAccessible(true);
fremark = clz_fr.getField("remark");
fremark.setAccessible(true);
fnick = clz_fr.getField("name");
fnick.setAccessible(true);
persons = new HashMap<>();
Iterator<Map.Entry> it = mStdRemarks.entrySet().iterator();
while (it.hasNext()) {
long t = System.currentTimeMillis() / 1000;
fr = it.next().getValue();
if (fr == null) continue;
try {
} catch (Exception e) {
continue;
}
FriendRecord f = new FriendRecord();
f.uin = Long.parseLong((String) fuin.get(fr));
f.remark = (String) fremark.get(fr);
f.nick = (String) fnick.get(fr);
f.friendStatus = FriendRecord.STATUS_RESERVED;
f.serverTime = t;
if (!persons.containsKey(f.uin))
persons.put(f.uin, f);
}
dbg();
saveConfigure();
dbg();
}
} catch (Exception e) {
log(e);
}
initForUin(uin);
}

public void reinit() {
persons = new HashMap();
events = new HashMap();
initForUin(mUin);
}

public ConfigManager getConfig() {
return fileData;
}

private void initForUin(long uin) {
cachedFriendChunks = new ArrayList<>();
synchronized (this) {
mUin = uin;
try {
loadSavedPersonsInfo();
dbg();
try {
mStdRemarks = getFriendsConcurrentHashMap(getFriendsManager());
} catch (Throwable e) {
}
if (persons.size() == 0 && mStdRemarks != null) {
dbg();
log("WARNING:INIT FROM THE INTERNAL");
//Here we try to copy friendlist
Object fr;
Field fuin, fremark, fnick;
Class clz_fr = load("com/tencent/mobileqq/data/Friends");
fuin = clz_fr.getField("uin");//long!!!
fuin.setAccessible(true);
fremark = clz_fr.getField("remark");
fremark.setAccessible(true);
fnick = clz_fr.getField("name");
fnick.setAccessible(true);
persons = new HashMap<>();
Iterator<Map.Entry> it = mStdRemarks.entrySet().iterator();
while (it.hasNext()) {
long t = System.currentTimeMillis() / 1000;
fr = it.next().getValue();
if (fr == null) continue;
try {
} catch (Exception e) {
continue;
}
FriendRecord f = new FriendRecord();
f.uin = Long.parseLong((String) fuin.get(fr));
f.remark = (String) fremark.get(fr);
f.nick = (String) fnick.get(fr);
f.friendStatus = FriendRecord.STATUS_RESERVED;
f.serverTime = t;
if (!persons.containsKey(f.uin))
persons.put(f.uin, f);
}
dbg();
saveConfigure();
dbg();
}
} catch (Exception e) {
log(e);
}
}
}

public @Nullable
void loadSavedPersonsInfo() {
Expand Down Expand Up @@ -446,11 +463,11 @@ public synchronized void recordFriendChunk(FriendChunk fc) {
cachedFriendChunks.toArray(update);
cachedFriendChunks.clear();
tp.execute(new Runnable() {
@Override
public void run() {
asyncUpdateFriendListTask(update);
}
});
@Override
public void run() {
asyncUpdateFriendListTask(update);
}
});
}
}
}
Expand All @@ -469,15 +486,15 @@ public void setRedDot() {
}
final int n = m;
((Activity) Utils.getContext(rd)).runOnUiThread(new Runnable() {
@Override
public void run() {
if (n < 1) rd.setVisibility(View.INVISIBLE);
else {
rd.setText("" + n);
rd.setVisibility(View.VISIBLE);
}
}
});
@Override
public void run() {
if (n < 1) rd.setVisibility(View.INVISIBLE);
else {
rd.setText("" + n);
rd.setVisibility(View.VISIBLE);
}
}
});
}

public void reportEventWithoutSave(EventRecord ev, Object[] out) {
Expand Down Expand Up @@ -693,11 +710,11 @@ public void timeToUpdateFl() {
//log(t+"/"+lastUpdateTimeSec);
if (t - lastUpdateTimeSec > FL_UPDATE_INT_MIN) {
tp.execute(new Runnable() {
@Override
public void run() {
doRequestFlRefresh();
}
});
@Override
public void run() {
doRequestFlRefresh();
}
});
}
}
}
Loading

0 comments on commit 713e2ab

Please sign in to comment.