diff --git a/.idea/misc.xml b/.idea/misc.xml
index 5d1998103..fbb68289f 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -37,7 +37,7 @@
-
+
diff --git a/app/build.gradle b/app/build.gradle
index 901bf61c5..45e47bbc5 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,8 +8,8 @@ android {
applicationId "com.fkzhang.wechatunrecalled"
minSdkVersion 14
targetSdkVersion 23
- versionCode 17
- versionName "1.4.5.4"
+ versionCode 18
+ versionName "1.4.6"
}
buildTypes {
release {
diff --git a/app/src/main/java/com/fkzhang/wechatunrecalled/Hooks/WechatUnrecalledHook.java b/app/src/main/java/com/fkzhang/wechatunrecalled/Hooks/WechatUnrecalledHook.java
index 301fde1ab..3f7d1f1b6 100644
--- a/app/src/main/java/com/fkzhang/wechatunrecalled/Hooks/WechatUnrecalledHook.java
+++ b/app/src/main/java/com/fkzhang/wechatunrecalled/Hooks/WechatUnrecalledHook.java
@@ -50,7 +50,7 @@
public class WechatUnrecalledHook {
protected final SettingsHelper mSettings;
protected final NotificationHelper mNotificationHelper;
- private final String TAG_DELETED = "[已删除]";
+ protected final String TAG_DELETED = "[已删除]";
protected WechatPackageNames w;
protected Object mObject;
protected Context mNotificationContext;
@@ -65,8 +65,8 @@ public class WechatUnrecalledHook {
protected Class> mConversationClass;
protected WechatMainDBHelper mDb;
protected WechatSnsDBHelper mSnsDb;
- private Class> SnsLuckyMoneyWantSeePhotoUI;
- private Class> snsLuckyMoneyDataClass;
+ protected Class> SnsLuckyMoneyWantSeePhotoUI;
+ protected Class> snsLuckyMoneyDataClass;
public WechatUnrecalledHook(WechatPackageNames packageNames) {
this.w = packageNames;
@@ -302,7 +302,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mSettings.reload();
- if (!mSettings.getBoolean("enable_new_comment_notification", false))
+ if (!mSettings.getBoolean("new_comment_notification_enable", true))
return;
String s = (String) param.args[0];
@@ -326,7 +326,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
intent.putExtra("INTENT_FROMSUI", true);
intent.putExtra("INTENT_FROMSUI_COMMENTID", v.getAsLong("commentSvrID"));
- mNotificationHelper.displayNewCommentNotification(title, content, icon, intent);
+ mNotificationHelper.showCommentNotification(title, content, icon,
+ intent, "new_comment");
}
});
@@ -468,7 +469,7 @@ protected void preventMsgRecall(XC_MethodHook.MethodHookParam param) {
if (cursor == null || !cursor.moveToFirst())
return;
- if (mSettings.getBoolean("enable_recall_notification", true)) {
+ if (mSettings.getBoolean("msg_recall_notification_enable", true)) {
final Bitmap icon = getAccountAvatar(talker);
int t = cursor.getInt(cursor.getColumnIndex("type"));
String content;
@@ -609,7 +610,7 @@ public void preventCommentRecall(XC_MethodHook.MethodHookParam param) {
setCommentDeleteFlag(v);
- if (!mSettings.getBoolean("enable_comment_recall_notification", true))
+ if (!mSettings.getBoolean("comment_recall_notification_enable", true))
return;
String talker = v.getAsString("talker");
@@ -623,7 +624,8 @@ public void preventCommentRecall(XC_MethodHook.MethodHookParam param) {
Intent resultIntent = new Intent();
resultIntent.setClassName(mNotificationContext.getPackageName(), w.SnsMsgUI);
- mNotificationHelper.displayNewCommentNotification(title, content, icon, resultIntent);
+ mNotificationHelper.showCommentNotification(title, content, icon, resultIntent,
+ "comment_recall");
}
}
diff --git a/app/src/main/java/com/fkzhang/wechatunrecalled/MainActivity.java b/app/src/main/java/com/fkzhang/wechatunrecalled/MainActivity.java
index ec45b33af..15eef5440 100644
--- a/app/src/main/java/com/fkzhang/wechatunrecalled/MainActivity.java
+++ b/app/src/main/java/com/fkzhang/wechatunrecalled/MainActivity.java
@@ -2,13 +2,14 @@
import android.app.Activity;
import android.content.ComponentName;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.database.Cursor;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
+import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
@@ -24,17 +25,15 @@
import com.fkzhang.wechatunrecalled.Util.SettingsHelper;
-import java.util.ArrayList;
-import java.util.HashMap;
+public class MainActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {
-public class MainActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener, View.OnClickListener {
-
- private static final int REQUEST_TONE_PICKER = 0;
+ private static final int REQUEST_TONE_PICKER_CUSTOM = 0;
+ private static final int REQUEST_TONE_PICKER_NEW_COMMENT = 1;
+ private static final int REQUEST_TONE_PICKER_MSG_RECALL = 2;
+ private static final int REQUEST_TONE_PICKER_COMMENT_RECALL = 3;
private MenuItem mMenuItemIcon;
private SettingsHelper mSettingsHelper;
- private TextView ringtone_select;
private TextView ringtone_name;
- private Ringtone ringTone;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -45,18 +44,6 @@ protected void onCreate(Bundle savedInstanceState) {
mSettingsHelper = new SettingsHelper(this, "com.fkzhang.wechatunrecalled");
- Switch enable_recall_notification = (Switch) findViewById(R.id.enable_recall_notification);
- enable_recall_notification.setChecked(mSettingsHelper.getBoolean("enable_recall_notification", true));
- enable_recall_notification.setOnCheckedChangeListener(this);
-
- Switch enable_comment_recall_notification = (Switch) findViewById(R.id.enable_comment_recall_notification);
- enable_comment_recall_notification.setChecked(mSettingsHelper.getBoolean("enable_comment_recall_notification", true));
- enable_comment_recall_notification.setOnCheckedChangeListener(this);
-
- Switch enable_new_comment_notification = (Switch) findViewById(R.id.enable_new_comment_notification);
- enable_new_comment_notification.setChecked(mSettingsHelper.getBoolean("enable_new_comment_notification", false));
- enable_new_comment_notification.setOnCheckedChangeListener(this);
-
Switch show_content = (Switch) findViewById(R.id.show_content);
show_content.setChecked(mSettingsHelper.getBoolean("show_content", false));
show_content.setOnCheckedChangeListener(this);
@@ -71,10 +58,30 @@ protected void onCreate(Bundle savedInstanceState) {
Switch snslucky = (Switch) findViewById(R.id.snslucky);
snslucky.setChecked(mSettingsHelper.getBoolean("snslucky", true));
- snslucky.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ snslucky.setOnCheckedChangeListener(this);
+
+ findViewById(R.id.replace_notification).setOnClickListener(new View.OnClickListener() {
@Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mSettingsHelper.setBoolean("snslucky", isChecked);
+ public void onClick(View v) {
+ showCustomNotificationDialog("custom", R.string.replace_wechat_notification);
+ }
+ });
+ findViewById(R.id.customize_new_comment_notification).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showCustomNotificationDialog("new_comment", R.string.customize_new_comment_notification);
+ }
+ });
+ findViewById(R.id.customize_msg_recall_notification).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showCustomNotificationDialog("msg_recall", R.string.customize_recall_notification);
+ }
+ });
+ findViewById(R.id.customize_comment_recall_notification).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showCustomNotificationDialog("comment_recall", R.string.customize_comment_recall_notification);
}
});
@@ -132,36 +139,6 @@ public void afterTextChanged(Editable s) {
}
});
- ringtone_select = (TextView) findViewById(R.id.ringtone_select);
- ringtone_name = (TextView) findViewById(R.id.ringtone_name);
- ringtone_select.setOnClickListener(this);
- ringtone_name.setOnClickListener(this);
-
- String uri = mSettingsHelper.getString("custom_ringtone", "");
- if (TextUtils.isEmpty(uri)) {
- ringtone_name.setText(R.string.default_text);
- } else {
- ringTone = RingtoneManager.getRingtone(getApplicationContext(), Uri.parse(uri));
- ringtone_name.setText(ringTone.getTitle(this));
- }
-
- Switch custom_notification_enable = (Switch) findViewById(R.id.enable_custom_notification);
- custom_notification_enable.setChecked(mSettingsHelper.getBoolean("custom_notification_enable", false));
- custom_notification_enable.setOnCheckedChangeListener(this);
-
- Switch ringtone_switch = (Switch) findViewById(R.id.ringtone);
- ringtone_switch.setChecked(mSettingsHelper.getBoolean("custom_ringtone_enable", false));
- ringtone_switch.setOnCheckedChangeListener(this);
-
- if (!mSettingsHelper.getBoolean("custom_ringtone_enable", false)) {
- ringtone_select.setVisibility(View.INVISIBLE);
- ringtone_name.setVisibility(View.INVISIBLE);
- }
-
- Switch vibrate_switch = (Switch) findViewById(R.id.vibrate);
- vibrate_switch.setChecked(mSettingsHelper.getBoolean("custom_vibrate_enable", false));
- vibrate_switch.setOnCheckedChangeListener(this);
-
final Activity thisActivity = this;
TextView support = (TextView) findViewById(R.id.textView0);
support.setOnClickListener(new View.OnClickListener() {
@@ -187,40 +164,26 @@ public void onClick(View v) {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
+ Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
+ Ringtone ringTone = RingtoneManager.getRingtone(getApplicationContext(), uri);
+ ringtone_name.setText(ringTone.getTitle(this));
switch (requestCode) {
- case REQUEST_TONE_PICKER:
- Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
+ case REQUEST_TONE_PICKER_CUSTOM:
mSettingsHelper.setString("custom_ringtone", uri.toString());
- ringTone = RingtoneManager.getRingtone(getApplicationContext(), uri);
- ringtone_name.setText(ringTone.getTitle(this));
+ break;
+ case REQUEST_TONE_PICKER_NEW_COMMENT:
+ mSettingsHelper.setString("new_comment_ringtone", uri.toString());
+ break;
+ case REQUEST_TONE_PICKER_MSG_RECALL:
+ mSettingsHelper.setString("msg_recall_ringtone", uri.toString());
+ break;
+ case REQUEST_TONE_PICKER_COMMENT_RECALL:
+ mSettingsHelper.setString("comment_recall_ringtone", uri.toString());
break;
}
}
}
- @Override
- public void onClick(View v) {
- if (!mSettingsHelper.getBoolean("custom_ringtone_enable", false))
- return;
-
-// HashMap map = getNotifications();
-// ArrayList list = getNotificationSounds();
-// Log.d("main", list.toString());
-//
-//
- String uri = mSettingsHelper.getString("custom_ringtone", "");
- final Uri currentTone = TextUtils.isEmpty(uri) ? RingtoneManager
- .getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION) :
- Uri.parse(uri);
- Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.ringtone_selection));
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentTone);
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
- startActivityForResult(intent, REQUEST_TONE_PICKER);
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
@@ -248,39 +211,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
- public ArrayList getNotificationSounds() {
- RingtoneManager manager = new RingtoneManager(this);
- manager.setType(RingtoneManager.TYPE_NOTIFICATION);
- Cursor cursor = manager.getCursor();
-
- ArrayList list = new ArrayList<>();
- while (cursor.moveToNext()) {
- String id = cursor.getString(RingtoneManager.ID_COLUMN_INDEX);
- String uri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX);
-
- list.add(uri + "/" + id);
- }
-
- return list;
- }
-
- public HashMap getNotifications() {
- RingtoneManager manager = new RingtoneManager(this);
- manager.setType(RingtoneManager.TYPE_NOTIFICATION);
- Cursor cursor = manager.getCursor();
-
- HashMap list = new HashMap<>();
- while (cursor.moveToNext()) {
- String id = cursor.getString(RingtoneManager.ID_COLUMN_INDEX);
- String notificationTitle = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
- String notificationUri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX);
-
- list.put(notificationTitle, notificationUri + "/" + id);
- }
-
- return list;
- }
-
private void setMenuIconTitle() {
if (isIconEnabled()) {
mMenuItemIcon.setTitle(R.string.hide_icon);
@@ -307,15 +237,6 @@ private boolean isIconEnabled() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
- case R.id.enable_recall_notification:
- mSettingsHelper.setBoolean("enable_recall_notification", isChecked);
- break;
- case R.id.enable_comment_recall_notification:
- mSettingsHelper.setBoolean("enable_comment_recall_notification", isChecked);
- break;
- case R.id.enable_new_comment_notification:
- mSettingsHelper.setBoolean("enable_new_comment_notification", isChecked);
- break;
case R.id.show_content:
mSettingsHelper.setBoolean("show_content", isChecked);
break;
@@ -325,8 +246,89 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
case R.id.enable_comment_recall_prevention:
mSettingsHelper.setBoolean("prevent_comments_recall", isChecked);
break;
- case R.id.ringtone:
- mSettingsHelper.setBoolean("custom_ringtone_enable", isChecked);
+ case R.id.snslucky:
+ mSettingsHelper.setBoolean("snslucky", isChecked);
+ break;
+ }
+ }
+
+ private void requestRingtone(String tag) {
+ if (!mSettingsHelper.getBoolean(tag + "_ringtone_enable", false))
+ return;
+
+ int request_code = -1;
+ switch (tag) {
+ case "custom":
+ request_code = REQUEST_TONE_PICKER_CUSTOM;
+ break;
+ case "new_comment":
+ request_code = REQUEST_TONE_PICKER_NEW_COMMENT;
+ break;
+ case "msg_recall":
+ request_code = REQUEST_TONE_PICKER_MSG_RECALL;
+ break;
+ case "comment_recall":
+ request_code = REQUEST_TONE_PICKER_COMMENT_RECALL;
+ }
+
+ if (request_code == -1)
+ return;
+
+ String uri = mSettingsHelper.getString(tag + "_ringtone", "");
+ final Uri currentTone = TextUtils.isEmpty(uri) ? RingtoneManager
+ .getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION) :
+ Uri.parse(uri);
+ Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
+ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
+ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.ringtone_selection));
+ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentTone);
+ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
+ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
+ startActivityForResult(intent, request_code);
+ }
+
+ private void showCustomNotificationDialog(final String tag, int title) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ View view = this.getLayoutInflater().inflate(R.layout.dialog_customize_notification, null);
+
+ final TextView ringtone_select = (TextView) view.findViewById(R.id.ringtone_select);
+ ringtone_name = (TextView) view.findViewById(R.id.ringtone_name);
+ ringtone_select.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ requestRingtone(tag);
+ }
+ });
+ ringtone_name.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ requestRingtone(tag);
+ }
+ });
+
+ String uri = mSettingsHelper.getString(tag + "_ringtone", "");
+ if (TextUtils.isEmpty(uri)) {
+ ringtone_name.setText(R.string.default_text);
+ } else {
+ Ringtone ringTone = RingtoneManager.getRingtone(getApplicationContext(), Uri.parse(uri));
+ ringtone_name.setText(ringTone.getTitle(this));
+ }
+
+ Switch notification_enable = (Switch) view.findViewById(R.id.enable_notification);
+ notification_enable.setChecked(mSettingsHelper.getBoolean(tag + "_notification_enable", true));
+ notification_enable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mSettingsHelper.setBoolean(tag + "_notification_enable", isChecked);
+ }
+ });
+
+ Switch ringtone_switch = (Switch) view.findViewById(R.id.ringtone);
+ ringtone_switch.setChecked(mSettingsHelper.getBoolean(tag + "_ringtone_enable", false));
+ ringtone_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mSettingsHelper.setBoolean(tag + "_ringtone_enable", isChecked);
if (isChecked) {
ringtone_select.setVisibility(View.VISIBLE);
ringtone_name.setVisibility(View.VISIBLE);
@@ -334,13 +336,31 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ringtone_select.setVisibility(View.INVISIBLE);
ringtone_name.setVisibility(View.INVISIBLE);
}
- break;
- case R.id.vibrate:
- mSettingsHelper.setBoolean("custom_vibrate_enable", isChecked);
- break;
- case R.id.enable_custom_notification:
- mSettingsHelper.setBoolean("custom_notification_enable", isChecked);
- break;
+ }
+ });
+
+ Switch vibrate_switch = (Switch) view.findViewById(R.id.vibrate);
+ vibrate_switch.setChecked(mSettingsHelper.getBoolean(tag + "_vibrate_enable", false));
+ vibrate_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mSettingsHelper.setBoolean(tag + "_vibrate_enable", isChecked);
+ }
+ });
+
+ if (!mSettingsHelper.getBoolean(tag + "_ringtone_enable", false)) {
+ ringtone_select.setVisibility(View.INVISIBLE);
+ ringtone_name.setVisibility(View.INVISIBLE);
}
+
+ builder.setView(view)
+ .setTitle(title)
+ .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ })
+ .create()
+ .show();
}
}
diff --git a/app/src/main/java/com/fkzhang/wechatunrecalled/Util/NotificationHelper.java b/app/src/main/java/com/fkzhang/wechatunrecalled/Util/NotificationHelper.java
index ac38f9b75..eaa38a406 100644
--- a/app/src/main/java/com/fkzhang/wechatunrecalled/Util/NotificationHelper.java
+++ b/app/src/main/java/com/fkzhang/wechatunrecalled/Util/NotificationHelper.java
@@ -41,21 +41,10 @@ public NotificationHelper(WechatPackageNames packageNames) {
}
//-- comment notification ======================================================================
-
- public void displayNewCommentNotification(String title, String content,
- Bitmap icon, Intent intent) {
- if (TextUtils.isEmpty(content))
- return;
-
- if (!mSettings.getBoolean("enable_new_comment_notification", true)) {
- return;
- }
-
- showCommentNotification(title, content, icon, intent);
- }
-
public void showCommentNotification(String contentTitle, String contentText,
- Bitmap icon, Intent resultIntent) {
+ Bitmap icon, Intent resultIntent, String tag) {
+ if (TextUtils.isEmpty(contentText))
+ return;
Bitmap largeIcon = icon == null ? getLargeIcon() : icon;
@@ -82,8 +71,8 @@ public void showCommentNotification(String contentTitle, String contentText,
notification.ledOffMS = 1000;
notification.ledARGB = Color.GREEN;
- setNotificationVibrate(notification);
- setNotificationSound(notification);
+ setNotificationVibrate(tag, notification);
+ setNotificationSound(tag, notification);
notifyNotification(notification, notifyId);
}
@@ -101,7 +90,7 @@ public void showTextNotification(String username, String title, String content,
if (!TextUtils.isEmpty(content)) {
builder.setContentText(content);
}
- showNotification(builder, getChatModeIntent(username));
+ showNotification(builder, getChatModeIntent(username), getNotificationId());
}
@@ -121,11 +110,11 @@ public void showImageNotification(String username, String title, Bitmap bitmap,
builder.setContentText(summary);
}
- setActionIntent(username, builder);
-
+ int notifyId = getNotificationId();
+ setActionIntent(username, builder, notifyId);
resultIntent.setClassName(mNotificationContext.getPackageName(), w.ImageGalleryUI);
- showNotification(builder, resultIntent);
+ showNotification(builder, resultIntent, notifyId);
}
public void showEmojiNotification(String title, Bitmap bitmap, Intent resultIntent,
@@ -146,21 +135,23 @@ public void showEmojiNotification(String title, Bitmap bitmap, Intent resultInte
resultIntent.setClassName(mNotificationContext.getPackageName(), w.ChattingUI);
- showNotification(builder, resultIntent);
+ showNotification(builder, resultIntent, getNotificationId());
}
- protected void showNotification(NotificationCompat.Builder builder, Intent intent) {
- int notifyId = getNotificationId();
+ protected void showNotification(NotificationCompat.Builder builder, Intent intent, int notifyId) {
builder.setContentIntent(PendingIntent.getActivity(mNotificationContext, notifyId, intent,
PendingIntent.FLAG_UPDATE_CURRENT));
Notification notification = builder.build();
- notification.flags = Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_SHOW_LIGHTS
- | Notification.FLAG_AUTO_CANCEL;
+ notification.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL;
notification.ledOnMS = 300;
notification.ledOffMS = 1000;
notification.ledARGB = Color.GREEN;
+ String tag = "msg_recall";
+ setNotificationVibrate(tag, notification);
+ setNotificationSound(tag, notification);
+
notifyNotification(notification, notifyId);
}
@@ -187,16 +178,17 @@ public void displayCustomNotification(final String username, String title, Strin
.bigPicture(bitmap).setSummaryText(content));
}
+ int notifyId = mUsernames.indexOf(username);
+
// Intent intent = new Intent();
if (type == 3 || type == 62) {
- setActionIntent(username, mBuilder);
+ setActionIntent(username, mBuilder, notifyId);
}
if (!mUsernames.contains(username)) {
mUsernames.add(username);
}
- int notifyId = mUsernames.indexOf(username);
mBuilder.setContentIntent(PendingIntent.getActivity(mNotificationContext, notifyId, intent,
PendingIntent.FLAG_UPDATE_CURRENT));
@@ -210,8 +202,9 @@ public void displayCustomNotification(final String username, String title, Strin
notification.ledOffMS = 1000;
notification.ledARGB = Color.GREEN;
- setNotificationVibrate(notification);
- setNotificationSound(notification);
+ String tag = "custom";
+ setNotificationVibrate(tag, notification);
+ setNotificationSound(tag, notification);
notifyNotification(notification, notifyId);
}
@@ -285,9 +278,10 @@ public Bitmap getLargeIcon() {
return mNotificationLargeIcon;
}
- private void setActionIntent(String username, NotificationCompat.Builder builder) {
+ private void setActionIntent(String username, NotificationCompat.Builder builder, int id) {
Intent action = getChatModeIntent(username);
- PendingIntent pendingIntent = PendingIntent.getActivity(mNotificationContext, 0, action, 0);
+ PendingIntent pendingIntent = PendingIntent.getActivity(mNotificationContext, id, action,
+ PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(android.R.drawable.sym_action_chat, mSettings.getString("reply", "回复"), pendingIntent);
}
@@ -305,23 +299,20 @@ public Intent getImageIntent() {
return intent;
}
- protected void setNotificationSound(Notification notification, String uriString) {
- if (!TextUtils.isEmpty(uriString)) {
- notification.sound = Uri.parse(uriString);
- } else {
- notification.defaults |= Notification.DEFAULT_SOUND;
- }
- }
-
- protected void setNotificationVibrate(Notification notification) {
- if (mSettings.getBoolean("custom_vibrate_enable", false)) {
+ protected void setNotificationVibrate(String tag, Notification notification) {
+ if (mSettings.getBoolean(tag + "_vibrate_enable", false)) {
notification.defaults |= Notification.DEFAULT_VIBRATE;
}
}
- protected void setNotificationSound(Notification notification) {
- if (mSettings.getBoolean("custom_ringtone_enable", false)) {
- setNotificationSound(notification, mSettings.getString("custom_ringtone", ""));
+ protected void setNotificationSound(String tag, Notification notification) {
+ if (mSettings.getBoolean(tag + "_ringtone_enable", false)) {
+ String uriString = mSettings.getString(tag + "_ringtone", "");
+ if (!TextUtils.isEmpty(uriString)) {
+ notification.sound = Uri.parse(uriString);
+ } else {
+ notification.defaults |= Notification.DEFAULT_SOUND;
+ }
}
}
diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml
index 01141620b..f3c60697e 100644
--- a/app/src/main/res/layout/content_main.xml
+++ b/app/src/main/res/layout/content_main.xml
@@ -61,79 +61,45 @@
android:text="@string/notification"
android:textAppearance="?android:attr/textAppearanceSmall" />
-
-
-
-
-
-
-
-
-
-
-
-
+ android:text="@string/replace_wechat_notification"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
-
+ android:text="@string/customize_recall_notification"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 1fad65436..20d757f6a 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -10,20 +10,15 @@
尝试撤回上一条消息 (已阻止)
尝试删除一条评论
评论删除消息
- 开启消息撤回通知
- 开启评论删除通知
(新评论)
- 开启新评论通知
[已删除]
- 防止朋友圈撤回
+ 防止朋友圈动态撤回
防止评论撤回
回复
[语音]
自定义消息
- 自定义通知
跟随系统
[动画表情]
- 开启自定义通知
开启铃声
开启震动
通知
@@ -35,4 +30,9 @@
如果喜欢我的作品,想支持我点这里
查看红包照片 (试验 有时无效 如有冲突请关闭)
分享图片
+ 替代微信通知
+ 自定义聊天消息撤回通知
+ 自定义新评论回复通知
+ 自定义评论删除通知
+ 开启通知
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 43a33b52f..65581dcdb 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,7 +1,6 @@
WechatUnrecalled
MainActivity
- Enable message recall notification
Show recalled content (only text)
Hide launcher icon
Show launcher icon
@@ -11,9 +10,7 @@
tried to recall above message (Prevented)
comment recalled message
tried to delete a comment
- Enable comment recall notification
(New comment)
- Enable new comment notification
[Deleted]
Prevent moments recall
Prevent comments recall
@@ -23,8 +20,6 @@
Prevent recall
Notification
Customize message
- Enable custom notification
- Customize notification
Enable vibration
Enable ringtone
Select ringtone
@@ -35,4 +30,9 @@
Alipay
Show luckymoney moments unblured image (Experimental)
Share image
+ Replace Wechat notification
+ Customize new comment notification
+ Customize message recall notification
+ Customize comment recall notification
+ Enable notification