diff --git a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java index a5254caf4a..4a0938b83c 100644 --- a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java +++ b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java @@ -80,6 +80,8 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr private static final String DISPLAY_CATEGORY_PREF = "pref_display_category"; private static final String PUSH_MESSAGING_PREF = "pref_toggle_push_messaging"; private static final String MMS_PREF = "pref_mms_preferences"; + private static final String KITKAT_DEFAULT_PREF = "pref_set_default"; + private final DynamicTheme dynamicTheme = new DynamicTheme(); private final DynamicLanguage dynamicLanguage = new DynamicLanguage(); @@ -108,16 +110,16 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr .setOnPreferenceChangeListener(new DisablePassphraseClickListener()); this.findPreference(MMS_PREF) .setOnPreferenceClickListener(new ApnPreferencesClickListener()); - this.findPreference(LED_COLOR_PREF) + this.findPreference(TextSecurePreferences.LED_COLOR_PREF) .setOnPreferenceChangeListener(new ListSummaryListener()); - this.findPreference(LED_BLINK_PREF) + this.findPreference(TextSecurePreferences.LED_BLINK_PREF) .setOnPreferenceChangeListener(new ListSummaryListener()); - this.findPreference(RINGTONE_PREF) + this.findPreference(TextSecurePreferences.RINGTONE_PREF) .setOnPreferenceChangeListener(new RingtoneSummaryListener()); - initializeListSummary((ListPreference) findPreference(LED_COLOR_PREF)); - initializeListSummary((ListPreference) findPreference(LED_BLINK_PREF)); - initializeRingtoneSummary((RingtonePreference) findPreference(RINGTONE_PREF)); + initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF)); + initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF)); + initializeRingtoneSummary((RingtonePreference) findPreference(TextSecurePreferences.RINGTONE_PREF)); } @Override @@ -178,8 +180,8 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - generalCategory.removePreference(findPreference(ALL_SMS_PREF)); - generalCategory.removePreference(findPreference(ALL_MMS_PERF)); + generalCategory.removePreference(findPreference(TextSecurePreferences.ALL_SMS_PREF)); + generalCategory.removePreference(findPreference(TextSecurePreferences.ALL_MMS_PREF)); if (Util.isDefaultSmsProvider(this)) { generalCategory.removePreference(defaultPreference); diff --git a/src/org/thoughtcrime/securesms/ConversationListActivity.java b/src/org/thoughtcrime/securesms/ConversationListActivity.java index 66969cf4af..520b14c90b 100644 --- a/src/org/thoughtcrime/securesms/ConversationListActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationListActivity.java @@ -22,10 +22,8 @@ import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; -import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.crypto.IdentityKeyUtil; import org.thoughtcrime.securesms.service.DirectoryRefreshListener; -import org.whispersystems.textsecure.crypto.MasterSecret; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.ThreadDatabase; import org.thoughtcrime.securesms.notifications.MessageNotifier; @@ -37,6 +35,7 @@ import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicTheme; import org.thoughtcrime.securesms.util.MemoryCleaner; import org.thoughtcrime.securesms.util.Util; +import org.whispersystems.textsecure.crypto.MasterSecret; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/org/thoughtcrime/securesms/database/MmsDatabase.java b/src/org/thoughtcrime/securesms/database/MmsDatabase.java index 6b6fbeaef5..666070916e 100644 --- a/src/org/thoughtcrime/securesms/database/MmsDatabase.java +++ b/src/org/thoughtcrime/securesms/database/MmsDatabase.java @@ -361,7 +361,8 @@ public class MmsDatabase extends Database implements MmsSmsColumns { { PduHeaders headers = retrieved.getPduHeaders(); ContentValues contentValues = getContentValuesFromHeader(headers); - boolean unread = Util.isDefaultSmsProvider(context) || ((mailbox & Types.SECURE_MESSAGE_BIT) != 0); + boolean unread = org.thoughtcrime.securesms.util.Util.isDefaultSmsProvider(context) || + ((mailbox & Types.SECURE_MESSAGE_BIT) != 0); if (threadId == -1 || retrieved.isGroupMessage()) { try { @@ -439,7 +440,7 @@ public class MmsDatabase extends Database implements MmsSmsColumns { contentValues.put(THREAD_ID, threadId); contentValues.put(STATUS, Status.DOWNLOAD_INITIALIZED); contentValues.put(DATE_RECEIVED, System.currentTimeMillis() / 1000); - contentValues.put(READ, Util.isDefaultSmsProvider(context) ? 0 : 1); + contentValues.put(READ, org.thoughtcrime.securesms.util.Util.isDefaultSmsProvider(context) ? 0 : 1); if (!contentValues.containsKey(DATE_SENT)) contentValues.put(DATE_SENT, contentValues.getAsLong(DATE_RECEIVED)); @@ -463,7 +464,7 @@ public class MmsDatabase extends Database implements MmsSmsColumns { notifyConversationListeners(threadId); DatabaseFactory.getThreadDatabase(context).update(threadId); - if (Util.isDefaultSmsProvider(context)) { + if (org.thoughtcrime.securesms.util.Util.isDefaultSmsProvider(context)) { DatabaseFactory.getThreadDatabase(context).setUnread(threadId); } diff --git a/src/org/thoughtcrime/securesms/database/SmsDatabase.java b/src/org/thoughtcrime/securesms/database/SmsDatabase.java index cd71f4b597..1e3a314c3b 100644 --- a/src/org/thoughtcrime/securesms/database/SmsDatabase.java +++ b/src/org/thoughtcrime/securesms/database/SmsDatabase.java @@ -260,7 +260,8 @@ public class SmsDatabase extends Database implements MmsSmsColumns { Recipient recipient = new Recipient(null, message.getSender(), null, null); Recipients recipients = new Recipients(recipient); long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients); - boolean unread = Util.isDefaultSmsProvider(context) || message.isSecureMessage() || message.isKeyExchange(); + boolean unread = org.thoughtcrime.securesms.util.Util.isDefaultSmsProvider(context) || + message.isSecureMessage() || message.isKeyExchange(); ContentValues values = new ContentValues(6); values.put(ADDRESS, message.getSender()); diff --git a/src/org/thoughtcrime/securesms/service/SmsListener.java b/src/org/thoughtcrime/securesms/service/SmsListener.java index 21f0f7aa09..02993176dc 100644 --- a/src/org/thoughtcrime/securesms/service/SmsListener.java +++ b/src/org/thoughtcrime/securesms/service/SmsListener.java @@ -111,8 +111,7 @@ public class SmsListener extends BroadcastReceiver { } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT || - PreferenceManager.getDefaultSharedPreferences(context) - .getBoolean(ApplicationPreferencesActivity.ALL_SMS_PREF, true)) + TextSecurePreferences.isInterceptAllSmsEnabled(context)) { return true; } diff --git a/src/org/thoughtcrime/securesms/transport/BaseTransport.java b/src/org/thoughtcrime/securesms/transport/BaseTransport.java index bd357dc9f6..9d8856434e 100644 --- a/src/org/thoughtcrime/securesms/transport/BaseTransport.java +++ b/src/org/thoughtcrime/securesms/transport/BaseTransport.java @@ -5,14 +5,14 @@ import android.content.Intent; import android.net.Uri; import org.thoughtcrime.securesms.service.SendReceiveService; -import org.thoughtcrime.securesms.service.SmsListener; +import org.thoughtcrime.securesms.service.SmsDeliveryListener; public abstract class BaseTransport { protected Intent constructSentIntent(Context context, long messageId, long type, boolean upgraded) { Intent pending = new Intent(SendReceiveService.SENT_SMS_ACTION, Uri.parse("custom://" + messageId + System.currentTimeMillis()), - context, SmsListener.class); + context, SmsDeliveryListener.class); pending.putExtra("type", type); pending.putExtra("message_id", messageId); @@ -24,7 +24,7 @@ public abstract class BaseTransport { protected Intent constructDeliveredIntent(Context context, long messageId, long type) { Intent pending = new Intent(SendReceiveService.DELIVERED_SMS_ACTION, Uri.parse("custom://" + messageId + System.currentTimeMillis()), - context, SmsListener.class); + context, SmsDeliveryListener.class); pending.putExtra("type", type); pending.putExtra("message_id", messageId); diff --git a/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java b/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java index 18bf084bce..59c20f7e0e 100644 --- a/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java +++ b/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java @@ -18,13 +18,14 @@ public class TextSecurePreferences { public static final String THREAD_TRIM_NOW = "pref_trim_now"; public static final String ENABLE_MANUAL_MMS_PREF = "pref_enable_manual_mms"; - private static final String RINGTONE_PREF = "pref_key_ringtone"; + public static final String RINGTONE_PREF = "pref_key_ringtone"; private static final String VIBRATE_PREF = "pref_key_vibrate"; private static final String NOTIFICATION_PREF = "pref_key_enable_notifications"; - private static final String LED_COLOR_PREF = "pref_led_color"; - private static final String LED_BLINK_PREF = "pref_led_blink"; + public static final String LED_COLOR_PREF = "pref_led_color"; + public static final String LED_BLINK_PREF = "pref_led_blink"; private static final String LED_BLINK_PREF_CUSTOM = "pref_led_blink_custom"; - private static final String ALL_MMS_PERF = "pref_all_mms"; + public static final String ALL_MMS_PREF = "pref_all_mms"; + public static final String ALL_SMS_PREF = "pref_all_sms"; private static final String PASSPHRASE_TIMEOUT_INTERVAL_PREF = "pref_timeout_interval"; private static final String PASSPHRASE_TIMEOUT_PREF = "pref_timeout_passphrase"; private static final String AUTO_KEY_EXCHANGE_PREF = "pref_auto_complete_key_exchange"; @@ -175,7 +176,11 @@ public class TextSecurePreferences { } public static boolean isInterceptAllMmsEnabled(Context context) { - return getBooleanPreference(context, ALL_MMS_PERF, true); + return getBooleanPreference(context, ALL_MMS_PREF, true); + } + + public static boolean isInterceptAllSmsEnabled(Context context) { + return getBooleanPreference(context, ALL_SMS_PREF, true); } public static boolean isNotificationsEnabled(Context context) {