GithubHelp home page GithubHelp logo

Comments (4)

jeacott avatar jeacott commented on June 20, 2024

A related problem is that the arrow position also gets messed up if you add different sized content to an existing quickaction object or try right aligning the control on a very small button.
the reason is because of the way the arrow left margin is calculated. would be nice if it were fixed.

from newquickaction3d.

TheVaan avatar TheVaan commented on June 20, 2024

Dudes, I solved your problem and I think this could be fixed in the main release too:

Replace the show function of the class QuickAction with the following:

public void show (View anchor) {
    preShow();

    int xPos, yPos, arrowPos; // int arrowPos is needed cause position of arrow has to be diffrent for buttons that are small and aligned to the right

    int[] location      = new int[2];

    anchor.getLocationOnScreen(location);

    Rect anchorRect     = new Rect(location[0], location[1], location[0] + anchor.getWidth(), location[1] 
                        + anchor.getHeight());

    //mRootView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    mRootView.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    int rootHeight      = mRootView.getMeasuredHeight();
    int rootWidth       = mRootView.getMeasuredWidth();

    int screenWidth     = mWindowManager.getDefaultDisplay().getWidth();
    int screenHeight    = mWindowManager.getDefaultDisplay().getHeight();

    //automatically get X coord of popup (top left)
    if ((anchorRect.left + rootWidth) > screenWidth) {
        xPos = anchorRect.right - (rootWidth-anchor.getWidth());
        arrowPos = anchorRect.right-xPos; // normally it is anchorRect.left-xPos but then there is a gap which is getting bigger on pressing the button a few times.
    } else {
        if (anchor.getWidth() > rootWidth) {
            xPos = anchorRect.centerX() - (rootWidth/2);
        } else {
            xPos = anchorRect.left;
        }
        arrowPos = anchorRect.centerX()-xPos; // that is the developers default
    }

    int dyTop           = anchorRect.top;
    int dyBottom        = screenHeight - anchorRect.bottom;

    boolean onTop       = (dyTop > dyBottom) ? true : false;

    if (onTop) {
        if (rootHeight > dyTop) {
            yPos            = 15;
            LayoutParams l  = mScroller.getLayoutParams();
            l.height        = dyTop - anchor.getHeight();
        } else {
            yPos = anchorRect.top - rootHeight;
        }
    } else {
        yPos = anchorRect.bottom;

        if (rootHeight > dyBottom) { 
            LayoutParams l  = mScroller.getLayoutParams();
            l.height        = dyBottom;
        }
    }

    showArrow(((onTop) ? R.id.arrow_down : R.id.arrow_up), arrowPos); // replaced developers default value with the var so in special cases the popup AND the arrow are displayed constrained to the right

    setAnimationStyle(screenWidth, anchorRect.centerX(), onTop);

    mWindow.showAtLocation(anchor, Gravity.NO_GRAVITY, xPos, yPos);
}

You can see a screenshot here: http://twitpic.com/6w4lnj (sorry for motion blur but I'm not allowed to show the layout of the app currently :/)

Hope I could help you!

from newquickaction3d.

lorensiuswlt avatar lorensiuswlt commented on June 20, 2024

This bug has been fixed on current update, thanx TheVaan for giving me the clue..

from newquickaction3d.

jeacott avatar jeacott commented on June 20, 2024

2 things - the existing update to the main line doesnt work properly for me.

  1. on rotation it calculates the arrow location incorrectly. I did this to fix :

//automatically get X coord of popup (top left)
//if ((anchorRect.left + rootWidth) > screenWidth) {
xPos = anchorRect.left - (rootWidth-anchor.getWidth());
xPos = (xPos < 0) ? 0 : xPos;
arrowPos = anchorRect.centerX()-xPos;
/} else {
if (anchor.getWidth() > rootWidth) {
xPos = anchorRect.centerX() - (rootWidth/2);
} else {
xPos = anchorRect.left;
}
arrowPos = anchorRect.centerX()-xPos;
}
/

  1. on my devices I needed to restore the line:
    mRootView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

without it I just get exceptions.

from newquickaction3d.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.