summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2015-05-21 09:31:45 -0700
committerMarco Nelissen <marcone@google.com>2015-05-21 16:00:56 -0700
commita3818dbc8cbd1d0ac65ba4f869ccdb100e3db66a (patch)
tree2cae011e2a970611f5364281ef030a4eae667752
parent9cc139ead24e57edc5e639d0dd8715d8912e12cf (diff)
downloadMusicFX-a3818dbc8cbd1d0ac65ba4f869ccdb100e3db66a.tar.gz
Use rotated platform SeekBar instead of custom SeekBar
This brings MusicFX's SeekBar up to date wrt to accessibility, ditches the Holo look, and removes the need to maintain a custom SeekBar. Bug: 18677068 Change-Id: I91d74021c3d1b3c9c35bc97f7fc1deca55738d84
-rw-r--r--res/drawable-hdpi/scrubber_vertical_primary_holo.9.pngbin189 -> 0 bytes
-rw-r--r--res/drawable-hdpi/scrubber_vertical_secondary_holo.9.pngbin189 -> 0 bytes
-rw-r--r--res/drawable-hdpi/scrubber_vertical_track_holo_dark.9.pngbin190 -> 0 bytes
-rw-r--r--res/drawable-mdpi/scrubber_vertical_primary_holo.9.pngbin179 -> 0 bytes
-rw-r--r--res/drawable-mdpi/scrubber_vertical_secondary_holo.9.pngbin180 -> 0 bytes
-rw-r--r--res/drawable-mdpi/scrubber_vertical_track_holo_dark.9.pngbin185 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/scrubber_vertical_primary_holo.9.pngbin196 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/scrubber_vertical_secondary_holo.9.pngbin196 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/scrubber_vertical_track_holo_dark.9.pngbin201 -> 0 bytes
-rw-r--r--res/drawable/scrubber_progress_vertical_holo_dark.xml28
-rw-r--r--res/layout-land/music_main.xml4
-rw-r--r--res/layout/music_eq.xml418
-rw-r--r--res/layout/music_main.xml4
-rw-r--r--res/values/styles.xml32
-rw-r--r--src/com/android/musicfx/ActivityMusic.java6
-rw-r--r--src/com/android/musicfx/SeekBarRotator.java87
-rw-r--r--src/com/android/musicfx/seekbar/AbsSeekBar.java561
-rw-r--r--src/com/android/musicfx/seekbar/ProgressBar.java1146
-rw-r--r--src/com/android/musicfx/seekbar/SeekBar.java121
19 files changed, 351 insertions, 2056 deletions
diff --git a/res/drawable-hdpi/scrubber_vertical_primary_holo.9.png b/res/drawable-hdpi/scrubber_vertical_primary_holo.9.png
deleted file mode 100644
index 03930e2..0000000
--- a/res/drawable-hdpi/scrubber_vertical_primary_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/scrubber_vertical_secondary_holo.9.png b/res/drawable-hdpi/scrubber_vertical_secondary_holo.9.png
deleted file mode 100644
index a19365c..0000000
--- a/res/drawable-hdpi/scrubber_vertical_secondary_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/scrubber_vertical_track_holo_dark.9.png b/res/drawable-hdpi/scrubber_vertical_track_holo_dark.9.png
deleted file mode 100644
index 9f12c60..0000000
--- a/res/drawable-hdpi/scrubber_vertical_track_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/scrubber_vertical_primary_holo.9.png b/res/drawable-mdpi/scrubber_vertical_primary_holo.9.png
deleted file mode 100644
index ecea48d..0000000
--- a/res/drawable-mdpi/scrubber_vertical_primary_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/scrubber_vertical_secondary_holo.9.png b/res/drawable-mdpi/scrubber_vertical_secondary_holo.9.png
deleted file mode 100644
index 35bf199..0000000
--- a/res/drawable-mdpi/scrubber_vertical_secondary_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/scrubber_vertical_track_holo_dark.9.png b/res/drawable-mdpi/scrubber_vertical_track_holo_dark.9.png
deleted file mode 100644
index 8a7fbde..0000000
--- a/res/drawable-mdpi/scrubber_vertical_track_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/scrubber_vertical_primary_holo.9.png b/res/drawable-xhdpi/scrubber_vertical_primary_holo.9.png
deleted file mode 100644
index 2e4a44b..0000000
--- a/res/drawable-xhdpi/scrubber_vertical_primary_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/scrubber_vertical_secondary_holo.9.png b/res/drawable-xhdpi/scrubber_vertical_secondary_holo.9.png
deleted file mode 100644
index a5b1461..0000000
--- a/res/drawable-xhdpi/scrubber_vertical_secondary_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/scrubber_vertical_track_holo_dark.9.png b/res/drawable-xhdpi/scrubber_vertical_track_holo_dark.9.png
deleted file mode 100644
index 5f0fc26..0000000
--- a/res/drawable-xhdpi/scrubber_vertical_track_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/scrubber_progress_vertical_holo_dark.xml b/res/drawable/scrubber_progress_vertical_holo_dark.xml
deleted file mode 100644
index 0cc56bf..0000000
--- a/res/drawable/scrubber_progress_vertical_holo_dark.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@android:id/background"
- android:drawable="@drawable/scrubber_vertical_track_holo_dark" />
- <item android:id="@android:id/secondaryProgress">
- <scale android:scaleHeight="100%" android:scaleGravity="bottom"
- android:drawable="@drawable/scrubber_vertical_secondary_holo" />
- </item>
- <item android:id="@android:id/progress">
- <scale android:scaleHeight="100%" android:scaleGravity="bottom"
- android:drawable="@drawable/scrubber_vertical_primary_holo" />
- </item>
-</layer-list>
diff --git a/res/layout-land/music_main.xml b/res/layout-land/music_main.xml
index 905a602..5153d87 100644
--- a/res/layout-land/music_main.xml
+++ b/res/layout-land/music_main.xml
@@ -86,7 +86,7 @@
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:text="@string/bass_boost_strength" />
- <com.android.musicfx.seekbar.SeekBar
+ <SeekBar
android:id="@+id/bBStrengthSeekBar"
android:layout_width="170dip"
android:layout_height="wrap_content"
@@ -117,7 +117,7 @@
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:text="@string/virtualizer_strength" />
- <com.android.musicfx.seekbar.SeekBar
+ <SeekBar
android:id="@+id/vIStrengthSeekBar"
android:layout_width="170dip"
android:layout_height="wrap_content"
diff --git a/res/layout/music_eq.xml b/res/layout/music_eq.xml
index 1af4c9d..309a34d 100644
--- a/res/layout/music_eq.xml
+++ b/res/layout/music_eq.xml
@@ -55,12 +55,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand0SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand0SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand0TextView"
android:layout_width="50dip"
@@ -71,12 +74,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand1SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand1SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand1TextView"
android:layout_width="50dip"
@@ -87,12 +93,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand2SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand2SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand2TextView"
android:layout_width="50dip"
@@ -103,12 +112,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand3SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand3SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand3TextView"
android:layout_width="50dip"
@@ -119,12 +131,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand4SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand4SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand4TextView"
android:layout_width="50dip"
@@ -135,12 +150,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand5SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand5SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand5TextView"
android:layout_width="50dip"
@@ -151,12 +169,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand6SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand6SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand6TextView"
android:layout_width="50dip"
@@ -167,12 +188,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand7SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand7SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand7TextView"
android:layout_width="50dip"
@@ -183,12 +207,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand8SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand8SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand8TextView"
android:layout_width="50dip"
@@ -199,12 +226,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand9SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand9SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand9TextView"
android:layout_width="50dip"
@@ -215,12 +245,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand10SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand10SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand10TextView"
android:layout_width="50dip"
@@ -231,12 +264,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand11SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand11SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand11TextView"
android:layout_width="50dip"
@@ -247,12 +283,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand12SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand12SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand12TextView"
android:layout_width="50dip"
@@ -263,12 +302,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand13SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand13SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand13TextView"
android:layout_width="50dip"
@@ -279,12 +321,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand14SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand14SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand14TextView"
android:layout_width="50dip"
@@ -295,12 +340,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand15SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand15SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand15TextView"
android:layout_width="50dip"
@@ -311,12 +359,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand16SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand16SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand16TextView"
android:layout_width="50dip"
@@ -327,12 +378,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand17SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand17SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand17TextView"
android:layout_width="50dip"
@@ -343,12 +397,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand18SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand18SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand18TextView"
android:layout_width="50dip"
@@ -359,12 +416,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand19SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand19SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand19TextView"
android:layout_width="50dip"
@@ -375,12 +435,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand20SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand20SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand20TextView"
android:layout_width="50dip"
@@ -391,12 +454,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand21SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand21SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand21TextView"
android:layout_width="50dip"
@@ -407,12 +473,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand22SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand22SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand22TextView"
android:layout_width="50dip"
@@ -423,12 +492,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand23SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand23SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand23TextView"
android:layout_width="50dip"
@@ -439,12 +511,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand24SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand24SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand24TextView"
android:layout_width="50dip"
@@ -455,12 +530,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand25SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand25SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand25TextView"
android:layout_width="50dip"
@@ -471,12 +549,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand26SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand26SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand26TextView"
android:layout_width="50dip"
@@ -487,12 +568,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand27SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand27SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand27TextView"
android:layout_width="50dip"
@@ -503,12 +587,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand28SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand28SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand28TextView"
android:layout_width="50dip"
@@ -519,12 +606,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand29SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand29SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand29TextView"
android:layout_width="50dip"
@@ -535,12 +625,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand30SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
+ <com.android.musicfx.SeekBarRotator
android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand30SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand30TextView"
android:layout_width="50dip"
@@ -551,12 +644,15 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <com.android.musicfx.seekbar.SeekBar
- android:id="@+id/EQBand31SeekBar"
- style="@style/Widget.Holo.SeekBar.Vertical"
- android:layout_margin="@dimen/eq_slider_margin"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/eq_slider_height" />
+ <com.android.musicfx.SeekBarRotator
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/eq_slider_height">
+ <SeekBar
+ android:id="@+id/EQBand31SeekBar"
+ android:layout_margin="@dimen/eq_slider_margin"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </com.android.musicfx.SeekBarRotator>
<TextView
android:id="@+id/EQBand31TextView"
android:layout_width="50dip"
diff --git a/res/layout/music_main.xml b/res/layout/music_main.xml
index eabe8d9..701b675 100644
--- a/res/layout/music_main.xml
+++ b/res/layout/music_main.xml
@@ -76,7 +76,7 @@
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:text="@string/bass_boost_strength" />
- <com.android.musicfx.seekbar.SeekBar
+ <SeekBar
android:id="@+id/bBStrengthSeekBar"
android:layout_width="170dip"
android:layout_height="wrap_content"
@@ -107,7 +107,7 @@
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:text="@string/virtualizer_strength" />
- <com.android.musicfx.seekbar.SeekBar
+ <SeekBar
android:id="@+id/vIStrengthSeekBar"
android:layout_width="170dip"
android:layout_height="wrap_content"
diff --git a/res/values/styles.xml b/res/values/styles.xml
deleted file mode 100644
index f92c230..0000000
--- a/res/values/styles.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <style name="Widget.Holo.SeekBar.Vertical" parent="@android:Widget.Holo.SeekBar">
- <item name="android:indeterminateOnly">false</item>
- <item name="android:progressDrawable">@drawable/scrubber_progress_vertical_holo_dark</item>
-<!-- not public <item name="android:indeterminateDrawable">@android:drawable/scrubber_progress_horizontal_holo_dark</item> -->
- <item name="android:minWidth">33dip</item>
- <item name="android:maxWidth">33dip</item>
-<!-- not public <item name="android:thumb">@android:drawable/scrubber_control_selector_holo</item> -->
- <item name="android:thumbOffset">16dip</item>
- <item name="android:focusable">true</item>
- <item name="android:paddingLeft">0dip</item>
- <item name="android:paddingRight">0dip</item>
- <item name="android:paddingTop">16dip</item>
- <item name="android:paddingBottom">16dip</item>
- </style>
-</resources>
diff --git a/src/com/android/musicfx/ActivityMusic.java b/src/com/android/musicfx/ActivityMusic.java
index 6f9718a..fb0b43a 100644
--- a/src/com/android/musicfx/ActivityMusic.java
+++ b/src/com/android/musicfx/ActivityMusic.java
@@ -17,8 +17,6 @@
package com.android.musicfx;
import com.android.audiofx.OpenSLESConstants;
-import com.android.musicfx.seekbar.SeekBar;
-import com.android.musicfx.seekbar.SeekBar.OnSeekBarChangeListener;
import android.app.ActionBar;
import android.app.Activity;
@@ -52,6 +50,8 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
@@ -550,7 +550,7 @@ public class ActivityMusic extends Activity implements OnSeekBarChangeListener {
final int count = viewGroup.getChildCount();
for (int i = 0; i < count; i++) {
final View view = viewGroup.getChildAt(i);
- if ((view instanceof LinearLayout) || (view instanceof RelativeLayout)) {
+ if ((view instanceof ViewGroup)) {
final ViewGroup vg = (ViewGroup) view;
setEnabledAllChildren(vg, enabled);
}
diff --git a/src/com/android/musicfx/SeekBarRotator.java b/src/com/android/musicfx/SeekBarRotator.java
new file mode 100644
index 0000000..d4ef0ca
--- /dev/null
+++ b/src/com/android/musicfx/SeekBarRotator.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.musicfx;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+
+
+/*
+ * This ViewGroup contains a single view, which will be rotated by 90 degrees counterclockwise.
+ */
+
+public class SeekBarRotator extends ViewGroup {
+
+
+ public SeekBarRotator(Context context) {
+ super(context);
+ }
+
+ public SeekBarRotator(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public SeekBarRotator(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public SeekBarRotator(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ final View child = getChildAt(0);
+
+ if (child.getVisibility() != GONE) {
+ // swap width and height for child
+ measureChild(child, heightMeasureSpec, widthMeasureSpec);
+ setMeasuredDimension(
+ child.getMeasuredHeightAndState(),
+ child.getMeasuredWidthAndState());
+ } else {
+ setMeasuredDimension(
+ resolveSizeAndState(0, widthMeasureSpec, 0),
+ resolveSizeAndState(0, heightMeasureSpec, 0));
+ }
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ final View child = getChildAt(0);
+
+ if (child.getVisibility() != GONE) {
+ // rotate the child 90 degrees counterclockwise around its upper-left
+ child.setPivotX(0);
+ child.setPivotY(0);
+ child.setRotation(-90);
+
+ // place the child below this view, so it rotates into view
+ int mywidth = r - l;
+ int myheight = b - t;
+ int childwidth = myheight;
+ int childheight = mywidth;
+
+ child.layout(0, myheight, childwidth, myheight + childheight);
+ }
+ }
+
+}
diff --git a/src/com/android/musicfx/seekbar/AbsSeekBar.java b/src/com/android/musicfx/seekbar/AbsSeekBar.java
deleted file mode 100644
index 00ad580..0000000
--- a/src/com/android/musicfx/seekbar/AbsSeekBar.java
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.musicfx.seekbar;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.ViewConfiguration;
-
-public abstract class AbsSeekBar extends ProgressBar {
- private Drawable mThumb;
- private int mThumbOffset;
-
- /**
- * On touch, this offset plus the scaled value from the position of the
- * touch will form the progress value. Usually 0.
- */
- float mTouchProgressOffset;
-
- /**
- * Whether this is user seekable.
- */
- boolean mIsUserSeekable = true;
-
- boolean mIsVertical = false;
- /**
- * On key presses (right or left), the amount to increment/decrement the
- * progress.
- */
- private int mKeyProgressIncrement = 1;
-
- private static final int NO_ALPHA = 0xFF;
- private float mDisabledAlpha;
-
- private int mScaledTouchSlop;
- private float mTouchDownX;
- private float mTouchDownY;
- private boolean mIsDragging;
-
- public AbsSeekBar(Context context) {
- super(context);
- }
-
- public AbsSeekBar(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public AbsSeekBar(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- TypedArray a = context.obtainStyledAttributes(attrs,
- com.android.internal.R.styleable.SeekBar, defStyle, 0);
- Drawable thumb = a.getDrawable(com.android.internal.R.styleable.SeekBar_thumb);
- setThumb(thumb); // will guess mThumbOffset if thumb != null...
- // ...but allow layout to override this
- int thumbOffset = a.getDimensionPixelOffset(
- com.android.internal.R.styleable.SeekBar_thumbOffset, getThumbOffset());
- setThumbOffset(thumbOffset);
- a.recycle();
-
- a = context.obtainStyledAttributes(attrs,
- com.android.internal.R.styleable.Theme, 0, 0);
- mDisabledAlpha = a.getFloat(com.android.internal.R.styleable.Theme_disabledAlpha, 0.5f);
- a.recycle();
-
- mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
- }
-
- /**
- * Sets the thumb that will be drawn at the end of the progress meter within the SeekBar.
- * <p>
- * If the thumb is a valid drawable (i.e. not null), half its width will be
- * used as the new thumb offset (@see #setThumbOffset(int)).
- *
- * @param thumb Drawable representing the thumb
- */
- public void setThumb(Drawable thumb) {
- boolean needUpdate;
- // This way, calling setThumb again with the same bitmap will result in
- // it recalcuating mThumbOffset (if for example it the bounds of the
- // drawable changed)
- if (mThumb != null && thumb != mThumb) {
- mThumb.setCallback(null);
- needUpdate = true;
- } else {
- needUpdate = false;
- }
- if (thumb != null) {
- thumb.setCallback(this);
-
- // Assuming the thumb drawable is symmetric, set the thumb offset
- // such that the thumb will hang halfway off either edge of the
- // progress bar.
- if (mIsVertical) {
- mThumbOffset = thumb.getIntrinsicHeight() / 2;
- } else {
- mThumbOffset = thumb.getIntrinsicWidth() / 2;
- }
-
- // If we're updating get the new states
- if (needUpdate &&
- (thumb.getIntrinsicWidth() != mThumb.getIntrinsicWidth()
- || thumb.getIntrinsicHeight() != mThumb.getIntrinsicHeight())) {
- requestLayout();
- }
- }
- mThumb = thumb;
- invalidate();
- if (needUpdate) {
- updateThumbPos(getWidth(), getHeight());
- if (thumb.isStateful()) {
- // Note that if the states are different this won't work.
- // For now, let's consider that an app bug.
- int[] state = getDrawableState();
- thumb.setState(state);
- }
- }
- }
-
- /**
- * @see #setThumbOffset(int)
- */
- public int getThumbOffset() {
- return mThumbOffset;
- }
-
- /**
- * Sets the thumb offset that allows the thumb to extend out of the range of
- * the track.
- *
- * @param thumbOffset The offset amount in pixels.
- */
- public void setThumbOffset(int thumbOffset) {
- mThumbOffset = thumbOffset;
- invalidate();
- }
-
- /**
- * Sets the amount of progress changed via the arrow keys.
- *
- * @param increment The amount to increment or decrement when the user
- * presses the arrow keys.
- */
- public void setKeyProgressIncrement(int increment) {
- mKeyProgressIncrement = increment < 0 ? -increment : increment;
- }
-
- /**
- * Returns the amount of progress changed via the arrow keys.
- * <p>
- * By default, this will be a value that is derived from the max progress.
- *
- * @return The amount to increment or decrement when the user presses the
- * arrow keys. This will be positive.
- */
- public int getKeyProgressIncrement() {
- return mKeyProgressIncrement;
- }
-
- @Override
- public synchronized void setMax(int max) {
- super.setMax(max);
-
- if ((mKeyProgressIncrement == 0) || (getMax() / mKeyProgressIncrement > 20)) {
- // It will take the user too long to change this via keys, change it
- // to something more reasonable
- setKeyProgressIncrement(Math.max(1, Math.round((float) getMax() / 20)));
- }
- }
-
- @Override
- protected boolean verifyDrawable(Drawable who) {
- return who == mThumb || super.verifyDrawable(who);
- }
-
- @Override
- public void jumpDrawablesToCurrentState() {
- super.jumpDrawablesToCurrentState();
- if (mThumb != null) mThumb.jumpToCurrentState();
- }
-
- @Override
- protected void drawableStateChanged() {
- super.drawableStateChanged();
-
- Drawable progressDrawable = getProgressDrawable();
- if (progressDrawable != null) {
- progressDrawable.setAlpha(isEnabled() ? NO_ALPHA : (int) (NO_ALPHA * mDisabledAlpha));
- }
-
- if (mThumb != null && mThumb.isStateful()) {
- int[] state = getDrawableState();
- mThumb.setState(state);
- }
- }
-
- @Override
- void onProgressRefresh(float scale, boolean fromUser) {
- super.onProgressRefresh(scale, fromUser);
- Drawable thumb = mThumb;
- if (thumb != null) {
- setThumbPos(getWidth(), getHeight(), thumb, scale, Integer.MIN_VALUE);
- /*
- * Since we draw translated, the drawable's bounds that it signals
- * for invalidation won't be the actual bounds we want invalidated,
- * so just invalidate this whole view.
- */
- invalidate();
- }
- }
-
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- updateThumbPos(w, h);
- }
-
- private void updateThumbPos(int w, int h) {
- Drawable d = getCurrentDrawable();
- Drawable thumb = mThumb;
- if (mIsVertical) {
- int thumbWidth = thumb == null ? 0 : thumb.getIntrinsicWidth();
- // The max width does not incorporate padding, whereas the width
- // parameter does
- int trackWidth = Math.min(mMaxWidth, w - mPaddingLeft - mPaddingRight);
-
- int max = getMax();
- float scale = max > 0 ? (float) getProgress() / (float) max : 0;
-
- if (thumbWidth > trackWidth) {
- if (thumb != null) {
- setThumbPos(w, h, thumb, scale, 0);
- }
- int gapForCenteringTrack = (thumbWidth - trackWidth) / 2;
- if (d != null) {
- // Canvas will be translated by the padding, so 0,0 is where we start drawing
- d.setBounds(gapForCenteringTrack, 0,
- w - mPaddingRight - gapForCenteringTrack - mPaddingLeft,
- h - mPaddingBottom - mPaddingTop);
- }
- } else {
- if (d != null) {
- // Canvas will be translated by the padding, so 0,0 is where we start drawing
- d.setBounds(0, 0, w - mPaddingRight - mPaddingLeft, h - mPaddingBottom
- - mPaddingTop);
- }
- int gap = (trackWidth - thumbWidth) / 2;
- if (thumb != null) {
- setThumbPos(w, h, thumb, scale, gap);
- }
- }
- } else {
- int thumbHeight = thumb == null ? 0 : thumb.getIntrinsicHeight();
- // The max height does not incorporate padding, whereas the height
- // parameter does
- int trackHeight = Math.min(mMaxHeight, h - mPaddingTop - mPaddingBottom);
-
- int max = getMax();
- float scale = max > 0 ? (float) getProgress() / (float) max : 0;
-
- if (thumbHeight > trackHeight) {
- if (thumb != null) {
- setThumbPos(w, h, thumb, scale, 0);
- }
- int gapForCenteringTrack = (thumbHeight - trackHeight) / 2;
- if (d != null) {
- // Canvas will be translated by the padding, so 0,0 is where we start drawing
- d.setBounds(0, gapForCenteringTrack,
- w - mPaddingRight - mPaddingLeft, h - mPaddingBottom - gapForCenteringTrack
- - mPaddingTop);
- }
- } else {
- if (d != null) {
- // Canvas will be translated by the padding, so 0,0 is where we start drawing
- d.setBounds(0, 0, w - mPaddingRight - mPaddingLeft, h - mPaddingBottom
- - mPaddingTop);
- }
- int gap = (trackHeight - thumbHeight) / 2;
- if (thumb != null) {
- setThumbPos(w, h, thumb, scale, gap);
- }
- }
- }
- }
-
- /**
- * @param gap If set to {@link Integer#MIN_VALUE}, this will be ignored and
- */
- private void setThumbPos(int w, int h, Drawable thumb, float scale, int gap) {
- int available;
- int thumbWidth = thumb.getIntrinsicWidth();
- int thumbHeight = thumb.getIntrinsicHeight();
- if (mIsVertical) {
- available = h - mPaddingTop - mPaddingBottom - thumbHeight;
- } else {
- available = w - mPaddingLeft - mPaddingRight - thumbWidth;
- }
-
- // The extra space for the thumb to move on the track
- available += mThumbOffset * 2;
-
-
- if (mIsVertical) {
- int thumbPos = (int) ((1.0f - scale) * available);
- int leftBound, rightBound;
- if (gap == Integer.MIN_VALUE) {
- Rect oldBounds = thumb.getBounds();
- leftBound = oldBounds.left;
- rightBound = oldBounds.right;
- } else {
- leftBound = gap;
- rightBound = gap + thumbWidth;
- }
-
- // Canvas will be translated, so 0,0 is where we start drawing
- thumb.setBounds(leftBound, thumbPos, rightBound, thumbPos + thumbHeight);
- } else {
- int thumbPos = (int) (scale * available);
- int topBound, bottomBound;
- if (gap == Integer.MIN_VALUE) {
- Rect oldBounds = thumb.getBounds();
- topBound = oldBounds.top;
- bottomBound = oldBounds.bottom;
- } else {
- topBound = gap;
- bottomBound = gap + thumbHeight;
- }
-
- // Canvas will be translated, so 0,0 is where we start drawing
- thumb.setBounds(thumbPos, topBound, thumbPos + thumbWidth, bottomBound);
- }
- }
-
- @Override
- protected synchronized void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- if (mThumb != null) {
- canvas.save();
- // Translate the padding. For the x/y, we need to allow the thumb to
- // draw in its extra space
- if (mIsVertical) {
- canvas.translate(mPaddingLeft, mPaddingTop - mThumbOffset);
- mThumb.draw(canvas);
- canvas.restore();
- } else {
- canvas.translate(mPaddingLeft - mThumbOffset, mPaddingTop);
- mThumb.draw(canvas);
- canvas.restore();
- }
- }
- }
-
- @Override
- protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- Drawable d = getCurrentDrawable();
-
- int thumbHeight = mThumb == null ? 0 : mThumb.getIntrinsicHeight();
- int dw = 0;
- int dh = 0;
- if (d != null) {
- dw = Math.max(mMinWidth, Math.min(mMaxWidth, d.getIntrinsicWidth()));
- dh = Math.max(mMinHeight, Math.min(mMaxHeight, d.getIntrinsicHeight()));
- dh = Math.max(thumbHeight, dh);
- }
- dw += mPaddingLeft + mPaddingRight;
- dh += mPaddingTop + mPaddingBottom;
-
- setMeasuredDimension(resolveSizeAndState(dw, widthMeasureSpec, 0),
- resolveSizeAndState(dh, heightMeasureSpec, 0));
-
- // TODO should probably make this an explicit attribute instead of implicitly
- // setting it based on the size
- if (getMeasuredHeight() > getMeasuredWidth()) {
- mIsVertical = true;
- }
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (!mIsUserSeekable || !isEnabled()) {
- return false;
- }
-
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- if (isInScrollingContainer()) {
- mTouchDownX = event.getX();
- mTouchDownY = event.getY();
- } else {
- setPressed(true);
- if (mThumb != null) {
- invalidate(mThumb.getBounds()); // This may be within the padding region
- }
- onStartTrackingTouch();
- trackTouchEvent(event);
- attemptClaimDrag();
- }
- break;
-
- case MotionEvent.ACTION_MOVE:
- if (mIsDragging) {
- trackTouchEvent(event);
- } else {
- final float x = event.getX();
- final float y = event.getX();
- if (Math.abs(mIsVertical ?
- (y - mTouchDownY) : (x - mTouchDownX)) > mScaledTouchSlop) {
- setPressed(true);
- if (mThumb != null) {
- invalidate(mThumb.getBounds()); // This may be within the padding region
- }
- onStartTrackingTouch();
- trackTouchEvent(event);
- attemptClaimDrag();
- }
- }
- break;
-
- case MotionEvent.ACTION_UP:
- if (mIsDragging) {
- trackTouchEvent(event);
- onStopTrackingTouch();
- setPressed(false);
- } else {
- // Touch up when we never crossed the touch slop threshold should
- // be interpreted as a tap-seek to that location.
- onStartTrackingTouch();
- trackTouchEvent(event);
- onStopTrackingTouch();
- }
- // ProgressBar doesn't know to repaint the thumb drawable
- // in its inactive state when the touch stops (because the
- // value has not apparently changed)
- invalidate();
- break;
-
- case MotionEvent.ACTION_CANCEL:
- if (mIsDragging) {
- onStopTrackingTouch();
- setPressed(false);
- }
- invalidate(); // see above explanation
- break;
- }
- return true;
- }
-
- private void trackTouchEvent(MotionEvent event) {
- float progress = 0;
- if (mIsVertical) {
- final int height = getHeight();
- final int available = height - mPaddingTop - mPaddingBottom;
- int y = (int)event.getY();
- float scale;
- if (y < mPaddingTop) {
- scale = 1.0f;
- } else if (y > height - mPaddingBottom) {
- scale = 0.0f;
- } else {
- scale = 1.0f - (float)(y - mPaddingTop) / (float)available;
- progress = mTouchProgressOffset;
- }
-
- final int max = getMax();
- progress += scale * max;
- } else {
- final int width = getWidth();
- final int available = width - mPaddingLeft - mPaddingRight;
- int x = (int)event.getX();
- float scale;
- if (x < mPaddingLeft) {
- scale = 0.0f;
- } else if (x > width - mPaddingRight) {
- scale = 1.0f;
- } else {
- scale = (float)(x - mPaddingLeft) / (float)available;
- progress = mTouchProgressOffset;
- }
-
- final int max = getMax();
- progress += scale * max;
- }
-
- setProgress((int) progress, true);
- }
-
- /**
- * Tries to claim the user's drag motion, and requests disallowing any
- * ancestors from stealing events in the drag.
- */
- private void attemptClaimDrag() {
- if (mParent != null) {
- mParent.requestDisallowInterceptTouchEvent(true);
- }
- }
-
- /**
- * This is called when the user has started touching this widget.
- */
- void onStartTrackingTouch() {
- mIsDragging = true;
- }
-
- /**
- * This is called when the user either releases his touch or the touch is
- * canceled.
- */
- void onStopTrackingTouch() {
- mIsDragging = false;
- }
-
- /**
- * Called when the user changes the seekbar's progress by using a key event.
- */
- void onKeyChange() {
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (isEnabled()) {
- int progress = getProgress();
- if ((keyCode == KeyEvent.KEYCODE_DPAD_LEFT && !mIsVertical)
- || (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && mIsVertical)) {
- if (progress > 0) {
- setProgress(progress - mKeyProgressIncrement, true);
- onKeyChange();
- return true;
- }
- } else if ((keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && !mIsVertical)
- || (keyCode == KeyEvent.KEYCODE_DPAD_UP && mIsVertical)) {
- if (progress < getMax()) {
- setProgress(progress + mKeyProgressIncrement, true);
- onKeyChange();
- return true;
- }
- }
- }
-
- return super.onKeyDown(keyCode, event);
- }
-
-}
diff --git a/src/com/android/musicfx/seekbar/ProgressBar.java b/src/com/android/musicfx/seekbar/ProgressBar.java
deleted file mode 100644
index 9c4264d..0000000
--- a/src/com/android/musicfx/seekbar/ProgressBar.java
+++ /dev/null
@@ -1,1146 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.musicfx.seekbar;
-
-import com.android.internal.R;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Bitmap;
-import android.graphics.BitmapShader;
-import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.graphics.Shader;
-import android.graphics.drawable.Animatable;
-import android.graphics.drawable.AnimationDrawable;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.ClipDrawable;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-import android.graphics.drawable.ShapeDrawable;
-import android.graphics.drawable.StateListDrawable;
-import android.graphics.drawable.shapes.RoundRectShape;
-import android.graphics.drawable.shapes.Shape;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.os.SystemClock;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.RemotableViewMethod;
-import android.view.View;
-import android.view.ViewDebug;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.view.animation.Interpolator;
-import android.view.animation.LinearInterpolator;
-import android.view.animation.Transformation;
-import android.widget.RemoteViews.RemoteView;
-
-
-/**
- * <p>
- * Visual indicator of progress in some operation. Displays a bar to the user
- * representing how far the operation has progressed; the application can
- * change the amount of progress (modifying the length of the bar) as it moves
- * forward. There is also a secondary progress displayable on a progress bar
- * which is useful for displaying intermediate progress, such as the buffer
- * level during a streaming playback progress bar.
- * </p>
- *
- * <p>
- * A progress bar can also be made indeterminate. In indeterminate mode, the
- * progress bar shows a cyclic animation without an indication of progress. This mode is used by
- * applications when the length of the task is unknown. The indeterminate progress bar can be either
- * a spinning wheel or a horizontal bar.
- * </p>
- *
- * <p>The following code example shows how a progress bar can be used from
- * a worker thread to update the user interface to notify the user of progress:
- * </p>
- *
- * <pre>
- * public class MyActivity extends Activity {
- * private static final int PROGRESS = 0x1;
- *
- * private ProgressBar mProgress;
- * private int mProgressStatus = 0;
- *
- * private Handler mHandler = new Handler();
- *
- * protected void onCreate(Bundle icicle) {
- * super.onCreate(icicle);
- *
- * setContentView(R.layout.progressbar_activity);
- *
- * mProgress = (ProgressBar) findViewById(R.id.progress_bar);
- *
- * // Start lengthy operation in a background thread
- * new Thread(new Runnable() {
- * public void run() {
- * while (mProgressStatus &lt; 100) {
- * mProgressStatus = doWork();
- *
- * // Update the progress bar
- * mHandler.post(new Runnable() {
- * public void run() {
- * mProgress.setProgress(mProgressStatus);
- * }
- * });
- * }
- * }
- * }).start();
- * }
- * }</pre>
- *
- * <p>To add a progress bar to a layout file, you can use the {@code &lt;ProgressBar&gt;} element.
- * By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a
- * horizontal progress bar, apply the {@link android.R.style#Widget_ProgressBar_Horizontal
- * Widget.ProgressBar.Horizontal} style, like so:</p>
- *
- * <pre>
- * &lt;ProgressBar
- * style="@android:style/Widget.ProgressBar.Horizontal"
- * ... /&gt;</pre>
- *
- * <p>If you will use the progress bar to show real progress, you must use the horizontal bar. You
- * can then increment the progress with {@link #incrementProgressBy incrementProgressBy()} or
- * {@link #setProgress setProgress()}. By default, the progress bar is full when it reaches 100. If
- * necessary, you can adjust the maximum value (the value for a full bar) using the {@link
- * android.R.styleable#ProgressBar_max android:max} attribute. Other attributes available are listed
- * below.</p>
- *
- * <p>Another common style to apply to the progress bar is {@link
- * android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}, which shows a smaller
- * version of the spinning wheel&mdash;useful when waiting for content to load.
- * For example, you can insert this kind of progress bar into your default layout for
- * a view that will be populated by some content fetched from the Internet&mdash;the spinning wheel
- * appears immediately and when your application receives the content, it replaces the progress bar
- * with the loaded content. For example:</p>
- *
- * <pre>
- * &lt;LinearLayout
- * android:orientation="horizontal"
- * ... &gt;
- * &lt;ProgressBar
- * android:layout_width="wrap_content"
- * android:layout_height="wrap_content"
- * style="@android:style/Widget.ProgressBar.Small"
- * android:layout_marginRight="5dp" /&gt;
- * &lt;TextView
- * android:layout_width="wrap_content"
- * android:layout_height="wrap_content"
- * android:text="@string/loading" /&gt;
- * &lt;/LinearLayout&gt;</pre>
- *
- * <p>Other progress bar styles provided by the system include:</p>
- * <ul>
- * <li>{@link android.R.style#Widget_ProgressBar_Horizontal Widget.ProgressBar.Horizontal}</li>
- * <li>{@link android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}</li>
- * <li>{@link android.R.style#Widget_ProgressBar_Large Widget.ProgressBar.Large}</li>
- * <li>{@link android.R.style#Widget_ProgressBar_Inverse Widget.ProgressBar.Inverse}</li>
- * <li>{@link android.R.style#Widget_ProgressBar_Small_Inverse
- * Widget.ProgressBar.Small.Inverse}</li>
- * <li>{@link android.R.style#Widget_ProgressBar_Large_Inverse
- * Widget.ProgressBar.Large.Inverse}</li>
- * </ul>
- * <p>The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary
- * if your application uses a light colored theme (a white background).</p>
- *
- * <p><strong>XML attributes</b></strong>
- * <p>
- * See {@link android.R.styleable#ProgressBar ProgressBar Attributes},
- * {@link android.R.styleable#View View Attributes}
- * </p>
- *
- * @attr ref android.R.styleable#ProgressBar_animationResolution
- * @attr ref android.R.styleable#ProgressBar_indeterminate
- * @attr ref android.R.styleable#ProgressBar_indeterminateBehavior
- * @attr ref android.R.styleable#ProgressBar_indeterminateDrawable
- * @attr ref android.R.styleable#ProgressBar_indeterminateDuration
- * @attr ref android.R.styleable#ProgressBar_indeterminateOnly
- * @attr ref android.R.styleable#ProgressBar_interpolator
- * @attr ref android.R.styleable#ProgressBar_max
- * @attr ref android.R.styleable#ProgressBar_maxHeight
- * @attr ref android.R.styleable#ProgressBar_maxWidth
- * @attr ref android.R.styleable#ProgressBar_minHeight
- * @attr ref android.R.styleable#ProgressBar_minWidth
- * @attr ref android.R.styleable#ProgressBar_progress
- * @attr ref android.R.styleable#ProgressBar_progressDrawable
- * @attr ref android.R.styleable#ProgressBar_secondaryProgress
- */
-@RemoteView
-public class ProgressBar extends View {
- private static final int MAX_LEVEL = 10000;
- private static final int ANIMATION_RESOLUTION = 200;
- private static final int TIMEOUT_SEND_ACCESSIBILITY_EVENT = 200;
-
- int mMinWidth;
- int mMaxWidth;
- int mMinHeight;
- int mMaxHeight;
-
- private int mProgress;
- private int mSecondaryProgress;
- private int mMax;
-
- private int mBehavior;
- private int mDuration;
- private boolean mIndeterminate;
- private boolean mOnlyIndeterminate;
- private Transformation mTransformation;
- private AlphaAnimation mAnimation;
- private Drawable mIndeterminateDrawable;
- private Drawable mProgressDrawable;
- private Drawable mCurrentDrawable;
- Bitmap mSampleTile;
- private boolean mNoInvalidate;
- private Interpolator mInterpolator;
- private RefreshProgressRunnable mRefreshProgressRunnable;
- private long mUiThreadId;
- private boolean mShouldStartAnimationDrawable;
- private long mLastDrawTime;
-
- private boolean mInDrawing;
-
- private int mAnimationResolution;
-
- private AccessibilityEventSender mAccessibilityEventSender;
-
- /**
- * Create a new progress bar with range 0...100 and initial progress of 0.
- * @param context the application environment
- */
- public ProgressBar(Context context) {
- this(context, null);
- }
-
- public ProgressBar(Context context, AttributeSet attrs) {
- this(context, attrs, com.android.internal.R.attr.progressBarStyle);
- }
-
- public ProgressBar(Context context, AttributeSet attrs, int defStyle) {
- this(context, attrs, defStyle, 0);
- }
-
- /**
- * @hide
- */
- public ProgressBar(Context context, AttributeSet attrs, int defStyle, int styleRes) {
- super(context, attrs, defStyle);
- mUiThreadId = Thread.currentThread().getId();
- initProgressBar();
-
- TypedArray a =
- context.obtainStyledAttributes(attrs, R.styleable.ProgressBar, defStyle, styleRes);
-
- mNoInvalidate = true;
-
- Drawable drawable = a.getDrawable(R.styleable.ProgressBar_progressDrawable);
- if (drawable != null) {
- drawable = tileify(drawable, false);
- // Calling this method can set mMaxHeight, make sure the corresponding
- // XML attribute for mMaxHeight is read after calling this method
- setProgressDrawable(drawable);
- }
-
-
- mDuration = a.getInt(R.styleable.ProgressBar_indeterminateDuration, mDuration);
-
- mMinWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_minWidth, mMinWidth);
- mMaxWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_maxWidth, mMaxWidth);
- mMinHeight = a.getDimensionPixelSize(R.styleable.ProgressBar_minHeight, mMinHeight);
- mMaxHeight = a.getDimensionPixelSize(R.styleable.ProgressBar_maxHeight, mMaxHeight);
-
- mBehavior = a.getInt(R.styleable.ProgressBar_indeterminateBehavior, mBehavior);
-
- final int resID = a.getResourceId(
- com.android.internal.R.styleable.ProgressBar_interpolator,
- android.R.anim.linear_interpolator); // default to linear interpolator
- if (resID > 0) {
- setInterpolator(context, resID);
- }
-
- setMax(a.getInt(R.styleable.ProgressBar_max, mMax));
-
- setProgress(a.getInt(R.styleable.ProgressBar_progress, mProgress));
-
- setSecondaryProgress(
- a.getInt(R.styleable.ProgressBar_secondaryProgress, mSecondaryProgress));
-
- drawable = a.getDrawable(R.styleable.ProgressBar_indeterminateDrawable);
- if (drawable != null) {
- drawable = tileifyIndeterminate(drawable);
- setIndeterminateDrawable(drawable);
- }
-
- mOnlyIndeterminate = a.getBoolean(
- R.styleable.ProgressBar_indeterminateOnly, mOnlyIndeterminate);
-
- mNoInvalidate = false;
-
- setIndeterminate(mOnlyIndeterminate || a.getBoolean(
- R.styleable.ProgressBar_indeterminate, mIndeterminate));
-
- mAnimationResolution = a.getInteger(R.styleable.ProgressBar_animationResolution,
- ANIMATION_RESOLUTION);
-
- a.recycle();
- }
-
- /**
- * Converts a drawable to a tiled version of itself. It will recursively
- * traverse layer and state list drawables.
- */
- private Drawable tileify(Drawable drawable, boolean clip) {
-
- if (drawable instanceof LayerDrawable) {
- LayerDrawable background = (LayerDrawable) drawable;
- final int N = background.getNumberOfLayers();
- Drawable[] outDrawables = new Drawable[N];
-
- for (int i = 0; i < N; i++) {
- int id = background.getId(i);
- outDrawables[i] = tileify(background.getDrawable(i),
- (id == R.id.progress || id == R.id.secondaryProgress));
- }
-
- LayerDrawable newBg = new LayerDrawable(outDrawables);
-
- for (int i = 0; i < N; i++) {
- newBg.setId(i, background.getId(i));
- }
-
- return newBg;
-
- } else if (drawable instanceof StateListDrawable) {
- StateListDrawable in = (StateListDrawable) drawable;
- StateListDrawable out = new StateListDrawable();
- int numStates = in.getStateCount();
- for (int i = 0; i < numStates; i++) {
- out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
- }
- return out;
-
- } else if (drawable instanceof BitmapDrawable) {
- final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
- if (mSampleTile == null) {
- mSampleTile = tileBitmap;
- }
-
- final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());
-
- final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
- Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
- shapeDrawable.getPaint().setShader(bitmapShader);
-
- return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
- ClipDrawable.HORIZONTAL) : shapeDrawable;
- }
-
- return drawable;
- }
-
- Shape getDrawableShape() {
- final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
- return new RoundRectShape(roundedCorners, null, null);
- }
-
- /**
- * Convert a AnimationDrawable for use as a barberpole animation.
- * Each frame of the animation is wrapped in a ClipDrawable and
- * given a tiling BitmapShader.
- */
- private Drawable tileifyIndeterminate(Drawable drawable) {
- if (drawable instanceof AnimationDrawable) {
- AnimationDrawable background = (AnimationDrawable) drawable;
- final int N = background.getNumberOfFrames();
- AnimationDrawable newBg = new AnimationDrawable();
- newBg.setOneShot(background.isOneShot());
-
- for (int i = 0; i < N; i++) {
- Drawable frame = tileify(background.getFrame(i), true);
- frame.setLevel(10000);
- newBg.addFrame(frame, background.getDuration(i));
- }
- newBg.setLevel(10000);
- drawable = newBg;
- }
- return drawable;
- }
-
- /**
- * <p>
- * Initialize the progress bar's default values:
- * </p>
- * <ul>
- * <li>progress = 0</li>
- * <li>max = 100</li>
- * <li>animation duration = 4000 ms</li>
- * <li>indeterminate = false</li>
- * <li>behavior = repeat</li>
- * </ul>
- */
- private void initProgressBar() {
- mMax = 100;
- mProgress = 0;
- mSecondaryProgress = 0;
- mIndeterminate = false;
- mOnlyIndeterminate = false;
- mDuration = 4000;
- mBehavior = AlphaAnimation.RESTART;
- mMinWidth = 24;
- mMaxWidth = 48;
- mMinHeight = 24;
- mMaxHeight = 48;
- }
-
- /**
- * <p>Indicate whether this progress bar is in indeterminate mode.</p>
- *
- * @return true if the progress bar is in indeterminate mode
- */
- @ViewDebug.ExportedProperty(category = "progress")
- public synchronized boolean isIndeterminate() {
- return mIndeterminate;
- }
-
- /**
- * <p>Change the indeterminate mode for this progress bar. In indeterminate
- * mode, the progress is ignored and the progress bar shows an infinite
- * animation instead.</p>
- *
- * If this progress bar's style only supports indeterminate mode (such as the circular
- * progress bars), then this will be ignored.
- *
- * @param indeterminate true to enable the indeterminate mode
- */
- @android.view.RemotableViewMethod
- public synchronized void setIndeterminate(boolean indeterminate) {
- if ((!mOnlyIndeterminate || !mIndeterminate) && indeterminate != mIndeterminate) {
- mIndeterminate = indeterminate;
-
- if (indeterminate) {
- // swap between indeterminate and regular backgrounds
- mCurrentDrawable = mIndeterminateDrawable;
- startAnimation();
- } else {
- mCurrentDrawable = mProgressDrawable;
- stopAnimation();
- }
- }
- }
-
- /**
- * <p>Get the drawable used to draw the progress bar in
- * indeterminate mode.</p>
- *
- * @return a {@link android.graphics.drawable.Drawable} instance
- *
- * @see #setIndeterminateDrawable(android.graphics.drawable.Drawable)
- * @see #setIndeterminate(boolean)
- */
- public Drawable getIndeterminateDrawable() {
- return mIndeterminateDrawable;
- }
-
- /**
- * <p>Define the drawable used to draw the progress bar in
- * indeterminate mode.</p>
- *
- * @param d the new drawable
- *
- * @see #getIndeterminateDrawable()
- * @see #setIndeterminate(boolean)
- */
- public void setIndeterminateDrawable(Drawable d) {
- if (d != null) {
- d.setCallback(this);
- }
- mIndeterminateDrawable = d;
- if (mIndeterminate) {
- mCurrentDrawable = d;
- postInvalidate();
- }
- }
-
- /**
- * <p>Get the drawable used to draw the progress bar in
- * progress mode.</p>
- *
- * @return a {@link android.graphics.drawable.Drawable} instance
- *
- * @see #setProgressDrawable(android.graphics.drawable.Drawable)
- * @see #setIndeterminate(boolean)
- */
- public Drawable getProgressDrawable() {
- return mProgressDrawable;
- }
-
- /**
- * <p>Define the drawable used to draw the progress bar in
- * progress mode.</p>
- *
- * @param d the new drawable
- *
- * @see #getProgressDrawable()
- * @see #setIndeterminate(boolean)
- */
- public void setProgressDrawable(Drawable d) {
- boolean needUpdate;
- if (mProgressDrawable != null && d != mProgressDrawable) {
- mProgressDrawable.setCallback(null);
- needUpdate = true;
- } else {
- needUpdate = false;
- }
-
- if (d != null) {
- d.setCallback(this);
-
- // Make sure the ProgressBar is always tall enough
- int drawableHeight = d.getMinimumHeight();
- if (mMaxHeight < drawableHeight) {
- mMaxHeight = drawableHeight;
- requestLayout();
- }
- }
- mProgressDrawable = d;
- if (!mIndeterminate) {
- mCurrentDrawable = d;
- postInvalidate();
- }
-
- if (needUpdate) {
- updateDrawableBounds(getWidth(), getHeight());
- updateDrawableState();
- doRefreshProgress(R.id.progress, mProgress, false, false);
- doRefreshProgress(R.id.secondaryProgress, mSecondaryProgress, false, false);
- }
- }
-
- /**
- * @return The drawable currently used to draw the progress bar
- */
- Drawable getCurrentDrawable() {
- return mCurrentDrawable;
- }
-
- @Override
- protected boolean verifyDrawable(Drawable who) {
- return who == mProgressDrawable || who == mIndeterminateDrawable
- || super.verifyDrawable(who);
- }
-
- @Override
- public void jumpDrawablesToCurrentState() {
- super.jumpDrawablesToCurrentState();
- if (mProgressDrawable != null) mProgressDrawable.jumpToCurrentState();
- if (mIndeterminateDrawable != null) mIndeterminateDrawable.jumpToCurrentState();
- }
-
- @Override
- public void postInvalidate() {
- if (!mNoInvalidate) {
- super.postInvalidate();
- }
- }
-
- private class RefreshProgressRunnable implements Runnable {
-
- private int mId;
- private int mProgress;
- private boolean mFromUser;
-
- RefreshProgressRunnable(int id, int progress, boolean fromUser) {
- mId = id;
- mProgress = progress;
- mFromUser = fromUser;
- }
-
- public void run() {
- doRefreshProgress(mId, mProgress, mFromUser, true);
- // Put ourselves back in the cache when we are done
- mRefreshProgressRunnable = this;
- }
-
- public void setup(int id, int progress, boolean fromUser) {
- mId = id;
- mProgress = progress;
- mFromUser = fromUser;
- }
-
- }
-
- private synchronized void doRefreshProgress(int id, int progress, boolean fromUser,
- boolean callBackToApp) {
- float scale = mMax > 0 ? (float) progress / (float) mMax : 0;
- final Drawable d = mCurrentDrawable;
- if (d != null) {
- Drawable progressDrawable = null;
-
- if (d instanceof LayerDrawable) {
- progressDrawable = ((LayerDrawable) d).findDrawableByLayerId(id);
- }
-
- final int level = (int) (scale * MAX_LEVEL);
- (progressDrawable != null ? progressDrawable : d).setLevel(level);
- } else {
- invalidate();
- }
-
- if (callBackToApp && id == R.id.progress) {
- onProgressRefresh(scale, fromUser);
- }
- }
-
- void onProgressRefresh(float scale, boolean fromUser) {
- if (AccessibilityManager.getInstance(mContext).isEnabled()) {
- scheduleAccessibilityEventSender();
- }
- }
-
- private synchronized void refreshProgress(int id, int progress, boolean fromUser) {
- if (mUiThreadId == Thread.currentThread().getId()) {
- doRefreshProgress(id, progress, fromUser, true);
- } else {
- RefreshProgressRunnable r;
- if (mRefreshProgressRunnable != null) {
- // Use cached RefreshProgressRunnable if available
- r = mRefreshProgressRunnable;
- // Uncache it
- mRefreshProgressRunnable = null;
- r.setup(id, progress, fromUser);
- } else {
- // Make a new one
- r = new RefreshProgressRunnable(id, progress, fromUser);
- }
- post(r);
- }
- }
-
- /**
- * <p>Set the current progress to the specified value. Does not do anything
- * if the progress bar is in indeterminate mode.</p>
- *
- * @param progress the new progress, between 0 and {@link #getMax()}
- *
- * @see #setIndeterminate(boolean)
- * @see #isIndeterminate()
- * @see #getProgress()
- * @see #incrementProgressBy(int)
- */
- @android.view.RemotableViewMethod
- public synchronized void setProgress(int progress) {
- setProgress(progress, false);
- }
-
- @android.view.RemotableViewMethod
- synchronized void setProgress(int progress, boolean fromUser) {
- if (mIndeterminate) {
- return;
- }
-
- if (progress < 0) {
- progress = 0;
- }
-
- if (progress > mMax) {
- progress = mMax;
- }
-
- if (progress != mProgress) {
- mProgress = progress;
- refreshProgress(R.id.progress, mProgress, fromUser);
- }
- }
-
- /**
- * <p>
- * Set the current secondary progress to the specified value. Does not do
- * anything if the progress bar is in indeterminate mode.
- * </p>
- *
- * @param secondaryProgress the new secondary progress, between 0 and {@link #getMax()}
- * @see #setIndeterminate(boolean)
- * @see #isIndeterminate()
- * @see #getSecondaryProgress()
- * @see #incrementSecondaryProgressBy(int)
- */
- @android.view.RemotableViewMethod
- public synchronized void setSecondaryProgress(int secondaryProgress) {
- if (mIndeterminate) {
- return;
- }
-
- if (secondaryProgress < 0) {
- secondaryProgress = 0;
- }
-
- if (secondaryProgress > mMax) {
- secondaryProgress = mMax;
- }
-
- if (secondaryProgress != mSecondaryProgress) {
- mSecondaryProgress = secondaryProgress;
- refreshProgress(R.id.secondaryProgress, mSecondaryProgress, false);
- }
- }
-
- /**
- * <p>Get the progress bar's current level of progress. Return 0 when the
- * progress bar is in indeterminate mode.</p>
- *
- * @return the current progress, between 0 and {@link #getMax()}
- *
- * @see #setIndeterminate(boolean)
- * @see #isIndeterminate()
- * @see #setProgress(int)
- * @see #setMax(int)
- * @see #getMax()
- */
- @ViewDebug.ExportedProperty(category = "progress")
- public synchronized int getProgress() {
- return mIndeterminate ? 0 : mProgress;
- }
-
- /**
- * <p>Get the progress bar's current level of secondary progress. Return 0 when the
- * progress bar is in indeterminate mode.</p>
- *
- * @return the current secondary progress, between 0 and {@link #getMax()}
- *
- * @see #setIndeterminate(boolean)
- * @see #isIndeterminate()
- * @see #setSecondaryProgress(int)
- * @see #setMax(int)
- * @see #getMax()
- */
- @ViewDebug.ExportedProperty(category = "progress")
- public synchronized int getSecondaryProgress() {
- return mIndeterminate ? 0 : mSecondaryProgress;
- }
-
- /**
- * <p>Return the upper limit of this progress bar's range.</p>
- *
- * @return a positive integer
- *
- * @see #setMax(int)
- * @see #getProgress()
- * @see #getSecondaryProgress()
- */
- @ViewDebug.ExportedProperty(category = "progress")
- public synchronized int getMax() {
- return mMax;
- }
-
- /**
- * <p>Set the range of the progress bar to 0...<tt>max</tt>.</p>
- *
- * @param max the upper range of this progress bar
- *
- * @see #getMax()
- * @see #setProgress(int)
- * @see #setSecondaryProgress(int)
- */
- @android.view.RemotableViewMethod
- public synchronized void setMax(int max) {
- if (max < 0) {
- max = 0;
- }
- if (max != mMax) {
- mMax = max;
- postInvalidate();
-
- if (mProgress > max) {
- mProgress = max;
- }
- refreshProgress(R.id.progress, mProgress, false);
- }
- }
-
- /**
- * <p>Increase the progress bar's progress by the specified amount.</p>
- *
- * @param diff the amount by which the progress must be increased
- *
- * @see #setProgress(int)
- */
- public synchronized final void incrementProgressBy(int diff) {
- setProgress(mProgress + diff);
- }
-
- /**
- * <p>Increase the progress bar's secondary progress by the specified amount.</p>
- *
- * @param diff the amount by which the secondary progress must be increased
- *
- * @see #setSecondaryProgress(int)
- */
- public synchronized final void incrementSecondaryProgressBy(int diff) {
- setSecondaryProgress(mSecondaryProgress + diff);
- }
-
- /**
- * <p>Start the indeterminate progress animation.</p>
- */
- void startAnimation() {
- if (getVisibility() != VISIBLE) {
- return;
- }
-
- if (mIndeterminateDrawable instanceof Animatable) {
- mShouldStartAnimationDrawable = true;
- mAnimation = null;
- } else {
- if (mInterpolator == null) {
- mInterpolator = new LinearInterpolator();
- }
-
- mTransformation = new Transformation();
- mAnimation = new AlphaAnimation(0.0f, 1.0f);
- mAnimation.setRepeatMode(mBehavior);
- mAnimation.setRepeatCount(Animation.INFINITE);
- mAnimation.setDuration(mDuration);
- mAnimation.setInterpolator(mInterpolator);
- mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
- }
- postInvalidate();
- }
-
- /**
- * <p>Stop the indeterminate progress animation.</p>
- */
- void stopAnimation() {
- mAnimation = null;
- mTransformation = null;
- if (mIndeterminateDrawable instanceof Animatable) {
- ((Animatable) mIndeterminateDrawable).stop();
- mShouldStartAnimationDrawable = false;
- }
- postInvalidate();
- }
-
- /**
- * Sets the acceleration curve for the indeterminate animation.
- * The interpolator is loaded as a resource from the specified context.
- *
- * @param context The application environment
- * @param resID The resource identifier of the interpolator to load
- */
- public void setInterpolator(Context context, int resID) {
- setInterpolator(AnimationUtils.loadInterpolator(context, resID));
- }
-
- /**
- * Sets the acceleration curve for the indeterminate animation.
- * Defaults to a linear interpolation.
- *
- * @param interpolator The interpolator which defines the acceleration curve
- */
- public void setInterpolator(Interpolator interpolator) {
- mInterpolator = interpolator;
- }
-
- /**
- * Gets the acceleration curve type for the indeterminate animation.
- *
- * @return the {@link Interpolator} associated to this animation
- */
- public Interpolator getInterpolator() {
- return mInterpolator;
- }
-
- @Override
- @RemotableViewMethod
- public void setVisibility(int v) {
- if (getVisibility() != v) {
- super.setVisibility(v);
-
- if (mIndeterminate) {
- // let's be nice with the UI thread
- if (v == GONE || v == INVISIBLE) {
- stopAnimation();
- } else {
- startAnimation();
- }
- }
- }
- }
-
- @Override
- protected void onVisibilityChanged(View changedView, int visibility) {
- super.onVisibilityChanged(changedView, visibility);
-
- if (mIndeterminate) {
- // let's be nice with the UI thread
- if (visibility == GONE || visibility == INVISIBLE) {
- stopAnimation();
- } else {
- startAnimation();
- }
- }
- }
-
- @Override
- public void invalidateDrawable(Drawable dr) {
- if (!mInDrawing) {
- if (verifyDrawable(dr)) {
- final Rect dirty = dr.getBounds();
- final int scrollX = mScrollX + mPaddingLeft;
- final int scrollY = mScrollY + mPaddingTop;
-
- invalidate(dirty.left + scrollX, dirty.top + scrollY,
- dirty.right + scrollX, dirty.bottom + scrollY);
- } else {
- super.invalidateDrawable(dr);
- }
- }
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- updateDrawableBounds(w, h);
- }
-
- private void updateDrawableBounds(int w, int h) {
- // onDraw will translate the canvas so we draw starting at 0,0
- int right = w - mPaddingRight - mPaddingLeft;
- int bottom = h - mPaddingBottom - mPaddingTop;
- int top = 0;
- int left = 0;
-
- if (mIndeterminateDrawable != null) {
- // Aspect ratio logic does not apply to AnimationDrawables
- if (mOnlyIndeterminate && !(mIndeterminateDrawable instanceof AnimationDrawable)) {
- // Maintain aspect ratio. Certain kinds of animated drawables
- // get very confused otherwise.
- final int intrinsicWidth = mIndeterminateDrawable.getIntrinsicWidth();
- final int intrinsicHeight = mIndeterminateDrawable.getIntrinsicHeight();
- final float intrinsicAspect = (float) intrinsicWidth / intrinsicHeight;
- final float boundAspect = (float) w / h;
- if (intrinsicAspect != boundAspect) {
- if (boundAspect > intrinsicAspect) {
- // New width is larger. Make it smaller to match height.
- final int width = (int) (h * intrinsicAspect);
- left = (w - width) / 2;
- right = left + width;
- } else {
- // New height is larger. Make it smaller to match width.
- final int height = (int) (w * (1 / intrinsicAspect));
- top = (h - height) / 2;
- bottom = top + height;
- }
- }
- }
- mIndeterminateDrawable.setBounds(left, top, right, bottom);
- }
-
- if (mProgressDrawable != null) {
- mProgressDrawable.setBounds(0, 0, right, bottom);
- }
- }
-
- @Override
- protected synchronized void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- Drawable d = mCurrentDrawable;
- if (d != null) {
- // Translate canvas so a indeterminate circular progress bar with padding
- // rotates properly in its animation
- canvas.save();
- canvas.translate(mPaddingLeft, mPaddingTop);
- long time = getDrawingTime();
- if (mAnimation != null) {
- mAnimation.getTransformation(time, mTransformation);
- float scale = mTransformation.getAlpha();
- try {
- mInDrawing = true;
- d.setLevel((int) (scale * MAX_LEVEL));
- } finally {
- mInDrawing = false;
- }
- if (SystemClock.uptimeMillis() - mLastDrawTime >= mAnimationResolution) {
- mLastDrawTime = SystemClock.uptimeMillis();
- postInvalidateDelayed(mAnimationResolution);
- }
- }
- d.draw(canvas);
- canvas.restore();
- if (mShouldStartAnimationDrawable && d instanceof Animatable) {
- ((Animatable) d).start();
- mShouldStartAnimationDrawable = false;
- }
- }
- }
-
- @Override
- protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- Drawable d = mCurrentDrawable;
-
- int dw = 0;
- int dh = 0;
- if (d != null) {
- dw = Math.max(mMinWidth, Math.min(mMaxWidth, d.getIntrinsicWidth()));
- dh = Math.max(mMinHeight, Math.min(mMaxHeight, d.getIntrinsicHeight()));
- }
- updateDrawableState();
- dw += mPaddingLeft + mPaddingRight;
- dh += mPaddingTop + mPaddingBottom;
-
- setMeasuredDimension(resolveSizeAndState(dw, widthMeasureSpec, 0),
- resolveSizeAndState(dh, heightMeasureSpec, 0));
- }
-
- @Override
- protected void drawableStateChanged() {
- super.drawableStateChanged();
- updateDrawableState();
- }
-
- private void updateDrawableState() {
- int[] state = getDrawableState();
-
- if (mProgressDrawable != null && mProgressDrawable.isStateful()) {
- mProgressDrawable.setState(state);
- }
-
- if (mIndeterminateDrawable != null && mIndeterminateDrawable.isStateful()) {
- mIndeterminateDrawable.setState(state);
- }
- }
-
- static class SavedState extends BaseSavedState {
- int progress;
- int secondaryProgress;
-
- /**
- * Constructor called from {@link ProgressBar#onSaveInstanceState()}
- */
- SavedState(Parcelable superState) {
- super(superState);
- }
-
- /**
- * Constructor called from {@link #CREATOR}
- */
- private SavedState(Parcel in) {
- super(in);
- progress = in.readInt();
- secondaryProgress = in.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- out.writeInt(progress);
- out.writeInt(secondaryProgress);
- }
-
- public static final Parcelable.Creator<SavedState> CREATOR
- = new Parcelable.Creator<SavedState>() {
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- // Force our ancestor class to save its state
- Parcelable superState = super.onSaveInstanceState();
- SavedState ss = new SavedState(superState);
-
- ss.progress = mProgress;
- ss.secondaryProgress = mSecondaryProgress;
-
- return ss;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- SavedState ss = (SavedState) state;
- super.onRestoreInstanceState(ss.getSuperState());
-
- setProgress(ss.progress);
- setSecondaryProgress(ss.secondaryProgress);
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- if (mIndeterminate) {
- startAnimation();
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if (mIndeterminate) {
- stopAnimation();
- }
- if(mRefreshProgressRunnable != null) {
- removeCallbacks(mRefreshProgressRunnable);
- }
- if (mAccessibilityEventSender != null) {
- removeCallbacks(mAccessibilityEventSender);
- }
- // This should come after stopAnimation(), otherwise an invalidate message remains in the
- // queue, which can prevent the entire view hierarchy from being GC'ed during a rotation
- super.onDetachedFromWindow();
- }
-
- @Override
- public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
- super.onInitializeAccessibilityEvent(event);
- event.setItemCount(mMax);
- event.setCurrentItemIndex(mProgress);
- }
-
- /**
- * Schedule a command for sending an accessibility event.
- * </br>
- * Note: A command is used to ensure that accessibility events
- * are sent at most one in a given time frame to save
- * system resources while the progress changes quickly.
- */
- private void scheduleAccessibilityEventSender() {
- if (mAccessibilityEventSender == null) {
- mAccessibilityEventSender = new AccessibilityEventSender();
- } else {
- removeCallbacks(mAccessibilityEventSender);
- }
- postDelayed(mAccessibilityEventSender, TIMEOUT_SEND_ACCESSIBILITY_EVENT);
- }
-
- /**
- * Command for sending an accessibility event.
- */
- private class AccessibilityEventSender implements Runnable {
- public void run() {
- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
- }
- }
-}
diff --git a/src/com/android/musicfx/seekbar/SeekBar.java b/src/com/android/musicfx/seekbar/SeekBar.java
deleted file mode 100644
index 2be99ce..0000000
--- a/src/com/android/musicfx/seekbar/SeekBar.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.musicfx.seekbar;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-
-
-/**
- * A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch
- * the thumb and drag left or right to set the current progress level or use the arrow keys.
- * Placing focusable widgets to the left or right of a SeekBar is discouraged.
- * <p>
- * Clients of the SeekBar can attach a {@link SeekBar.OnSeekBarChangeListener} to
- * be notified of the user's actions.
- *
- * @attr ref android.R.styleable#SeekBar_thumb
- */
-public class SeekBar extends AbsSeekBar {
-
- /**
- * A callback that notifies clients when the progress level has been
- * changed. This includes changes that were initiated by the user through a
- * touch gesture or arrow key/trackball as well as changes that were initiated
- * programmatically.
- */
- public interface OnSeekBarChangeListener {
-
- /**
- * Notification that the progress level has changed. Clients can use the fromUser parameter
- * to distinguish user-initiated changes from those that occurred programmatically.
- *
- * @param seekBar The SeekBar whose progress has changed
- * @param progress The current progress level. This will be in the range 0..max where max
- * was set by {@link ProgressBar#setMax(int)}. (The default value for max is 100.)
- * @param fromUser True if the progress change was initiated by the user.
- */
- void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser);
-
- /**
- * Notification that the user has started a touch gesture. Clients may want to use this
- * to disable advancing the seekbar.
- * @param seekBar The SeekBar in which the touch gesture began
- */
- void onStartTrackingTouch(SeekBar seekBar);
-
- /**
- * Notification that the user has finished a touch gesture. Clients may want to use this
- * to re-enable advancing the seekbar.
- * @param seekBar The SeekBar in which the touch gesture began
- */
- void onStopTrackingTouch(SeekBar seekBar);
- }
-
- private OnSeekBarChangeListener mOnSeekBarChangeListener;
-
- public SeekBar(Context context) {
- this(context, null);
- }
-
- public SeekBar(Context context, AttributeSet attrs) {
- this(context, attrs, com.android.internal.R.attr.seekBarStyle);
- }
-
- public SeekBar(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- void onProgressRefresh(float scale, boolean fromUser) {
- super.onProgressRefresh(scale, fromUser);
-
- if (mOnSeekBarChangeListener != null) {
- mOnSeekBarChangeListener.onProgressChanged(this, getProgress(), fromUser);
- }
- }
-
- /**
- * Sets a listener to receive notifications of changes to the SeekBar's progress level. Also
- * provides notifications of when the user starts and stops a touch gesture within the SeekBar.
- *
- * @param l The seek bar notification listener
- *
- * @see SeekBar.OnSeekBarChangeListener
- */
- public void setOnSeekBarChangeListener(OnSeekBarChangeListener l) {
- mOnSeekBarChangeListener = l;
- }
-
- @Override
- void onStartTrackingTouch() {
- super.onStartTrackingTouch();
- if (mOnSeekBarChangeListener != null) {
- mOnSeekBarChangeListener.onStartTrackingTouch(this);
- }
- }
-
- @Override
- void onStopTrackingTouch() {
- super.onStopTrackingTouch();
- if (mOnSeekBarChangeListener != null) {
- mOnSeekBarChangeListener.onStopTrackingTouch(this);
- }
- }
-
-}