[Android] [PATCH] Style inheritage
Geoffrey Métais
geoffrey.metais at gmail.com
Wed Nov 19 13:20:56 CET 2014
Avoid to duplicate xml code beween Android versions
---
vlc-android/res/values-v17/styles.xml | 11 ++++++++---
vlc-android/res/values-v19/styles.xml | 10 +++-------
vlc-android/res/values-v21/styles.xml | 20 +++++++++++---------
.../videolan/vlc/gui/video/VideoPlayerActivity.java | 7 ++++---
4 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/vlc-android/res/values-v17/styles.xml b/vlc-android/res/values-v17/styles.xml
index 67bed55..469ae03 100644
--- a/vlc-android/res/values-v17/styles.xml
+++ b/vlc-android/res/values-v17/styles.xml
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style name="Theme.VLC.Player" parent="android:Theme.Holo">
+ <style name="Theme.VLC.Player" parent="Theme.VLC.Player.17"/>
+ <style name="Theme.VLC" parent="Theme.VLC.17"/>
+ <style name="Theme.VLC.Black" parent="Theme.VLC.Black.17"/>
+
+ <style name="Theme.VLC.Player.17" parent="Theme.AppCompat">
<item name="android:windowBackground">@color/black</item>
<item name="android:windowActionBarOverlay">true</item>
@@ -8,7 +12,8 @@
<item name="status_bar_overlay">@android:color/transparent</item>
<item name="advanced_options_style">@style/Theme.VLC.AdvancedOptionsBlack</item>
</style>
- <style name="Theme.VLC" parent="Theme.VLC.Apearance">
+
+ <style name="Theme.VLC.17" parent="Theme.VLC.Apearance">
<item name="actionBarStyle">@style/ActionBar</item>
<item name="actionBarSize">50dp</item>
<item name="windowActionBarOverlay">true</item>
@@ -18,7 +23,7 @@
<item name="android:buttonStyle">@style/RobotoButtonStyle</item>
<item name="drawerArrowStyle">@style/ActionBar.ArrowToggle</item>
</style>
- <style name="Theme.VLC.Black" parent="Theme.VLC.Apearance.Black">
+ <style name="Theme.VLC.Black.17" parent="Theme.VLC.Apearance.Black">
<item name="actionBarStyle">@style/ActionBar</item>
<item name="actionBarSize">50dp</item>
<item name="windowActionBarOverlay">true</item>
diff --git a/vlc-android/res/values-v19/styles.xml b/vlc-android/res/values-v19/styles.xml
index e817582..11a7b3a 100644
--- a/vlc-android/res/values-v19/styles.xml
+++ b/vlc-android/res/values-v19/styles.xml
@@ -1,15 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style name="Theme.VLC.Player" parent="android:Theme.Holo">
- <item name="android:windowBackground">@color/black</item>
+ <style name="Theme.VLC.Player" parent="Theme.VLC.Player.19"/>
+
+ <style name="Theme.VLC.Player.19" parent="Theme.VLC.Player.17">
<item name="android:windowTranslucentStatus">true</item>
- <item name="android:windowActionBarOverlay">true</item>
<item name="android:fontFamily">sans-serif-light</item>
<item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
<item name="android:buttonStyle">@style/RobotoButtonStyle</item>
-
- <item name="video_player_overlay">@color/transparent_gray</item>
- <item name="status_bar_overlay">@android:color/transparent</item>
- <item name="advanced_options_style">@style/Theme.VLC.AdvancedOptionsBlack</item>
</style>
</resources>
diff --git a/vlc-android/res/values-v21/styles.xml b/vlc-android/res/values-v21/styles.xml
index 1326f52..afb8ccc 100644
--- a/vlc-android/res/values-v21/styles.xml
+++ b/vlc-android/res/values-v21/styles.xml
@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style name="Theme.VLC" parent="Theme.VLC.Apearance">
- <item name="actionBarStyle">@style/ActionBar</item>
- <item name="actionBarSize">50dp</item>
- <item name="windowActionBarOverlay">true</item>
- <item name="actionOverflowButtonStyle">@style/ActionBar.OverflowButton</item>
+ <style name="Theme.VLC" parent="Theme.VLC.21"/>
+ <style name="Theme.VLC.Black" parent="Theme.VLC.Black.21"/>
+ <style name="Theme.VLC.Player" parent="Theme.VLC.Player.21"/>
+
+ <style name="Theme.VLC.21" parent="Theme.VLC.17">
<item name="android:statusBarColor">@color/darkorange</item>
- <item name="android:fontFamily">sans-serif-light</item>
- <item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
- <item name="android:buttonStyle">@style/RobotoButtonStyle</item>
- <item name="drawerArrowStyle">@style/ActionBar.ArrowToggle</item>
+ </style>
+ <style name="Theme.VLC.Black.21" parent="Theme.VLC.Black.17">
+ <item name="android:statusBarColor">@color/black3</item>
+ </style>
+ <style name="Theme.VLC.Player.21" parent="Theme.VLC.Player.19">
+ <item name="android:navigationBarColor">?attr/video_player_overlay</item>
</style>
</resources>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 06b9f20..abcecec 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -58,7 +58,6 @@ import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
import android.annotation.TargetApi;
-import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.KeyguardManager;
@@ -89,6 +88,8 @@ import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarActivity;
import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -118,7 +119,7 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
-public class VideoPlayerActivity extends Activity implements IVideoPlayer {
+public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlayer {
public final static String TAG = "VLC/VideoPlayerActivity";
@@ -312,7 +313,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
/** initialize Views an their Events */
if (mOverlayUseStatusBar) {
- mActionBar = getActionBar();
+ mActionBar = getSupportActionBar();
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.setBackgroundDrawable(null);
--
1.9.1
More information about the Android
mailing list