diff --git a/res/drawable-hdpi/ic_push_black.png b/res/drawable-hdpi/ic_push_black.png
deleted file mode 100644
index c26a83771c..0000000000
Binary files a/res/drawable-hdpi/ic_push_black.png and /dev/null differ
diff --git a/res/drawable-hdpi/ic_push_gray.png b/res/drawable-hdpi/ic_push_gray.png
deleted file mode 100644
index c779f5eb4d..0000000000
Binary files a/res/drawable-hdpi/ic_push_gray.png and /dev/null differ
diff --git a/res/drawable-mdpi/ic_push_black.png b/res/drawable-mdpi/ic_push_black.png
deleted file mode 100644
index 1144dcb673..0000000000
Binary files a/res/drawable-mdpi/ic_push_black.png and /dev/null differ
diff --git a/res/drawable-mdpi/ic_push_gray.png b/res/drawable-mdpi/ic_push_gray.png
deleted file mode 100644
index 568c2b27af..0000000000
Binary files a/res/drawable-mdpi/ic_push_gray.png and /dev/null differ
diff --git a/res/drawable-xhdpi/ic_push_black.png b/res/drawable-xhdpi/ic_push_black.png
deleted file mode 100644
index 465e6135dc..0000000000
Binary files a/res/drawable-xhdpi/ic_push_black.png and /dev/null differ
diff --git a/res/drawable-xhdpi/ic_push_gray.png b/res/drawable-xhdpi/ic_push_gray.png
deleted file mode 100644
index 112bc73de5..0000000000
Binary files a/res/drawable-xhdpi/ic_push_gray.png and /dev/null differ
diff --git a/res/drawable-xxhdpi/ic_push_black.png b/res/drawable-xxhdpi/ic_push_black.png
deleted file mode 100644
index b642256ede..0000000000
Binary files a/res/drawable-xxhdpi/ic_push_black.png and /dev/null differ
diff --git a/res/drawable-xxhdpi/ic_push_gray.png b/res/drawable-xxhdpi/ic_push_gray.png
deleted file mode 100644
index 24ba43f8ba..0000000000
Binary files a/res/drawable-xxhdpi/ic_push_gray.png and /dev/null differ
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 9de4d9f541..a1a8777b41 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -97,7 +97,6 @@
-
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1a29d2e96d..41c1b13750 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -28,19 +28,15 @@
You will need to re-register your phone number to use push messages again in the future.
Error connecting to server!
- Incoming SMS Enabled
+ SMS Enabled
Touch to change your default SMS app
- Incoming SMS Disabled
+ SMS Disabled
Touch to make TextSecure your default SMS app
on
On
off
Off
- partial
- SMS
- MMS
- Incoming %s
- outgoing %s
+ SMS %1$s, MMS %2$s
%d minutes
@@ -467,9 +463,7 @@
Send TextSecure message
- Send secure SMS
Send unsecured SMS
- Send secure MMS
Send unsecured MMS
Send
Remove
@@ -700,11 +694,10 @@
General
SMS and MMS
- Push and SMS
Receive all SMS
Receive all MMS
- Use TextSecure for viewing and storing all incoming text messages
- Use TextSecure for viewing and storing all incoming multimedia messages
+ Use TextSecure for all incoming text messages
+ Use TextSecure for all incoming multimedia messages
Input Settings
Enable Enter key
Replace the smiley key with an Enter key
@@ -787,22 +780,11 @@
Default
Language
Language %s
- Set as default SMS app
- Make TextSecure the default SMS/MMS application for your system.
- Push messages
+ TextSecure messages
- Increase privacy and avoid SMS fees by using the data channel for communication with other TextSecure users
+ Free private messaging to TextSecure and Signal users
- Outgoing SMS/MMS
Submit debug log
- TextSecure users
- ask first
- no MMS
- Send secure SMS if data connectivity is lost
- Ask before sending SMS/MMS
- Never send MMS
- Non-TextSecure users
- Nobody
\'WiFi Calling\' compatibility mode
Enable if your device uses SMS/MMS delivery over WiFi (only enable when \'WiFi Calling\' is enabled on your device).
diff --git a/res/values/themes.xml b/res/values/themes.xml
index ca54a980fb..4fecf33fe6 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -103,7 +103,6 @@
- #ff1d85d7
- - @drawable/ic_push_black
- @drawable/ic_message_black
- @drawable/ic_notifications_black
- @drawable/ic_app_protection_black
@@ -210,7 +209,6 @@
- @color/textsecure_primary_dark
- - @drawable/ic_push_gray
- @drawable/ic_message_gray
- @drawable/ic_notifications_gray
- @drawable/ic_app_protection_gray
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 3d4ef492c2..2d0d0a00a8 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -1,12 +1,6 @@
-
-
diff --git a/res/xml/preferences_advanced.xml b/res/xml/preferences_advanced.xml
index f324b05504..5cb1ba6c75 100644
--- a/res/xml/preferences_advanced.xml
+++ b/res/xml/preferences_advanced.xml
@@ -1,6 +1,11 @@
+
+
+ android:title="@string/ApplicationPreferencesActivity_sms_disabled"
+ android:summary="@string/ApplicationPreferencesActivity_touch_to_make_textsecure_your_default_sms_app" />
{
- private final CheckBoxPreference checkBoxPreference;
-
- public DisablePushMessagesTask(final CheckBoxPreference checkBoxPreference) {
- super(getActivity(), R.string.ApplicationPreferencesActivity_unregistering, R.string.ApplicationPreferencesActivity_unregistering_for_data_based_communication);
- this.checkBoxPreference = checkBoxPreference;
- }
-
- @Override
- protected void onPostExecute(Integer result) {
- super.onPostExecute(result);
- switch (result) {
- case NETWORK_ERROR:
- Toast.makeText(getActivity(),
- R.string.ApplicationPreferencesActivity_error_connecting_to_server,
- Toast.LENGTH_LONG).show();
- break;
- case SUCCESS:
- checkBoxPreference.setChecked(false);
- TextSecurePreferences.setPushRegistered(getActivity(), false);
- break;
- }
- }
-
- @Override
- protected Integer doInBackground(Void... params) {
- try {
- Context context = getActivity();
- TextSecureAccountManager accountManager = TextSecureCommunicationFactory.createManager(context);
-
- accountManager.setGcmId(Optional.absent());
- GoogleCloudMessaging.getInstance(context).unregister();
-
- return SUCCESS;
- } catch (AuthorizationFailedException afe) {
- Log.w(TAG, afe);
- return SUCCESS;
- } catch (IOException ioe) {
- Log.w(TAG, ioe);
- return NETWORK_ERROR;
- }
- }
- }
-
- @Override
- public boolean onPreferenceChange(final Preference preference, Object newValue) {
- if (((CheckBoxPreference)preference).isChecked()) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setIcon(ResUtil.getDrawable(getActivity(), R.attr.dialog_info_icon));
- builder.setTitle(R.string.ApplicationPreferencesActivity_disable_push_messages);
- builder.setMessage(R.string.ApplicationPreferencesActivity_this_will_disable_push_messages);
- builder.setNegativeButton(android.R.string.cancel, null);
- builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- new DisablePushMessagesTask((CheckBoxPreference)preference).execute();
- }
- });
- builder.show();
- } else {
- Intent nextIntent = new Intent(getActivity(), ApplicationPreferencesActivity.class);
- nextIntent.putExtra("master_secret", getActivity().getIntent().getParcelableExtra("master_secret"));
-
- Intent intent = new Intent(getActivity(), RegistrationActivity.class);
- intent.putExtra("cancel_button", true);
- intent.putExtra("next_intent", nextIntent);
- intent.putExtra("master_secret", getActivity().getIntent().getParcelableExtra("master_secret"));
- startActivity(intent);
- }
-
- return false;
- }
- }
}
}
diff --git a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java
index 72e84ef8b7..18232a8722 100644
--- a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java
+++ b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java
@@ -1,24 +1,41 @@
package org.thoughtcrime.securesms.preferences;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.provider.ContactsContract;
import android.support.v4.preference.PreferenceFragment;
import android.util.Log;
+import android.widget.Toast;
+
+import com.google.android.gms.gcm.GoogleCloudMessaging;
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
import org.thoughtcrime.securesms.LogSubmitActivity;
import org.thoughtcrime.securesms.R;
+import org.thoughtcrime.securesms.RegistrationActivity;
import org.thoughtcrime.securesms.contacts.ContactAccessor;
import org.thoughtcrime.securesms.contacts.ContactIdentityManager;
+import org.thoughtcrime.securesms.push.TextSecureCommunicationFactory;
+import org.thoughtcrime.securesms.util.ProgressDialogAsyncTask;
+import org.thoughtcrime.securesms.util.ResUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
+import org.whispersystems.libaxolotl.util.guava.Optional;
+import org.whispersystems.textsecure.api.TextSecureAccountManager;
+import org.whispersystems.textsecure.api.push.exceptions.AuthorizationFailedException;
+
+import java.io.IOException;
public class AdvancedPreferenceFragment extends PreferenceFragment {
private static final String TAG = AdvancedPreferenceFragment.class.getSimpleName();
+ private static final String PUSH_MESSAGING_PREF = "pref_toggle_push_messaging";
private static final String SUBMIT_DEBUG_LOG_PREF = "pref_submit_debug_logs";
private static final int PICK_IDENTITY_CONTACT = 1;
@@ -28,6 +45,7 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
super.onCreate(paramBundle);
addPreferencesFromResource(R.xml.preferences_advanced);
+ initializePushMessagingToggle();
initializeIdentitySelection();
this.findPreference(SUBMIT_DEBUG_LOG_PREF)
@@ -50,6 +68,12 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
}
}
+ private void initializePushMessagingToggle() {
+ CheckBoxPreference preference = (CheckBoxPreference)this.findPreference(PUSH_MESSAGING_PREF);
+ preference.setChecked(TextSecurePreferences.isPushRegistered(getActivity()));
+ preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
+ }
+
private void initializeIdentitySelection() {
ContactIdentityManager identity = ContactIdentityManager.getInstance(getActivity());
@@ -97,4 +121,82 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
return true;
}
}
+
+ private class PushMessagingClickListener implements Preference.OnPreferenceChangeListener {
+ private static final int SUCCESS = 0;
+ private static final int NETWORK_ERROR = 1;
+
+ private class DisablePushMessagesTask extends ProgressDialogAsyncTask {
+ private final CheckBoxPreference checkBoxPreference;
+
+ public DisablePushMessagesTask(final CheckBoxPreference checkBoxPreference) {
+ super(getActivity(), R.string.ApplicationPreferencesActivity_unregistering, R.string.ApplicationPreferencesActivity_unregistering_for_data_based_communication);
+ this.checkBoxPreference = checkBoxPreference;
+ }
+
+ @Override
+ protected void onPostExecute(Integer result) {
+ super.onPostExecute(result);
+ switch (result) {
+ case NETWORK_ERROR:
+ Toast.makeText(getActivity(),
+ R.string.ApplicationPreferencesActivity_error_connecting_to_server,
+ Toast.LENGTH_LONG).show();
+ break;
+ case SUCCESS:
+ checkBoxPreference.setChecked(false);
+ TextSecurePreferences.setPushRegistered(getActivity(), false);
+ break;
+ }
+ }
+
+ @Override
+ protected Integer doInBackground(Void... params) {
+ try {
+ Context context = getActivity();
+ TextSecureAccountManager accountManager = TextSecureCommunicationFactory.createManager(context);
+
+ accountManager.setGcmId(Optional.absent());
+ GoogleCloudMessaging.getInstance(context).unregister();
+
+ return SUCCESS;
+ } catch (AuthorizationFailedException afe) {
+ Log.w(TAG, afe);
+ return SUCCESS;
+ } catch (IOException ioe) {
+ Log.w(TAG, ioe);
+ return NETWORK_ERROR;
+ }
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(final Preference preference, Object newValue) {
+ if (((CheckBoxPreference)preference).isChecked()) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setIcon(ResUtil.getDrawable(getActivity(), R.attr.dialog_info_icon));
+ builder.setTitle(R.string.ApplicationPreferencesActivity_disable_push_messages);
+ builder.setMessage(R.string.ApplicationPreferencesActivity_this_will_disable_push_messages);
+ builder.setNegativeButton(android.R.string.cancel, null);
+ builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ new DisablePushMessagesTask((CheckBoxPreference)preference).execute();
+ }
+ });
+ builder.show();
+ } else {
+ Intent nextIntent = new Intent(getActivity(), ApplicationPreferencesActivity.class);
+ nextIntent.putExtra("master_secret", getActivity().getIntent().getParcelableExtra("master_secret"));
+
+ Intent intent = new Intent(getActivity(), RegistrationActivity.class);
+ intent.putExtra("cancel_button", true);
+ intent.putExtra("next_intent", nextIntent);
+ intent.putExtra("master_secret", getActivity().getIntent().getParcelableExtra("master_secret"));
+ startActivity(intent);
+ }
+
+ return false;
+ }
+ }
}
diff --git a/src/org/thoughtcrime/securesms/preferences/SmsMmsPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/SmsMmsPreferenceFragment.java
index 305923566f..54ac9c5da7 100644
--- a/src/org/thoughtcrime/securesms/preferences/SmsMmsPreferenceFragment.java
+++ b/src/org/thoughtcrime/securesms/preferences/SmsMmsPreferenceFragment.java
@@ -81,29 +81,23 @@ public class SmsMmsPreferenceFragment extends PreferenceFragment {
}
public static CharSequence getSummary(Context context) {
- return getIncomingSmsSummary(context);
- }
+ final String on = context.getString(R.string.ApplicationPreferencesActivity_on);
+ final String onCaps = context.getString(R.string.ApplicationPreferencesActivity_On);
+ final String off = context.getString(R.string.ApplicationPreferencesActivity_off);
+ final String offCaps = context.getString(R.string.ApplicationPreferencesActivity_Off);
+ final int smsMmsSummaryResId = R.string.ApplicationPreferencesActivity_sms_mms_summary;
- private static CharSequence getIncomingSmsSummary(Context context) {
- final int onResId = R.string.ApplicationPreferencesActivity_on;
- final int offResId = R.string.ApplicationPreferencesActivity_off;
- final int smsResId = R.string.ApplicationPreferencesActivity_sms;
- final int mmsResId = R.string.ApplicationPreferencesActivity_mms;
- final int incomingSmsResId = R.string.ApplicationPreferencesActivity_incoming_sms_summary;
-
- final int incomingSmsSummary;
boolean postKitkatSMS = Util.isDefaultSmsProvider(context);
boolean preKitkatSMS = TextSecurePreferences.isInterceptAllSmsEnabled(context);
boolean preKitkatMMS = TextSecurePreferences.isInterceptAllMmsEnabled(context);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- if (postKitkatSMS) incomingSmsSummary = onResId;
- else incomingSmsSummary = offResId;
+ if (postKitkatSMS) return onCaps;
+ else return offCaps;
} else {
- if (preKitkatSMS && preKitkatMMS) incomingSmsSummary = onResId;
- else if (preKitkatSMS && !preKitkatMMS) incomingSmsSummary = smsResId;
- else if (!preKitkatSMS && preKitkatMMS) incomingSmsSummary = mmsResId;
- else incomingSmsSummary = offResId;
+ if (preKitkatSMS && preKitkatMMS) return onCaps;
+ else if (preKitkatSMS && !preKitkatMMS) return context.getString(smsMmsSummaryResId, on, off);
+ else if (!preKitkatSMS && preKitkatMMS) return context.getString(smsMmsSummaryResId, off, on);
+ else return offCaps;
}
- return context.getString(incomingSmsResId, context.getString(incomingSmsSummary));
}
}