[vlc-devel] [PATCH] android: apply theme to preference activty

Geoffrey Métais geoffrey.metais at gmail.com
Fri Mar 6 14:57:32 CET 2015


LGTM,


btw, you should post your patches concerning Android ports on android@
videolan.org.

On Fri, Mar 6, 2015 at 11:03 AM, Tse, Kit Yam <me at kytse.com> wrote:

> This patch fix one of the problems mentioned in #12828, the theme won't be
> applied on preference activity.
>
>
> From 884b95580de9e7080a336b507c2ba3bca978b97b Mon Sep 17 00:00:00 2001
> From: Tse Kit Yam <me at kytse.com>
> Date: Thu, 5 Mar 2015 10:31:48 +0800
> Subject: [PATCH] apply theme to preferences activity (#12828)
>
> ---
>  .../org/videolan/vlc/gui/PreferencesActivity.java    | 20
> ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
> b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
> index 91d078b..ae713f2 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
> @@ -34,6 +34,7 @@ import org.videolan.vlc.util.Logcat;
>  import org.videolan.vlc.util.Util;
>  import org.videolan.vlc.util.VLCInstance;
>
> +import android.annotation.TargetApi;
>  import android.app.AlertDialog;
>  import android.app.Dialog;
>  import android.content.Context;
> @@ -81,6 +82,9 @@ public class PreferencesActivity extends
> PreferenceActivity implements OnSharedP
>
>      @Override
>      protected void onCreate(Bundle savedInstanceState) {
> +        /* Theme must be applied before super.onCreate */
> +        applyTheme();
> +
>          super.onCreate(savedInstanceState);
>          addPreferencesFromResource(R.xml.preferences);
>
> @@ -146,6 +150,9 @@ public class PreferencesActivity extends
> PreferenceActivity implements OnSharedP
>                      @Override
>                      public boolean onPreferenceClick(Preference
> preference) {
>                          setResult(RESULT_RESTART);
> +                        Intent intent = getIntent();
> +                        finish();
> +                        startActivity(intent);
>                          return true;
>                      }
>                  });
> @@ -276,6 +283,19 @@ public class PreferencesActivity extends
> PreferenceActivity implements OnSharedP
>          sharedPrefs.registerOnSharedPreferenceChangeListener(this);
>      }
>
> +    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
> +    private void applyTheme() {
> +        SharedPreferences pref =
> PreferenceManager.getDefaultSharedPreferences(this);
> +        boolean enableBlackTheme = pref.getBoolean("enable_black_theme",
> false);
> +        if (enableBlackTheme) {
> +            setTheme(R.style.Theme_VLC_Black);
> +            //We need to manually change statusbar color, otherwise, it
> remains orange.
> +            if (LibVlcUtil.isLolliPopOrLater()) {
> +                getWindow().setStatusBarColor(Color.DKGRAY);
> +            }
> +        }
> +    }
> +
>      @Override
>      protected void onPostCreate(Bundle savedInstanceState) {
>          super.onPostCreate(savedInstanceState);
> --
> 2.3.1
>
>
> --
> Tse Kit Yam
> me at kytse.com
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150306/5df4eba5/attachment.html>


More information about the vlc-devel mailing list