1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Fixes issue 1711

Owner: fiouzy
Don't display message subject in notification bar when keyguard is active (system locked)
This commit is contained in:
Fiouz 2010-09-01 22:26:36 +00:00
parent f21d86d8ce
commit f43db5235c
5 changed files with 71 additions and 31 deletions

View File

@ -326,6 +326,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="global_settings_confirm_action_spam">Spam</string>
<string name="global_settings_confirm_action_send">Send</string>
<string name="global_settings_privacy_mode_title">Privacy mode</string>
<string name="global_settings_privacy_mode_summary">Don\'t display message subject in notification bar when system is locked</string>
<string name="account_setup_basics_title">Set up a new account</string>
<string name="account_setup_basics_instructions">Enter this account\'s email address:</string>
<string name="account_setup_basics_instructions2_fmt">(You may add <xliff:g id="number_accounts">%d</xliff:g> more accounts.)</string>

View File

@ -79,6 +79,11 @@
android:negativeButtonText="@android:string/cancel"
/>
<CheckBoxPreference
android:key="privacy_mode"
android:title="@string/global_settings_privacy_mode_title"
android:summary="@string/global_settings_privacy_mode_summary"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/accountlist_preferences" android:key="accountlist_preferences">

View File

@ -107,6 +107,7 @@ public class K9 extends Application
private static boolean mAnimations = true;
private static boolean mConfirmDelete = false;
private static boolean mKeyguardPrivacy = false;
private static boolean mMessageListStars = true;
private static boolean mMessageListCheckboxes = false;
@ -356,6 +357,8 @@ public class K9 extends Application
editor.putBoolean("confirmDelete", mConfirmDelete);
editor.putBoolean("keyguardPrivacy", mKeyguardPrivacy);
fontSizes.save(editor);
}
@ -389,6 +392,8 @@ public class K9 extends Application
mConfirmDelete = sprefs.getBoolean("confirmDelete", false);
mKeyguardPrivacy = sprefs.getBoolean("keyguardPrivacy", false);
fontSizes.load(sprefs);
try
@ -699,6 +704,19 @@ public class K9 extends Application
mConfirmDelete = confirm;
}
/**
* @return Whether privacy rules should be applied when system is locked
*/
public static boolean keyguardPrivacy()
{
return mKeyguardPrivacy;
}
public static void setKeyguardPrivacy(final boolean state)
{
mKeyguardPrivacy = state;
}
/**
* Check if this system contains a buggy Gallery 3D package.
*

View File

@ -58,6 +58,8 @@ public class Prefs extends K9PreferenceActivity
private static final String PREFERENCE_CONFIRM_ACTIONS = "confirm_actions";
private static final String PREFERENCE_PRIVACY_MODE = "privacy_mode";
private ListPreference mLanguage;
private ListPreference mTheme;
private ListPreference mDateFormat;
@ -82,6 +84,8 @@ public class Prefs extends K9PreferenceActivity
private CheckboxListPreference mConfirmActions;
private CheckBoxPreference mPrivacyMode;
private String initBackgroundOps;
@ -243,6 +247,9 @@ public class Prefs extends K9PreferenceActivity
mConfirmActions = (CheckboxListPreference) findPreference(PREFERENCE_CONFIRM_ACTIONS);
mConfirmActions.setItems(new CharSequence[] {getString(R.string.global_settings_confirm_action_delete)});
mConfirmActions.setCheckedItems(new boolean[] {K9.confirmDelete()});
mPrivacyMode = (CheckBoxPreference) findPreference(PREFERENCE_PRIVACY_MODE);
mPrivacyMode.setChecked(K9.keyguardPrivacy());
}
@Override
@ -284,6 +291,8 @@ public class Prefs extends K9PreferenceActivity
K9.setConfirmDelete(mConfirmActions.getCheckedItems()[0]);
K9.setKeyguardPrivacy(mPrivacyMode.isChecked());
Editor editor = preferences.edit();
K9.save(editor);
DateFormatter.setDateFormat(editor, mDateFormat.getValue());

View File

@ -22,6 +22,7 @@ import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import android.app.Application;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
@ -4565,52 +4566,56 @@ public class MessagingController implements Runnable
{
// If we have a message, set the notification to "<From>: <Subject>"
StringBuffer messageNotice = new StringBuffer();
try
final KeyguardManager keyguardService = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if (!K9.keyguardPrivacy() || !keyguardService.inKeyguardRestrictedInputMode())
{
if (message != null && message.getFrom() != null)
try
{
Address[] fromAddrs = message.getFrom();
String from = fromAddrs.length > 0 ? fromAddrs[0].toFriendly().toString() : null;
String subject = message.getSubject();
if (subject == null)
if (message != null && message.getFrom() != null)
{
subject = context.getString(R.string.general_no_subject);
}
if (from != null)
{
// Show From: address by default
if (!account.isAnIdentity(fromAddrs))
Address[] fromAddrs = message.getFrom();
String from = fromAddrs.length > 0 ? fromAddrs[0].toFriendly().toString() : null;
String subject = message.getSubject();
if (subject == null)
{
messageNotice.append(from + ": " + subject);
subject = context.getString(R.string.general_no_subject);
}
// show To: if the message was sent from me
else
{
if (!account.isNotifySelfNewMail())
{
return false;
}
Address[] rcpts = message.getRecipients(Message.RecipientType.TO);
String to = rcpts.length > 0 ? rcpts[0].toFriendly().toString() : null;
if (to != null)
if (from != null)
{
// Show From: address by default
if (!account.isAnIdentity(fromAddrs))
{
messageNotice.append(String.format(context.getString(R.string.message_list_to_fmt), to) +": "+subject);
messageNotice.append(from + ": " + subject);
}
// show To: if the message was sent from me
else
{
messageNotice.append(context.getString(R.string.general_no_sender) + ": "+subject);
if (!account.isNotifySelfNewMail())
{
return false;
}
Address[] rcpts = message.getRecipients(Message.RecipientType.TO);
String to = rcpts.length > 0 ? rcpts[0].toFriendly().toString() : null;
if (to != null)
{
messageNotice.append(String.format(context.getString(R.string.message_list_to_fmt), to) +": "+subject);
}
else
{
messageNotice.append(context.getString(R.string.general_no_sender) + ": "+subject);
}
}
}
}
}
}
catch (MessagingException e)
{
Log.e(K9.LOG_TAG, "Unable to get message information for notification.", e);
catch (MessagingException e)
{
Log.e(K9.LOG_TAG, "Unable to get message information for notification.", e);
}
}