[Android] [PATCH] Fix Locale resetting problem when opening about

Geoffrey Métais geoffrey at videolan.org
Fri Jun 2 13:12:25 CEST 2017


Ah crap, just launched the build for 2.1.10 :/
i'll fix the patch

Le ven. 2 juin 2017 à 13:00, Habib Kazemi <kazemihabib1996 at gmail.com> a
écrit :

> The rotation problem happens in older devices too (I tested in 4.4.4
> genymotion)
> but the webview problem just happens in android 7+.
>
> On Fri, Jun 2, 2017 at 12:39 PM, Geoffrey Métais <geoffrey at videolan.org>
> wrote:
> > Looks good.
> > But if it's for Android 7+, maybe we should apply it on these devices
> only
> > and spare the older ones?
> >
> > Le ven. 2 juin 2017 à 00:26, habib kazemi <kazemihabib1996 at gmail.com> a
> > écrit :
> >>
> >> https://code.videolan.org/videolan/vlc-android/issues/285
> >> ---
> >>  .../src/org/videolan/vlc/VLCApplication.java       | 26
> >> +++++++++++++++-------
> >>  .../src/org/videolan/vlc/gui/AboutFragment.java    |  4 ++++
> >>  2 files changed, 22 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java
> >> b/vlc-android/src/org/videolan/vlc/VLCApplication.java
> >> index 8973f5d93..abfba212e 100644
> >> --- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
> >> +++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
> >> @@ -83,13 +83,9 @@ public class VLCApplication extends Application {
> >>
> >>      private static int sDialogCounter = 0;
> >>
> >> -    @Override
> >> -    public void onCreate() {
> >> -        super.onCreate();
> >> -        instance = this;
> >> -
> >> +    public static void setLocale(Context context){
> >>          // Are we using advanced debugging - locale?
> >> -        mSettings =
> PreferenceManager.getDefaultSharedPreferences(this);
> >> +        mSettings =
> >> PreferenceManager.getDefaultSharedPreferences(context);
> >>          String p = mSettings.getString("set_locale", "");
> >>          if (!p.equals("")) {
> >>              Locale locale;
> >> @@ -115,9 +111,17 @@ public class VLCApplication extends Application {
> >>              Locale.setDefault(locale);
> >>              Configuration config = new Configuration();
> >>              config.locale = locale;
> >> -            getResources().updateConfiguration(config,
> >> -                    getResources().getDisplayMetrics());
> >> +            context.getResources().updateConfiguration(config,
> >> +                    context.getResources().getDisplayMetrics());
> >>          }
> >> +    }
> >> +
> >> +    @Override
> >> +    public void onCreate() {
> >> +        super.onCreate();
> >> +        instance = this;
> >> +
> >> +        setLocale(this);
> >>
> >>          runBackground(new Runnable() {
> >>              @Override
> >> @@ -138,6 +142,12 @@ public class VLCApplication extends Application {
> >>          });
> >>      }
> >>
> >> +    @Override
> >> +    public void onConfigurationChanged(Configuration newConfig) {
> >> +        super.onConfigurationChanged(newConfig);
> >> +        setLocale(this);
> >> +    }
> >> +
> >>      /**
> >>       * Called when the overall system is running low on memory
> >>       */
> >> diff --git a/vlc-android/src/org/videolan/vlc/gui/AboutFragment.java
> >> b/vlc-android/src/org/videolan/vlc/gui/AboutFragment.java
> >> index ad9d05c68..fb1cfd3ae 100644
> >> --- a/vlc-android/src/org/videolan/vlc/gui/AboutFragment.java
> >> +++ b/vlc-android/src/org/videolan/vlc/gui/AboutFragment.java
> >> @@ -32,6 +32,7 @@ import android.webkit.WebView;
> >>
> >>  import org.videolan.vlc.BuildConfig;
> >>  import org.videolan.vlc.R;
> >> +import org.videolan.vlc.VLCApplication;
> >>  import org.videolan.vlc.gui.audio.AudioPagerAdapter;
> >>  import org.videolan.vlc.gui.helpers.UiTools;
> >>  import org.videolan.vlc.util.Util;
> >> @@ -51,6 +52,9 @@ public class AboutFragment extends Fragment {
> >>          if (getActivity() instanceof AppCompatActivity)
> >>              ((AppCompatActivity)
> >> getActivity()).getSupportActionBar().setTitle("VLC " +
> >> BuildConfig.VERSION_NAME);
> >>          View v = inflater.inflate(R.layout.about, container, false);
> >> +        //Fix android 7 Locale problem with webView
> >> +
> >> //
> https://stackoverflow.com/questions/40398528/android-webview-locale-changes-abruptly-on-android-n
> >> +        VLCApplication.setLocale(getContext());
> >>
> >>          View aboutMain = v.findViewById(R.id.about_main);
> >>          WebView webView = (WebView)v.findViewById(R.id.webview);
> >> --
> >> 2.12.2
> >>
> >> _______________________________________________
> >> Android mailing list
> >> Android at videolan.org
> >> https://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20170602/8908e967/attachment.html>


More information about the Android mailing list