Search in sources :

Example 1 with SmartButtonView

use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.

the class SmartBarView method updateAnimationStyle.

private void updateAnimationStyle() {
    mButtonAnimationStyle = Settings.Secure.getIntForUser(getContext().getContentResolver(), "smartbar_button_animation_style", SmartButtonView.ANIM_STYLE_RIPPLE, UserHandle.USER_CURRENT);
    ViewGroup hidden = (ViewGroup) getHiddenView().findViewWithTag(Res.Common.NAV_BUTTONS);
    for (String buttonTag : mCurrentSequence) {
        SmartButtonView v = findCurrentButton(buttonTag);
        if (v != null) {
            v.setAnimationStyle(mScreenPinningEnabled ? SmartButtonView.ANIM_STYLE_RIPPLE : mButtonAnimationStyle);
        }
        v = (SmartButtonView) hidden.findViewWithTag(buttonTag);
        if (v != null) {
            v.setAnimationStyle(mScreenPinningEnabled ? SmartButtonView.ANIM_STYLE_RIPPLE : mButtonAnimationStyle);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView)

Example 2 with SmartButtonView

use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.

the class SmartBarView method recreateButtonLayout.

void recreateButtonLayout(ArrayList<ButtonConfig> buttonConfigs, boolean landscape, boolean updateCurrentButtons) {
    int extraKeyWidth = getContext().getResources().getDimensionPixelSize(R.dimen.navigation_extra_key_width);
    int extraKeyHeight = getContext().getResources().getDimensionPixelSize(R.dimen.navigation_extra_key_height);
    LinearLayout navButtonLayout = (LinearLayout) (landscape ? mRot90.findViewWithTag(Res.Common.NAV_BUTTONS) : mRot0.findViewWithTag(Res.Common.NAV_BUTTONS));
    navButtonLayout.removeAllViews();
    if (buttonConfigs == null) {
        buttonConfigs = Config.getConfig(getContext(), ActionConstants.getDefaults(ActionConstants.SMARTBAR));
    }
    // left context frame layout
    FrameLayout leftContext = generateContextKeyLayout(landscape, Res.Softkey.CONTEXT_VIEW_LEFT, extraKeyWidth, extraKeyHeight);
    SmartBarHelper.addViewToRoot(navButtonLayout, leftContext, landscape);
    // tablets get a spacer here
    if (BaseNavigationBar.sIsTablet) {
        SmartBarHelper.addViewToRoot(navButtonLayout, SmartBarHelper.makeSeparator(getContext()), landscape);
    }
    // softkey buttons
    ButtonConfig buttonConfig;
    int dimen = SmartBarHelper.getButtonSize(getContext(), buttonConfigs.size(), landscape);
    for (int j = 0; j < buttonConfigs.size(); j++) {
        buttonConfig = buttonConfigs.get(j);
        OpaLayout v = SmartBarHelper.generatePrimaryKey(getContext(), this, landscape, buttonConfig);
        SmartBarHelper.updateButtonSize(v, dimen, landscape);
        SmartButtonView sb = v.getButton();
        SmartBarHelper.updateButtonSize(sb, dimen, landscape);
        SmartBarHelper.addViewToRoot(navButtonLayout, v, landscape);
        // only add once for master sequence holder
        if (updateCurrentButtons) {
            mCurrentSequence.add((String) v.getButton().getTag());
        }
        // tablets get a spacer before first and after last
        if (j != buttonConfigs.size() - 1 && !BaseNavigationBar.sIsTablet) {
            // adding spacers between buttons on phones
            SmartBarHelper.addViewToRoot(navButtonLayout, SmartBarHelper.makeSeparator(getContext()), landscape);
        }
        if (j == buttonConfigs.size() - 1 && BaseNavigationBar.sIsTablet) {
            // adding spacers after last button on tablets
            SmartBarHelper.addViewToRoot(navButtonLayout, SmartBarHelper.makeSeparator(getContext()), landscape);
        }
    }
    // right context frame layout
    FrameLayout rightContext = generateContextKeyLayout(landscape, Res.Softkey.CONTEXT_VIEW_RIGHT, extraKeyWidth, extraKeyHeight);
    SmartBarHelper.addViewToRoot(navButtonLayout, rightContext, landscape);
}
Also used : ButtonConfig(com.android.internal.utils.du.Config.ButtonConfig) OpaLayout(com.android.systemui.navigation.OpaLayout) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView) FrameLayout(android.widget.FrameLayout) LinearLayout(android.widget.LinearLayout)

Example 3 with SmartButtonView

use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.

the class SmartBarView method generateContextKey.

private SmartButtonView generateContextKey(boolean landscape, String tag) {
    SmartButtonView v = new SmartButtonView(getContext());
    ButtonConfig buttonConfig = new ButtonConfig(getContext());
    ActionConfig actionConfig = new ActionConfig(getContext());
    int extraKeyWidth = getContext().getResources().getDimensionPixelSize(R.dimen.navigation_extra_key_width);
    int extraKeyHeight = getContext().getResources().getDimensionPixelSize(R.dimen.navigation_extra_key_height);
    v.setHost(this);
    v.setLayoutParams(new FrameLayout.LayoutParams(landscape && !BaseNavigationBar.sIsTablet ? LayoutParams.MATCH_PARENT : extraKeyWidth, landscape && !BaseNavigationBar.sIsTablet ? extraKeyHeight : LayoutParams.MATCH_PARENT));
    v.loadRipple();
    v.setScaleType(ScaleType.CENTER_INSIDE);
    if (tag.equals(Res.Softkey.MENU_BUTTON)) {
        actionConfig = new ActionConfig(getContext(), ActionHandler.SYSTEMUI_TASK_MENU);
    } else if (tag.equals(Res.Softkey.IME_SWITCHER)) {
        actionConfig = new ActionConfig(getContext(), ActionHandler.SYSTEMUI_TASK_IME_SWITCHER);
    } else if (tag.equals(Res.Softkey.IME_ARROW_LEFT)) {
        actionConfig = new ActionConfig(getContext(), ActionHandler.SYSTEMUI_TASK_IME_NAVIGATION_LEFT);
    } else if (tag.equals(Res.Softkey.IME_ARROW_RIGHT)) {
        actionConfig = new ActionConfig(getContext(), ActionHandler.SYSTEMUI_TASK_IME_NAVIGATION_RIGHT);
    } else if (tag.equals(Res.Softkey.MEDIA_ARROW_LEFT)) {
        actionConfig = new ActionConfig(getContext(), ActionHandler.SYSTEMUI_TASK_MEDIA_PREVIOUS);
    } else if (tag.equals(Res.Softkey.MEDIA_ARROW_RIGHT)) {
        actionConfig = new ActionConfig(getContext(), ActionHandler.SYSTEMUI_TASK_MEDIA_NEXT);
    }
    buttonConfig.setActionConfig(actionConfig, ActionConfig.PRIMARY);
    buttonConfig.setTag(tag);
    v.setButtonConfig(buttonConfig);
    v.setVisibility(View.INVISIBLE);
    setButtonDrawable(v);
    v.setContentDescription(buttonConfig.getActionConfig(ActionConfig.PRIMARY).getLabel());
    v.setAnimationStyle(SmartButtonView.ANIM_STYLE_RIPPLE);
    return v;
}
Also used : ActionConfig(com.android.internal.utils.du.Config.ActionConfig) ButtonConfig(com.android.internal.utils.du.Config.ButtonConfig) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView) FrameLayout(android.widget.FrameLayout)

Example 4 with SmartButtonView

use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.

the class SmartBarHelper method generatePrimaryKey.

static OpaLayout generatePrimaryKey(Context ctx, SmartBarView host, boolean landscape, ButtonConfig config) {
    OpaLayout opa = (OpaLayout) View.inflate(ctx, R.layout.opa_smartbutton, null);
    SmartButtonView v = opa.getButton();
    v.setHost(host);
    v.setButtonConfig(config);
    int width = ctx.getResources().getDimensionPixelSize(R.dimen.navigation_key_width);
    int height = ctx.getResources().getDimensionPixelSize(R.dimen.navigation_key_height);
    v.loadRipple();
    updateButtonScalingAndPadding(opa, landscape);
    host.setButtonDrawable(v);
    if (BaseNavigationBar.sIsTablet) {
        v.setLayoutParams(new FrameLayout.LayoutParams(width, LayoutParams.MATCH_PARENT));
        opa.setLayoutParams(new LinearLayout.LayoutParams(width, LayoutParams.MATCH_PARENT));
    } else {
        if (landscape) {
            v.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, height));
            opa.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, height));
        } else {
            v.setLayoutParams(new FrameLayout.LayoutParams(width, LayoutParams.MATCH_PARENT));
            opa.setLayoutParams(new LinearLayout.LayoutParams(width, LayoutParams.MATCH_PARENT));
        }
    }
    return opa;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) OpaLayout(com.android.systemui.navigation.OpaLayout) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView) FrameLayout(android.widget.FrameLayout) LinearLayout(android.widget.LinearLayout)

Example 5 with SmartButtonView

use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.

the class SmartBarView method setListeners.

@Override
public void setListeners(OnTouchListener userAutoHideListener, View.OnLongClickListener longPressBackListener) {
    super.setListeners(userAutoHideListener, longPressBackListener);
    setOnTouchListener(mUserAutoHideListener);
    getBackButton().setScreenPinningMode(mScreenPinningEnabled);
    getBackButton().setLongPressBackListener(mLongPressBackListener);
    ViewGroup hidden = (ViewGroup) getHiddenView().findViewWithTag(Res.Common.NAV_BUTTONS);
    SmartButtonView back = (SmartButtonView) hidden.findViewWithTag(Res.Softkey.BUTTON_BACK);
    back.setScreenPinningMode(mScreenPinningEnabled);
    back.setLongPressBackListener(mLongPressBackListener);
}
Also used : ViewGroup(android.view.ViewGroup) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView)

Aggregations

SmartButtonView (com.android.systemui.navigation.smartbar.SmartButtonView)19 OpaLayout (com.android.systemui.navigation.OpaLayout)11 ButtonConfig (com.android.internal.utils.du.Config.ButtonConfig)8 ViewGroup (android.view.ViewGroup)5 FrameLayout (android.widget.FrameLayout)5 Point (android.graphics.Point)3 LinearLayout (android.widget.LinearLayout)3 ActionConfig (com.android.internal.utils.du.Config.ActionConfig)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 View (android.view.View)1 OvershootInterpolator (android.view.animation.OvershootInterpolator)1 ImageView (android.widget.ImageView)1 LayoutParams (android.widget.LinearLayout.LayoutParams)1 SmartBarView (com.android.systemui.navigation.smartbar.SmartBarView)1 ArrayList (java.util.ArrayList)1