adapt SMS strings in preferences

Fixes #2672
Closes #2682

//FREEBIE
This commit is contained in:
agrajaghh 2015-03-14 11:36:35 +01:00 committed by Moxie Marlinspike
parent 142f84703b
commit 0f572d1e5d
17 changed files with 127 additions and 159 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 789 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 962 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -97,7 +97,6 @@
<attr name="android:foregroundGravity" />
</declare-styleable>
<attr name="pref_ic_push" format="reference" />
<attr name="pref_ic_sms_mms" format="reference" />
<attr name="pref_ic_notifications" format="reference" />
<attr name="pref_ic_app_protection" format="reference" />

View File

@ -28,19 +28,15 @@
You will need to re-register your phone number to use push messages again in the future.
</string>
<string name="ApplicationPreferencesActivity_error_connecting_to_server">Error connecting to server!</string>
<string name="ApplicationPreferencesActivity_sms_enabled">Incoming SMS Enabled</string>
<string name="ApplicationPreferencesActivity_sms_enabled">SMS Enabled</string>
<string name="ApplicationPreferencesActivity_touch_to_change_your_default_sms_app">Touch to change your default SMS app</string>
<string name="ApplicationPreferencesActivity_sms_disabled">Incoming SMS Disabled</string>
<string name="ApplicationPreferencesActivity_sms_disabled">SMS Disabled</string>
<string name="ApplicationPreferencesActivity_touch_to_make_textsecure_your_default_sms_app">Touch to make TextSecure your default SMS app</string>
<string name="ApplicationPreferencesActivity_on">on</string>
<string name="ApplicationPreferencesActivity_On">On</string>
<string name="ApplicationPreferencesActivity_off">off</string>
<string name="ApplicationPreferencesActivity_Off">Off</string>
<string name="ApplicationPreferencesActivity_partial">partial</string>
<string name="ApplicationPreferencesActivity_sms">SMS</string>
<string name="ApplicationPreferencesActivity_mms">MMS</string>
<string name="ApplicationPreferencesActivity_incoming_sms_summary">Incoming %s</string>
<string name="ApplicationPreferencesActivity_outgoing_sms_summary">outgoing %s</string>
<string name="ApplicationPreferencesActivity_sms_mms_summary">SMS %1$s, MMS %2$s</string>
<!-- AppProtectionPreferenceFragment -->
<string name="AppProtectionPreferenceFragment_minutes">%d minutes</string>
@ -467,9 +463,7 @@
<!-- conversation_activity -->
<string name="conversation_activity__type_message_push">Send TextSecure message</string>
<string name="conversation_activity__type_message_sms_secure">Send secure SMS</string>
<string name="conversation_activity__type_message_sms_insecure">Send unsecured SMS</string>
<string name="conversation_activity__type_message_mms_secure">Send secure MMS</string>
<string name="conversation_activity__type_message_mms_insecure">Send unsecured MMS</string>
<string name="conversation_activity__send">Send</string>
<string name="conversation_activity__remove">Remove</string>
@ -700,11 +694,10 @@
<!-- preferences.xml -->
<string name="preferences__general">General</string>
<string name="preferences__sms_mms">SMS and MMS</string>
<string name="preferences__push_sms_category">Push and SMS</string>
<string name="preferences__pref_all_sms_title">Receive all SMS</string>
<string name="preferences__pref_all_mms_title">Receive all MMS</string>
<string name="preferences__use_textsecure_for_viewing_and_storing_all_incoming_text_messages">Use TextSecure for viewing and storing all incoming text messages</string>
<string name="preferences__use_textsecure_for_viewing_and_storing_all_incoming_multimedia_messages">Use TextSecure for viewing and storing all incoming multimedia messages</string>
<string name="preferences__use_textsecure_for_viewing_and_storing_all_incoming_text_messages">Use TextSecure for all incoming text messages</string>
<string name="preferences__use_textsecure_for_viewing_and_storing_all_incoming_multimedia_messages">Use TextSecure for all incoming multimedia messages</string>
<string name="preferences__input_settings">Input Settings</string>
<string name="preferences__enable_enter_key_title">Enable Enter key</string>
<string name="preferences__replace_smiley_with_enter_key">Replace the smiley key with an Enter key</string>
@ -787,22 +780,11 @@
<string name="preferences__default">Default</string>
<string name="preferences__language">Language</string>
<string name="preferences__language_summary">Language %s</string>
<string name="preferences__make_default_sms_app">Set as default SMS app</string>
<string name="preferences__make_textsecure_the_default_sms_mms_app">Make TextSecure the default SMS/MMS application for your system.</string>
<string name="preferences__use_data_channel">Push messages</string>
<string name="preferences__textsecure_messages">TextSecure messages</string>
<string name="preferences__use_the_data_channel_for_communication_with_other_textsecure_users">
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
</string>
<string name="preferences__sms_fallback">Outgoing SMS/MMS</string>
<string name="preferences__submit_debug_log">Submit debug log</string>
<string name="preferences__sms_outgoing_push_users">TextSecure users</string>
<string name="preferences__sms_fallback_push_users_ask">ask first</string>
<string name="preferences__sms_fallback_push_users_no_mms">no MMS</string>
<string name="preferences__sms_outgoing_push_users_description">Send secure SMS if data connectivity is lost</string>
<string name="preferences__sms_fallback_ask_before_sending_sms_mms">Ask before sending SMS/MMS</string>
<string name="preferences__sms_fallback_never_send_mms">Never send MMS</string>
<string name="preferences__sms_fallback_non_push_users">Non-TextSecure users</string>
<string name="preferences__sms_fallback_nobody">Nobody</string>
<string name="preferences__support_wifi_calling">\'WiFi Calling\' compatibility mode</string>
<string name="preferences__enable_if_your_device_supports_sms_mms_delivery_over_wifi">Enable if your device uses SMS/MMS delivery over WiFi (only enable when \'WiFi Calling\' is enabled on your device).</string>

View File

@ -103,7 +103,6 @@
<item name="reminder_header_background">#ff1d85d7</item>
<item name="pref_ic_push">@drawable/ic_push_black</item>
<item name="pref_ic_sms_mms">@drawable/ic_message_black</item>
<item name="pref_ic_notifications">@drawable/ic_notifications_black</item>
<item name="pref_ic_app_protection">@drawable/ic_app_protection_black</item>
@ -210,7 +209,6 @@
<item name="reminder_header_background">@color/textsecure_primary_dark</item>
<item name="pref_ic_push">@drawable/ic_push_gray</item>
<item name="pref_ic_sms_mms">@drawable/ic_message_gray</item>
<item name="pref_ic_notifications">@drawable/ic_notifications_gray</item>
<item name="pref_ic_app_protection">@drawable/ic_app_protection_gray</item>

View File

@ -1,12 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:defaultValue="false"
android:key="pref_toggle_push_messaging"
android:title="@string/preferences__use_data_channel"
android:summary="@string/preferences__use_the_data_channel_for_communication_with_other_textsecure_users"
android:icon="?pref_ic_push"/>
<Preference android:key="preference_category_sms_mms"
android:title="@string/preferences__sms_mms"
android:icon="?pref_ic_sms_mms"/>

View File

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:defaultValue="false"
android:key="pref_toggle_push_messaging"
android:title="@string/preferences__textsecure_messages"
android:summary="@string/preferences__use_the_data_channel_for_communication_with_other_textsecure_users"/>
<CheckBoxPreference android:defaultValue="false"
android:key="pref_enter_key"
android:title="@string/preferences__enable_enter_key_title"

View File

@ -12,8 +12,8 @@
android:title="@string/preferences__pref_all_mms_title" />
<Preference android:key="pref_set_default"
android:title="@string/preferences__make_default_sms_app"
android:summary="@string/preferences__make_textsecure_the_default_sms_mms_app" />
android:title="@string/ApplicationPreferencesActivity_sms_disabled"
android:summary="@string/ApplicationPreferencesActivity_touch_to_make_textsecure_your_default_sms_app" />
<CheckBoxPreference android:defaultValue="false"
android:key="pref_delivery_report_sms"

View File

@ -16,22 +16,14 @@
*/
package org.thoughtcrime.securesms;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
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.crypto.MasterSecret;
import org.thoughtcrime.securesms.preferences.AdvancedPreferenceFragment;
@ -40,20 +32,11 @@ import org.thoughtcrime.securesms.preferences.AppearancePreferenceFragment;
import org.thoughtcrime.securesms.preferences.NotificationsPreferenceFragment;
import org.thoughtcrime.securesms.preferences.SmsMmsPreferenceFragment;
import org.thoughtcrime.securesms.preferences.StoragePreferenceFragment;
import org.thoughtcrime.securesms.push.TextSecureCommunicationFactory;
import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.util.Dialogs;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.MemoryCleaner;
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;
/**
* The Activity for application preference display and management.
@ -74,8 +57,6 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
private static final String PREFERENCE_CATEGORY_STORAGE = "preference_category_storage";
private static final String PREFERENCE_CATEGORY_ADVANCED = "preference_category_advanced";
private static final String PUSH_MESSAGING_PREF = "pref_toggle_push_messaging";
private final DynamicTheme dynamicTheme = new DynamicTheme();
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
@ -146,11 +127,8 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.preferences);
initializePushMessagingToggle();
this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_SMS_MMS));
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
@ -228,89 +206,5 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
return true;
}
}
private void initializePushMessagingToggle() {
CheckBoxPreference preference = (CheckBoxPreference)this.findPreference(PUSH_MESSAGING_PREF);
preference.setChecked(TextSecurePreferences.isPushRegistered(getActivity()));
preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
}
private class PushMessagingClickListener implements Preference.OnPreferenceChangeListener {
private static final int SUCCESS = 0;
private static final int NETWORK_ERROR = 1;
private class DisablePushMessagesTask extends ProgressDialogAsyncTask<Void, Void, Integer> {
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.<String>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;
}
}
}
}

View File

@ -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<Void, Void, Integer> {
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.<String>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;
}
}
}

View File

@ -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));
}
}