[Android] Show the band value in the equalizer

Nicolas Pomepuy git at videolan.org
Tue Mar 24 15:55:03 CET 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Mar 24 10:28:43 2020 +0100| [c2b41e5c865e5564279d31654a776fedf11f2f47] | committer: Nicolas Pomepuy

Show the band value in the equalizer

Fixes #1238

> https://code.videolan.org/videolan/vlc-android/commit/c2b41e5c865e5564279d31654a776fedf11f2f47
---

 application/vlc-android/res/layout/equalizer_bar.xml      | 10 ++++++++++
 .../src/org/videolan/vlc/gui/view/EqualizerBar.kt         | 15 +++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/res/layout/equalizer_bar.xml b/application/vlc-android/res/layout/equalizer_bar.xml
index 28e00e17e..238551c95 100644
--- a/application/vlc-android/res/layout/equalizer_bar.xml
+++ b/application/vlc-android/res/layout/equalizer_bar.xml
@@ -48,5 +48,15 @@
         android:textSize="10sp"
         tools:ignore="HardcodedText" />
 
+    <TextView
+            android:id="@+id/band_value"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:fontFamily="sans-serif-medium"
+            android:textColor="?attr/font_audio_light"
+            android:gravity="center"
+            android:textSize="10sp" />
+
 
 </LinearLayout>
\ No newline at end of file
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/EqualizerBar.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/EqualizerBar.kt
index f02bf0efb..7ef519da7 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/view/EqualizerBar.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/view/EqualizerBar.kt
@@ -36,8 +36,9 @@ import org.videolan.vlc.interfaces.OnEqualizerBarChangeListener
 
 class EqualizerBar : LinearLayout {
 
+    private lateinit var bandValueTextView: TextView
     private lateinit var verticalSeekBar: VerticalSeekBar
-    private var bandTextView: TextView? = null
+    private lateinit var bandTextView: TextView
     private var listener: OnEqualizerBarChangeListener? = null
 
     override fun setNextFocusLeftId(nextFocusLeftId: Int) {
@@ -63,6 +64,7 @@ class EqualizerBar : LinearLayout {
             //          fromUser will always be false
             //          So use custom getFromUser() instead of fromUser
             listener?.onProgressChanged(value, isFromUser())
+            updateValueText()
         }
     }
 
@@ -88,14 +90,22 @@ class EqualizerBar : LinearLayout {
         verticalSeekBar.progress = RANGE
         verticalSeekBar.setOnSeekBarChangeListener(seekListener)
         bandTextView = findViewById(R.id.equalizer_band)
-        bandTextView!!.text = if (band < 999.5f)
+        bandValueTextView = findViewById(R.id.band_value)
+        bandTextView.text = if (band < 999.5f)
             (band + 0.5f).toInt().toString() + "Hz"
         else
             (band / 1000.0f + 0.5f).toInt().toString() + "kHz"
+        updateValueText()
+    }
+
+    private fun updateValueText() {
+        val newValue = (verticalSeekBar.progress / 10) - 20
+        bandValueTextView.text = if (newValue > 0) "+${newValue}dB" else "${newValue}dB"
     }
 
     fun setValue(value: Float) {
         verticalSeekBar.progress = (value * PRECISION + RANGE).toInt()
+        updateValueText()
     }
 
     fun setListener(listener: OnEqualizerBarChangeListener?) {
@@ -104,6 +114,7 @@ class EqualizerBar : LinearLayout {
 
     fun setProgress(fl: Int) {
         verticalSeekBar.progress = fl
+        updateValueText()
     }
 
     fun getProgress(): Int = verticalSeekBar.progress



More information about the Android mailing list