Search in sources :

Example 6 with OpaLayout

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

the class SmartBarEditor method resetIcon.

private void resetIcon() {
    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.clearCustomIconIconUri();
    otherConfig.clearCustomIconIconUri();
    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 7 with OpaLayout

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

the class SmartBarEditor method onImagePicked.

protected void onImagePicked(String uri) {
    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.setCustomImageUri(Uri.parse(uri));
    otherConfig.setCustomImageUri(Uri.parse(uri));
    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 8 with OpaLayout

use of com.android.systemui.navigation.OpaLayout 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 9 with OpaLayout

use of com.android.systemui.navigation.OpaLayout 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 10 with OpaLayout

use of com.android.systemui.navigation.OpaLayout 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)

Aggregations

OpaLayout (com.android.systemui.navigation.OpaLayout)15 SmartButtonView (com.android.systemui.navigation.smartbar.SmartButtonView)11 ButtonConfig (com.android.internal.utils.du.Config.ButtonConfig)5 Point (android.graphics.Point)2 ViewGroup (android.view.ViewGroup)2 FrameLayout (android.widget.FrameLayout)2 LinearLayout (android.widget.LinearLayout)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 OvershootInterpolator (android.view.animation.OvershootInterpolator)1 LayoutParams (android.widget.LinearLayout.LayoutParams)1 ActionConfig (com.android.internal.utils.du.Config.ActionConfig)1