diff --git a/FAQ.md b/FAQ.md index 92f16dc8da..245c17f3d2 100644 --- a/FAQ.md +++ b/FAQ.md @@ -40,7 +40,6 @@ Anything on this list is in random order and *might* be added in the near future * *Rich text editor* / [Markdown](https://en.wikipedia.org/wiki/Markdown) support: besides that very few people would use this on a small mobile device, Android doesn't support a rich text editor and most rich text editor open source projects are abandoned. See [here](https://forum.xda-developers.com/showpost.php?p=79061829&postcount=4919) for some more details. * *Widget to read messages*: widgets can have limited user interaction only, so a widget to read e-mail would not be very useful. Moreover, it would be not very useful to duplicate functions which are already available in the app. -* *Switch language*: Android is not designed to change the language of an app and on recent Android versions it even causes problems. So, better fix the translation in your language if needed, see [this FAQ](#user-content-faq26) about how to. * *Design*: the design is based on many discussions and if you like you can discuss about it [in this forum](https://forum.xda-developers.com/android/apps-games/source-email-t3824168) too. * *ActiveSync*: using the Exchange ActiveSync protocol requires [a license](https://en.wikipedia.org/wiki/Exchange_ActiveSync#Licensing), so this cannot be added. Moreover, the ActiveSync protocol is being phased out. diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index 0149fabffd..bf2c916022 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -20,6 +20,7 @@ package eu.faircode.email; */ import android.Manifest; +import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; @@ -38,6 +39,11 @@ import androidx.preference.PreferenceManager; abstract class ActivityBase extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener { private boolean contacts; + @Override + protected void attachBaseContext(Context base) { + super.attachBaseContext(ApplicationEx.getLocalizedContext(base)); + } + @Override protected void onCreate(Bundle savedInstanceState) { Log.i("Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME); diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java index 1af396784f..a02b0a2d37 100644 --- a/app/src/main/java/eu/faircode/email/ApplicationEx.java +++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java @@ -25,12 +25,15 @@ import android.app.NotificationChannel; import android.app.NotificationChannelGroup; import android.app.NotificationManager; import android.content.Context; +import android.content.SharedPreferences; +import android.content.res.Configuration; import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; import android.os.DeadSystemException; import android.os.RemoteException; +import android.preference.PreferenceManager; import android.webkit.CookieManager; import org.json.JSONArray; @@ -44,6 +47,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Locale; import androidx.annotation.RequiresApi; @@ -54,6 +58,11 @@ public class ApplicationEx extends Application { "service", "notification", "warning", "error" )); + @Override + protected void attachBaseContext(Context base) { + super.attachBaseContext(getLocalizedContext(base)); + } + @Override public void onCreate() { super.onCreate(); @@ -86,6 +95,18 @@ public class ApplicationEx extends Application { Core.init(this); } + static Context getLocalizedContext(Context context) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean english = prefs.getBoolean("english", false); + + if (english) { + Configuration config = new Configuration(context.getResources().getConfiguration()); + config.setLocale(Locale.US); + return context.createConfigurationContext(config); + } else + return context; + } + private void createNotificationChannels() { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index e63db55d6e..f8d158703b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -105,6 +105,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O private SwitchCompat swLight; private Button btnSound; + private SwitchCompat swEnglish; private SwitchCompat swUpdates; private SwitchCompat swDebug; @@ -182,6 +183,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O swLight = view.findViewById(R.id.swLight); btnSound = view.findViewById(R.id.btnSound); + swEnglish = view.findViewById(R.id.swEnglish); swUpdates = view.findViewById(R.id.swUpdates); swDebug = view.findViewById(R.id.swDebug); @@ -247,6 +249,18 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O } }); + swEnglish.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("english", checked).commit(); // apply won't work here + + Intent intent = new Intent(getContext(), ActivityMain.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + startActivity(intent); + Runtime.getRuntime().exit(0); + } + }); + swUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -634,6 +648,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O swNotifyPreview.setEnabled(Helper.isPro(getContext())); swSearchLocal.setChecked(prefs.getBoolean("search_local", false)); swLight.setChecked(prefs.getBoolean("light", false)); + swEnglish.setChecked(prefs.getBoolean("english", false)); swUpdates.setChecked(prefs.getBoolean("updates", true)); swUpdates.setVisibility(Helper.isPlayStoreInstall(getContext()) ? View.GONE : View.VISIBLE); swDebug.setChecked(prefs.getBoolean("debug", false)); diff --git a/app/src/main/res/layout/fragment_options.xml b/app/src/main/res/layout/fragment_options.xml index 2fdf5ac642..d3cae91c8b 100644 --- a/app/src/main/res/layout/fragment_options.xml +++ b/app/src/main/res/layout/fragment_options.xml @@ -801,6 +801,31 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swLight" /> + + + + External search on device Use notification light Select notification sound + Force English language Check for updates Debug mode @@ -204,6 +205,7 @@ Most providers do not allow modified sender addresses Only available when message text was downloaded Instead of searching in the primary archive folder on the server + This will restart the app Select … Your name