Respect privacy settings on ticker content for Android <5

Fixes #5517
Closes #5592

// FREEBIE
This commit is contained in:
FeuRenard 2016-08-01 00:15:49 +02:00 committed by Moxie Marlinspike
parent e7ad77398f
commit a370f086c0
4 changed files with 16 additions and 11 deletions

View File

@ -6,6 +6,9 @@
<string name="delete">Delete</string>
<string name="please_wait">Please wait...</string>
<!-- AbstractNotificationBuilder -->
<string name="AbstractNotificationBuilder_new_message">New message</string>
<!-- ApplicationPreferencesActivity -->
<string name="ApplicationPreferencesActivity_currently_s">Currently: %s</string>
<string name="ApplicationPreferenceActivity_you_havent_set_a_passphrase_yet">You haven\'t set a passphrase yet!</string>

View File

@ -10,6 +10,7 @@ import android.support.v4.app.NotificationCompat;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase;
import org.thoughtcrime.securesms.preferences.NotificationPrivacyPreference;
import org.thoughtcrime.securesms.recipients.Recipient;
@ -61,6 +62,16 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
}
}
public void setTicker(@NonNull Recipient recipient, @Nullable CharSequence message) {
if (privacy.isDisplayMessage()) {
setTicker(getStyledMessage(recipient, message));
} else if (privacy.isDisplayContact()) {
setTicker(getStyledMessage(recipient, context.getString(R.string.AbstractNotificationBuilder_new_message)));
} else {
setTicker(context.getString(R.string.AbstractNotificationBuilder_new_message));
}
}
private String[] parseBlinkPattern(String blinkPattern, String blinkPatternCustom) {
if (blinkPattern.equals("custom"))
blinkPattern = blinkPatternCustom;

View File

@ -278,7 +278,8 @@ public class MessageNotifier {
if (signal) {
builder.setAlarms(notificationState.getRingtone(), notificationState.getVibrate());
builder.setTicker(notifications.get(0).getText());
builder.setTicker(notifications.get(0).getIndividualRecipient(),
notifications.get(0).getText());
}
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))

View File

@ -150,16 +150,6 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
}
}
public void setTicker(@NonNull Recipient recipient, @Nullable CharSequence message) {
if (privacy.isDisplayMessage()) {
setTicker(getStyledMessage(recipient, message));
} else if (privacy.isDisplayContact()) {
setTicker(getStyledMessage(recipient, context.getString(R.string.SingleRecipientNotificationBuilder_new_message)));
} else {
setTicker(context.getString(R.string.SingleRecipientNotificationBuilder_new_message));
}
}
@Override
public Notification build() {
if (privacy.isDisplayMessage()) {