diff options
author | Chris Wren <cwren@android.com> | 2012-06-07 09:44:54 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-07 09:44:54 -0700 |
commit | 059537e7924a5547849b537bf0e50d2f814b80a5 (patch) | |
tree | 6f10c5723f593829c996cc45d0c3dd72dab87570 /packages/SystemUI | |
parent | 8a71888975aba851edc8916b189f4c73daa1926b (diff) | |
parent | 3d32a24adf02cecca86ec16ac8827ce195daeaec (diff) | |
download | frameworks_base-059537e7924a5547849b537bf0e50d2f814b80a5.zip frameworks_base-059537e7924a5547849b537bf0e50d2f814b80a5.tar.gz frameworks_base-059537e7924a5547849b537bf0e50d2f814b80a5.tar.bz2 |
Merge "Back from the dead: Carrier name, background dimming." into jb-dev
Diffstat (limited to 'packages/SystemUI')
7 files changed, 152 insertions, 10 deletions
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index 0966a28..47e5b71 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -29,6 +29,17 @@ android:layout_marginLeft="@dimen/notification_panel_margin_left" > + <TextView + android:id="@+id/carrier_label" + android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Network" + android:layout_height="@dimen/carrier_label_height" + android:layout_width="match_parent" + android:layout_gravity="bottom" + android:layout_marginBottom="@dimen/close_handle_height" + android:gravity="center" + android:visibility="invisible" + /> + <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 0b362d1..3ed63ed 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -133,7 +133,7 @@ <dimen name="notification_panel_header_height">48dp</dimen> <!-- Extra space above the panel --> - <dimen name="notification_panel_padding_top">4dp</dimen> + <dimen name="notification_panel_padding_top">0dp</dimen> <!-- Extra space above the clock in the panel --> <dimen name="notification_panel_header_padding_top">0dp</dimen> @@ -145,4 +145,7 @@ <!-- Gravity for the notification panel --> <!-- 0x37 = fill_horizontal|top --> <integer name="notification_panel_layout_gravity">0x37</integer> + + <!-- Height of the carrier/wifi name label --> + <dimen name="carrier_label_height">24dp</dimen> </resources> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index a23fe12..1d5bf3c 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -63,6 +63,10 @@ <item name="android:textAllCaps">true</item> </style> + <style name="TextAppearance.StatusBar.Expanded.Network" parent="@style/TextAppearance.StatusBar.Expanded.Date"> + <item name="android:textColor">#999999</item> + </style> + <style name="Animation" /> <style name="Animation.ShirtPocketPanel"> 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 4393258..87e95da 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.phone; import android.animation.Animator; +import android.animation.Animator.AnimatorListener; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; @@ -86,6 +87,7 @@ import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.DateView; import com.android.systemui.statusbar.policy.IntruderAlertView; import com.android.systemui.statusbar.policy.LocationController; +import com.android.systemui.statusbar.policy.OnSizeChangedListener; import com.android.systemui.statusbar.policy.NetworkController; import com.android.systemui.statusbar.policy.NotificationRowLayout; @@ -105,7 +107,8 @@ public class PhoneStatusBar extends BaseStatusBar { public static final String ACTION_STATUSBAR_START = "com.android.internal.policy.statusbar.START"; - private static final boolean DIM_BEHIND_EXPANDED_PANEL = false; + private static final boolean DIM_BEHIND_EXPANDED_PANEL = true; + private static final boolean SHOW_CARRIER_LABEL = true; private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; @@ -170,6 +173,11 @@ public class PhoneStatusBar extends BaseStatusBar { View mSettingsButton; RotationToggle mRotationButton; + // carrier/wifi label + private TextView mCarrierLabel; + private boolean mCarrierLabelVisible = false; + private int mCarrierLabelHeight; + // drag bar CloseDragHandle mCloseView; private int mCloseViewHeight; @@ -385,6 +393,14 @@ public class PhoneStatusBar extends BaseStatusBar { mPile = (NotificationRowLayout)mStatusBarWindow.findViewById(R.id.latestItems); mPile.setLongPressListener(getNotificationLongClicker()); + if (SHOW_CARRIER_LABEL) { + mPile.setOnSizeChangedListener(new OnSizeChangedListener() { + @Override + public void onSizeChanged(View view, int w, int h, int oldw, int oldh) { + updateCarrierLabelVisibility(); + } + }); + } mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout); mClearButton = mStatusBarWindow.findViewById(R.id.clear_all_button); @@ -396,6 +412,9 @@ public class PhoneStatusBar extends BaseStatusBar { mSettingsButton = mStatusBarWindow.findViewById(R.id.settings_button); mSettingsButton.setOnClickListener(mSettingsButtonListener); mRotationButton = (RotationToggle) mStatusBarWindow.findViewById(R.id.rotation_lock_button); + + mCarrierLabel = (TextView)mStatusBarWindow.findViewById(R.id.carrier_label); + mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE); mScrollView = (ScrollView)mStatusBarWindow.findViewById(R.id.scroll); mScrollView.setVerticalScrollBarEnabled(false); // less drawing during pulldowns @@ -421,8 +440,17 @@ public class PhoneStatusBar extends BaseStatusBar { mNetworkController = new NetworkController(mContext); final SignalClusterView signalCluster = (SignalClusterView)mStatusBarView.findViewById(R.id.signal_cluster); + mNetworkController.addSignalCluster(signalCluster); signalCluster.setNetworkController(mNetworkController); + + // for wifi-only devices, we show SSID; otherwise, we show PLMN + if (mNetworkController.hasMobileDataFeature()) { + mNetworkController.addMobileLabelView(mCarrierLabel); + } else { + mNetworkController.addWifiLabelView(mCarrierLabel); + } + // final ImageView wimaxRSSI = // (ImageView)sb.findViewById(R.id.wimax_signal); // if (wimaxRSSI != null) { @@ -861,6 +889,45 @@ public class PhoneStatusBar extends BaseStatusBar { } } + protected void updateCarrierLabelVisibility() { + if (!SHOW_CARRIER_LABEL) return; + // The idea here is to only show the carrier label when there is enough room to see it, + // i.e. when there aren't enough notifications to fill the panel. + if (DEBUG) { + Slog.d(TAG, String.format("pileh=%d scrollh=%d carrierh=%d", + mPile.getHeight(), mScrollView.getHeight(), mCarrierLabelHeight)); + } + + final boolean makeVisible = + mPile.getHeight() < (mScrollView.getHeight() - mCarrierLabelHeight); + + if (mCarrierLabelVisible != makeVisible) { + mCarrierLabelVisible = makeVisible; + if (DEBUG) { + Slog.d(TAG, "making carrier label " + (makeVisible?"visible":"invisible")); + } + mCarrierLabel.animate().cancel(); + if (makeVisible) { + mCarrierLabel.setVisibility(View.VISIBLE); + } + mCarrierLabel.animate() + .alpha(makeVisible ? 1f : 0f) + //.setStartDelay(makeVisible ? 500 : 0) + //.setDuration(makeVisible ? 750 : 100) + .setDuration(150) + .setListener(makeVisible ? null : new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + if (!mCarrierLabelVisible) { // race + mCarrierLabel.setVisibility(View.INVISIBLE); + mCarrierLabel.setAlpha(0f); + } + } + }) + .start(); + } + } + @Override protected void setAreThereNotifications() { final boolean any = mNotificationData.size() > 0; @@ -918,6 +985,8 @@ public class PhoneStatusBar extends BaseStatusBar { }) .start(); } + + updateCarrierLabelVisibility(); } public void showClock(boolean show) { @@ -1092,6 +1161,8 @@ public class PhoneStatusBar extends BaseStatusBar { mExpandedVisible = true; makeSlippery(mNavigationBarView, true); + updateCarrierLabelVisibility(); + updateExpandedViewPos(EXPANDED_LEAVE_ALONE); // Expand the window to encompass the full screen in anticipation of the drag. @@ -1947,6 +2018,8 @@ public class PhoneStatusBar extends BaseStatusBar { panelh = 0; } + if (panelh == mTrackingPosition) return; + mTrackingPosition = panelh; FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mNotificationPanel.getLayoutParams(); @@ -1958,13 +2031,17 @@ public class PhoneStatusBar extends BaseStatusBar { } mNotificationPanel.setLayoutParams(lp); + final int barh = getCloseViewHeight() + getStatusBarHeight(); + final float frac = saturate((float)(panelh - barh) / (disph - barh)); + if (DIM_BEHIND_EXPANDED_PANEL && ActivityManager.isHighEndGfx(mDisplay)) { // woo, special effects - final int barh = getCloseViewHeight() + getStatusBarHeight(); - final float frac = saturate((float)(panelh - barh) / (disph - barh)); - final int color = ((int)(0xB0 * Math.sin(frac * 1.57f))) << 24; + final float k = (float)(1f-0.5f*(1f-Math.cos(3.14159f * Math.pow(1f-frac, 2.2f)))); + final int color = ((int)(0xB0 * k)) << 24; mStatusBarWindow.setBackgroundColor(color); } + + updateCarrierLabelVisibility(); } void updateDisplaySize() { @@ -2199,11 +2276,15 @@ public class PhoneStatusBar extends BaseStatusBar { if (mNotificationPanelGravity <= 0) { mNotificationPanelGravity = Gravity.CENTER_VERTICAL | Gravity.TOP; } - mNotificationPanelMinHeight = + final int notificationPanelDecorationHeight = res.getDimensionPixelSize(R.dimen.notification_panel_padding_top) + res.getDimensionPixelSize(R.dimen.notification_panel_header_height) - + res.getDimensionPixelSize(R.dimen.close_handle_underlap) + getNinePatchPadding(res.getDrawable(R.drawable.notification_panel_bg)).bottom; + mNotificationPanelMinHeight = + notificationPanelDecorationHeight + + res.getDimensionPixelSize(R.dimen.close_handle_underlap); + + mCarrierLabelHeight = res.getDimensionPixelSize(R.dimen.carrier_label_height); if (false) Slog.v(TAG, "updateResources"); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java index 273076c..b8f6054 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java @@ -237,6 +237,10 @@ public class NetworkController extends BroadcastReceiver { mBatteryStats = BatteryStatsService.getService(); } + public boolean hasMobileDataFeature() { + return mHasMobileDataFeature; + } + public void addPhoneSignalIconView(ImageView v) { mPhoneSignalIconViews.add(v); } @@ -1049,6 +1053,9 @@ public class NetworkController extends BroadcastReceiver { + Integer.toHexString(combinedSignalIconId) + "/" + getResourceName(combinedSignalIconId) + " combinedActivityIconId=0x" + Integer.toHexString(combinedActivityIconId) + + " mobileLabel=" + mobileLabel + + " wifiLabel=" + wifiLabel + + " combinedLabel=" + combinedLabel + " mAirplaneMode=" + mAirplaneMode + " mDataActivity=" + mDataActivity + " mPhoneSignalIconId=0x" + Integer.toHexString(mPhoneSignalIconId) @@ -1194,11 +1201,11 @@ public class NetworkController extends BroadcastReceiver { N = mWifiLabelViews.size(); for (int i=0; i<N; i++) { TextView v = mWifiLabelViews.get(i); + v.setText(wifiLabel); if ("".equals(wifiLabel)) { v.setVisibility(View.GONE); } else { v.setVisibility(View.VISIBLE); - v.setText(wifiLabel); } } @@ -1206,11 +1213,11 @@ public class NetworkController extends BroadcastReceiver { N = mMobileLabelViews.size(); for (int i=0; i<N; i++) { TextView v = mMobileLabelViews.get(i); + v.setText(mobileLabel); if ("".equals(mobileLabel)) { v.setVisibility(View.GONE); } else { v.setVisibility(View.VISIBLE); - v.setText(mobileLabel); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java index 0284644..42db8cf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java @@ -44,7 +44,7 @@ import java.util.HashMap; public class NotificationRowLayout extends LinearLayout - implements SwipeHelper.Callback, ExpandHelper.Callback + implements SwipeHelper.Callback, ExpandHelper.Callback { private static final String TAG = "NotificationRowLayout"; private static final boolean DEBUG = false; @@ -61,6 +61,8 @@ public class NotificationRowLayout HashMap<View, ValueAnimator> mDisappearingViews = new HashMap<View, ValueAnimator>(); private SwipeHelper mSwipeHelper; + + private OnSizeChangedListener mOnSizeChangedListener; // Flag set during notification removal animation to avoid causing too much work until // animation is done @@ -101,6 +103,10 @@ public class NotificationRowLayout mSwipeHelper.setLongPressListener(listener); } + public void setOnSizeChangedListener(OnSizeChangedListener l) { + mOnSizeChangedListener = l; + } + @Override public void onWindowFocusChanged(boolean hasWindowFocus) { super.onWindowFocusChanged(hasWindowFocus); @@ -247,4 +253,11 @@ public class NotificationRowLayout c.restore(); } } + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + if (mOnSizeChangedListener != null) { + mOnSizeChangedListener.onSizeChanged(this, w, h, oldw, oldh); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/OnSizeChangedListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/OnSizeChangedListener.java new file mode 100644 index 0000000..0377123 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/OnSizeChangedListener.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2012 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 android.view.View; + +public interface OnSizeChangedListener { + void onSizeChanged(View view, int w, int h, int oldw, int oldh); +} |