[Android] Vertical volume/brightness bar

Vladimír Pokorný git at videolan.org
Tue Apr 7 16:05:23 CEST 2015


vlc-ports/android | branch: master | Vladimír Pokorný <vlada.pokorny at seznam.cz> | Mon Apr  6 22:13:06 2015 +0200| [43f099926e691888d25faf0c02c849501a6d497f] | committer: Geoffrey Métais

Vertical volume/brightness bar

Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=43f099926e691888d25faf0c02c849501a6d497f
---

 vlc-android/res/drawable/verticalbar_border.xml    |    6 ++++
 vlc-android/res/layout/player.xml                  |   27 +++++++++++++++++
 .../vlc/gui/video/VideoPlayerActivity.java         |   32 ++++++++++++++++++--
 3 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/vlc-android/res/drawable/verticalbar_border.xml b/vlc-android/res/drawable/verticalbar_border.xml
new file mode 100644
index 0000000..276679e
--- /dev/null
+++ b/vlc-android/res/drawable/verticalbar_border.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+    <solid android:color="#00000000" />
+    <stroke android:width="1dp"
+            android:color="#77ffffff" />
+</shape>
\ No newline at end of file
diff --git a/vlc-android/res/layout/player.xml b/vlc-android/res/layout/player.xml
index a4906a6..fccd979 100644
--- a/vlc-android/res/layout/player.xml
+++ b/vlc-android/res/layout/player.xml
@@ -77,6 +77,33 @@
             android:textColor="#ffffff"
             android:textSize="36sp"
             android:visibility="invisible" />
+
+        <FrameLayout android:id="@+id/verticalbar"
+            android:layout_width="28dp"
+            android:layout_height="100dp"
+            android:layout_above="@+id/progress_overlay"
+            android:layout_toLeftOf="@+id/player_overlay_info"
+            android:layout_marginRight="8dp"
+            android:layout_marginBottom="-16dp"
+            android:background="@drawable/video_list_length_bg"
+            android:visibility="invisible">
+
+            <LinearLayout android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_margin="7dp"
+                android:background="@drawable/verticalbar_border"
+                android:orientation="vertical"
+                android:weightSum="15"
+                android:gravity="bottom">
+
+                <View android:id="@+id/verticalbar_progress"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_margin="2dp"
+                    android:background="@color/orange500transparent" />
+            </LinearLayout>
+        </FrameLayout>
+
         <ImageView
             android:id="@+id/player_delay_minus"
             android:layout_width="wrap_content"
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 59c1a58..f49ebb8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -89,6 +89,7 @@ import android.view.animation.DecelerateInterpolator;
 import android.view.animation.RotateAnimation;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
 import android.widget.SeekBar;
 import android.widget.SeekBar.OnSeekBarChangeListener;
@@ -200,6 +201,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
     private TextView mTime;
     private TextView mLength;
     private TextView mInfo;
+    private View mVerticalBar;
+    private View mVerticalBarProgress;
     private ImageView mLoading;
     private TextView mLoadingText;
     private ImageView mTipsBackground;
@@ -401,6 +404,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
 
         // the info textView is not on the overlay
         mInfo = (TextView) findViewById(R.id.player_overlay_info);
+        mVerticalBar = findViewById(R.id.verticalbar);
+        mVerticalBarProgress = findViewById(R.id.verticalbar_progress);
 
         mEnableBrightnessGesture = mSettings.getBoolean("enable_brightness_gesture", true);
         mScreenOrientation = Integer.valueOf(
@@ -1199,11 +1204,26 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
     }
 
     /**
+     * Show text in the info view and vertical progress bar for "duration" milliseconds
+     * @param text
+     * @param duration
+     * @param barNewValue new volume/brightness value (range: 0 - 15)
+     */
+    private void showInfoWithVerticalBar(String text, int duration, int barNewValue) {
+        showInfo(text, duration);
+        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mVerticalBarProgress.getLayoutParams();
+        layoutParams.weight = barNewValue;
+        mVerticalBarProgress.setLayoutParams(layoutParams);
+        mVerticalBar.setVisibility(View.VISIBLE);
+    }
+
+    /**
      * Show text in the info view for "duration" milliseconds
      * @param text
      * @param duration
      */
     private void showInfo(String text, int duration) {
+        mVerticalBar.setVisibility(View.INVISIBLE);
         mInfo.setVisibility(View.VISIBLE);
         mInfo.setText(text);
         mHandler.removeMessages(FADE_OUT_INFO);
@@ -1211,6 +1231,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
     }
 
     private void showInfo(int textid, int duration) {
+        mVerticalBar.setVisibility(View.INVISIBLE);
         mInfo.setVisibility(View.VISIBLE);
         mInfo.setText(textid);
         mHandler.removeMessages(FADE_OUT_INFO);
@@ -1222,6 +1243,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
      * @param text
      */
     private void showInfo(String text) {
+        mVerticalBar.setVisibility(View.INVISIBLE);
         mHandler.removeMessages(FADE_OUT_INFO);
         mInfo.setVisibility(View.VISIBLE);
         mInfo.setText(text);
@@ -1248,6 +1270,11 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
             mInfo.startAnimation(AnimationUtils.loadAnimation(
                     VideoPlayerActivity.this, android.R.anim.fade_out));
         mInfo.setVisibility(View.INVISIBLE);
+
+        if (mVerticalBar.getVisibility() == View.VISIBLE)
+            mVerticalBar.startAnimation(AnimationUtils.loadAnimation(
+                    VideoPlayerActivity.this, android.R.anim.fade_out));
+        mVerticalBar.setVisibility(View.INVISIBLE);
     }
 
     private OnAudioFocusChangeListener mAudioFocusListener = !LibVlcUtil.isFroyoOrLater() ? null :
@@ -1840,7 +1867,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
             mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, vol, AudioManager.FLAG_SHOW_UI);
 
         mTouchAction = TOUCH_VOLUME;
-        showInfo(getString(R.string.volume) + '\u00A0' + Integer.toString(vol),1000);
+        showInfoWithVerticalBar(getString(R.string.volume) + '\u00A0' + Integer.toString(vol), 1000, vol);
     }
 
     private void mute(boolean mute) {
@@ -1898,7 +1925,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
         lp.screenBrightness =  Math.min(Math.max(lp.screenBrightness + delta, 0.01f), 1);
         // Set Brightness
         getWindow().setAttributes(lp);
-        showInfo(getString(R.string.brightness) + '\u00A0' + Math.round(lp.screenBrightness * 15),1000);
+        int brightness = Math.round(lp.screenBrightness * 15);
+        showInfoWithVerticalBar(getString(R.string.brightness) + '\u00A0' + brightness, 1000, brightness);
     }
 
     /**



More information about the Android mailing list