Search in sources :

Example 11 with SmartButtonView

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

the class SmartBarEditor method findInterceptingView.

/**
     * Find intersecting view in mButtonViews
     * 
     * @param pos - pointer location
     * @param v - view being dragged
     * @return intersecting view or null
     */
private View findInterceptingView(float pos, View v) {
    for (String buttonTag : mHost.getCurrentSequence()) {
        SmartButtonView otherButton = mHost.findCurrentButton(buttonTag);
        OpaLayout otherOpa = (OpaLayout) otherButton.getParent();
        if (otherOpa == v) {
            continue;
        }
        if (mSquatters.contains(otherOpa)) {
            continue;
        }
        otherOpa.getLocationOnScreen(sLocation);
        float otherPos = sLocation[mHost.isVertical() ? 1 : 0];
        float otherDimension = mHost.isVertical() ? v.getHeight() : v.getWidth();
        if (pos > (otherPos + otherDimension / 4) && pos < (otherPos + otherDimension)) {
            mSquatters.add(otherOpa);
            return otherOpa;
        }
    }
    return null;
}
Also used : OpaLayout(com.android.systemui.navigation.OpaLayout) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView)

Example 12 with SmartButtonView

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

the class SmartBarEditor method switchId.

/**
     * Switches positions of two views and updates their mButtonViews entry
     * 
     * @param targetView - view to be replaced animate out
     * @param view - view being dragged
     */
private void switchId(View replaceView, View dragView) {
    final OpaLayout squatter = (OpaLayout) replaceView;
    final OpaLayout dragger = (OpaLayout) dragView;
    final boolean vertical = mHost.isVertical();
    ViewGroup parent = (ViewGroup) replaceView.getParent();
    float slideTo = vertical ? mDragOrigin - parent.getTop() : mDragOrigin - parent.getLeft();
    replaceView.getLocationOnScreen(sLocation);
    mDragOrigin = sLocation[vertical ? 1 : 0];
    final int targetIndex = mHost.getCurrentSequence().indexOf(squatter.getButton().getTag());
    final int draggedIndex = mHost.getCurrentSequence().indexOf(dragger.getButton().getTag());
    Collections.swap(mHost.getCurrentSequence(), draggedIndex, targetIndex);
    SmartButtonView hidden1 = (SmartButtonView) getHiddenNavButtons().findViewWithTag(squatter.getButton().getTag());
    SmartButtonView hidden2 = (SmartButtonView) getHiddenNavButtons().findViewWithTag(dragger.getButton().getTag());
    OpaLayout hidden1Opa = (OpaLayout) hidden1.getParent();
    OpaLayout hidden2Opa = (OpaLayout) hidden2.getParent();
    swapConfigs(hidden1Opa, hidden2Opa);
    Animator anim = getButtonSlideAnimator(squatter, vertical, slideTo);
    anim.setInterpolator(new OvershootInterpolator());
    anim.setDuration(250);
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mSquatters.remove(squatter);
        }
    });
    anim.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) OpaLayout(com.android.systemui.navigation.OpaLayout) OvershootInterpolator(android.view.animation.OvershootInterpolator) ViewGroup(android.view.ViewGroup) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Point(android.graphics.Point)

Example 13 with SmartButtonView

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

the class SmartBarEditor method onIconPicked.

@Override
protected void onIconPicked(String type, String packageName, String iconName) {
    final String buttonFocus = getEditButtonTag();
    SmartButtonView currentButton = mHost.findCurrentButton(buttonFocus);
    SmartButtonView otherButton = (SmartButtonView) getHiddenNavButtons().findViewWithTag(buttonFocus);
    ButtonConfig currentConfig = currentButton.getButtonConfig();
    ButtonConfig otherConfig = otherButton.getButtonConfig();
    OpaLayout currentOpa = (OpaLayout) currentButton.getParent();
    OpaLayout otherOpa = (OpaLayout) otherButton.getParent();
    currentConfig.setCustomIconUri(type, packageName, iconName);
    otherConfig.setCustomIconUri(type, packageName, iconName);
    currentButton.setButtonConfig(currentConfig);
    otherButton.setButtonConfig(otherConfig);
    mHost.setButtonDrawable(currentButton);
    SmartBarHelper.updateButtonScalingAndPadding(currentOpa, isLandscape());
    mHost.setButtonDrawable(otherButton);
    SmartBarHelper.updateButtonScalingAndPadding(otherOpa, !isLandscape());
    onCommitChanges();
}
Also used : ButtonConfig(com.android.internal.utils.du.Config.ButtonConfig) OpaLayout(com.android.systemui.navigation.OpaLayout) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView)

Example 14 with SmartButtonView

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

the class SmartBarEditor method onCommitChanges.

@Override
public void onCommitChanges() {
    ArrayList<ButtonConfig> buttonConfigs = new ArrayList<ButtonConfig>();
    final int size = mHost.getCurrentSequence().size();
    for (int i = 0; i < size; i++) {
        String tag = mHost.getCurrentSequence().get(i);
        SmartButtonView v = mHost.findCurrentButton(tag);
        if (v == null)
            continue;
        ButtonConfig config = v.getButtonConfig();
        if (config == null)
            continue;
        buttonConfigs.add(config);
    }
    Config.setConfig(mContext, ActionConstants.getDefaults(ActionConstants.SMARTBAR), buttonConfigs);
}
Also used : ButtonConfig(com.android.internal.utils.du.Config.ButtonConfig) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView) ArrayList(java.util.ArrayList) Point(android.graphics.Point)

Example 15 with SmartButtonView

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

the class SmartBarView method setDisabledFlags.

@Override
public void setDisabledFlags(int disabledFlags, boolean force) {
    super.setDisabledFlags(disabledFlags, force);
    if (mEditor != null) {
        mEditor.changeEditMode(BaseEditor.MODE_OFF);
    }
    final boolean disableHome = ((disabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);
    final boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
    final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0) && ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0);
    OpaLayout opaBack = (OpaLayout) getBackButton().getParent();
    opaBack.setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
    OpaLayout opaHome = (OpaLayout) getHomeButton().getParent();
    opaHome.setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);
    // to disable custom buttons as well
    for (String buttonTag : mCurrentSequence) {
        SmartButtonView v = findCurrentButton(buttonTag);
        OpaLayout opa = (OpaLayout) v.getParent();
        if (v != null && v != getBackButton() && v != getHomeButton()) {
            if (disableHome || disableBack || disableRecent) {
                opa.setVisibility(View.INVISIBLE);
            } else {
                opa.setVisibility(View.VISIBLE);
            }
        }
    }
}
Also used : OpaLayout(com.android.systemui.navigation.OpaLayout) 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