Bug fixes

This commit is contained in:
DrKLO 2014-11-21 03:14:44 +03:00
parent a38e46cd8b
commit baed4120bc
26 changed files with 444 additions and 85 deletions

View file

@ -8,6 +8,7 @@
package org.telegram.android;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
@ -235,8 +236,10 @@ public class NotificationsController {
try {
AlarmManager alarm = (AlarmManager) ApplicationLoader.applicationContext.getSystemService(Context.ALARM_SERVICE);
PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, NotificationRepeat.class), 0);
if (personal_count > 0) {
alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 60 * 60 * 1000, pintent);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
int minutes = preferences.getInt("repeat_messages", 60);
if (minutes > 0 || personal_count > 0) {
alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + minutes * 60 * 1000, pintent);
} else {
alarm.cancel(pintent);
}
@ -289,6 +292,9 @@ public class NotificationsController {
boolean inAppSounds = false;
boolean inAppVibrate = false;
boolean inAppPreview = false;
boolean inAppPriority = false;
int priority = 0;
int priority_override = 0;
int vibrate_override = 0;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
@ -302,7 +308,9 @@ public class NotificationsController {
inAppSounds = preferences.getBoolean("EnableInAppSounds", true);
inAppVibrate = preferences.getBoolean("EnableInAppVibrate", true);
inAppPreview = preferences.getBoolean("EnableInAppPreview", true);
inAppPriority = preferences.getBoolean("EnableInAppPriority", false);
vibrate_override = preferences.getInt("vibrate_" + dialog_id, 0);
priority_override = preferences.getInt("priority_" + dialog_id, 3);
choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null);
if (chat_id != 0) {
@ -312,6 +320,7 @@ public class NotificationsController {
choosenSoundPath = preferences.getString("GroupSoundPath", defaultPath);
}
needVibrate = preferences.getInt("vibrate_group", 0);
priority = preferences.getInt("priority_group", 1);
ledColor = preferences.getInt("GroupLed", 0xff00ff00);
} else if (user_id != 0) {
if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) {
@ -320,12 +329,17 @@ public class NotificationsController {
choosenSoundPath = preferences.getString("GlobalSoundPath", defaultPath);
}
needVibrate = preferences.getInt("vibrate_messages", 0);
priority = preferences.getInt("priority_group", 1);
ledColor = preferences.getInt("MessagesLed", 0xff00ff00);
}
if (preferences.contains("color_" + dialog_id)) {
ledColor = preferences.getInt("color_" + dialog_id, 0);
}
if (priority_override != 3) {
priority = priority_override;
}
if (needVibrate == 2 && (vibrate_override == 1 || vibrate_override == 3 || vibrate_override == 5) || needVibrate != 2 && vibrate_override == 2 || vibrate_override != 0) {
needVibrate = vibrate_override;
}
@ -336,6 +350,11 @@ public class NotificationsController {
if (!inAppVibrate) {
needVibrate = 2;
}
if (!inAppPriority) {
priority = 0;
} else if (priority == 2) {
priority = 1;
}
}
}
@ -397,9 +416,13 @@ public class NotificationsController {
.setGroup("messages")
.setGroupSummary(true);
//if (ApplicationLoader.mainInterfacePaused) {
// mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
//}
if (priority == 0) {
mBuilder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
} else if (priority == 1) {
mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
} else if (priority == 2) {
mBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
}
String lastMessage = null;
String lastMessageFull = null;