From dc10030581d6eec1c96acd62ed511f91d25d73a1 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Tue, 11 Jan 2011 17:07:41 -0800 Subject: The status bar half of making the status bar resize when hdmi is plugged in. Change-Id: Ia349413774ba709fb3242780671c7b459850f4a4 --- packages/SystemUI/res/layout-xlarge/status_bar.xml | 6 +- .../com/android/systemui/statusbar/StatusBar.java | 4 +- .../systemui/statusbar/phone/PhoneStatusBar.java | 8 +- .../systemui/statusbar/tablet/HeightReceiver.java | 103 +++++++++++++++++++++ .../statusbar/tablet/NotificationPanel.java | 6 -- .../systemui/statusbar/tablet/TabletStatusBar.java | 40 ++++++-- 6 files changed, 149 insertions(+), 18 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java (limited to 'packages') 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 @@ mListeners = new ArrayList(); + 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