diff options
author | Joe Onorato <joeo@google.com> | 2011-01-11 17:09:16 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-01-11 17:09:16 -0800 |
commit | 14770e049e10377bd963623891ccb0976b2dd6ee (patch) | |
tree | aff1116fd09ff5387dce5af03b5eab00cccbed1a /packages | |
parent | d938e216cb24f7c154cf62135e90b8e6f3de2464 (diff) | |
parent | dc10030581d6eec1c96acd62ed511f91d25d73a1 (diff) | |
download | frameworks_base-14770e049e10377bd963623891ccb0976b2dd6ee.zip frameworks_base-14770e049e10377bd963623891ccb0976b2dd6ee.tar.gz frameworks_base-14770e049e10377bd963623891ccb0976b2dd6ee.tar.bz2 |
Merge "The status bar half of making the status bar resize when hdmi is plugged in." into honeycomb
Diffstat (limited to 'packages')
6 files changed, 149 insertions, 18 deletions
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml index 0eaf08e..0533b6f 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml @@ -25,7 +25,8 @@ <FrameLayout android:id="@+id/bar_contents_holder" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="@*android:dimen/status_bar_height" + android:layout_gravity="bottom" > <RelativeLayout android:id="@+id/bar_contents" @@ -93,7 +94,8 @@ <FrameLayout android:id="@+id/bar_shadow_holder" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="@*android:dimen/status_bar_height" + android:layout_gravity="bottom" > <!-- lights out shade --> <RelativeLayout diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java index 472a225..8fca759 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java @@ -52,6 +52,7 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac // Up-call methods protected abstract View makeStatusBarView(); protected abstract int getStatusBarGravity(); + public abstract int getStatusBarHeight(); private DoNotDisturb mDoNotDisturb; @@ -104,8 +105,7 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac } // Put up the view - final Resources res = mContext.getResources(); - final int height= res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); + final int height = getStatusBarHeight(); final WindowManager.LayoutParams lp = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 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 0d6c5f6..132433b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -287,9 +287,13 @@ public class PhoneStatusBar extends StatusBar { return Gravity.TOP | Gravity.FILL_HORIZONTAL; } - private void addIntruderView() { + public int getStatusBarHeight() { final Resources res = mContext.getResources(); - final int height= res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); + return res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); + } + + private void addIntruderView() { + final int height = getStatusBarHeight(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java new file mode 100644 index 0000000..5616159 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2011 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.tablet; + +import java.util.ArrayList; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.res.Resources; +import android.util.DisplayMetrics; +import android.util.Slog; +import android.view.View; +import android.view.WindowManager; +import android.view.WindowManagerImpl; +import android.view.WindowManagerPolicy; + +public class HeightReceiver extends BroadcastReceiver { + private static final String TAG = "StatusBar.HeightReceiver"; + + public interface OnBarHeightChangedListener { + public void onBarHeightChanged(int height); + } + + Context mContext; + ArrayList<OnBarHeightChangedListener> mListeners = new ArrayList<OnBarHeightChangedListener>(); + WindowManager mWindowManager; + int mHeight; + + public HeightReceiver(Context context) { + mContext = context; + mWindowManager = WindowManagerImpl.getDefault(); + } + + public void addOnBarHeightChangedListener(OnBarHeightChangedListener l) { + mListeners.add(l); + l.onBarHeightChanged(mHeight); + } + + public void removeOnBarHeightChangedListener(OnBarHeightChangedListener l) { + mListeners.remove(l); + } + + @Override + public void onReceive(Context context, Intent intent) { + final boolean plugged + = intent.getBooleanExtra(WindowManagerPolicy.EXTRA_HDMI_PLUGGED_STATE, false); + setPlugged(plugged); + } + + public void registerReceiver() { + final IntentFilter filter = new IntentFilter(); + filter.addAction(WindowManagerPolicy.ACTION_HDMI_PLUGGED); + final Intent val = mContext.registerReceiver(this, filter); + onReceive(mContext, val); + } + + private void setPlugged(boolean plugged) { + final Resources res = mContext.getResources(); + + Slog.d(TAG, "plugged=" + plugged); + int height = -1; + if (plugged) { + final DisplayMetrics metrics = new DisplayMetrics(); + mWindowManager.getDefaultDisplay().getMetrics(metrics); + Slog.d(TAG, "metrics=" + metrics); + height = metrics.heightPixels - 720; + } + + final int minHeight + = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); + if (height < minHeight) { + height = minHeight; + } + Slog.d(TAG, "using height=" + height + " old=" + mHeight); + mHeight = height; + + final int N = mListeners.size(); + for (int i=0; i<N; i++) { + mListeners.get(i).onBarHeightChanged(height); + } + } + + public int getHeight() { + return mHeight; + } +} + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java index 3201d06..ffbc0e3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java @@ -58,7 +58,6 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel, ViewGroup mContentParent; Choreographer mChoreo = new Choreographer(); - int mStatusBarHeight; public NotificationPanel(Context context, AttributeSet attrs) { this(context, attrs, 0); @@ -66,11 +65,6 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel, public NotificationPanel(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - - final Resources res = context.getResources(); - - mStatusBarHeight = res.getDimensionPixelSize( - com.android.internal.R.dimen.status_bar_height); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index cd39d71..f858f61 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -74,7 +74,8 @@ import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.NetworkController; import com.android.systemui.recent.RecentApplicationsActivity; -public class TabletStatusBar extends StatusBar { +public class TabletStatusBar extends StatusBar implements + HeightReceiver.OnBarHeightChangedListener { public static final boolean DEBUG = false; public static final String TAG = "TabletStatusBar"; @@ -97,7 +98,9 @@ public class TabletStatusBar extends StatusBar { public static final int LIGHTS_ON_DELAY = 5000; - int mBarHeight = -1; + // The height of the bar, as definied by the build. It may be taller if we're plugged + // into hdmi. + int mNaturalBarHeight = -1; int mIconSize = -1; int mIconHPadding = -1; @@ -134,6 +137,7 @@ public class TabletStatusBar extends StatusBar { ViewGroup mPile; + HeightReceiver mHeightReceiver; BatteryController mBatteryController; NetworkController mNetworkController; @@ -269,15 +273,15 @@ public class TabletStatusBar extends StatusBar { } @Override - protected void onConfigurationChanged (Configuration newConfig) { + protected void onConfigurationChanged(Configuration newConfig) { loadDimens(); } protected void loadDimens() { final Resources res = mContext.getResources(); - mBarHeight = res.getDimensionPixelSize( - com.android.internal.R.dimen.status_bar_height); + mNaturalBarHeight = res.getDimensionPixelSize( + com.android.internal.R.dimen.status_bar_height); int newIconSize = res.getDimensionPixelSize( com.android.internal.R.dimen.status_bar_icon_size); @@ -298,6 +302,10 @@ public class TabletStatusBar extends StatusBar { mWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); + // This guy will listen for HDMI plugged broadcasts so we can resize the + // status bar as appropriate. + mHeightReceiver = new HeightReceiver(mContext); + mHeightReceiver.registerReceiver(); loadDimens(); final TabletStatusBarView sb = (TabletStatusBarView)View.inflate( @@ -408,13 +416,33 @@ public class TabletStatusBar extends StatusBar { ScrollView scroller = (ScrollView)mPile.getParent(); scroller.setFillViewport(true); + mHeightReceiver.addOnBarHeightChangedListener(this); + return sb; } + public int getStatusBarHeight() { + return mHeightReceiver.getHeight(); + } + protected int getStatusBarGravity() { return Gravity.BOTTOM | Gravity.FILL_HORIZONTAL; } + public void onBarHeightChanged(int height) { + final WindowManager.LayoutParams lp + = (WindowManager.LayoutParams)mStatusBarView.getLayoutParams(); + if (lp == null) { + // haven't been added yet + return; + } + if (lp.height != height) { + lp.height = height; + final WindowManager wm = WindowManagerImpl.getDefault(); + wm.updateViewLayout(mStatusBarView, lp); + } + } + private class H extends Handler { public void handleMessage(Message m) { switch (m.what) { @@ -1048,7 +1076,7 @@ public class TabletStatusBar extends StatusBar { if (mIconLayout == null) return; final LinearLayout.LayoutParams params - = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mBarHeight); + = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight); int N = mNotns.size(); |