diff options
Diffstat (limited to 'packages')
8 files changed, 205 insertions, 2 deletions
diff --git a/packages/SystemUI/res/drawable/brightness_mirror_background.xml b/packages/SystemUI/res/drawable/brightness_mirror_background.xml new file mode 100644 index 0000000..fadfe63 --- /dev/null +++ b/packages/SystemUI/res/drawable/brightness_mirror_background.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2014 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 + --> +<shape xmlns:android="http://schemas.android.com/apk/res/android"> + <solid android:color="@color/system_primary_color" /> + <corners + android:topLeftRadius="@dimen/notification_material_rounded_rect_radius" + android:topRightRadius="@dimen/notification_material_rounded_rect_radius" + android:bottomLeftRadius="@dimen/notification_material_rounded_rect_radius" + android:bottomRightRadius="@dimen/notification_material_rounded_rect_radius"/> +</shape> diff --git a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml index 58547b9..7ded708 100644 --- a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml +++ b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml @@ -15,8 +15,7 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui" - style="@style/BrightnessDialogContainer" - android:clickable="true"> + style="@style/BrightnessDialogContainer"> <ImageView android:id="@+id/brightness_icon" diff --git a/packages/SystemUI/res/layout/super_status_bar.xml b/packages/SystemUI/res/layout/super_status_bar.xml index ac998f6..365a7d2 100644 --- a/packages/SystemUI/res/layout/super_status_bar.xml +++ b/packages/SystemUI/res/layout/super_status_bar.xml @@ -26,6 +26,22 @@ android:fitsSystemWindows="true" android:descendantFocusability="afterDescendants"> + <FrameLayout android:id="@+id/brightness_mirror" + android:layout_width="@dimen/notification_panel_width" + android:layout_height="wrap_content" + android:layout_gravity="@integer/notification_panel_layout_gravity" + android:paddingLeft="@dimen/notification_side_padding" + android:paddingRight="@dimen/notification_side_padding" + android:visibility="gone"> + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:elevation="2dp" + android:background="@drawable/brightness_mirror_background"> + <include layout="@layout/quick_settings_brightness_dialog" /> + </FrameLayout> + </FrameLayout> + <com.android.systemui.statusbar.AlphaOptimizedFrameLayout android:id="@+id/backdrop" android:layout_width="match_parent" diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index cbf6e29..6d88214 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -35,6 +35,7 @@ import com.android.systemui.qs.QSTile.DetailAdapter; import com.android.systemui.settings.BrightnessController; import com.android.systemui.settings.ToggleSlider; import com.android.systemui.statusbar.phone.QSTileHost; +import com.android.systemui.statusbar.policy.BrightnessMirrorController; import java.util.ArrayList; import java.util.Collection; @@ -105,6 +106,14 @@ public class QSPanel extends ViewGroup { }); } + public void setBrightnessMirror(BrightnessMirrorController c) { + super.onFinishInflate(); + ToggleSlider brightnessSlider = (ToggleSlider) findViewById(R.id.brightness_slider); + ToggleSlider mirror = (ToggleSlider) c.getMirror().findViewById(R.id.brightness_slider); + brightnessSlider.setMirror(mirror); + brightnessSlider.setMirrorController(c); + } + public void setCallback(Callback callback) { mCallback = callback; } diff --git a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java index 108c8df..2113c68 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java +++ b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java @@ -188,6 +188,7 @@ public class BrightnessController implements ToggleSlider.Listener { mListening = false; } + @Override public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) { updateIcon(mAutomatic); if (!mAutomatic) { diff --git a/packages/SystemUI/src/com/android/systemui/settings/ToggleSlider.java b/packages/SystemUI/src/com/android/systemui/settings/ToggleSlider.java index 4b78072..acfeb4f 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/ToggleSlider.java +++ b/packages/SystemUI/src/com/android/systemui/settings/ToggleSlider.java @@ -29,6 +29,7 @@ import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; import com.android.systemui.R; +import com.android.systemui.statusbar.policy.BrightnessMirrorController; public class ToggleSlider extends RelativeLayout { public interface Listener { @@ -43,6 +44,9 @@ public class ToggleSlider extends RelativeLayout { private SeekBar mSlider; private TextView mLabel; + private ToggleSlider mMirror; + private BrightnessMirrorController mMirrorController; + public ToggleSlider(Context context) { this(context, null); } @@ -72,6 +76,18 @@ public class ToggleSlider extends RelativeLayout { a.recycle(); } + public void setMirror(ToggleSlider toggleSlider) { + mMirror = toggleSlider; + if (mMirror != null) { + mMirror.mToggle.setChecked(mToggle.isChecked()); + mMirror.mSlider.setProgress(mSlider.getProgress()); + } + } + + public void setMirrorController(BrightnessMirrorController c) { + mMirrorController = c; + } + @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); @@ -109,6 +125,10 @@ public class ToggleSlider extends RelativeLayout { mListener.onChanged( ToggleSlider.this, mTracking, checked, mSlider.getProgress()); } + + if (mMirror != null) { + mMirror.mToggle.setChecked(checked); + } } }; @@ -119,6 +139,10 @@ public class ToggleSlider extends RelativeLayout { mListener.onChanged( ToggleSlider.this, mTracking, mToggle.isChecked(), progress); } + + if (mMirror != null) { + mMirror.mSlider.setProgress(progress); + } } @Override @@ -131,6 +155,15 @@ public class ToggleSlider extends RelativeLayout { } mToggle.setChecked(false); + + if (mMirror != null) { + mMirror.mSlider.setPressed(true); + } + + if (mMirrorController != null) { + mMirrorController.showMirror(); + mMirrorController.setLocation((View) getParent()); + } } @Override @@ -141,6 +174,14 @@ public class ToggleSlider extends RelativeLayout { mListener.onChanged( ToggleSlider.this, mTracking, mToggle.isChecked(), mSlider.getProgress()); } + + if (mMirror != null) { + mMirror.mSlider.setPressed(false); + } + + if (mMirrorController != null) { + mMirrorController.hideMirror(); + } } }; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index ad60cc8..f8319c2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -133,6 +133,7 @@ import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; import com.android.systemui.statusbar.policy.BluetoothControllerImpl; +import com.android.systemui.statusbar.policy.BrightnessMirrorController; import com.android.systemui.statusbar.policy.CastControllerImpl; import com.android.systemui.statusbar.policy.FlashlightController; import com.android.systemui.statusbar.policy.HeadsUpNotificationView; @@ -229,6 +230,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, UserSwitcherController mUserSwitcherController; NextAlarmController mNextAlarmController; KeyguardMonitor mKeyguardMonitor; + BrightnessMirrorController mBrightnessMirrorController; int mNaturalBarHeight = -1; int mIconSize = -1; @@ -819,6 +821,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mSecurityController); mQSPanel.setHost(qsh); mQSPanel.setTiles(qsh.getTiles()); + mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow); + mQSPanel.setBrightnessMirror(mBrightnessMirrorController); mHeader.setQSPanel(mQSPanel); qsh.setCallback(new QSTileHost.Callback() { @Override @@ -3048,6 +3052,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, if (mHeadsUpNotificationView != null) { mHeadsUpNotificationView.updateResources(); } + if (mBrightnessMirrorController != null) { + mBrightnessMirrorController.updateResources(); + } } protected void loadDimens() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java new file mode 100644 index 0000000..7bd2e5c --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2014 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.systemui.statusbar.policy; + +import com.android.systemui.R; +import com.android.systemui.statusbar.phone.PhoneStatusBar; +import com.android.systemui.statusbar.phone.StatusBarWindowView; + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewPropertyAnimator; +import android.widget.FrameLayout; + +/** + * Controls showing and hiding of the brightness mirror. + */ +public class BrightnessMirrorController { + + public long TRANSITION_DURATION_OUT = 150; + public long TRANSITION_DURATION_IN = 200; + + private final View mScrimBehind; + private final View mBrightnessMirror; + private final View mPanelHolder; + private final int[] mInt2Cache = new int[2]; + + public BrightnessMirrorController(StatusBarWindowView statusBarWindow) { + mScrimBehind = statusBarWindow.findViewById(R.id.scrim_behind); + mBrightnessMirror = statusBarWindow.findViewById(R.id.brightness_mirror); + mPanelHolder = statusBarWindow.findViewById(R.id.panel_holder); + } + + public void showMirror() { + mBrightnessMirror.setVisibility(View.VISIBLE); + outAnimation(mScrimBehind.animate()); + outAnimation(mPanelHolder.animate()) + .withLayer(); + } + + public void hideMirror() { + inAnimation(mScrimBehind.animate()); + inAnimation(mPanelHolder.animate()) + .withLayer() + .withEndAction(new Runnable() { + @Override + public void run() { + mBrightnessMirror.setVisibility(View.GONE); + } + }); + } + + private ViewPropertyAnimator outAnimation(ViewPropertyAnimator a) { + return a.alpha(0.0f) + .setDuration(TRANSITION_DURATION_OUT) + .setInterpolator(PhoneStatusBar.ALPHA_OUT); + } + private ViewPropertyAnimator inAnimation(ViewPropertyAnimator a) { + return a.alpha(1.0f) + .setDuration(TRANSITION_DURATION_IN) + .setInterpolator(PhoneStatusBar.ALPHA_IN); + } + + + public void setLocation(View original) { + original.getLocationInWindow(mInt2Cache); + int originalY = mInt2Cache[1]; + mBrightnessMirror.getLocationInWindow(mInt2Cache); + int mirrorY = mInt2Cache[1]; + + mBrightnessMirror.setTranslationY(mBrightnessMirror.getTranslationY() + + originalY - mirrorY); + } + + public View getMirror() { + return mBrightnessMirror; + } + + public void updateResources() { + FrameLayout.LayoutParams lp = + (FrameLayout.LayoutParams) mBrightnessMirror.getLayoutParams(); + lp.width = mBrightnessMirror.getResources().getDimensionPixelSize( + R.dimen.notification_panel_width); + lp.gravity = mBrightnessMirror.getResources().getInteger( + R.integer.notification_panel_layout_gravity); + mBrightnessMirror.setLayoutParams(lp); + + int padding = mBrightnessMirror.getResources().getDimensionPixelSize( + R.dimen.notification_side_padding); + mBrightnessMirror.setPadding(padding, mBrightnessMirror.getPaddingTop(), + padding, mBrightnessMirror.getPaddingBottom()); + } +} |