diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/ConversationPrefsHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/common/ConversationPrefsHelper.java
index 5c303238..0240e5e7 100644
--- a/QKSMS/src/main/java/com/moez/QKSMS/common/ConversationPrefsHelper.java
+++ b/QKSMS/src/main/java/com/moez/QKSMS/common/ConversationPrefsHelper.java
@@ -41,8 +41,8 @@ public class ConversationPrefsHelper {
return getBoolean(SettingsFragment.NOTIFICATION_TICKER, true);
}
- public boolean getPrivateNotificationsEnabled() {
- return getBoolean(SettingsFragment.NOTIFICATION_PRIVATE, false);
+ public Integer getPrivateNotificationsSetting(){
+ return Integer.parseInt(mPrefs.getString(SettingsFragment.PRIVATE_NOTIFICATION, "0"));
}
public boolean getVibrateEnabled() {
diff --git a/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java b/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java
index e50e6cb0..2b088800 100644
--- a/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java
+++ b/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java
@@ -185,11 +185,17 @@ public class NotificationManager {
builder.setLights(getLedColour(conversationPrefs), 1000, 1000);
}
- boolean privateNotifications = conversationPrefs.getPrivateNotificationsEnabled();
+ Integer privateNotifications = conversationPrefs.getPrivateNotificationsSetting();
if (conversationPrefs.getTickerEnabled()) {
- String messageBody = privateNotifications ? sRes.getString(R.string.new_message) : lastMessage.mBody;
- builder.setTicker(String.format("%s: %s", lastMessage.mContact, messageBody));
+ switch (privateNotifications) {
+ case 0:
+ builder.setTicker(String.format("%s: %s", lastMessage.mContact, lastMessage.mBody));
+ case 1:
+ builder.setTicker(String.format("%s: %s", lastMessage.mContact, sRes.getString(R.string.new_message)));
+ case 2:
+ builder.setTicker(String.format("%s: %s", "QKSMS", sRes.getString(R.string.new_message)));
+ }
}
if (conversationPrefs.getWakePhoneEnabled()) {
@@ -266,7 +272,7 @@ public class NotificationManager {
builder.setLights(getLedColour(conversationPrefs), 1000, 1000);
}
- boolean privateNotifications = conversationPrefs.getPrivateNotificationsEnabled();
+ Integer privateNotifications = conversationPrefs.getPrivateNotificationsSetting();
if (conversations.size() == 1 && lastConversation.size() == 1) {
singleMessage(context, lastConversation, threadId, builder, conversationPrefs, privateNotifications);
@@ -312,11 +318,18 @@ public class NotificationManager {
PI = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
- boolean privateNotifications = sPrefs.getBoolean(SettingsFragment.NOTIFICATION_PRIVATE, false);
+
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
+
for (Message message : SmsHelper.getFailedMessages(context)) {
- String body = privateNotifications ? sRes.getString(R.string.new_message) : message.getBody();
- inboxStyle.addLine(Html.fromHtml("" + message.getName() + " " + body));
+ switch (Integer.parseInt(sPrefs.getString(SettingsFragment.PRIVATE_NOTIFICATION, "0"))) {
+ case 0:
+ inboxStyle.addLine(Html.fromHtml("" + message.getName() + " " + message.getBody()));
+ case 1:
+ inboxStyle.addLine(Html.fromHtml("" + message.getName() + " " + sRes.getString(R.string.new_message)));
+ case 2:
+ inboxStyle.addLine(Html.fromHtml("" + "QKSMS" + " " + sRes.getString(R.string.new_message)));
+ }
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
@@ -411,7 +424,7 @@ public class NotificationManager {
*/
private static void singleMessage(final Context context, final ArrayList messages, final long threadId,
final NotificationCompat.Builder builder, final ConversationPrefsHelper conversationPrefs,
- final boolean privateNotifications) {
+ final Integer privateNotifications) {
MessageItem message = messages.get(0);
@@ -442,7 +455,7 @@ public class NotificationManager {
*/
private static void buildSingleMessageNotification(final Context context, ArrayList messages, long threadId,
final NotificationCompat.Builder builder, ConversationPrefsHelper conversationPrefs,
- final boolean privateNotifications) {
+ final Integer privateNotifications) {
MessageItem message = messages.get(0);
@@ -464,12 +477,35 @@ public class NotificationManager {
final PendingIntent seenPI = PendingIntent.getBroadcast(context, buildRequestCode(threadId, 4), seenIntent, PendingIntent.FLAG_UPDATE_CURRENT);
int unreadMessageCount = SmsHelper.getUnreadMessageCount(context);
- builder.setContentTitle(message.mContact)
- .setContentText(privateNotifications ? sRes.getString(R.string.new_message) : message.mBody)
- .setLargeIcon(getLargeIcon(context, Contact.get(message.mAddress, false)))
+ String body;
+ String title;
+ NotificationCompat.Style nstyle = null;
+ switch (privateNotifications){
+ case 0: //Hide nothing
+ body = message.mBody;
+ title = message.mContact;
+ nstyle = new NotificationCompat.BigTextStyle().bigText(message.mBody);
+ break;
+ case 1: //Hide message
+ body = sRes.getString(R.string.new_message);
+ title = message.mContact;
+ break;
+ case 2: //Hide sender & message
+ body = sRes.getString(R.string.new_message);
+ title = "QKSMS";
+ break;
+ default:
+ body = message.mBody;
+ title = message.mContact;
+ nstyle = null;
+ }
+
+ builder.setContentTitle(title)
+ .setContentText(body)
+ .setLargeIcon(getLargeIcon(context, Contact.get(message.mAddress, false), privateNotifications))
.setContentIntent(threadPI)
.setNumber(unreadMessageCount)
- .setStyle(privateNotifications ? null : new NotificationCompat.BigTextStyle().bigText(message.mBody))
+ .setStyle(nstyle)
.addAction(R.drawable.ic_reply, sRes.getString(R.string.reply), replyPI)
.addAction(R.drawable.ic_accept, sRes.getString(R.string.read), readPI)
.extend(WearableIntentReceiver.getSingleConversationExtender(context, message.mContact, message.mAddress, threadId))
@@ -495,16 +531,15 @@ public class NotificationManager {
NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle()
.setBigContentTitle(message.mContact)
.setSummaryText(message.mBody)
- .bigLargeIcon(getLargeIcon(context, Contact.get(message.mAddress, false)))
+ .bigLargeIcon(getLargeIcon(context, Contact.get(message.mAddress, false), privateNotifications))
.bigPicture(image);
+ if (privateNotifications == 0) builder.setStyle(style);
+ else builder.setStyle(null);
- builder.setStyle(privateNotifications ? null : style);
} else {
Log.d(TAG, "MMS Type: not an image lol");
- NotificationCompat.BigTextStyle style = privateNotifications ?
- null : new NotificationCompat.BigTextStyle().bigText(message.mBody);
-
- builder.setStyle(style);
+ if (privateNotifications == 0) builder.setStyle(new NotificationCompat.BigTextStyle().bigText(message.mBody));
+ else builder.setStyle(null);
}
}
@@ -517,7 +552,7 @@ public class NotificationManager {
*/
private static void singleSender(final Context context, ArrayList messages, long threadId,
final NotificationCompat.Builder builder, ConversationPrefsHelper conversationPrefs,
- final boolean privateNotifications) {
+ final Integer privateNotifications) {
MessageItem message = messages.get(0);
@@ -543,13 +578,18 @@ public class NotificationManager {
inboxStyle.addLine(message1.mBody);
}
+ String notificationTitle = message.mContact;
+
+ if (!(privateNotifications == 0)) inboxStyle = null;
+ if (privateNotifications == 2) notificationTitle = "QKSMS";
+
int unreadMessageCount = SmsHelper.getUnreadMessageCount(context);
- builder.setContentTitle(message.mContact)
+ builder.setContentTitle(notificationTitle)
.setContentText(SmsHelper.getUnseenSMSCount(context, threadId) + " " + sRes.getString(R.string.new_messages))
- .setLargeIcon(getLargeIcon(context, Contact.get(message.mAddress, false)))
+ .setLargeIcon(getLargeIcon(context, Contact.get(message.mAddress, false), privateNotifications))
.setContentIntent(threadPI)
.setNumber(unreadMessageCount)
- .setStyle(privateNotifications ? null : inboxStyle)
+ .setStyle(inboxStyle)
.addAction(R.drawable.ic_reply, sRes.getString(R.string.reply), replyPI)
.addAction(R.drawable.ic_accept, sRes.getString(R.string.read), readPI)
.extend(WearableIntentReceiver.getSingleConversationExtender(context, message.mContact, message.mAddress, threadId))
@@ -580,10 +620,11 @@ public class NotificationManager {
for (long threadId : threadIds) {
if (!oldThreads.contains(threadId)) {
ConversationPrefsHelper conversationPrefs = new ConversationPrefsHelper(context, threadId);
+ Integer privateNotification = conversationPrefs.getPrivateNotificationsSetting();
if (conversations.get(threadId).size() == 1) {
- singleMessage(context, conversations.get(threadId), threadId, copyBuilder(builder), conversationPrefs, false);
+ singleMessage(context, conversations.get(threadId), threadId, copyBuilder(builder), conversationPrefs, privateNotification);
} else {
- singleSender(context, conversations.get(threadId), threadId, copyBuilder(builder), conversationPrefs, false);
+ singleSender(context, conversations.get(threadId), threadId, copyBuilder(builder), conversationPrefs, privateNotification);
}
}
}
@@ -656,17 +697,21 @@ public class NotificationManager {
* Retreives the avatar to be used for the notification's large icon. If the user is running Lollipop, then let's
* crop their avatar to a circle
*/
- private static Bitmap getLargeIcon(Context context, Contact contact) {
+ private static Bitmap getLargeIcon(Context context, Contact contact, Integer privateNotification) {
Drawable avatarDrawable = contact.getAvatar(context, new BitmapDrawable(sRes, ContactHelper.blankContact(context, contact.getName())));
int idealIconWidth = sRes.getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
int idealIconHeight = sRes.getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
Bitmap bitmap = Bitmap.createScaledBitmap(((BitmapDrawable) avatarDrawable).getBitmap(), idealIconWidth, idealIconHeight, true);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- return ImageUtils.getCircleBitmap(bitmap, idealIconWidth);
- } else {
- return bitmap;
+ if (privateNotification == 2) {
+ return null;
+ }
+ else {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ return ImageUtils.getCircleBitmap(bitmap, idealIconWidth);
+ }
+ else return bitmap;
}
}
diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/ConversationNotificationSettingsDialog.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/ConversationNotificationSettingsDialog.java
index b316ea24..012a4bfa 100644
--- a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/ConversationNotificationSettingsDialog.java
+++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/ConversationNotificationSettingsDialog.java
@@ -99,9 +99,6 @@ public class ConversationNotificationSettingsDialog extends QKDialog implements
list.addView(new QKCheckBoxPreference(getActivity(), this, SettingsFragment.NOTIFICATION_TICKER,
mConversationPrefs.getConversationPrefs(), mConversationPrefs.getTickerEnabled(), R.string.pref_ticker, R.string.pref_ticker_summary).getView());
- list.addView(new QKCheckBoxPreference(getActivity(), this, SettingsFragment.NOTIFICATION_PRIVATE,
- mConversationPrefs.getConversationPrefs(), mConversationPrefs.getPrivateNotificationsEnabled(), R.string.pref_notifications_private, R.string.pref_notifications_private_summary).getView());
-
list.addView(new QKCheckBoxPreference(getActivity(), this, SettingsFragment.NOTIFICATION_VIBRATE,
mConversationPrefs.getConversationPrefs(), mConversationPrefs.getVibrateEnabled(), R.string.pref_vibration, R.string.pref_vibration_summary).getView());
diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java
index 4b9c1390..19c3b8a7 100644
--- a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java
+++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java
@@ -123,7 +123,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
public static final String NOTIFICATION_LED_COLOR = "pref_key_theme_led";
public static final String WAKE = "pref_key_wake";
public static final String NOTIFICATION_TICKER = "pref_key_ticker";
- public static final String NOTIFICATION_PRIVATE = "pref_key_notifications_private";
+ public static final String PRIVATE_NOTIFICATION = "pref_key_notification_private";
public static final String NOTIFICATION_VIBRATE = "pref_key_vibration";
public static final String NOTIFICATION_TONE = "pref_key_ringtone";
public static final String NOTIFICATION_CALL_BUTTON = "pref_key_notification_call";
diff --git a/QKSMS/src/main/res/values-de/strings.xml b/QKSMS/src/main/res/values-de/strings.xml
index d9dd1ca9..bf0162a9 100755
--- a/QKSMS/src/main/res/values-de/strings.xml
+++ b/QKSMS/src/main/res/values-de/strings.xml
@@ -11,7 +11,7 @@
Nachricht eingeben
Code eingeben
Neue Nachricht
- Neue Nachrichten
+ neue Nachrichten
Nachricht konnte nicht gesendet werden
Nachrichten konnten nicht gesendet werden
Berühre zum Ansehen
diff --git a/QKSMS/src/main/res/values/strings.xml b/QKSMS/src/main/res/values/strings.xml
index 4ececf11..3b89fad0 100644
--- a/QKSMS/src/main/res/values/strings.xml
+++ b/QKSMS/src/main/res/values/strings.xml
@@ -204,7 +204,7 @@
Wake phone
Turn your screen on when you receive a new message
Private notifications
- Hide message text in notifications
+ Tap to change what should be hidden in notfication
Notification sound
Select a notification sound
Show ticker
@@ -798,6 +798,12 @@
- Send message
+
+ - Show all
+ - Hide message
+ - Hide message and sender
+
+
diff --git a/QKSMS/src/main/res/xml/settings.xml b/QKSMS/src/main/res/xml/settings.xml
index ea71779e..9069905c 100644
--- a/QKSMS/src/main/res/xml/settings.xml
+++ b/QKSMS/src/main/res/xml/settings.xml
@@ -106,8 +106,8 @@
android:defaultValue="true"
android:key="pref_key_ticker" />
+ android:defaultValue="0"
+ android:key="pref_key_notification_private" />
diff --git a/QKSMS/src/main/res/xml/settings_notifications.xml b/QKSMS/src/main/res/xml/settings_notifications.xml
index 0d442413..85687eca 100644
--- a/QKSMS/src/main/res/xml/settings_notifications.xml
+++ b/QKSMS/src/main/res/xml/settings_notifications.xml
@@ -39,14 +39,14 @@
android:summary="@string/pref_ticker_summary"
android:title="@string/pref_ticker"
android:widgetLayout="@layout/view_checkbox" />
-
+ android:title="@string/pref_notifications_private" />