Skip to content

Commit 738ba60

Browse files
Utkarsh GuptaGerrit Code Review
authored andcommitted
SystemUI: use new visualizer from Eleven
Change-Id: I4441440868cac71caa32c91a0875f00a630fe596 Signed-off-by: Utkarsh Gupta <[email protected]> Signed-off-by: Roman Birg <[email protected]>
1 parent cf60acb commit 738ba60

File tree

10 files changed

+416
-313
lines changed

10 files changed

+416
-313
lines changed

core/java/android/provider/Settings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6085,8 +6085,8 @@ public static boolean putFloatForUser(ContentResolver cr, String name, float val
60856085
public static final String LIVE_DISPLAY_COLOR_MATRIX = "live_display_color_matrix";
60866086

60876087
/**
6088-
* Whether to show the lockscreen visualizer.
6089-
* 0 will disable it, anything else will enable it. Default is on.
6088+
* Whether to show the keyguard visualizer.
6089+
* Boolean setting. 0 = no, 1 = yes.
60906090
* @hide
60916091
*/
60926092
public static final String LOCKSCREEN_VISUALIZER_ENABLED = "lockscreen_visualizer";

packages/SystemUI/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
<!-- Weather -->
121121
<uses-permission android:name="com.cyanogenmod.lockclock.permission.READ_WEATHER" />
122122

123-
<!-- Visualizer tile -->
123+
<!-- Visualizer -->
124124
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
125125
<uses-permission android:name="android.permission.RECORD_AUDIO" />
126126

packages/SystemUI/res/layout/super_status_bar.xml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,25 @@
3939
android:layout_height="match_parent"
4040
android:scaleType="centerCrop"
4141
android:visibility="invisible" />
42-
<com.pheelicks.visualizer.VisualizerView
43-
android:id="@+id/visualizerView"
44-
android:gravity="bottom"
45-
android:layout_gravity="bottom"
46-
android:layout_width="match_parent"
47-
android:layout_height="match_parent"
48-
android:clipChildren="false"
49-
android:clipToPadding="false"
50-
android:visibility="visible"/>
5142
</com.android.systemui.statusbar.BackDropView>
5243

53-
<com.android.systemui.statusbar.ScrimView android:id="@+id/scrim_behind"
54-
android:layout_width="match_parent"
55-
android:layout_height="match_parent"
56-
android:importantForAccessibility="no" />
44+
<FrameLayout android:id="@+id/scrimview"
45+
android:layout_width="match_parent"
46+
android:layout_height="match_parent"
47+
android:visibility="visible">
48+
<com.android.systemui.statusbar.ScrimView
49+
android:id="@+id/scrim_behind"
50+
android:layout_width="match_parent"
51+
android:layout_height="match_parent"
52+
android:importantForAccessibility="no"/>
53+
<com.android.systemui.statusbar.VisualizerView
54+
android:id="@+id/visualizerview"
55+
android:gravity="bottom"
56+
android:layout_gravity="bottom"
57+
android:layout_width="match_parent"
58+
android:layout_height="match_parent"
59+
android:visibility="visible"/>
60+
</FrameLayout>
5761

5862
<include layout="@layout/status_bar"
5963
android:layout_width="match_parent"

packages/SystemUI/src/com/android/systemui/statusbar/BackDropView.java

Lines changed: 1 addition & 212 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/**
4141
* A view who contains media artwork.
4242
*/
43-
public class BackDropView extends FrameLayout implements Palette.PaletteAsyncListener {
43+
public class BackDropView extends FrameLayout {
4444
private Runnable mOnVisibilityChangedRunnable;
4545

4646
public BackDropView(Context context) {
@@ -59,11 +59,6 @@ public BackDropView(Context context, AttributeSet attrs, int defStyleAttr, int d
5959
super(context, attrs, defStyleAttr, defStyleRes);
6060
}
6161

62-
@Override
63-
public boolean hasOverlappingRendering() {
64-
return mLinked;
65-
}
66-
6762
@Override
6863
protected void onVisibilityChanged(View changedView, int visibility) {
6964
super.onVisibilityChanged(changedView, visibility);
@@ -76,210 +71,4 @@ public void setOnVisibilityChangedRunnable(Runnable runnable) {
7671
mOnVisibilityChangedRunnable = runnable;
7772
}
7873

79-
private boolean mLinked = false;
80-
private boolean mVisible = false;
81-
private boolean mPlaying = false;
82-
private boolean mAnimating = false;
83-
private boolean mTouching = false;
84-
private boolean mPowerSaveMode = false;
85-
private boolean mQsExpanded = false;
86-
private int mColor;
87-
88-
private VisualizerView mVisualizer;
89-
private TileBarGraphRenderer mBarRenderer;
90-
private ObjectAnimator mVisualizerColorAnimator;
91-
92-
private final Runnable mLinkVisualizer = new Runnable() {
93-
@Override
94-
public void run() {
95-
if (mVisualizer != null) {
96-
mVisualizer.link(0);
97-
}
98-
}
99-
};
100-
101-
private final Runnable mUnlinkVisualizer = new Runnable() {
102-
@Override
103-
public void run() {
104-
if (mVisualizer != null) {
105-
mVisualizer.unlink();
106-
}
107-
}
108-
};
109-
110-
private static class TileBarGraphRenderer extends Renderer {
111-
private int mDivisions;
112-
private Paint mPaint;
113-
private int mDbFuzz;
114-
private int mDbFuzzFactor;
115-
116-
/**
117-
* Renders the FFT data as a series of lines, in histogram form
118-
*
119-
* @param divisions - must be a power of 2. Controls how many lines to draw
120-
* @param paint - Paint to draw lines with
121-
* @param dbfuzz - final dB display adjustment
122-
* @param dbFactor - dbfuzz is multiplied by dbFactor.
123-
*/
124-
public TileBarGraphRenderer(int divisions, Paint paint, int dbfuzz, int dbFactor) {
125-
super();
126-
mDivisions = divisions;
127-
mPaint = paint;
128-
mDbFuzz = dbfuzz;
129-
mDbFuzzFactor = dbFactor;
130-
}
131-
132-
@Override
133-
public void onRender(Canvas canvas, AudioData data, Rect rect) {
134-
// Do nothing, we only display FFT data
135-
}
136-
137-
@Override
138-
public void onRender(Canvas canvas, FFTData data, Rect rect) {
139-
for (int i = 0; i < data.bytes.length / mDivisions; i++) {
140-
mFFTPoints[i * 4] = i * 4 * mDivisions;
141-
mFFTPoints[i * 4 + 2] = i * 4 * mDivisions;
142-
byte rfk = data.bytes[mDivisions * i];
143-
byte ifk = data.bytes[mDivisions * i + 1];
144-
float magnitude = (rfk * rfk + ifk * ifk);
145-
int dbValue = magnitude > 0 ? (int) (10 * Math.log10(magnitude)) : 0;
146-
147-
mFFTPoints[i * 4 + 1] = rect.height();
148-
mFFTPoints[i * 4 + 3] = rect.height() - (dbValue * mDbFuzzFactor + mDbFuzz);
149-
}
150-
151-
canvas.drawLines(mFFTPoints, mPaint);
152-
}
153-
}
154-
155-
@Override
156-
protected void onFinishInflate() {
157-
super.onFinishInflate();
158-
159-
mVisualizer = (VisualizerView) findViewById(R.id.visualizerView);
160-
mVisualizer.setEnabled(false);
161-
162-
Resources res = mContext.getResources();
163-
mColor = res.getColor(R.color.equalizer_fill_color);
164-
Paint paint = new Paint();
165-
paint.setStrokeWidth(res.getDimensionPixelSize(R.dimen.kg_visualizer_path_stroke_width));
166-
paint.setAntiAlias(true);
167-
paint.setColor(mColor);
168-
paint.setPathEffect(new DashPathEffect(new float[]{
169-
res.getDimensionPixelSize(R.dimen.kg_visualizer_path_effect_1),
170-
res.getDimensionPixelSize(R.dimen.kg_visualizer_path_effect_2)
171-
}, 0));
172-
173-
int bars = res.getInteger(R.integer.kg_visualizer_divisions);
174-
mBarRenderer = new TileBarGraphRenderer(bars, paint,
175-
res.getInteger(R.integer.kg_visualizer_db_fuzz),
176-
res.getInteger(R.integer.kg_visualizer_db_fuzz_factor));
177-
mVisualizer.addRenderer(mBarRenderer);
178-
}
179-
180-
public void setVisible(boolean visible) {
181-
if (mVisible != visible) {
182-
mVisible = visible;
183-
if (!mVisible) {
184-
mAnimating = false;
185-
mTouching = false;
186-
}
187-
checkStateChanged();
188-
}
189-
}
190-
191-
public void setPlaying(boolean playing) {
192-
if (mPlaying != playing) {
193-
mPlaying = playing;
194-
checkStateChanged();
195-
}
196-
}
197-
198-
public void setAnimating(boolean animating) {
199-
if (mAnimating != animating) {
200-
mAnimating = animating;
201-
checkStateChanged();
202-
}
203-
}
204-
205-
public void setTouching(boolean touching) {
206-
if (mTouching != touching) {
207-
mTouching = touching;
208-
checkStateChanged();
209-
}
210-
}
211-
212-
public void setPowerSaveMode(boolean powerSaveMode) {
213-
if (mPowerSaveMode != powerSaveMode) {
214-
mPowerSaveMode = powerSaveMode;
215-
checkStateChanged();
216-
}
217-
}
218-
219-
public void setQsExpanded(boolean qsExpanded) {
220-
if (mQsExpanded != qsExpanded) {
221-
mQsExpanded = qsExpanded;
222-
checkStateChanged();
223-
}
224-
}
225-
226-
@Override
227-
public void onGenerated(Palette palette) {
228-
int color = Color.TRANSPARENT;
229-
230-
color = palette.getLightVibrantColor(color);
231-
if (color == Color.TRANSPARENT) {
232-
color = palette.getVibrantColor(color);
233-
if (color == Color.TRANSPARENT) {
234-
color = palette.getDarkVibrantColor(color);
235-
}
236-
}
237-
setVisualizerColor(color);
238-
}
239-
240-
public void setBitmap(Bitmap bitmap) {
241-
if (bitmap != null) {
242-
Palette.generateAsync(bitmap, this);
243-
} else {
244-
setVisualizerColor(Color.TRANSPARENT);
245-
}
246-
}
247-
248-
private void setVisualizerColor(int color) {
249-
if (color == Color.TRANSPARENT) {
250-
color = mContext.getResources().getColor(R.color.equalizer_fill_color);
251-
}
252-
if (mColor != color) {
253-
mColor = color;
254-
255-
if (mLinked) {
256-
if (mVisualizerColorAnimator != null) {
257-
mVisualizerColorAnimator.cancel();
258-
}
259-
mVisualizerColorAnimator = ObjectAnimator.ofArgb(mBarRenderer.mPaint, "color",
260-
mBarRenderer.mPaint.getColor(), mColor);
261-
mVisualizerColorAnimator.setStartDelay(500);
262-
mVisualizerColorAnimator.setDuration(1200);
263-
mVisualizerColorAnimator.start();
264-
} else {
265-
mBarRenderer.mPaint.setColor(mColor);
266-
}
267-
}
268-
}
269-
270-
private void checkStateChanged() {
271-
if (mVisible && mPlaying && !mAnimating && !mTouching && !mPowerSaveMode && !mQsExpanded) {
272-
if (!mLinked) {
273-
mVisualizer.animate().alpha(1f).setDuration(300);
274-
AsyncTask.execute(mLinkVisualizer);
275-
mLinked = true;
276-
}
277-
} else {
278-
if (mLinked) {
279-
mVisualizer.animate().alpha(0f).setDuration(0);
280-
AsyncTask.execute(mUnlinkVisualizer);
281-
mLinked = false;
282-
}
283-
}
284-
}
28574
}

0 commit comments

Comments
 (0)