From 0f572d1e5d26fa8225b898c2cdaeceb477cd6b39 Mon Sep 17 00:00:00 2001 From: agrajaghh Date: Sat, 14 Mar 2015 11:36:35 +0100 Subject: [PATCH] adapt SMS strings in preferences Fixes #2672 Closes #2682 //FREEBIE --- res/drawable-hdpi/ic_push_black.png | Bin 527 -> 0 bytes res/drawable-hdpi/ic_push_gray.png | Bin 617 -> 0 bytes res/drawable-mdpi/ic_push_black.png | Bin 385 -> 0 bytes res/drawable-mdpi/ic_push_gray.png | Bin 451 -> 0 bytes res/drawable-xhdpi/ic_push_black.png | Bin 651 -> 0 bytes res/drawable-xhdpi/ic_push_gray.png | Bin 789 -> 0 bytes res/drawable-xxhdpi/ic_push_black.png | Bin 962 -> 0 bytes res/drawable-xxhdpi/ic_push_gray.png | Bin 1137 -> 0 bytes res/values/attrs.xml | 1 - res/values/strings.xml | 32 ++---- res/values/themes.xml | 2 - res/xml/preferences.xml | 6 - res/xml/preferences_advanced.xml | 5 + res/xml/preferences_sms_mms.xml | 4 +- .../ApplicationPreferencesActivity.java | 106 ------------------ .../AdvancedPreferenceFragment.java | 102 +++++++++++++++++ .../preferences/SmsMmsPreferenceFragment.java | 28 ++--- 17 files changed, 127 insertions(+), 159 deletions(-) delete mode 100644 res/drawable-hdpi/ic_push_black.png delete mode 100644 res/drawable-hdpi/ic_push_gray.png delete mode 100644 res/drawable-mdpi/ic_push_black.png delete mode 100644 res/drawable-mdpi/ic_push_gray.png delete mode 100644 res/drawable-xhdpi/ic_push_black.png delete mode 100644 res/drawable-xhdpi/ic_push_gray.png delete mode 100644 res/drawable-xxhdpi/ic_push_black.png delete mode 100644 res/drawable-xxhdpi/ic_push_gray.png diff --git a/res/drawable-hdpi/ic_push_black.png b/res/drawable-hdpi/ic_push_black.png deleted file mode 100644 index c26a83771cc3d087df95999a79b9623f91dfa4ba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 527 zcmV+q0`UEbP)$j$Y8U0|CTNd4DrqT`pq|c^Y>iecLs)UXNN=Oh#6;=6ohYA~rXKgAR&>-&+|9DG+ z4QL_-dyb8(NI;h{46}s<^qC=4_mIHupy+2C3G54f;>p0D*OABPpsk75K zO{+^ksF6C!jygMo(+xyzn|=UdJ{gmfIMt1{9a0@*@*++n=3h#xWlWBdXAD4np|hq#apCq7CEE4%9vq6jI>{UBswEod8uH zsPF$xYJ_8y26L>?Wc9yqpkYcjl==R-0MM%&ta5^$NDwxu(=!7+B%wTq{sLgsi&3oF RtBe2u002ovPDHLkV1kqi>q!6r diff --git a/res/drawable-hdpi/ic_push_gray.png b/res/drawable-hdpi/ic_push_gray.png deleted file mode 100644 index c779f5eb4d1f71ad55fd98c4c74c528d4f19c38b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 617 zcmV-v0+#)WP)=ZdmfA!ci*WIZG=U%y zOy#M^X8&*0g}_-TMpMK@kqBo*Mx$ZzVD`=K&X#$v{m<|HnQw1hxoEmo`fvqfsKNi^ z8p^mVebcSEz~ulQ;0v_DOKK$8?*yOOCzH??PpG|_;JO7j@B=!58|s>FNs0G2V+uNj zAHUd?2EPpfbV|>>+?o`>0nec`_*u1(C_q)9vsoS{!JmZAZaHqj&vs$XB|yDboiqT~ zq1~*m5`5T>dDj4Z^xNY5KLPD-bu4~?M{Q^J?^X9b^IpOyI`k=eR;z;Tn4onZV(>vP zpIh1T-%+g7N!n=)ki#_KPE+kA8gR%Q&`$?lY?{mxZRU(QV2}pfYpNZh%RFEX7@%E! zd%Y)GgI!pp0fWW>oQ0;I58MB}(0IoyrQf`Zik5)IsFejvFn(KER4vG4YWz=>()>=_kdg0003$%i%sn42s2QvmFf2F#Edce*ZFIo_U{v*QV7oZ_x{Hy|HA`Nj=53yYGvr=d-)E zDR9gO(VR7NCb(il^$; z)(3l${jPuDmp`%};JfT^KJu|hodu^v>Uq8g%d)G6hOWt0$zF-V)@&s^YAlMnNwYge z<4Y=7e{Z)|H+*XuU&-Uy5wAsKBQuJ0%vrFizRNQ^{HLy6ZVTb7>pG@#L3nAO fsU3Go$0qgkdg0004sNklfZ0nydgDl8%l`lX002ovPDHLkV1lBZ$hH6g diff --git a/res/drawable-xhdpi/ic_push_black.png b/res/drawable-xhdpi/ic_push_black.png deleted file mode 100644 index 465e6135dc2c491a9dc3bb8e28314308ee01a907..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)w@Jx~NL#0a56P|JlNi3MQ_f|%Gt5H5mGSDGkMH(69d z8M-Jz7g)rid1+W&yO z&Jb!Z0WuY^gPa5z?8h!(7Mc1&zC~o}2L+8FQ}4+48ku@YK_`%@$K-p6OkKuc9vK>^ zEw87@&^m`PxP~GsjY$Q|D3V$+8blE^i&>mGTKYbHQmOHrg7$YbBBrbuy8$W!aI z<6t*4$V)>w+T-P&{D>INcJZR*%a@=;SI8j8o{+$U2FKfQpE#bx=wTjVFT((y#pxtX zV0?tO5RoHXWSoW2gUnGw6bJA#qh%R|6;ZTsp%`IMQJ_*TTu6}xfho8UGwcsRv{Xu>ZMGFO? zjD(1+lyId?HqHH>nFcK_DUfv0rWWEKxxo+1X^8jEyK`S|=JQ?Oa}LaV@7}qTkzoQ` zP|qQ>ql)#Qp*`dS z_LD7%b$9^nJ=_snOX*X4_%pO&#<(=y_O+OSP9xJ?L*}@~xxFYes3tS0#vHVT%&01p z_S^6S+ETv9wvso)t1$v?F^Nbnd4U_ymeWFVYNzO8M=LqO74awKTJj5}&Rg1+)kSD& zxQ-U^5omFm$qDM^rJ|L;$F6`D=M*_XiHFU#Ao&dtXCFBUuMwYx<|4~zL1z}Gr31tZ z$r-}JQlBV^^h1oVtn6=#gF?oY?R@;A3dE|`_ zqRU$Qd80eCftBdDG(a<%;Z;`tC*RQlGBvhBJxcfCOZ(OoCoyf>Uft`=qV(}D9x!Tu zO9#mg9pE}7JYG>YkzG27YSk?~F-@YJ{1M%(j;b~cIesYzBl+aF#PVn{m;Qeic>CwQ zD2D{ky-ny@Y|n3^#q_V?<*%DSw2b7CW%66a9#uq3Lv>?P)zZ@8ruat6$T0R32~mvK TmJ2%w00000NkvXXu0mjf%7AS= diff --git a/res/drawable-xxhdpi/ic_push_black.png b/res/drawable-xxhdpi/ic_push_black.png deleted file mode 100644 index b642256ede16a651af0af796857960d7c2adfab6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 962 zcmV;z13mnSP)Ji*9-uVCZfG^wLci>#3)xJ;V+MxrUZ#f&sSEOp#f}9xkB&U7qv2LOn$x%W-nZ zqa1^@64c{-$^tU9z$dg3#B$D{m>Qyql)cPN6l0U@BsI%8g%apPYDvLrMo~gtWF-k} zXBs8g6i<+#ZOo#Cn`J8r*}@!3p*c2_fOc{yrE+W}W~-S*DRzTZ#Hfy|DCK^nhS>C@ z039VJ&yz<1%CimZGEAaC{Z0dBM^M1t!Dt=xC}4NUVls>ZcN&8>6udm^@b(cRd?)bq zF!PA;&C`sRgQ!S)121E!NctWRt*D4vgR=w3*e~>Rfc^CG6Ee0BXQzxS!*(k8*CwtY zLnm=m!4&dtf>lH{@-6c2CKWizBJXl!DWsX-kaufw@&fX%hsEqc-gV&Q5b`X~3Kmn% zE#%poI2lBqU1KRAK6Ue(x z7PA3)H;xm_4m3(Ng`H0C0WKm#eF(5#hT*HJ%!oLBTtWK`#p294#1R_yYy42cx|xV1LqpQ6*z2 zSckwa%Pb1gcT^IK-6%k}$r78PuwS2cRh&hsc7_UKRnI6&t;^IAyA@2JRQij@NJJwe zDDnPgJ&DQi4N9~-Y$Z|E98L7{=^zCiOrr$4#gn9D4PT;|o8~D})yZ`fTNAXBx+-2` z9AWPq83K8LeOyAOj&VPMwb93~o+sOGipE-A<6|y6OjtkDMiHuHCC~62o$S5aK~%6j zN2s9$w4efAWg{h`84>M0>L?ja=s#U&3nk^j$lGEqP^u5`1MQTc3_{HCI`>hM8W1O0 kPRXia2W4etW%sCm0Pig>fbv4dX8-^I07*qoM6N<$f^>qlf&c&j diff --git a/res/drawable-xxhdpi/ic_push_gray.png b/res/drawable-xxhdpi/ic_push_gray.png deleted file mode 100644 index 24ba43f8ba3d1adc6f1749d7a63e0312ba5ce3e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1137 zcmV-%1djWOP)U*IHS0pxGaAR5t z#*`v4qH)A1qQodk6A@eE(^c)ZL8o+}4J-QRQ<7zG;7!aHhtfiEkehKB8cdRs28tFx ziL=lE8^z`bkF0zQ4L*KX=27?tZU>+tm6k;mF08_NXo#KTdnr7;9^=rE8|QTt4q1x{ zXar4QO*kK(JT#*6d{6L4cN7|7XZ+hJID@swK_f2f)lg8l8ybDQhk_xGU>X`j)4ZPC z`E?kD#?;TefLviWG`{3Da^o+@Bs9kUNH>!UJ_3z5K1BBXJE5^R?Jp-=cpn;na)9il zZ^R@t0Zm$NG595DLi!)sV1Xv20WvqR6q=lPF`42Qpl-IBp9bNby>ex0i<@k^L zC~wpX`Uh6yB-EjUWJW7+4r<--%xOMbkAA3iXSKp`VF@zT6Qv|@%&g+W5mU570t?Fy8$wRVW@4gfo35qp|fv=!0$^J`ELaLHqb=)rXkqLYXb<3|SSWc>AN67?UcfF{f0?zBPcgO^` zL!I)d0Q#U#y+S6i#`WTq3djMdQ*C6zyA=uzaw3%us8bJ-84N)kdX@^{X{bYg4%U(x z?1ehCnhK;JfZE4Grm#8KEkfoNs6%g%DQR%n%T3K3CbR+*PV<#Hd}6;)p&}fXEBWj- zWDbu(E$gKs@v^#S;6lZD$*F#E`Eya@J?s~I+Lp=JK1`SLF0~hl09@nV{XE0 za=T>x1sZ3vi`<|c8e{)=z9~*s#(B{pJIGzS8RO76lJ9!2pdiQ=XbfFUH&aj~75~?# zlWY}^LL=?4Rs{U09)L!boEWU7pz%TsLnG!@!8(v3Y z%2o58Fee{wrSNfUNDq)N$bA$IUW_lG0e9ZNpQ0p><1{p|hGY0SO14U#;8V~5>hSYZuH3nfpgQWo)p@~~_`JKAS` zx;Bm7UJWIm*90w6E`2wZhD;-LMsK=Ln~{+Q=p~(&wNy&H>!JVZJ+FyM%eU7-|1N`7 zRC@e6C=_Gzymuv)B3=N+LEJ>8%B$f`R9042cA5GM_RJ-947&@#00000NkvXXu0mjf Dp4tU5 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)); } }