use of com.android.systemui.statusbar.policy.DockBatteryController in project android_frameworks_base by ParanoidAndroid.
the class PhoneStatusBar method makeStatusBarView.
// ================================================================================
// Constructing the view
// ================================================================================
protected PhoneStatusBarView makeStatusBarView() {
final Context context = mContext;
Resources res = context.getResources();
// populates mDisplayMetrics
updateDisplaySize();
loadDimens();
mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
mStatusBarWindow = (StatusBarWindowView) View.inflate(context, R.layout.super_status_bar, null);
mStatusBarWindow.mService = this;
mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (mExpandedVisible) {
animateCollapsePanels();
}
}
return mStatusBarWindow.onTouchEvent(event);
}
});
mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar);
mStatusBarView.setStatusBar(this);
mStatusBarView.setBar(this);
mBarView = (ViewGroup) mStatusBarView;
// status bar clock
mClock = (Clock) mStatusBarView.findViewById(R.id.clock);
PanelHolder holder = (PanelHolder) mStatusBarWindow.findViewById(R.id.panel_holder);
mStatusBarView.setPanelHolder(holder);
mNotificationPanel = (NotificationPanelView) mStatusBarWindow.findViewById(R.id.notification_panel);
mNotificationPanel.setStatusBar(this);
mNotificationPanelIsFullScreenWidth = (mNotificationPanel.getLayoutParams().width == ViewGroup.LayoutParams.MATCH_PARENT);
// make the header non-responsive to clicks
mNotificationPanel.findViewById(R.id.header).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// e eats everything
return true;
}
});
if (!ActivityManager.isHighEndGfx()) {
mStatusBarWindow.setBackground(null);
mNotificationPanel.setBackground(new FastColorDrawable(context.getResources().getColor(R.color.notification_panel_solid_background)));
}
if (ENABLE_INTRUDERS) {
mIntruderAlertView = (IntruderAlertView) View.inflate(context, R.layout.intruder_alert, null);
mIntruderAlertView.setVisibility(View.GONE);
mIntruderAlertView.setBar(this);
}
if (MULTIUSER_DEBUG) {
mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById(R.id.header_debug_info);
mNotificationPanelDebugText.setVisibility(View.VISIBLE);
}
updateShowSearchHoldoff();
try {
boolean showNav = mWindowManagerService.hasNavigationBar();
if (DEBUG)
Slog.v(TAG, "hasNavigationBar=" + showNav);
if (showNav && !mRecreating) {
mNavigationBarView = (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);
mNavigationBarView.setDisabledFlags(mDisabled);
mNavigationBarView.setBar(this);
}
} catch (RemoteException ex) {
// no window manager? good luck with that
}
// set recents activity navigation bar view
RecentsActivity.addNavigationCallback(mNavigationBarView);
// figure out which pixel-format to use for the status bar.
mPixelFormat = PixelFormat.TRANSLUCENT;
mSystemIconArea = (LinearLayout) mStatusBarView.findViewById(R.id.system_icon_area);
mStatusIcons = (LinearLayout) mStatusBarView.findViewById(R.id.statusIcons);
mNotificationIcons = (IconMerger) mStatusBarView.findViewById(R.id.notificationIcons);
mMoreIcon = mStatusBarView.findViewById(R.id.moreIcon);
mNotificationIcons.setOverflowIndicator(mMoreIcon);
mStatusBarContents = (LinearLayout) mStatusBarView.findViewById(R.id.status_bar_contents);
mTickerView = mStatusBarView.findViewById(R.id.ticker);
mPile = (NotificationRowLayout) mStatusBarWindow.findViewById(R.id.latestItems);
mPile.setLayoutTransitionsEnabled(false);
mPile.setLongPressListener(getNotificationLongClicker());
// was: expanded.findViewById(R.id.notificationLinearLayout);
mExpandedContents = mPile;
mNotificationPanelHeader = mStatusBarWindow.findViewById(R.id.header);
mClearButton = mStatusBarWindow.findViewById(R.id.clear_all_button);
mClearButton.setOnClickListener(mClearButtonListener);
mClearButton.setAlpha(0f);
mClearButton.setVisibility(View.GONE);
mClearButton.setEnabled(false);
mDateView = (DateView) mStatusBarWindow.findViewById(R.id.date);
mHasSettingsPanel = res.getBoolean(R.bool.config_hasSettingsPanel);
mHasFlipSettings = res.getBoolean(R.bool.config_hasFlipSettingsPanel);
mDateTimeView = mNotificationPanelHeader.findViewById(R.id.datetime);
if (mDateTimeView != null) {
mDateTimeView.setOnClickListener(mClockClickListener);
mDateTimeView.setEnabled(true);
}
mSettingsButton = (ImageView) mStatusBarWindow.findViewById(R.id.settings_button);
if (mSettingsButton != null) {
mSettingsButton.setOnClickListener(mSettingsButtonListener);
if (mHasSettingsPanel) {
if (mStatusBarView.hasFullWidthNotifications()) {
// the settings panel is hiding behind this button
mSettingsButton.setImageResource(R.drawable.ic_notify_quicksettings);
mSettingsButton.setVisibility(View.VISIBLE);
} else {
// there is a settings panel, but it's on the other side of the (large) screen
final View buttonHolder = mStatusBarWindow.findViewById(R.id.settings_button_holder);
if (buttonHolder != null) {
buttonHolder.setVisibility(View.GONE);
}
}
} else {
// no settings panel, go straight to settings
mSettingsButton.setVisibility(View.VISIBLE);
mSettingsButton.setImageResource(R.drawable.ic_notify_settings);
}
}
mHaloButton = (ImageView) mStatusBarWindow.findViewById(R.id.halo_button);
if (mHaloButton != null) {
mHaloButton.setOnClickListener(mHaloButtonListener);
mHaloButtonVisible = true;
updateHaloButton();
}
if (mHasFlipSettings) {
mNotificationButton = (ImageView) mStatusBarWindow.findViewById(R.id.notification_button);
if (mNotificationButton != null) {
mNotificationButton.setOnClickListener(mNotificationButtonListener);
}
}
mScrollView = (ScrollView) mStatusBarWindow.findViewById(R.id.scroll);
// less drawing during pulldowns
mScrollView.setVerticalScrollBarEnabled(false);
if (!mNotificationPanelIsFullScreenWidth) {
mScrollView.setSystemUiVisibility(View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER | View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS | View.STATUS_BAR_DISABLE_CLOCK);
}
mTicker = new MyTicker(context, mStatusBarView);
TickerView tickerView = (TickerView) mStatusBarView.findViewById(R.id.tickerText);
tickerView.mTicker = mTicker;
if (mHaloActive)
mTickerView.setVisibility(View.GONE);
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
// set the inital view visibility
setAreThereNotifications();
// Other icons
// will post a notification
mLocationController = new LocationController(mContext);
mBatteryController = new BatteryController(mContext);
mBatteryController.addIconView((ImageView) mStatusBarView.findViewById(R.id.battery));
mNetworkController = new NetworkController(mContext);
mBluetoothController = new BluetoothController(mContext);
mSignalCluster = (SignalClusterView) mStatusBarView.findViewById(R.id.signal_cluster);
mNetworkController.addSignalCluster(mSignalCluster);
mSignalCluster.setNetworkController(mNetworkController);
mHasDockBattery = mContext.getResources().getBoolean(com.android.internal.R.bool.config_hasDockBattery);
if (mHasDockBattery) {
mDockBatteryController = new DockBatteryController(mContext);
mDockBatteryController.addIconView((ImageView) mStatusBarView.findViewById(R.id.dock_battery));
}
final boolean isAPhone = mNetworkController.hasVoiceCallingFeature();
if (isAPhone) {
mEmergencyCallLabel = (TextView) mStatusBarWindow.findViewById(R.id.emergency_calls_only);
if (mEmergencyCallLabel != null) {
mNetworkController.addEmergencyLabelView(mEmergencyCallLabel);
mEmergencyCallLabel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
mEmergencyCallLabel.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
updateCarrierLabelVisibility(false);
}
});
}
}
mCarrierLabel = (TextView) mStatusBarWindow.findViewById(R.id.carrier_label);
mShowCarrierInPanel = (mCarrierLabel != null);
if (DEBUG)
Slog.v(TAG, "carrierlabel=" + mCarrierLabel + " show=" + mShowCarrierInPanel);
if (mShowCarrierInPanel) {
mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE);
// for other devices, we show whatever network is connected
if (mNetworkController.hasMobileDataFeature()) {
mNetworkController.addMobileLabelView(mCarrierLabel);
} else {
mNetworkController.addCombinedLabelView(mCarrierLabel);
}
// set up the dynamic hide/show of the label
mPile.setOnSizeChangedListener(new OnSizeChangedListener() {
@Override
public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
updateCarrierLabelVisibility(false);
}
});
}
// Quick Settings (where available, some restrictions apply)
if (mHasSettingsPanel) {
// first, figure out where quick settings should be inflated
final View settings_stub;
if (mHasFlipSettings) {
// a version of quick settings that flips around behind the notifications
settings_stub = mStatusBarWindow.findViewById(R.id.flip_settings_stub);
if (settings_stub != null) {
mFlipSettingsView = ((ViewStub) settings_stub).inflate();
mFlipSettingsView.setVisibility(View.GONE);
mFlipSettingsView.setVerticalScrollBarEnabled(false);
}
} else {
// full quick settings panel
settings_stub = mStatusBarWindow.findViewById(R.id.quick_settings_stub);
if (settings_stub != null) {
mSettingsPanel = (SettingsPanelView) ((ViewStub) settings_stub).inflate();
} else {
mSettingsPanel = (SettingsPanelView) mStatusBarWindow.findViewById(R.id.settings_panel);
}
if (mSettingsPanel != null) {
if (!ActivityManager.isHighEndGfx()) {
mSettingsPanel.setBackground(new FastColorDrawable(context.getResources().getColor(R.color.notification_panel_solid_background)));
}
}
}
// wherever you find it, Quick Settings needs a container to survive
mSettingsContainer = (QuickSettingsContainerView) mStatusBarWindow.findViewById(R.id.quick_settings_container);
// wherever you find it, Quick Settings needs a container to survive
mSettingsContainer = (QuickSettingsContainerView) mStatusBarWindow.findViewById(R.id.quick_settings_container);
if (mSettingsContainer != null) {
mQS = new QuickSettingsController(mContext, mSettingsContainer, this);
if (mSettingsPanel != null) {
mSettingsPanel.setQuickSettings(mQS);
}
mQS.setService(this);
mQS.setBar(mStatusBarView);
mQS.setupQuickSettings();
// Start observing for changes
mTilesChangedObserver = new TilesChangedObserver(mHandler);
mTilesChangedObserver.startObserving();
} else {
// fly away, be free
mQS = null;
}
}
mClingShown = !(DEBUG_CLINGS || !Prefs.read(mContext).getBoolean(Prefs.SHOWN_QUICK_SETTINGS_HELP, false));
if (!ENABLE_NOTIFICATION_PANEL_CLING || ActivityManager.isRunningInTestHarness()) {
mClingShown = true;
}
// final ImageView wimaxRSSI =
// (ImageView)sb.findViewById(R.id.wimax_signal);
// if (wimaxRSSI != null) {
// mNetworkController.addWimaxIconView(wimaxRSSI);
// }
// receive broadcasts
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
context.registerReceiver(mBroadcastReceiver, filter);
// listen for USER_SETUP_COMPLETE setting (per-user)
resetUserSetupObserver();
return mStatusBarView;
}
use of com.android.systemui.statusbar.policy.DockBatteryController in project android_frameworks_base by ParanoidAndroid.
the class TabletStatusBar method makeStatusBarView.
protected View makeStatusBarView() {
final Context context = mContext;
CustomTheme currentTheme = mContext.getResources().getConfiguration().customTheme;
if (currentTheme != null) {
mCurrentTheme = (CustomTheme) currentTheme.clone();
}
loadDimens();
final TabletStatusBarView sb = (TabletStatusBarView) View.inflate(context, R.layout.system_bar, null);
mStatusBarView = sb;
sb.setHandler(mHandler);
try {
// bar on a tablet that has only the system bar
if (mWindowManagerService.hasNavigationBar()) {
Slog.e(TAG, "Tablet device cannot show navigation bar and system bar");
}
} catch (RemoteException ex) {
}
// Overload screen with views that literally do nothing, thank you Google
int[] dummyGravity = { Gravity.LEFT, Gravity.TOP, Gravity.RIGHT, Gravity.BOTTOM };
for (int i = 0; i < 4; i++) {
mPieDummyTrigger[i] = new View(mContext);
mWindowManager.addView(mPieDummyTrigger[i], getDummyTriggerLayoutParams(mContext, dummyGravity[i]));
}
// set recents activity navigation bar view
RecentsActivity.addNavigationCallback(this);
mBarContents = (ViewGroup) sb.findViewById(R.id.bar_contents);
// system bar clock
mClock = (Clock) mBarContents.findViewById(R.id.clock);
// the whole right-hand side of the bar
mNotificationArea = sb.findViewById(R.id.notificationArea);
mNotificationArea.setOnTouchListener(new NotificationTriggerTouchListener());
// the button to open the notification area
mNotificationTrigger = sb.findViewById(R.id.notificationTrigger);
// the more notifications icon
mNotificationIconArea = (NotificationIconArea) sb.findViewById(R.id.notificationIcons);
// where the icons go
mIconLayout = (NotificationIconArea.IconLayout) sb.findViewById(R.id.icons);
mNotificationPeekTapDuration = ViewConfiguration.getTapTimeout();
// px/s
mNotificationFlingVelocity = 300;
mTabletTicker = new TabletTicker(this);
// The icons
// will post a notification
mLocationController = new LocationController(mContext);
// watch the PREF_DO_NOT_DISTURB and convert to appropriate disable() calls
mDoNotDisturb = new DoNotDisturb(mContext);
mBatteryController = new BatteryController(mContext);
mBatteryController.addIconView((ImageView) sb.findViewById(R.id.battery));
mBluetoothController = new BluetoothController(mContext);
mBluetoothController.addIconView((ImageView) sb.findViewById(R.id.bluetooth));
mNetworkController = new NetworkController(mContext);
mSignalCluster = (SignalClusterView) sb.findViewById(R.id.signal_cluster);
mNetworkController.addSignalCluster(mSignalCluster);
mSignalCluster.setNetworkController(mNetworkController);
mBarView = (ViewGroup) mStatusBarView;
mHasDockBattery = mContext.getResources().getBoolean(com.android.internal.R.bool.config_hasDockBattery);
if (mHasDockBattery) {
mDockBatteryController = new DockBatteryController(mContext);
mDockBatteryController.addIconView((ImageView) sb.findViewById(R.id.dock_battery));
}
// The navigation buttons
mBackButton = (ImageView) sb.findViewById(R.id.back);
mNavigationArea = (ViewGroup) sb.findViewById(R.id.navigationArea);
mHomeButton = mNavigationArea.findViewById(R.id.home);
mMenuButton = mNavigationArea.findViewById(R.id.menu);
mRecentButton = mNavigationArea.findViewById(R.id.recent_apps);
if (Settings.System.getInt(context.getContentResolver(), Settings.System.NAV_BAR_TABUI_MENU, 0) == 1) {
MarginLayoutParams marginParams = new MarginLayoutParams(mMenuButton.getLayoutParams());
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams);
layoutParams.addRule(RelativeLayout.RIGHT_OF, R.id.recent_apps);
layoutParams.setMargins(-(context.getResources().getDimensionPixelSize(R.dimen.navigation_menu_key_width) / 3), 0, 0, 0);
mMenuButton.setLayoutParams(layoutParams);
((ImageView) mMenuButton).setImageDrawable(context.getResources().getDrawable(R.drawable.ic_sysbar_menu));
} else {
mRecentButton.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
((KeyButtonView) mMenuButton).sendEventSequence(new int[][] { new int[] { KeyEvent.ACTION_DOWN, KeyEvent.FLAG_CANCELED }, new int[] { KeyEvent.ACTION_UP, 0 } });
mButtonBusy = false;
return true;
}
});
}
mRecentButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (mButtonBusy) {
onClickRecentButton();
} else {
mButtonBusy = true;
}
}
});
LayoutTransition lt = new LayoutTransition();
lt.setDuration(250);
// don't wait for these transitions; we just want icons to fade in/out, not move around
lt.setDuration(LayoutTransition.CHANGE_APPEARING, 0);
lt.setDuration(LayoutTransition.CHANGE_DISAPPEARING, 0);
lt.addTransitionListener(new LayoutTransition.TransitionListener() {
public void endTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
// ensure the menu button doesn't stick around on the status bar after it's been
// removed
mBarContents.invalidate();
}
public void startTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
}
});
mNavigationArea.setLayoutTransition(lt);
// no multi-touch on the nav buttons
mNavigationArea.setMotionEventSplittingEnabled(false);
// The bar contents buttons
mFeedbackIconArea = (ViewGroup) sb.findViewById(R.id.feedbackIconArea);
mInputMethodSwitchButton = (InputMethodButton) sb.findViewById(R.id.imeSwitchButton);
// Overwrite the lister
mInputMethodSwitchButton.setOnClickListener(mOnClickListener);
mCompatModeButton = (CompatModeButton) sb.findViewById(R.id.compatModeButton);
mCompatModeButton.setOnClickListener(mOnClickListener);
mCompatModeButton.setVisibility(View.GONE);
// for redirecting errant bar taps to the IME
mFakeSpaceBar = sb.findViewById(R.id.fake_space_bar);
// "shadows" of the status bar features, for lights-out mode
mShadow = sb.findViewById(R.id.bar_shadow);
mShadow.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
// even though setting the systemUI visibility below will turn these views
// on, we need them to come up faster so that they can catch this motion
// event
mShadow.setVisibility(View.GONE);
mBarContents.setVisibility(View.VISIBLE);
try {
mBarService.setSystemUiVisibility(0, View.SYSTEM_UI_FLAG_LOW_PROFILE);
} catch (RemoteException ex) {
// system process dead
}
}
return false;
}
});
// tuning parameters
final int LIGHTS_GOING_OUT_SYSBAR_DURATION = 750;
final int LIGHTS_GOING_OUT_SHADOW_DURATION = 750;
final int LIGHTS_GOING_OUT_SHADOW_DELAY = 0;
final int LIGHTS_COMING_UP_SYSBAR_DURATION = 200;
// final int LIGHTS_COMING_UP_SYSBAR_DELAY = 50;
final int LIGHTS_COMING_UP_SHADOW_DURATION = 0;
LayoutTransition xition = new LayoutTransition();
xition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(null, "alpha", 0.5f, 1f));
xition.setDuration(LayoutTransition.APPEARING, LIGHTS_COMING_UP_SYSBAR_DURATION);
xition.setStartDelay(LayoutTransition.APPEARING, 0);
xition.setAnimator(LayoutTransition.DISAPPEARING, ObjectAnimator.ofFloat(null, "alpha", 1f, 0f));
xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_GOING_OUT_SYSBAR_DURATION);
xition.setStartDelay(LayoutTransition.DISAPPEARING, 0);
((ViewGroup) sb.findViewById(R.id.bar_contents_holder)).setLayoutTransition(xition);
xition = new LayoutTransition();
xition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(null, "alpha", 0f, 1f));
xition.setDuration(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DURATION);
xition.setStartDelay(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DELAY);
xition.setAnimator(LayoutTransition.DISAPPEARING, ObjectAnimator.ofFloat(null, "alpha", 1f, 0f));
xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_COMING_UP_SHADOW_DURATION);
xition.setStartDelay(LayoutTransition.DISAPPEARING, 0);
((ViewGroup) sb.findViewById(R.id.bar_shadow_holder)).setLayoutTransition(xition);
// set the initial view visibility
setAreThereNotifications();
// receive broadcasts
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
filter.addAction(Intent.ACTION_SCREEN_OFF);
context.registerReceiver(mBroadcastReceiver, filter);
return sb;
}
Aggregations