Loading packages/SystemUI/res/layout/volume_dialog.xml +25 −15 Original line number Original line Diff line number Diff line Loading @@ -13,25 +13,15 @@ See the License for the specific language governing permissions and See the License for the specific language governing permissions and limitations under the License. limitations under the License. --> --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/volume_dialog" android:id="@+id/volume_dialog" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/volume_dialog_margin_bottom" android:layout_marginBottom="@dimen/volume_dialog_margin_bottom" android:background="@drawable/volume_dialog_background" android:background="@drawable/volume_dialog_background" android:translationZ="4dp" > android:translationZ="4dp" android:paddingTop="8dp"> <com.android.keyguard.AlphaOptimizedImageButton android:id="@+id/volume_expand_button" style="@style/VolumeButtons" android:layout_width="@dimen/volume_button_size" android:layout_height="@dimen/volume_button_size" android:layout_alignParentLeft="true" android:clickable="true" android:soundEffectsEnabled="false" android:src="@drawable/ic_volume_collapse_animation" tools:ignore="RtlHardcoded" /> <LinearLayout <LinearLayout android:id="@+id/volume_dialog_content" android:id="@+id/volume_dialog_content" Loading @@ -39,9 +29,15 @@ android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:orientation="vertical" android:paddingBottom="8dp" android:paddingBottom="8dp" android:paddingTop="8dp" > android:paddingStart="8dp"> <!-- volume rows added and removed here! :-) --> <!-- volume rows added and removed here! :-) --> <LinearLayout android:id="@+id/volume_row_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="@dimen/volume_button_size" android:orientation="vertical"/> <include layout="@layout/volume_zen_footer" /> <include layout="@layout/volume_zen_footer" /> Loading @@ -49,4 +45,18 @@ <include layout="@layout/tuner_zen_mode_panel" /> <include layout="@layout/tuner_zen_mode_panel" /> </LinearLayout> </LinearLayout> <com.android.keyguard.AlphaOptimizedImageButton xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/volume_expand_button" style="@style/VolumeButtons" android:layout_width="@dimen/volume_button_size" android:layout_height="@dimen/volume_button_size" android:clickable="true" android:soundEffectsEnabled="false" android:src="@drawable/ic_volume_collapse_animation" tools:ignore="RtlHardcoded" android:layout_alignParentEnd="true" android:layout_alignParentTop="true"/> </RelativeLayout> </RelativeLayout> packages/SystemUI/res/layout/volume_dialog_row.xml +5 −13 Original line number Original line Diff line number Diff line Loading @@ -13,13 +13,12 @@ See the License for the specific language governing permissions and See the License for the specific language governing permissions and limitations under the License. limitations under the License. --> --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:clipChildren="false" android:clipChildren="false" android:id="@+id/volume_dialog_row" android:id="@+id/volume_dialog_row" > android:paddingEnd="8dp" android:paddingStart="8dp" > <TextView <TextView android:id="@+id/volume_row_header" android:id="@+id/volume_row_header" Loading @@ -31,7 +30,8 @@ android:paddingBottom="0dp" android:paddingBottom="0dp" android:paddingEnd="12dp" android:paddingEnd="12dp" android:paddingStart="12dp" android:paddingStart="12dp" android:paddingTop="4dp" /> android:paddingTop="4dp" android:visibility="gone" /> <com.android.keyguard.AlphaOptimizedImageButton <com.android.keyguard.AlphaOptimizedImageButton android:id="@+id/volume_row_icon" android:id="@+id/volume_row_icon" Loading @@ -55,12 +55,4 @@ android:paddingEnd="8dp" android:paddingEnd="8dp" android:paddingStart="8dp" /> android:paddingStart="8dp" /> <com.android.keyguard.AlphaOptimizedImageButton android:id="@+id/volume_settings_button" style="@style/VolumeButtons" android:layout_width="@dimen/volume_button_size" android:layout_height="@dimen/volume_button_size" android:layout_alignParentEnd="true" android:layout_below="@id/volume_row_header" /> </RelativeLayout> </RelativeLayout> No newline at end of file packages/SystemUI/res/layout/volume_zen_footer.xml +1 −3 Original line number Original line Diff line number Diff line Loading @@ -32,9 +32,7 @@ android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:gravity="center_vertical" android:orientation="horizontal" android:orientation="horizontal" > android:paddingEnd="8dp" android:paddingStart="8dp" > <ImageView <ImageView android:id="@+id/volume_zen_icon" android:id="@+id/volume_zen_icon" Loading packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +112 −140 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.app.KeyguardManager; import android.content.Context; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.res.ColorStateList; import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Color; import android.graphics.PixelFormat; import android.graphics.PixelFormat; Loading @@ -42,6 +43,7 @@ import android.os.SystemClock; import android.provider.Settings.Global; import android.provider.Settings.Global; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.Log; import android.util.Log; import android.util.Slog; import android.util.SparseBooleanArray; import android.util.SparseBooleanArray; import android.view.Gravity; import android.view.Gravity; import android.view.MotionEvent; import android.view.MotionEvent; Loading @@ -49,7 +51,6 @@ import android.view.View; import android.view.View.AccessibilityDelegate; import android.view.View.AccessibilityDelegate; import android.view.View.OnAttachStateChangeListener; import android.view.View.OnAttachStateChangeListener; import android.view.View.OnClickListener; import android.view.View.OnClickListener; import android.view.View.OnLayoutChangeListener; import android.view.View.OnTouchListener; import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.ViewGroup.MarginLayoutParams; import android.view.ViewGroup.MarginLayoutParams; Loading Loading @@ -91,39 +92,40 @@ public class VolumeDialog implements TunerService.Tunable { public static final String SHOW_FULL_ZEN = "sysui_show_full_zen"; public static final String SHOW_FULL_ZEN = "sysui_show_full_zen"; private static final long USER_ATTEMPT_GRACE_PERIOD = 1000; private static final long USER_ATTEMPT_GRACE_PERIOD = 1000; private static final int WAIT_FOR_RIPPLE = 200; private final Context mContext; private final Context mContext; private final H mHandler = new H(); private final H mHandler = new H(); private final VolumeDialogController mController; private final VolumeDialogController mController; private final CustomDialog mDialog; private CustomDialog mDialog; private final ViewGroup mDialogView; private ViewGroup mDialogView; private final ViewGroup mDialogContentView; private ViewGroup mDialogContentView; private final ImageButton mExpandButton; private ViewGroup mVolumeRowContainer; private final View mSettingsButton; private ImageButton mExpandButton; private final List<VolumeRow> mRows = new ArrayList<VolumeRow>(); private final List<VolumeRow> mRows = new ArrayList<>(); private final SpTexts mSpTexts; private final SpTexts mSpTexts; private final SparseBooleanArray mDynamic = new SparseBooleanArray(); private final SparseBooleanArray mDynamic = new SparseBooleanArray(); private final KeyguardManager mKeyguard; private final KeyguardManager mKeyguard; private final AudioManager mAudioManager; private final AudioManager mAudioManager; private final int mExpandButtonAnimationDuration; private int mExpandButtonAnimationDuration; private final ZenFooter mZenFooter; private ZenFooter mZenFooter; private final LayoutTransition mLayoutTransition; private final LayoutTransition mLayoutTransition; private final Object mSafetyWarningLock = new Object(); private final Object mSafetyWarningLock = new Object(); private final Accessibility mAccessibility = new Accessibility(); private final Accessibility mAccessibility = new Accessibility(); private final ColorStateList mActiveSliderTint; private final ColorStateList mActiveSliderTint; private final ColorStateList mInactiveSliderTint; private final ColorStateList mInactiveSliderTint; private final VolumeDialogMotion mMotion; private VolumeDialogMotion mMotion; private final int mWindowType; private final ZenModeController mZenModeController; private boolean mShowing; private boolean mShowing; private boolean mExpanded; private boolean mExpanded; private int mActiveStream; private int mActiveStream; private boolean mShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; private boolean mShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE; private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE; private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; private State mState; private State mState; private int mExpandButtonRes; private boolean mExpandButtonAnimationRunning; private boolean mExpandButtonAnimationRunning; private SafetyWarningDialog mSafetyWarning; private SafetyWarningDialog mSafetyWarning; private Callback mCallback; private Callback mCallback; Loading @@ -131,22 +133,43 @@ public class VolumeDialog implements TunerService.Tunable { private boolean mPendingRecheckAll; private boolean mPendingRecheckAll; private long mCollapseTime; private long mCollapseTime; private boolean mHovering = false; private boolean mHovering = false; private int mLastActiveStream; private int mDensity; private boolean mShowFullZen; private boolean mShowFullZen; private final TunerZenModePanel mZenPanel; private TunerZenModePanel mZenPanel; public VolumeDialog(Context context, int windowType, VolumeDialogController controller, public VolumeDialog(Context context, int windowType, VolumeDialogController controller, ZenModeController zenModeController, Callback callback) { ZenModeController zenModeController, Callback callback) { mContext = context; mContext = context; mController = controller; mController = controller; mCallback = callback; mCallback = callback; mWindowType = windowType; mZenModeController = zenModeController; mSpTexts = new SpTexts(mContext); mSpTexts = new SpTexts(mContext); mKeyguard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); mKeyguard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mActiveSliderTint = loadColorStateList(R.color.system_accent_color); mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive); mLayoutTransition = new LayoutTransition(); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); initDialog(); mAccessibility.init(); controller.addCallback(mControllerCallbackH, mHandler); controller.getState(); TunerService.get(mContext).addTunable(this, SHOW_FULL_ZEN); final Configuration currentConfig = mContext.getResources().getConfiguration(); mDensity = currentConfig.densityDpi; } private void initDialog() { mDialog = new CustomDialog(mContext); mDialog = new CustomDialog(mContext); mHovering = false; mShowing = false; final Window window = mDialog.getWindow(); final Window window = mDialog.getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); window.requestFeature(Window.FEATURE_NO_TITLE); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); Loading @@ -160,7 +183,7 @@ public class VolumeDialog implements TunerService.Tunable { mDialog.setCanceledOnTouchOutside(true); mDialog.setCanceledOnTouchOutside(true); final Resources res = mContext.getResources(); final Resources res = mContext.getResources(); final WindowManager.LayoutParams lp = window.getAttributes(); final WindowManager.LayoutParams lp = window.getAttributes(); lp.type = windowType; lp.type = mWindowType; lp.format = PixelFormat.TRANSLUCENT; lp.format = PixelFormat.TRANSLUCENT; lp.setTitle(VolumeDialog.class.getSimpleName()); lp.setTitle(VolumeDialog.class.getSimpleName()); lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; Loading @@ -170,8 +193,7 @@ public class VolumeDialog implements TunerService.Tunable { window.setAttributes(lp); window.setAttributes(lp); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); mActiveSliderTint = loadColorStateList(R.color.system_accent_color); mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive); mDialog.setContentView(R.layout.volume_dialog); mDialog.setContentView(R.layout.volume_dialog); mDialogView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog); mDialogView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog); mDialogView.setOnHoverListener(new View.OnHoverListener() { mDialogView.setOnHoverListener(new View.OnHoverListener() { Loading @@ -185,12 +207,14 @@ public class VolumeDialog implements TunerService.Tunable { } } }); }); mDialogContentView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog_content); mDialogContentView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog_content); mVolumeRowContainer = (ViewGroup) mDialogContentView.findViewById(R.id.volume_row_container); mExpanded = false; mExpandButton = (ImageButton) mDialogView.findViewById(R.id.volume_expand_button); mExpandButton = (ImageButton) mDialogView.findViewById(R.id.volume_expand_button); mExpandButton.setOnClickListener(mClickExpand); mExpandButton.setOnClickListener(mClickExpand); updateWindowWidthH(); updateWindowWidthH(); updateExpandButtonH(); updateExpandButtonH(); mLayoutTransition = new LayoutTransition(); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); mDialogContentView.setLayoutTransition(mLayoutTransition); mDialogContentView.setLayoutTransition(mLayoutTransition); mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton, mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton, new VolumeDialogMotion.Callback() { new VolumeDialogMotion.Callback() { Loading @@ -208,6 +232,7 @@ public class VolumeDialog implements TunerService.Tunable { } } }); }); if (mRows.isEmpty()) { addRow(AudioManager.STREAM_RING, addRow(AudioManager.STREAM_RING, R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); addRow(AudioManager.STREAM_MUSIC, addRow(AudioManager.STREAM_MUSIC, Loading @@ -220,21 +245,15 @@ public class VolumeDialog implements TunerService.Tunable { R.drawable.ic_volume_bt_sco, R.drawable.ic_volume_bt_sco, false); R.drawable.ic_volume_bt_sco, R.drawable.ic_volume_bt_sco, false); addRow(AudioManager.STREAM_SYSTEM, addRow(AudioManager.STREAM_SYSTEM, R.drawable.ic_volume_system, R.drawable.ic_volume_system_mute, false); R.drawable.ic_volume_system, R.drawable.ic_volume_system_mute, false); } else { mSettingsButton = mDialog.findViewById(R.id.volume_settings_button); addExistingRows(); mSettingsButton.setOnClickListener(mClickSettings); } mExpandButtonAnimationDuration = res.getInteger(R.integer.volume_expand_animation_duration); mExpandButtonAnimationDuration = res.getInteger(R.integer.volume_expand_animation_duration); mZenFooter = (ZenFooter) mDialog.findViewById(R.id.volume_zen_footer); mZenFooter = (ZenFooter) mDialog.findViewById(R.id.volume_zen_footer); mZenFooter.init(zenModeController); mZenFooter.init(mZenModeController); mZenPanel = (TunerZenModePanel) mDialog.findViewById(R.id.tuner_zen_mode_panel); mZenPanel = (TunerZenModePanel) mDialog.findViewById(R.id.tuner_zen_mode_panel); mZenPanel.init(zenModeController); mZenPanel.init(mZenModeController); mZenPanel.setCallback(mZenPanelCallback); mZenPanel.setCallback(mZenPanelCallback); mAccessibility.init(); controller.addCallback(mControllerCallbackH, mHandler); controller.getState(); TunerService.get(mContext).addTunable(this, SHOW_FULL_ZEN); } } @Override @Override Loading Loading @@ -285,45 +304,37 @@ public class VolumeDialog implements TunerService.Tunable { } } private void addRow(int stream, int iconRes, int iconMuteRes, boolean important) { private void addRow(int stream, int iconRes, int iconMuteRes, boolean important) { final VolumeRow row = initRow(stream, iconRes, iconMuteRes, important); VolumeRow row = new VolumeRow(); initRow(row, stream, iconRes, iconMuteRes, important); if (!mRows.isEmpty()) { if (!mRows.isEmpty()) { addSpacer(row); } mVolumeRowContainer.addView(row.view); mRows.add(row); } private void addExistingRows() { int N = mRows.size(); for (int i = 0; i < N; i++) { final VolumeRow row = mRows.get(i); initRow(row, row.stream, row.iconRes, row.iconMuteRes, row.important); if (i > 0) { addSpacer(row); } mVolumeRowContainer.addView(row.view); } } private void addSpacer(VolumeRow row) { final View v = new View(mContext); final View v = new View(mContext); v.setId(android.R.id.background); v.setId(android.R.id.background); final int h = mContext.getResources() final int h = mContext.getResources() .getDimensionPixelSize(R.dimen.volume_slider_interspacing); .getDimensionPixelSize(R.dimen.volume_slider_interspacing); final LinearLayout.LayoutParams lp = final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, h); new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, h); mDialogContentView.addView(v, mDialogContentView.getChildCount() - 2, lp); mVolumeRowContainer.addView(v, lp); row.space = v; row.space = v; } } row.settingsButton.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { final boolean moved = mLastActiveStream != mActiveStream || oldLeft != left || oldTop != top; if (D.BUG) Log.d(TAG, "onLayoutChange moved=" + moved + " old=" + new Rect(oldLeft, oldTop, oldRight, oldBottom).toShortString() + "," + mLastActiveStream + " new=" + new Rect(left,top,right,bottom).toShortString() + "," + mActiveStream); mLastActiveStream = mActiveStream; if (moved) { for (int i = 0; i < mDialogContentView.getChildCount(); i++) { final View c = mDialogContentView.getChildAt(i); if (!c.isShown()) continue; if (c == row.view) { repositionExpandAnim(row); } return; } } } }); // add new row just before the footer mDialogContentView.addView(row.view, mDialogContentView.getChildCount() - 2); mRows.add(row); } private boolean isAttached() { private boolean isAttached() { return mDialogContentView != null && mDialogContentView.isAttachedToWindow(); return mDialogContentView != null && mDialogContentView.isAttachedToWindow(); Loading @@ -345,18 +356,6 @@ public class VolumeDialog implements TunerService.Tunable { return null; return null; } } private void repositionExpandAnim(VolumeRow row) { final int[] loc = new int[2]; row.settingsButton.getLocationInWindow(loc); final MarginLayoutParams mlp = (MarginLayoutParams) mDialogView.getLayoutParams(); final int x = loc[0] - mlp.leftMargin; final int y = loc[1] - mlp.topMargin; if (D.BUG) Log.d(TAG, "repositionExpandAnim x=" + x + " y=" + y); mExpandButton.setTranslationX(x); mExpandButton.setTranslationY(y); mExpandButton.setTag((Integer) y); } public void dump(PrintWriter writer) { public void dump(PrintWriter writer) { writer.println(VolumeDialog.class.getSimpleName() + " state:"); writer.println(VolumeDialog.class.getSimpleName() + " state:"); writer.print(" mShowing: "); writer.println(mShowing); writer.print(" mShowing: "); writer.println(mShowing); Loading @@ -374,8 +373,8 @@ public class VolumeDialog implements TunerService.Tunable { } } @SuppressLint("InflateParams") @SuppressLint("InflateParams") private VolumeRow initRow(final int stream, int iconRes, int iconMuteRes, boolean important) { private void initRow(final VolumeRow row, final int stream, int iconRes, int iconMuteRes, final VolumeRow row = new VolumeRow(); boolean important) { row.stream = stream; row.stream = stream; row.iconRes = iconRes; row.iconRes = iconRes; row.iconMuteRes = iconMuteRes; row.iconMuteRes = iconMuteRes; Loading Loading @@ -442,9 +441,6 @@ public class VolumeDialog implements TunerService.Tunable { row.userAttempt = 0; // reset the grace period, slider should update immediately row.userAttempt = 0; // reset the grace period, slider should update immediately } } }); }); row.settingsButton = (ImageButton) row.view.findViewById(R.id.volume_settings_button); row.settingsButton.setOnClickListener(mClickSettings); return row; } } public void destroy() { public void destroy() { Loading Loading @@ -573,8 +569,6 @@ public class VolumeDialog implements TunerService.Tunable { if (mExpandButtonAnimationRunning && isAttached()) return; if (mExpandButtonAnimationRunning && isAttached()) return; final int res = mExpanded ? R.drawable.ic_volume_collapse_animation final int res = mExpanded ? R.drawable.ic_volume_collapse_animation : R.drawable.ic_volume_expand_animation; : R.drawable.ic_volume_expand_animation; if (res == mExpandButtonRes) return; mExpandButtonRes = res; if (hasTouchFeature()) { if (hasTouchFeature()) { mExpandButton.setImageResource(res); mExpandButton.setImageResource(res); } else { } else { Loading Loading @@ -606,16 +600,6 @@ public class VolumeDialog implements TunerService.Tunable { final boolean visible = isVisibleH(row, isActive); final boolean visible = isVisibleH(row, isActive); Util.setVisOrGone(row.view, visible); Util.setVisOrGone(row.view, visible); Util.setVisOrGone(row.space, visible && mExpanded); Util.setVisOrGone(row.space, visible && mExpanded); final int expandButtonRes = mExpanded ? R.drawable.ic_volume_settings : 0; if (expandButtonRes != row.cachedExpandButtonRes) { row.cachedExpandButtonRes = expandButtonRes; if (expandButtonRes == 0) { row.settingsButton.setImageDrawable(null); } else { row.settingsButton.setImageResource(expandButtonRes); } } Util.setVisOrInvis(row.settingsButton, false); updateVolumeRowHeaderVisibleH(row); updateVolumeRowHeaderVisibleH(row); row.header.setAlpha(mExpanded && isActive ? 1 : 0.5f); row.header.setAlpha(mExpanded && isActive ? 1 : 0.5f); updateVolumeRowSliderTintH(row, isActive); updateVolumeRowSliderTintH(row, isActive); Loading @@ -629,8 +613,8 @@ public class VolumeDialog implements TunerService.Tunable { if (row.ss == null || !row.ss.dynamic) continue; if (row.ss == null || !row.ss.dynamic) continue; if (!mDynamic.get(row.stream)) { if (!mDynamic.get(row.stream)) { mRows.remove(i); mRows.remove(i); mDialogContentView.removeView(row.view); mVolumeRowContainer.removeView(row.view); mDialogContentView.removeView(row.space); mVolumeRowContainer.removeView(row.space); } } } } } } Loading Loading @@ -911,6 +895,12 @@ public class VolumeDialog implements TunerService.Tunable { @Override @Override public void onConfigurationChanged() { public void onConfigurationChanged() { Configuration newConfig = mContext.getResources().getConfiguration(); final int density = newConfig.densityDpi; if (density != mDensity) { mDialog.dismiss(); initDialog(); } updateWindowWidthH(); updateWindowWidthH(); mSpTexts.update(); mSpTexts.update(); mZenFooter.onConfigurationChanged(); mZenFooter.onConfigurationChanged(); Loading Loading @@ -963,21 +953,6 @@ public class VolumeDialog implements TunerService.Tunable { } } }; }; private final OnClickListener mClickSettings = new OnClickListener() { @Override public void onClick(View v) { mSettingsButton.postDelayed(new Runnable() { @Override public void run() { Events.writeEvent(mContext, Events.EVENT_SETTINGS_CLICK); if (mCallback != null) { mCallback.onSettingsClicked(); } } }, WAIT_FOR_RIPPLE); } }; private final class H extends Handler { private final class H extends Handler { private static final int SHOW = 1; private static final int SHOW = 1; private static final int DISMISS = 2; private static final int DISMISS = 2; Loading Loading @@ -1155,7 +1130,6 @@ public class VolumeDialog implements TunerService.Tunable { private TextView header; private TextView header; private ImageButton icon; private ImageButton icon; private SeekBar slider; private SeekBar slider; private ImageButton settingsButton; private int stream; private int stream; private StreamState ss; private StreamState ss; private long userAttempt; // last user-driven slider change private long userAttempt; // last user-driven slider change Loading @@ -1168,12 +1142,10 @@ public class VolumeDialog implements TunerService.Tunable { private ColorStateList cachedSliderTint; private ColorStateList cachedSliderTint; private int iconState; // from Events private int iconState; // from Events private boolean cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; private boolean cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; private int cachedExpandButtonRes; private int lastAudibleLevel = 1; private int lastAudibleLevel = 1; } } public interface Callback { public interface Callback { void onSettingsClicked(); void onZenSettingsClicked(); void onZenSettingsClicked(); void onZenPrioritySettingsClicked(); void onZenPrioritySettingsClicked(); } } Loading packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java +0 −5 Original line number Original line Diff line number Diff line Loading @@ -167,11 +167,6 @@ public class VolumeDialogComponent implements VolumeComponent, TunerService.Tuna } } private final VolumeDialog.Callback mVolumeDialogCallback = new VolumeDialog.Callback() { private final VolumeDialog.Callback mVolumeDialogCallback = new VolumeDialog.Callback() { @Override public void onSettingsClicked() { startSettings(new Intent(Settings.ACTION_NOTIFICATION_SETTINGS)); } @Override @Override public void onZenSettingsClicked() { public void onZenSettingsClicked() { startSettings(ZenModePanel.ZEN_SETTINGS); startSettings(ZenModePanel.ZEN_SETTINGS); Loading Loading
packages/SystemUI/res/layout/volume_dialog.xml +25 −15 Original line number Original line Diff line number Diff line Loading @@ -13,25 +13,15 @@ See the License for the specific language governing permissions and See the License for the specific language governing permissions and limitations under the License. limitations under the License. --> --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/volume_dialog" android:id="@+id/volume_dialog" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/volume_dialog_margin_bottom" android:layout_marginBottom="@dimen/volume_dialog_margin_bottom" android:background="@drawable/volume_dialog_background" android:background="@drawable/volume_dialog_background" android:translationZ="4dp" > android:translationZ="4dp" android:paddingTop="8dp"> <com.android.keyguard.AlphaOptimizedImageButton android:id="@+id/volume_expand_button" style="@style/VolumeButtons" android:layout_width="@dimen/volume_button_size" android:layout_height="@dimen/volume_button_size" android:layout_alignParentLeft="true" android:clickable="true" android:soundEffectsEnabled="false" android:src="@drawable/ic_volume_collapse_animation" tools:ignore="RtlHardcoded" /> <LinearLayout <LinearLayout android:id="@+id/volume_dialog_content" android:id="@+id/volume_dialog_content" Loading @@ -39,9 +29,15 @@ android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:orientation="vertical" android:paddingBottom="8dp" android:paddingBottom="8dp" android:paddingTop="8dp" > android:paddingStart="8dp"> <!-- volume rows added and removed here! :-) --> <!-- volume rows added and removed here! :-) --> <LinearLayout android:id="@+id/volume_row_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="@dimen/volume_button_size" android:orientation="vertical"/> <include layout="@layout/volume_zen_footer" /> <include layout="@layout/volume_zen_footer" /> Loading @@ -49,4 +45,18 @@ <include layout="@layout/tuner_zen_mode_panel" /> <include layout="@layout/tuner_zen_mode_panel" /> </LinearLayout> </LinearLayout> <com.android.keyguard.AlphaOptimizedImageButton xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/volume_expand_button" style="@style/VolumeButtons" android:layout_width="@dimen/volume_button_size" android:layout_height="@dimen/volume_button_size" android:clickable="true" android:soundEffectsEnabled="false" android:src="@drawable/ic_volume_collapse_animation" tools:ignore="RtlHardcoded" android:layout_alignParentEnd="true" android:layout_alignParentTop="true"/> </RelativeLayout> </RelativeLayout>
packages/SystemUI/res/layout/volume_dialog_row.xml +5 −13 Original line number Original line Diff line number Diff line Loading @@ -13,13 +13,12 @@ See the License for the specific language governing permissions and See the License for the specific language governing permissions and limitations under the License. limitations under the License. --> --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:clipChildren="false" android:clipChildren="false" android:id="@+id/volume_dialog_row" android:id="@+id/volume_dialog_row" > android:paddingEnd="8dp" android:paddingStart="8dp" > <TextView <TextView android:id="@+id/volume_row_header" android:id="@+id/volume_row_header" Loading @@ -31,7 +30,8 @@ android:paddingBottom="0dp" android:paddingBottom="0dp" android:paddingEnd="12dp" android:paddingEnd="12dp" android:paddingStart="12dp" android:paddingStart="12dp" android:paddingTop="4dp" /> android:paddingTop="4dp" android:visibility="gone" /> <com.android.keyguard.AlphaOptimizedImageButton <com.android.keyguard.AlphaOptimizedImageButton android:id="@+id/volume_row_icon" android:id="@+id/volume_row_icon" Loading @@ -55,12 +55,4 @@ android:paddingEnd="8dp" android:paddingEnd="8dp" android:paddingStart="8dp" /> android:paddingStart="8dp" /> <com.android.keyguard.AlphaOptimizedImageButton android:id="@+id/volume_settings_button" style="@style/VolumeButtons" android:layout_width="@dimen/volume_button_size" android:layout_height="@dimen/volume_button_size" android:layout_alignParentEnd="true" android:layout_below="@id/volume_row_header" /> </RelativeLayout> </RelativeLayout> No newline at end of file
packages/SystemUI/res/layout/volume_zen_footer.xml +1 −3 Original line number Original line Diff line number Diff line Loading @@ -32,9 +32,7 @@ android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:gravity="center_vertical" android:orientation="horizontal" android:orientation="horizontal" > android:paddingEnd="8dp" android:paddingStart="8dp" > <ImageView <ImageView android:id="@+id/volume_zen_icon" android:id="@+id/volume_zen_icon" Loading
packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +112 −140 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.app.KeyguardManager; import android.content.Context; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.res.ColorStateList; import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Color; import android.graphics.PixelFormat; import android.graphics.PixelFormat; Loading @@ -42,6 +43,7 @@ import android.os.SystemClock; import android.provider.Settings.Global; import android.provider.Settings.Global; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.Log; import android.util.Log; import android.util.Slog; import android.util.SparseBooleanArray; import android.util.SparseBooleanArray; import android.view.Gravity; import android.view.Gravity; import android.view.MotionEvent; import android.view.MotionEvent; Loading @@ -49,7 +51,6 @@ import android.view.View; import android.view.View.AccessibilityDelegate; import android.view.View.AccessibilityDelegate; import android.view.View.OnAttachStateChangeListener; import android.view.View.OnAttachStateChangeListener; import android.view.View.OnClickListener; import android.view.View.OnClickListener; import android.view.View.OnLayoutChangeListener; import android.view.View.OnTouchListener; import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.ViewGroup.MarginLayoutParams; import android.view.ViewGroup.MarginLayoutParams; Loading Loading @@ -91,39 +92,40 @@ public class VolumeDialog implements TunerService.Tunable { public static final String SHOW_FULL_ZEN = "sysui_show_full_zen"; public static final String SHOW_FULL_ZEN = "sysui_show_full_zen"; private static final long USER_ATTEMPT_GRACE_PERIOD = 1000; private static final long USER_ATTEMPT_GRACE_PERIOD = 1000; private static final int WAIT_FOR_RIPPLE = 200; private final Context mContext; private final Context mContext; private final H mHandler = new H(); private final H mHandler = new H(); private final VolumeDialogController mController; private final VolumeDialogController mController; private final CustomDialog mDialog; private CustomDialog mDialog; private final ViewGroup mDialogView; private ViewGroup mDialogView; private final ViewGroup mDialogContentView; private ViewGroup mDialogContentView; private final ImageButton mExpandButton; private ViewGroup mVolumeRowContainer; private final View mSettingsButton; private ImageButton mExpandButton; private final List<VolumeRow> mRows = new ArrayList<VolumeRow>(); private final List<VolumeRow> mRows = new ArrayList<>(); private final SpTexts mSpTexts; private final SpTexts mSpTexts; private final SparseBooleanArray mDynamic = new SparseBooleanArray(); private final SparseBooleanArray mDynamic = new SparseBooleanArray(); private final KeyguardManager mKeyguard; private final KeyguardManager mKeyguard; private final AudioManager mAudioManager; private final AudioManager mAudioManager; private final int mExpandButtonAnimationDuration; private int mExpandButtonAnimationDuration; private final ZenFooter mZenFooter; private ZenFooter mZenFooter; private final LayoutTransition mLayoutTransition; private final LayoutTransition mLayoutTransition; private final Object mSafetyWarningLock = new Object(); private final Object mSafetyWarningLock = new Object(); private final Accessibility mAccessibility = new Accessibility(); private final Accessibility mAccessibility = new Accessibility(); private final ColorStateList mActiveSliderTint; private final ColorStateList mActiveSliderTint; private final ColorStateList mInactiveSliderTint; private final ColorStateList mInactiveSliderTint; private final VolumeDialogMotion mMotion; private VolumeDialogMotion mMotion; private final int mWindowType; private final ZenModeController mZenModeController; private boolean mShowing; private boolean mShowing; private boolean mExpanded; private boolean mExpanded; private int mActiveStream; private int mActiveStream; private boolean mShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; private boolean mShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE; private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE; private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; private State mState; private State mState; private int mExpandButtonRes; private boolean mExpandButtonAnimationRunning; private boolean mExpandButtonAnimationRunning; private SafetyWarningDialog mSafetyWarning; private SafetyWarningDialog mSafetyWarning; private Callback mCallback; private Callback mCallback; Loading @@ -131,22 +133,43 @@ public class VolumeDialog implements TunerService.Tunable { private boolean mPendingRecheckAll; private boolean mPendingRecheckAll; private long mCollapseTime; private long mCollapseTime; private boolean mHovering = false; private boolean mHovering = false; private int mLastActiveStream; private int mDensity; private boolean mShowFullZen; private boolean mShowFullZen; private final TunerZenModePanel mZenPanel; private TunerZenModePanel mZenPanel; public VolumeDialog(Context context, int windowType, VolumeDialogController controller, public VolumeDialog(Context context, int windowType, VolumeDialogController controller, ZenModeController zenModeController, Callback callback) { ZenModeController zenModeController, Callback callback) { mContext = context; mContext = context; mController = controller; mController = controller; mCallback = callback; mCallback = callback; mWindowType = windowType; mZenModeController = zenModeController; mSpTexts = new SpTexts(mContext); mSpTexts = new SpTexts(mContext); mKeyguard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); mKeyguard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mActiveSliderTint = loadColorStateList(R.color.system_accent_color); mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive); mLayoutTransition = new LayoutTransition(); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); initDialog(); mAccessibility.init(); controller.addCallback(mControllerCallbackH, mHandler); controller.getState(); TunerService.get(mContext).addTunable(this, SHOW_FULL_ZEN); final Configuration currentConfig = mContext.getResources().getConfiguration(); mDensity = currentConfig.densityDpi; } private void initDialog() { mDialog = new CustomDialog(mContext); mDialog = new CustomDialog(mContext); mHovering = false; mShowing = false; final Window window = mDialog.getWindow(); final Window window = mDialog.getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); window.requestFeature(Window.FEATURE_NO_TITLE); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); Loading @@ -160,7 +183,7 @@ public class VolumeDialog implements TunerService.Tunable { mDialog.setCanceledOnTouchOutside(true); mDialog.setCanceledOnTouchOutside(true); final Resources res = mContext.getResources(); final Resources res = mContext.getResources(); final WindowManager.LayoutParams lp = window.getAttributes(); final WindowManager.LayoutParams lp = window.getAttributes(); lp.type = windowType; lp.type = mWindowType; lp.format = PixelFormat.TRANSLUCENT; lp.format = PixelFormat.TRANSLUCENT; lp.setTitle(VolumeDialog.class.getSimpleName()); lp.setTitle(VolumeDialog.class.getSimpleName()); lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; Loading @@ -170,8 +193,7 @@ public class VolumeDialog implements TunerService.Tunable { window.setAttributes(lp); window.setAttributes(lp); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); mActiveSliderTint = loadColorStateList(R.color.system_accent_color); mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive); mDialog.setContentView(R.layout.volume_dialog); mDialog.setContentView(R.layout.volume_dialog); mDialogView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog); mDialogView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog); mDialogView.setOnHoverListener(new View.OnHoverListener() { mDialogView.setOnHoverListener(new View.OnHoverListener() { Loading @@ -185,12 +207,14 @@ public class VolumeDialog implements TunerService.Tunable { } } }); }); mDialogContentView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog_content); mDialogContentView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog_content); mVolumeRowContainer = (ViewGroup) mDialogContentView.findViewById(R.id.volume_row_container); mExpanded = false; mExpandButton = (ImageButton) mDialogView.findViewById(R.id.volume_expand_button); mExpandButton = (ImageButton) mDialogView.findViewById(R.id.volume_expand_button); mExpandButton.setOnClickListener(mClickExpand); mExpandButton.setOnClickListener(mClickExpand); updateWindowWidthH(); updateWindowWidthH(); updateExpandButtonH(); updateExpandButtonH(); mLayoutTransition = new LayoutTransition(); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); mDialogContentView.setLayoutTransition(mLayoutTransition); mDialogContentView.setLayoutTransition(mLayoutTransition); mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton, mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton, new VolumeDialogMotion.Callback() { new VolumeDialogMotion.Callback() { Loading @@ -208,6 +232,7 @@ public class VolumeDialog implements TunerService.Tunable { } } }); }); if (mRows.isEmpty()) { addRow(AudioManager.STREAM_RING, addRow(AudioManager.STREAM_RING, R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); addRow(AudioManager.STREAM_MUSIC, addRow(AudioManager.STREAM_MUSIC, Loading @@ -220,21 +245,15 @@ public class VolumeDialog implements TunerService.Tunable { R.drawable.ic_volume_bt_sco, R.drawable.ic_volume_bt_sco, false); R.drawable.ic_volume_bt_sco, R.drawable.ic_volume_bt_sco, false); addRow(AudioManager.STREAM_SYSTEM, addRow(AudioManager.STREAM_SYSTEM, R.drawable.ic_volume_system, R.drawable.ic_volume_system_mute, false); R.drawable.ic_volume_system, R.drawable.ic_volume_system_mute, false); } else { mSettingsButton = mDialog.findViewById(R.id.volume_settings_button); addExistingRows(); mSettingsButton.setOnClickListener(mClickSettings); } mExpandButtonAnimationDuration = res.getInteger(R.integer.volume_expand_animation_duration); mExpandButtonAnimationDuration = res.getInteger(R.integer.volume_expand_animation_duration); mZenFooter = (ZenFooter) mDialog.findViewById(R.id.volume_zen_footer); mZenFooter = (ZenFooter) mDialog.findViewById(R.id.volume_zen_footer); mZenFooter.init(zenModeController); mZenFooter.init(mZenModeController); mZenPanel = (TunerZenModePanel) mDialog.findViewById(R.id.tuner_zen_mode_panel); mZenPanel = (TunerZenModePanel) mDialog.findViewById(R.id.tuner_zen_mode_panel); mZenPanel.init(zenModeController); mZenPanel.init(mZenModeController); mZenPanel.setCallback(mZenPanelCallback); mZenPanel.setCallback(mZenPanelCallback); mAccessibility.init(); controller.addCallback(mControllerCallbackH, mHandler); controller.getState(); TunerService.get(mContext).addTunable(this, SHOW_FULL_ZEN); } } @Override @Override Loading Loading @@ -285,45 +304,37 @@ public class VolumeDialog implements TunerService.Tunable { } } private void addRow(int stream, int iconRes, int iconMuteRes, boolean important) { private void addRow(int stream, int iconRes, int iconMuteRes, boolean important) { final VolumeRow row = initRow(stream, iconRes, iconMuteRes, important); VolumeRow row = new VolumeRow(); initRow(row, stream, iconRes, iconMuteRes, important); if (!mRows.isEmpty()) { if (!mRows.isEmpty()) { addSpacer(row); } mVolumeRowContainer.addView(row.view); mRows.add(row); } private void addExistingRows() { int N = mRows.size(); for (int i = 0; i < N; i++) { final VolumeRow row = mRows.get(i); initRow(row, row.stream, row.iconRes, row.iconMuteRes, row.important); if (i > 0) { addSpacer(row); } mVolumeRowContainer.addView(row.view); } } private void addSpacer(VolumeRow row) { final View v = new View(mContext); final View v = new View(mContext); v.setId(android.R.id.background); v.setId(android.R.id.background); final int h = mContext.getResources() final int h = mContext.getResources() .getDimensionPixelSize(R.dimen.volume_slider_interspacing); .getDimensionPixelSize(R.dimen.volume_slider_interspacing); final LinearLayout.LayoutParams lp = final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, h); new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, h); mDialogContentView.addView(v, mDialogContentView.getChildCount() - 2, lp); mVolumeRowContainer.addView(v, lp); row.space = v; row.space = v; } } row.settingsButton.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { final boolean moved = mLastActiveStream != mActiveStream || oldLeft != left || oldTop != top; if (D.BUG) Log.d(TAG, "onLayoutChange moved=" + moved + " old=" + new Rect(oldLeft, oldTop, oldRight, oldBottom).toShortString() + "," + mLastActiveStream + " new=" + new Rect(left,top,right,bottom).toShortString() + "," + mActiveStream); mLastActiveStream = mActiveStream; if (moved) { for (int i = 0; i < mDialogContentView.getChildCount(); i++) { final View c = mDialogContentView.getChildAt(i); if (!c.isShown()) continue; if (c == row.view) { repositionExpandAnim(row); } return; } } } }); // add new row just before the footer mDialogContentView.addView(row.view, mDialogContentView.getChildCount() - 2); mRows.add(row); } private boolean isAttached() { private boolean isAttached() { return mDialogContentView != null && mDialogContentView.isAttachedToWindow(); return mDialogContentView != null && mDialogContentView.isAttachedToWindow(); Loading @@ -345,18 +356,6 @@ public class VolumeDialog implements TunerService.Tunable { return null; return null; } } private void repositionExpandAnim(VolumeRow row) { final int[] loc = new int[2]; row.settingsButton.getLocationInWindow(loc); final MarginLayoutParams mlp = (MarginLayoutParams) mDialogView.getLayoutParams(); final int x = loc[0] - mlp.leftMargin; final int y = loc[1] - mlp.topMargin; if (D.BUG) Log.d(TAG, "repositionExpandAnim x=" + x + " y=" + y); mExpandButton.setTranslationX(x); mExpandButton.setTranslationY(y); mExpandButton.setTag((Integer) y); } public void dump(PrintWriter writer) { public void dump(PrintWriter writer) { writer.println(VolumeDialog.class.getSimpleName() + " state:"); writer.println(VolumeDialog.class.getSimpleName() + " state:"); writer.print(" mShowing: "); writer.println(mShowing); writer.print(" mShowing: "); writer.println(mShowing); Loading @@ -374,8 +373,8 @@ public class VolumeDialog implements TunerService.Tunable { } } @SuppressLint("InflateParams") @SuppressLint("InflateParams") private VolumeRow initRow(final int stream, int iconRes, int iconMuteRes, boolean important) { private void initRow(final VolumeRow row, final int stream, int iconRes, int iconMuteRes, final VolumeRow row = new VolumeRow(); boolean important) { row.stream = stream; row.stream = stream; row.iconRes = iconRes; row.iconRes = iconRes; row.iconMuteRes = iconMuteRes; row.iconMuteRes = iconMuteRes; Loading Loading @@ -442,9 +441,6 @@ public class VolumeDialog implements TunerService.Tunable { row.userAttempt = 0; // reset the grace period, slider should update immediately row.userAttempt = 0; // reset the grace period, slider should update immediately } } }); }); row.settingsButton = (ImageButton) row.view.findViewById(R.id.volume_settings_button); row.settingsButton.setOnClickListener(mClickSettings); return row; } } public void destroy() { public void destroy() { Loading Loading @@ -573,8 +569,6 @@ public class VolumeDialog implements TunerService.Tunable { if (mExpandButtonAnimationRunning && isAttached()) return; if (mExpandButtonAnimationRunning && isAttached()) return; final int res = mExpanded ? R.drawable.ic_volume_collapse_animation final int res = mExpanded ? R.drawable.ic_volume_collapse_animation : R.drawable.ic_volume_expand_animation; : R.drawable.ic_volume_expand_animation; if (res == mExpandButtonRes) return; mExpandButtonRes = res; if (hasTouchFeature()) { if (hasTouchFeature()) { mExpandButton.setImageResource(res); mExpandButton.setImageResource(res); } else { } else { Loading Loading @@ -606,16 +600,6 @@ public class VolumeDialog implements TunerService.Tunable { final boolean visible = isVisibleH(row, isActive); final boolean visible = isVisibleH(row, isActive); Util.setVisOrGone(row.view, visible); Util.setVisOrGone(row.view, visible); Util.setVisOrGone(row.space, visible && mExpanded); Util.setVisOrGone(row.space, visible && mExpanded); final int expandButtonRes = mExpanded ? R.drawable.ic_volume_settings : 0; if (expandButtonRes != row.cachedExpandButtonRes) { row.cachedExpandButtonRes = expandButtonRes; if (expandButtonRes == 0) { row.settingsButton.setImageDrawable(null); } else { row.settingsButton.setImageResource(expandButtonRes); } } Util.setVisOrInvis(row.settingsButton, false); updateVolumeRowHeaderVisibleH(row); updateVolumeRowHeaderVisibleH(row); row.header.setAlpha(mExpanded && isActive ? 1 : 0.5f); row.header.setAlpha(mExpanded && isActive ? 1 : 0.5f); updateVolumeRowSliderTintH(row, isActive); updateVolumeRowSliderTintH(row, isActive); Loading @@ -629,8 +613,8 @@ public class VolumeDialog implements TunerService.Tunable { if (row.ss == null || !row.ss.dynamic) continue; if (row.ss == null || !row.ss.dynamic) continue; if (!mDynamic.get(row.stream)) { if (!mDynamic.get(row.stream)) { mRows.remove(i); mRows.remove(i); mDialogContentView.removeView(row.view); mVolumeRowContainer.removeView(row.view); mDialogContentView.removeView(row.space); mVolumeRowContainer.removeView(row.space); } } } } } } Loading Loading @@ -911,6 +895,12 @@ public class VolumeDialog implements TunerService.Tunable { @Override @Override public void onConfigurationChanged() { public void onConfigurationChanged() { Configuration newConfig = mContext.getResources().getConfiguration(); final int density = newConfig.densityDpi; if (density != mDensity) { mDialog.dismiss(); initDialog(); } updateWindowWidthH(); updateWindowWidthH(); mSpTexts.update(); mSpTexts.update(); mZenFooter.onConfigurationChanged(); mZenFooter.onConfigurationChanged(); Loading Loading @@ -963,21 +953,6 @@ public class VolumeDialog implements TunerService.Tunable { } } }; }; private final OnClickListener mClickSettings = new OnClickListener() { @Override public void onClick(View v) { mSettingsButton.postDelayed(new Runnable() { @Override public void run() { Events.writeEvent(mContext, Events.EVENT_SETTINGS_CLICK); if (mCallback != null) { mCallback.onSettingsClicked(); } } }, WAIT_FOR_RIPPLE); } }; private final class H extends Handler { private final class H extends Handler { private static final int SHOW = 1; private static final int SHOW = 1; private static final int DISMISS = 2; private static final int DISMISS = 2; Loading Loading @@ -1155,7 +1130,6 @@ public class VolumeDialog implements TunerService.Tunable { private TextView header; private TextView header; private ImageButton icon; private ImageButton icon; private SeekBar slider; private SeekBar slider; private ImageButton settingsButton; private int stream; private int stream; private StreamState ss; private StreamState ss; private long userAttempt; // last user-driven slider change private long userAttempt; // last user-driven slider change Loading @@ -1168,12 +1142,10 @@ public class VolumeDialog implements TunerService.Tunable { private ColorStateList cachedSliderTint; private ColorStateList cachedSliderTint; private int iconState; // from Events private int iconState; // from Events private boolean cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; private boolean cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; private int cachedExpandButtonRes; private int lastAudibleLevel = 1; private int lastAudibleLevel = 1; } } public interface Callback { public interface Callback { void onSettingsClicked(); void onZenSettingsClicked(); void onZenSettingsClicked(); void onZenPrioritySettingsClicked(); void onZenPrioritySettingsClicked(); } } Loading
packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java +0 −5 Original line number Original line Diff line number Diff line Loading @@ -167,11 +167,6 @@ public class VolumeDialogComponent implements VolumeComponent, TunerService.Tuna } } private final VolumeDialog.Callback mVolumeDialogCallback = new VolumeDialog.Callback() { private final VolumeDialog.Callback mVolumeDialogCallback = new VolumeDialog.Callback() { @Override public void onSettingsClicked() { startSettings(new Intent(Settings.ACTION_NOTIFICATION_SETTINGS)); } @Override @Override public void onZenSettingsClicked() { public void onZenSettingsClicked() { startSettings(ZenModePanel.ZEN_SETTINGS); startSettings(ZenModePanel.ZEN_SETTINGS); Loading