Search in sources :

Example 6 with KeyButtonView

use of com.android.systemui.statusbar.policy.KeyButtonView 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;
}
Also used : LocationController(com.android.systemui.statusbar.policy.LocationController) LayoutTransition(android.animation.LayoutTransition) BluetoothController(com.android.systemui.statusbar.policy.BluetoothController) OnLongClickListener(android.view.View.OnLongClickListener) DockBatteryController(com.android.systemui.statusbar.policy.DockBatteryController) BatteryController(com.android.systemui.statusbar.policy.BatteryController) ImageView(android.widget.ImageView) Context(android.content.Context) IntentFilter(android.content.IntentFilter) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) ViewGroup(android.view.ViewGroup) DockBatteryController(com.android.systemui.statusbar.policy.DockBatteryController) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) ImageView(android.widget.ImageView) QuickSettingsContainerView(com.android.systemui.statusbar.phone.QuickSettingsContainerView) View(android.view.View) TextView(android.widget.TextView) SignalClusterView(com.android.systemui.statusbar.SignalClusterView) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) ScrollView(android.widget.ScrollView) CustomTheme(android.content.res.CustomTheme) Point(android.graphics.Point) NetworkController(com.android.systemui.statusbar.policy.NetworkController) MotionEvent(android.view.MotionEvent) RelativeLayout(android.widget.RelativeLayout) DoNotDisturb(com.android.systemui.statusbar.DoNotDisturb) OnClickListener(android.view.View.OnClickListener) RemoteException(android.os.RemoteException)

Example 7 with KeyButtonView

use of com.android.systemui.statusbar.policy.KeyButtonView in project android_frameworks_base by AOSPA.

the class NavigationBarInflaterView method inflateButton.

@Nullable
protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape) {
    LayoutInflater inflater = landscape ? mLandscapeInflater : mLayoutInflater;
    float size = extractSize(buttonSpec);
    String button = extractButton(buttonSpec);
    View v = null;
    if (HOME.equals(button)) {
        v = inflater.inflate(R.layout.home, parent, false);
    } else if (BACK.equals(button)) {
        v = inflater.inflate(R.layout.back, parent, false);
    } else if (RECENT.equals(button)) {
        v = inflater.inflate(R.layout.recent_apps, parent, false);
    } else if (MENU_IME.equals(button)) {
        v = inflater.inflate(R.layout.menu_ime, parent, false);
    } else if (NAVSPACE.equals(button)) {
        v = inflater.inflate(R.layout.nav_key_space, parent, false);
    } else if (CLIPBOARD.equals(button)) {
        v = inflater.inflate(R.layout.clipboard, parent, false);
    } else if (button.startsWith(KEY)) {
        String uri = extractImage(button);
        int code = extractKeycode(button);
        v = inflater.inflate(R.layout.custom_key, parent, false);
        ((KeyButtonView) v).setCode(code);
        if (uri != null) {
            ((KeyButtonView) v).loadAsync(uri);
        }
    } else {
        return null;
    }
    if (size != 0) {
        ViewGroup.LayoutParams params = v.getLayoutParams();
        params.width = (int) (params.width * size);
    }
    parent.addView(v);
    addToDispatchers(v);
    View lastView = landscape ? mLastLandscape : mLastPortrait;
    if (lastView != null) {
        v.setAccessibilityTraversalAfter(lastView.getId());
    }
    if (landscape) {
        mLastLandscape = v;
    } else {
        mLastPortrait = v;
    }
    return v;
}
Also used : KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) View(android.view.View) Nullable(android.annotation.Nullable)

Example 8 with KeyButtonView

use of com.android.systemui.statusbar.policy.KeyButtonView in project android_frameworks_base by DirtyUnicorns.

the class NavigationBarInflaterView method inflateButton.

@Nullable
protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape) {
    LayoutInflater inflater = landscape ? mLandscapeInflater : mLayoutInflater;
    float size = extractSize(buttonSpec);
    String button = extractButton(buttonSpec);
    View v = null;
    if (HOME.equals(button)) {
        v = inflater.inflate(R.layout.home, parent, false);
    } else if (BACK.equals(button)) {
        v = inflater.inflate(R.layout.back, parent, false);
    } else if (RECENT.equals(button)) {
        v = inflater.inflate(R.layout.recent_apps, parent, false);
    } else if (MENU_IME.equals(button)) {
        v = inflater.inflate(R.layout.menu_ime, parent, false);
    } else if (NAVSPACE.equals(button)) {
        v = inflater.inflate(R.layout.nav_key_space, parent, false);
    } else if (CLIPBOARD.equals(button)) {
        v = inflater.inflate(R.layout.clipboard, parent, false);
    } else if (button.startsWith(KEY)) {
        String uri = extractImage(button);
        int code = extractKeycode(button);
        v = inflater.inflate(R.layout.custom_key, parent, false);
        ((KeyButtonView) v).setCode(code);
        if (uri != null) {
            ((KeyButtonView) v).loadAsync(uri);
        }
    } else {
        return null;
    }
    if (size != 0) {
        ViewGroup.LayoutParams params = v.getLayoutParams();
        params.width = (int) (params.width * size);
    }
    parent.addView(v);
    addToDispatchers(v);
    View lastView = landscape ? mLastLandscape : mLastPortrait;
    if (lastView != null) {
        v.setAccessibilityTraversalAfter(lastView.getId());
    }
    if (landscape) {
        mLastLandscape = v;
    } else {
        mLastPortrait = v;
    }
    return v;
}
Also used : KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) View(android.view.View) Nullable(android.annotation.Nullable)

Example 9 with KeyButtonView

use of com.android.systemui.statusbar.policy.KeyButtonView in project android_frameworks_base by ResurrectionRemix.

the class NavigationBarInflaterView method inflateButton.

@Nullable
protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape) {
    LayoutInflater inflater = landscape ? mLandscapeInflater : mLayoutInflater;
    float size = extractSize(buttonSpec);
    String button = extractButton(buttonSpec);
    View v = null;
    if (HOME.equals(button)) {
        v = inflater.inflate(R.layout.home, parent, false);
    } else if (BACK.equals(button)) {
        v = inflater.inflate(R.layout.back, parent, false);
    } else if (RECENT.equals(button)) {
        v = inflater.inflate(R.layout.recent_apps, parent, false);
    } else if (MENU_IME.equals(button)) {
        v = inflater.inflate(R.layout.menu_ime, parent, false);
    } else if (NAVSPACE.equals(button)) {
        v = inflater.inflate(R.layout.nav_key_space, parent, false);
    } else if (CLIPBOARD.equals(button)) {
        v = inflater.inflate(R.layout.clipboard, parent, false);
    } else if (button.startsWith(KEY)) {
        String uri = extractImage(button);
        int code = extractKeycode(button);
        v = inflater.inflate(R.layout.custom_key, parent, false);
        ((KeyButtonView) v).setCode(code);
        if (uri != null) {
            ((KeyButtonView) v).loadAsync(uri);
        }
    } else {
        return null;
    }
    if (size != 0) {
        ViewGroup.LayoutParams params = v.getLayoutParams();
        params.width = (int) (params.width * size);
    }
    parent.addView(v);
    addToDispatchers(v);
    View lastView = landscape ? mLastLandscape : mLastPortrait;
    if (lastView != null) {
        v.setAccessibilityTraversalAfter(lastView.getId());
    }
    if (landscape) {
        mLastLandscape = v;
    } else {
        mLastPortrait = v;
    }
    return v;
}
Also used : KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) View(android.view.View) Nullable(android.annotation.Nullable)

Example 10 with KeyButtonView

use of com.android.systemui.statusbar.policy.KeyButtonView in project android_frameworks_base by crdroidandroid.

the class NavigationBarInflaterView method inflateButton.

@Nullable
protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape) {
    LayoutInflater inflater = landscape ? mLandscapeInflater : mLayoutInflater;
    float size = extractSize(buttonSpec);
    String button = extractButton(buttonSpec);
    View v = null;
    if (HOME.equals(button)) {
        v = inflater.inflate(R.layout.home, parent, false);
    } else if (BACK.equals(button)) {
        v = inflater.inflate(R.layout.back, parent, false);
    } else if (RECENT.equals(button)) {
        v = inflater.inflate(R.layout.recent_apps, parent, false);
    } else if (MENU_IME.equals(button)) {
        v = inflater.inflate(R.layout.menu_ime, parent, false);
    } else if (MENU_IME_ALWAYS_SHOW.equals(button)) {
        v = inflater.inflate(R.layout.menu_ime_always_show, parent, false);
    } else if (SEARCH.equals(button)) {
        v = inflater.inflate(R.layout.search, parent, false);
    } else if (NAVSPACE.equals(button)) {
        v = inflater.inflate(R.layout.nav_key_space, parent, false);
    } else if (CLIPBOARD.equals(button)) {
        v = inflater.inflate(R.layout.clipboard, parent, false);
    } else if (button.startsWith(KEY)) {
        String uri = extractImage(button);
        int code = extractKeycode(button);
        v = inflater.inflate(R.layout.custom_key, parent, false);
        ((KeyButtonView) v).setCode(code);
        if (uri != null) {
            ((KeyButtonView) v).loadAsync(uri);
        }
    } else {
        return null;
    }
    if (size != 0) {
        ViewGroup.LayoutParams params = v.getLayoutParams();
        params.width = (int) (params.width * size);
    }
    parent.addView(v);
    addToDispatchers(v);
    View lastView = landscape ? mLastLandscape : mLastPortrait;
    if (lastView != null) {
        v.setAccessibilityTraversalAfter(lastView.getId());
    }
    if (landscape) {
        mLastLandscape = v;
    } else {
        mLastPortrait = v;
    }
    return v;
}
Also used : KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) View(android.view.View) Nullable(android.annotation.Nullable)

Aggregations

KeyButtonView (com.android.systemui.statusbar.policy.KeyButtonView)11 ViewGroup (android.view.ViewGroup)8 View (android.view.View)7 Nullable (android.annotation.Nullable)5 LayoutInflater (android.view.LayoutInflater)5 RemoteException (android.os.RemoteException)3 IActivityManager (android.app.IActivityManager)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 LayoutTransition (android.animation.LayoutTransition)1 AlertDialog (android.app.AlertDialog)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 IntentFilter (android.content.IntentFilter)1 CustomTheme (android.content.res.CustomTheme)1 Point (android.graphics.Point)1 MotionEvent (android.view.MotionEvent)1 OnClickListener (android.view.View.OnClickListener)1 OnLongClickListener (android.view.View.OnLongClickListener)1 LayoutParams (android.view.ViewGroup.LayoutParams)1