Skip to content

Commit 431c41d

Browse files
committed
UPDATE: Migrate to SDK v2.
1 parent 63b27be commit 431c41d

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.3.2'
8+
classpath 'com.android.tools.build:gradle:3.5.0-rc01'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files
@@ -20,7 +20,7 @@ repositories {
2020
if (! project.plugins.hasPlugin("com.android.feature")) apply plugin: 'com.android.application'
2121

2222
android {
23-
compileSdkVersion 28
23+
compileSdkVersion 29
2424

2525
defaultConfig {
2626
minSdkVersion 23
@@ -41,7 +41,7 @@ android {
4141
}
4242

4343
dependencies {
44-
implementation 'com.oasisfeng.nevo:sdk:1.2.0'
44+
implementation 'com.oasisfeng.nevo:sdk:2.0.0-rc01'
4545
implementation 'androidx.core:core:1.0.1'
4646

4747
androidTestImplementation 'androidx.test:runner:1.1.1'

src/main/java/com/oasisfeng/nevo/decorators/wechat/WeChatDecorator.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ public class WeChatDecorator extends NevoDecoratorService {
8787
static final String ACTION_SETTINGS_CHANGED = "SETTINGS_CHANGED";
8888
static final String ACTION_DEBUG_NOTIFICATION = "DEBUG";
8989

90-
@Override public void apply(final MutableStatusBarNotification evolving) {
90+
@Override public boolean apply(final MutableStatusBarNotification evolving) {
9191
final MutableNotification n = evolving.getNotification();
9292
final Bundle extras = n.extras;
9393

9494
CharSequence title = extras.getCharSequence(EXTRA_TITLE);
9595
if (title == null || title.length() == 0) {
9696
Log.e(TAG, "Title is missing: " + evolving);
97-
return;
97+
return false;
9898
}
9999
if (title != (title = EmojiTranslator.translate(title))) extras.putCharSequence(EXTRA_TITLE, title);
100100
n.color = PRIMARY_COLOR; // Tint the small icon
@@ -105,10 +105,10 @@ public class WeChatDecorator extends NevoDecoratorService {
105105
n.setGroup(GROUP_MISC); // Avoid being auto-grouped
106106
if (! mOngoingCallTweaker.apply(this, evolving.getOriginalKey(), n))
107107
Log.d(TAG, "Skip further process for non-conversation notification: " + title); // E.g. web login confirmation notification.
108-
return;
108+
return true;
109109
}
110110
final CharSequence content_text = extras.getCharSequence(EXTRA_TEXT);
111-
if (content_text == null) return;
111+
if (content_text == null) return true;
112112

113113
// WeChat previously uses dynamic counter starting from 4097 as notification ID, which is reused after cancelled by WeChat itself,
114114
// causing conversation duplicate or overwritten notifications.
@@ -140,16 +140,17 @@ public class WeChatDecorator extends NevoDecoratorService {
140140
MessagingStyle messaging = mMessagingBuilder.buildFromExtender(conversation, evolving);
141141
if (messaging == null) // EXTRA_TEXT will be written in buildFromArchive()
142142
messaging = mMessagingBuilder.buildFromArchive(conversation, n, title, getArchivedNotifications(evolving.getOriginalKey(), MAX_NUM_ARCHIVED));
143-
if (messaging == null) return;
143+
if (messaging == null) return true;
144144
final List<MessagingStyle.Message> messages = messaging.getMessages();
145-
if (messages.isEmpty()) return;
145+
if (messages.isEmpty()) return true;
146146

147147
if (is_group_chat) messaging.setGroupConversation(true).setConversationTitle(title);
148148
MessagingBuilder.flatIntoExtras(messaging, extras);
149149
extras.putString(Notification.EXTRA_TEMPLATE, TEMPLATE_MESSAGING);
150150

151151
if (SDK_INT >= N && extras.getCharSequenceArray(Notification.EXTRA_REMOTE_INPUT_HISTORY) != null)
152152
n.flags |= Notification.FLAG_ONLY_ALERT_ONCE; // No more alert for direct-replied notification.
153+
return true;
153154
}
154155

155156
private boolean isDistinctId(final Notification n, final String pkg) {
@@ -168,15 +169,16 @@ private boolean isDistinctId(final Notification n, final String pkg) {
168169
}
169170
private Boolean mDistinctIdSupported;
170171

171-
@Override protected void onNotificationRemoved(final String key, final int reason) {
172-
if (reason == REASON_APP_CANCEL) { // Only if "Removal-Aware" of Nevolution is activated
172+
@Override protected boolean onNotificationRemoved(final String key, final int reason) {
173+
if (reason == REASON_APP_CANCEL) { // For ongoing notification, or if "Removal-Aware" of Nevolution is activated
173174
Log.d(TAG, "Cancel notification: " + key);
174175
mOngoingCallTweaker.onNotificationRemoved(key);
175176
} else if (reason == REASON_CHANNEL_BANNED) { // In case WeChat deleted our notification channel for group conversation in Insider delivery mode
176177
mHandler.post(() -> reviveNotification(key));
177178
} else if (SDK_INT < O || reason == REASON_CANCEL) { // Exclude the removal request by us in above case. (Removal-Aware is only supported on Android 8+)
178179
mMessagingBuilder.markRead(key);
179180
}
181+
return false;
180182
}
181183

182184
@Override protected void onConnected() {

0 commit comments

Comments
 (0)