Loading core/java/android/view/VolumePanel.java +65 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,11 @@ package android.view; import com.android.internal.R; import android.animation.Animator; import android.animation.Animator.AnimatorListener; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface.OnDismissListener; Loading @@ -42,6 +47,7 @@ import android.os.Vibrator; import android.provider.Settings; import android.util.Log; import android.view.WindowManager.LayoutParams; import android.view.animation.AccelerateInterpolator; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; Loading Loading @@ -111,6 +117,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie public static final int VOLUME_OVERLAY_EXPANDED = 2; public static final int VOLUME_OVERLAY_NONE = 3; private static final int TRANSLUCENT_START_LEVEL = 160; private static final int TRANSLUCENT_TO_OPAQUE_DURATION = 400; protected Context mContext; private AudioManager mAudioManager; protected AudioService mAudioService; Loading @@ -120,6 +129,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie private boolean mVolumeLinkNotification; private int mCurrentOverlayStyle = -1; private final boolean mTranslucentDialog; private boolean mShouldRunDropTranslucentAnimation = false; private boolean mRunningDropTranslucentAnimation = false; // True if we want to play tones on the system stream when the master stream is specified. private final boolean mPlayMasterStreamTones; Loading Loading @@ -280,6 +293,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie mContext = context; mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mAudioService = volumeService; mTranslucentDialog = ActivityManager.isHighEndGfx(); // For now, only show master volume if master volume is supported boolean useMasterVolume = context.getResources().getBoolean( Loading Loading @@ -368,6 +382,8 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie mMoreButton.setOnClickListener(this); listenToRingerMode(); applyTranslucentWindow(); } public void setLayoutDirection(int layoutDirection) { Loading Loading @@ -1076,6 +1092,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie case MSG_TIMEOUT: { if (mDialog.isShowing()) { applyTranslucentWindow(); mDialog.dismiss(); mActiveStreamType = -1; } Loading Loading @@ -1134,6 +1151,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } public void onStartTrackingTouch(SeekBar seekBar) { if (mTranslucentDialog && mShouldRunDropTranslucentAnimation) { startRemoveTranslucentAnimation(); } } public void onStopTrackingTouch(SeekBar seekBar) { Loading @@ -1151,7 +1171,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } public void onClick(View v) { if (v == mMoreButton) { if (mTranslucentDialog && mShouldRunDropTranslucentAnimation) { startRemoveTranslucentAnimation(); } else if (v == mMoreButton) { expand(); } else if (v instanceof ImageView) { Intent volumeSettings = new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS); Loading @@ -1162,4 +1184,46 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } resetTimeout(); } private void applyTranslucentWindow() { if (!mTranslucentDialog || mRunningDropTranslucentAnimation) return; mPanel.getBackground().setAlpha(TRANSLUCENT_START_LEVEL); mMoreButton.setAlpha(0.0f); mDivider.setAlpha(0.0f); mShouldRunDropTranslucentAnimation = true; } private void startRemoveTranslucentAnimation() { if (mRunningDropTranslucentAnimation) return; mRunningDropTranslucentAnimation = true; AnimatorSet set = new AnimatorSet(); Animator panelAlpha = ObjectAnimator.ofInt( mPanel.getBackground(), "alpha", mPanel.getBackground().getAlpha(), 255); Animator moreAlpha = ObjectAnimator.ofFloat( mMoreButton, "alpha", mMoreButton.getAlpha(), 255); Animator dividerAlpha = ObjectAnimator.ofFloat( mDivider, "alpha", mDivider.getAlpha(), 255); set.setInterpolator(new AccelerateInterpolator()); set.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} @Override public void onAnimationEnd(Animator animation) { mRunningDropTranslucentAnimation = false; mShouldRunDropTranslucentAnimation = false; } @Override public void onAnimationCancel(Animator animation) {} }); set.setDuration(TRANSLUCENT_TO_OPAQUE_DURATION); set.playTogether(panelAlpha, moreAlpha, dividerAlpha); set.start(); } } Loading
core/java/android/view/VolumePanel.java +65 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,11 @@ package android.view; import com.android.internal.R; import android.animation.Animator; import android.animation.Animator.AnimatorListener; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface.OnDismissListener; Loading @@ -42,6 +47,7 @@ import android.os.Vibrator; import android.provider.Settings; import android.util.Log; import android.view.WindowManager.LayoutParams; import android.view.animation.AccelerateInterpolator; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; Loading Loading @@ -111,6 +117,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie public static final int VOLUME_OVERLAY_EXPANDED = 2; public static final int VOLUME_OVERLAY_NONE = 3; private static final int TRANSLUCENT_START_LEVEL = 160; private static final int TRANSLUCENT_TO_OPAQUE_DURATION = 400; protected Context mContext; private AudioManager mAudioManager; protected AudioService mAudioService; Loading @@ -120,6 +129,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie private boolean mVolumeLinkNotification; private int mCurrentOverlayStyle = -1; private final boolean mTranslucentDialog; private boolean mShouldRunDropTranslucentAnimation = false; private boolean mRunningDropTranslucentAnimation = false; // True if we want to play tones on the system stream when the master stream is specified. private final boolean mPlayMasterStreamTones; Loading Loading @@ -280,6 +293,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie mContext = context; mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mAudioService = volumeService; mTranslucentDialog = ActivityManager.isHighEndGfx(); // For now, only show master volume if master volume is supported boolean useMasterVolume = context.getResources().getBoolean( Loading Loading @@ -368,6 +382,8 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie mMoreButton.setOnClickListener(this); listenToRingerMode(); applyTranslucentWindow(); } public void setLayoutDirection(int layoutDirection) { Loading Loading @@ -1076,6 +1092,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie case MSG_TIMEOUT: { if (mDialog.isShowing()) { applyTranslucentWindow(); mDialog.dismiss(); mActiveStreamType = -1; } Loading Loading @@ -1134,6 +1151,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } public void onStartTrackingTouch(SeekBar seekBar) { if (mTranslucentDialog && mShouldRunDropTranslucentAnimation) { startRemoveTranslucentAnimation(); } } public void onStopTrackingTouch(SeekBar seekBar) { Loading @@ -1151,7 +1171,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } public void onClick(View v) { if (v == mMoreButton) { if (mTranslucentDialog && mShouldRunDropTranslucentAnimation) { startRemoveTranslucentAnimation(); } else if (v == mMoreButton) { expand(); } else if (v instanceof ImageView) { Intent volumeSettings = new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS); Loading @@ -1162,4 +1184,46 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } resetTimeout(); } private void applyTranslucentWindow() { if (!mTranslucentDialog || mRunningDropTranslucentAnimation) return; mPanel.getBackground().setAlpha(TRANSLUCENT_START_LEVEL); mMoreButton.setAlpha(0.0f); mDivider.setAlpha(0.0f); mShouldRunDropTranslucentAnimation = true; } private void startRemoveTranslucentAnimation() { if (mRunningDropTranslucentAnimation) return; mRunningDropTranslucentAnimation = true; AnimatorSet set = new AnimatorSet(); Animator panelAlpha = ObjectAnimator.ofInt( mPanel.getBackground(), "alpha", mPanel.getBackground().getAlpha(), 255); Animator moreAlpha = ObjectAnimator.ofFloat( mMoreButton, "alpha", mMoreButton.getAlpha(), 255); Animator dividerAlpha = ObjectAnimator.ofFloat( mDivider, "alpha", mDivider.getAlpha(), 255); set.setInterpolator(new AccelerateInterpolator()); set.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} @Override public void onAnimationEnd(Animator animation) { mRunningDropTranslucentAnimation = false; mShouldRunDropTranslucentAnimation = false; } @Override public void onAnimationCancel(Animator animation) {} }); set.setDuration(TRANSLUCENT_TO_OPAQUE_DURATION); set.playTogether(panelAlpha, moreAlpha, dividerAlpha); set.start(); } }