diff options
author | John Spurlock <jspurlock@google.com> | 2014-05-31 20:15:59 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2014-05-31 20:17:26 -0400 |
commit | 5f640e4a867b3a8d3bce136416f07a460ffa5b1c (patch) | |
tree | a5d5ff2ef1b002f06e176da7e5ab95f2e2d67d38 /packages | |
parent | 254310450a5e03a8e7113ed9d159d01cb67f93f0 (diff) | |
download | frameworks_base-5f640e4a867b3a8d3bce136416f07a460ffa5b1c.zip frameworks_base-5f640e4a867b3a8d3bce136416f07a460ffa5b1c.tar.gz frameworks_base-5f640e4a867b3a8d3bce136416f07a460ffa5b1c.tar.bz2 |
VolumeZen: Pulse silent mode icon on disabled slider touch.
Bug:15330217
Change-Id: Icb54e5ea0466bb5fbd7e08b99e8f0dac15ded447
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SystemUI/res/layout/volume_panel_item.xml | 52 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java | 43 |
2 files changed, 69 insertions, 26 deletions
diff --git a/packages/SystemUI/res/layout/volume_panel_item.xml b/packages/SystemUI/res/layout/volume_panel_item.xml index 759679b..4a2a0c0 100644 --- a/packages/SystemUI/res/layout/volume_panel_item.xml +++ b/packages/SystemUI/res/layout/volume_panel_item.xml @@ -15,30 +15,34 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="80dip" - android:orientation="horizontal" - android:layout_marginTop="8dip" - android:layout_marginBottom="8dip" - android:gravity="start|center_vertical"> + android:layout_width="match_parent" + android:layout_height="80dip" + android:orientation="horizontal" + android:layout_marginTop="8dip" + android:layout_marginBottom="8dip" + android:gravity="start|center_vertical"> <ImageView - android:id="@+id/stream_icon" - style="@style/BorderlessButton.Tiny" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:padding="16dip" - android:contentDescription="@null" /> - <SeekBar - style="?android:attr/seekBarStyle" - android:id="@+id/seekbar" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:paddingTop="16dip" - android:paddingBottom="16dip" - android:paddingStart="11dip" - android:paddingEnd="11dip" - android:layout_marginEnd="16dip" /> - + android:id="@+id/stream_icon" + style="@style/BorderlessButton.Tiny" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="16dip" + android:contentDescription="@null" /> + <FrameLayout + android:id="@+id/seekbar_container" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1"> + <SeekBar + style="?android:attr/seekBarStyle" + android:id="@+id/seekbar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="16dip" + android:paddingBottom="16dip" + android:paddingStart="11dip" + android:paddingEnd="11dip" + android:layout_marginEnd="16dip" /> + </FrameLayout> </LinearLayout> diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java index 7000e82..cc01ded 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java @@ -16,6 +16,8 @@ package com.android.systemui.volume; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.app.AlertDialog; import android.app.Dialog; import android.content.BroadcastReceiver; @@ -49,7 +51,8 @@ import android.view.ViewStub; import android.view.Window; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; -import android.widget.FrameLayout; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; @@ -83,6 +86,7 @@ public class VolumePanel extends Handler { private static final int FREE_DELAY = 10000; private static final int TIMEOUT_DELAY = 3000; private static final int TIMEOUT_DELAY_EXPANDED = 10000; + private static final float ICON_PULSE_SCALE = 1.3f; private static final int MSG_VOLUME_CHANGED = 0; private static final int MSG_FREE_RESOURCES = 1; @@ -107,6 +111,7 @@ public class VolumePanel extends Handler { protected final Context mContext; private final AudioManager mAudioManager; private final ZenModeController mZenController; + private final Interpolator mFastOutSlowInInterpolator; private boolean mRingIsSilent; private boolean mVoiceCapable; private boolean mZenModeCapable; @@ -222,6 +227,7 @@ public class VolumePanel extends Handler { ViewGroup group; ImageView icon; SeekBar seekbarView; + View seekbarContainer; int iconRes; int iconMuteRes; } @@ -275,6 +281,8 @@ public class VolumePanel extends Handler { mParent = parent; mZenController = zenController; mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(mContext, + android.R.interpolator.fast_out_slow_in); // For now, only show master volume if master volume is supported final Resources res = context.getResources(); @@ -473,6 +481,8 @@ public class VolumePanel extends Handler { } }); } + sc.seekbarContainer = + sc.group.findViewById(com.android.systemui.R.id.seekbar_container); sc.seekbarView = (SeekBar) sc.group.findViewById(com.android.systemui.R.id.seekbar); final int plusOne = (streamType == AudioSystem.STREAM_BLUETOOTH_SCO || streamType == AudioSystem.STREAM_VOICE_CALL) ? 1 : 0; @@ -533,7 +543,8 @@ public class VolumePanel extends Handler { updateSliderEnabled(sc, muted, false); } - private void updateSliderEnabled(StreamControl sc, boolean muted, boolean fixedVolume) { + private void updateSliderEnabled(final StreamControl sc, boolean muted, boolean fixedVolume) { + final boolean wasEnabled = sc.seekbarView.isEnabled(); if (sc.streamType == AudioService.STREAM_REMOTE_MUSIC) { // never disable touch interactions for remote playback, the muting is not tied to // the state of the phone. @@ -548,6 +559,34 @@ public class VolumePanel extends Handler { } else { sc.seekbarView.setEnabled(true); } + // pulse the ringer icon when the disabled slider is touched in silent mode + if (sc.icon.isClickable() && wasEnabled != sc.seekbarView.isEnabled()) { + if (sc.seekbarView.isEnabled()) { + sc.seekbarContainer.setOnTouchListener(null); + } else { + sc.seekbarContainer.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + resetTimeout(); + pulseIcon(sc.icon); + return false; + } + }); + } + } + } + + private void pulseIcon(final ImageView icon) { + if (icon.getScaleX() != 1) return; // already running + icon.animate().cancel(); + icon.animate().scaleX(ICON_PULSE_SCALE).scaleY(ICON_PULSE_SCALE) + .setInterpolator(mFastOutSlowInInterpolator) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + icon.animate().scaleX(1).scaleY(1).setListener(null); + } + }); } private static boolean isNotificationOrRing(int streamType) { |