Search in sources :

Example 1 with ButtonConfig

use of com.android.internal.utils.du.Config.ButtonConfig in project android_frameworks_base by DirtyUnicorns.

the class HardkeyActionHandler method updateKeyAssignments.

private void updateKeyAssignments() {
    ContentResolver cr = mContext.getContentResolver();
    synchronized (mLock) {
        mHwKeysDisabled = Settings.Secure.getIntForUser(cr, Settings.Secure.HARDWARE_KEYS_DISABLE, 0, UserHandle.USER_CURRENT) != 0;
        final boolean hasMenu = (mDeviceHardwareKeys & KEY_MASK_MENU) != 0;
        final boolean hasHome = (mDeviceHardwareKeys & KEY_MASK_HOME) != 0;
        final boolean hasAssist = (mDeviceHardwareKeys & KEY_MASK_ASSIST) != 0;
        final boolean hasAppSwitch = (mDeviceHardwareKeys & KEY_MASK_APP_SWITCH) != 0;
        ArrayList<ButtonConfig> configs = Config.getConfig(mContext, ActionConstants.getDefaults(ActionConstants.HWKEYS));
        ButtonConfig config = Config.getButtonConfigFromTag(configs, ActionConstants.Hwkeys.BACK_BUTTON_TAG);
        mBackButton.setConfig(config);
        config = Config.getButtonConfigFromTag(configs, ActionConstants.Hwkeys.HOME_BUTTON_TAG);
        mHomeButton.setConfig(config);
        config = Config.getButtonConfigFromTag(configs, ActionConstants.Hwkeys.OVERVIEW_BUTTON_TAG);
        mRecentButton.setConfig(config);
        config = Config.getButtonConfigFromTag(configs, ActionConstants.Hwkeys.MENU_BUTTON_TAG);
        mMenuButton.setConfig(config);
        config = Config.getButtonConfigFromTag(configs, ActionConstants.Hwkeys.ASSIST_BUTTON_TAG);
        mAssistButton.setConfig(config);
        boolean hasMenuKeyEnabled = false;
        if (hasHome) {
            hasMenuKeyEnabled = mHomeButton.keyHasMenuAction();
        }
        if (hasMenu) {
            hasMenuKeyEnabled |= mMenuButton.keyHasMenuAction();
        }
        if (hasAssist) {
            hasMenuKeyEnabled |= mAssistButton.keyHasMenuAction();
        }
        if (hasAppSwitch) {
            hasMenuKeyEnabled |= mRecentButton.keyHasMenuAction();
        }
        hasMenuKeyEnabled |= mBackButton.keyHasMenuAction();
        // let PWM know to update menu key settings
        Message msg = mHandler.obtainMessage(MSG_UPDATE_MENU_KEY);
        msg.arg1 = hasMenuKeyEnabled ? 1 : 0;
        mHandler.sendMessage(msg);
    //            mRingHomeBehavior = Settings.Secure.getIntForUser(cr,
    //                    Settings.Secure.RING_HOME_BUTTON_BEHAVIOR,
    //                    Settings.Secure.RING_HOME_BUTTON_BEHAVIOR_DEFAULT,
    //                    UserHandle.USER_CURRENT);
    }
}
Also used : ButtonConfig(com.android.internal.utils.du.Config.ButtonConfig) Message(android.os.Message) ContentResolver(android.content.ContentResolver)

Example 2 with ButtonConfig

use of com.android.internal.utils.du.Config.ButtonConfig 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 ButtonConfig

use of com.android.internal.utils.du.Config.ButtonConfig in project android_packages_apps_DUI by DirtyUnicorns.

the class SmartBarView method setButtonDrawable.

public void setButtonDrawable(SmartButtonView button) {
    ButtonConfig config = button.getButtonConfig();
    Drawable d = null;
    if (config != null) {
        // a system navigation action icon is showing, get it locally
        if (!config.hasCustomIcon() && config.isSystemAction()) {
            d = mResourceMap.getActionDrawable(config.getActionConfig(ActionConfig.PRIMARY).getAction());
        } else {
            // custom icon or intent icon, get from library
            d = config.getCurrentIcon(getContext());
        }
        if (TextUtils.equals(config.getTag(), Res.Softkey.BUTTON_BACK)) {
            SmartBackButtonDrawable backDrawable = new SmartBackButtonDrawable(d);
            button.setImageDrawable(null);
            button.setImageDrawable(backDrawable);
            final boolean backAlt = (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
            backDrawable.setImeVisible(backAlt);
        } else {
            button.setImageDrawable(null);
            button.setImageDrawable(d);
        }
    }
}
Also used : ButtonConfig(com.android.internal.utils.du.Config.ButtonConfig) Drawable(android.graphics.drawable.Drawable) SmartBackButtonDrawable(com.android.systemui.navigation.smartbar.SmartBackButtonDrawable) SmartBackButtonDrawable(com.android.systemui.navigation.smartbar.SmartBackButtonDrawable)

Example 4 with ButtonConfig

use of com.android.internal.utils.du.Config.ButtonConfig 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 5 with ButtonConfig

use of com.android.internal.utils.du.Config.ButtonConfig in project android_packages_apps_DUI by DirtyUnicorns.

the class SmartBarEditor method addButton.

private void addButton() {
    mLockEditMode = true;
    final String buttonFocus = getEditButtonTag();
    ArrayList<ButtonConfig> buttonConfigs = Config.getConfig(mContext, ActionConstants.getDefaults(ActionConstants.SMARTBAR));
    int newIndex = mHost.getCurrentSequence().indexOf(buttonFocus) + 1;
    String newTag = String.valueOf(System.currentTimeMillis());
    ButtonConfig newConfig = new ButtonConfig(mContext);
    newConfig.setTag(newTag);
    buttonConfigs.add(newIndex, newConfig);
    Config.setConfig(mContext, ActionConstants.getDefaults(ActionConstants.SMARTBAR), buttonConfigs);
    mHost.recreateLayouts();
    setButtonsEditMode(true);
    mLockEditMode = false;
}
Also used : ButtonConfig(com.android.internal.utils.du.Config.ButtonConfig) Point(android.graphics.Point)

Aggregations

ButtonConfig (com.android.internal.utils.du.Config.ButtonConfig)20 SmartButtonView (com.android.systemui.navigation.smartbar.SmartButtonView)8 ActionConfig (com.android.internal.utils.du.Config.ActionConfig)5 OpaLayout (com.android.systemui.navigation.OpaLayout)5 Point (android.graphics.Point)3 ContentResolver (android.content.ContentResolver)2 Message (android.os.Message)2 FrameLayout (android.widget.FrameLayout)2 ActionPreference (com.android.settings.rr.Preferences.ActionPreference)2 Intent (android.content.Intent)1 Drawable (android.graphics.drawable.Drawable)1 ViewGroup (android.view.ViewGroup)1 ScaleType (android.widget.ImageView.ScaleType)1 LinearLayout (android.widget.LinearLayout)1 ConfigMap (com.android.internal.utils.du.ActionConstants.ConfigMap)1 SmartBackButtonDrawable (com.android.systemui.navigation.smartbar.SmartBackButtonDrawable)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1