TourGuide icon indicating copy to clipboard operation
TourGuide copied to clipboard

getYForTooTip does not handle CENTER_VERTICAL gravity

Open peterosterlund2 opened this issue 9 years ago • 1 comments

I think the getYForTooTip method should look something like this:

private int getYForTooTip(int gravity, int toolTipMeasuredHeight, int targetViewY, float adjustment){
    int y;
    if ((gravity & Gravity.TOP) == Gravity.TOP) {

        if (((gravity & Gravity.LEFT) == Gravity.LEFT) || ((gravity & Gravity.RIGHT) == Gravity.RIGHT)) {
            y =  targetViewY - toolTipMeasuredHeight + (int)adjustment;
        } else {
            y =  targetViewY - toolTipMeasuredHeight - (int)adjustment;
        }
    } else if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
        if (((gravity & Gravity.LEFT) == Gravity.LEFT) || ((gravity & Gravity.RIGHT) == Gravity.RIGHT)) {
            y =  targetViewY + mHighlightedView.getHeight() - (int) adjustment;
        } else {
            y =  targetViewY + mHighlightedView.getHeight() + (int) adjustment;
        }
    } else { // this is center
        if (((gravity & Gravity.LEFT) == Gravity.LEFT) || ((gravity & Gravity.RIGHT) == Gravity.RIGHT)) {
            y =  targetViewY + mHighlightedView.getHeight() / 2 - (int) adjustment;
        } else {
            y =  targetViewY + mHighlightedView.getHeight() / 2 + (int) adjustment;
        }
    }
    return y;
}

peterosterlund2 avatar Jan 11 '16 21:01 peterosterlund2

Hi @peterosterlund2 Your code actually looks good, that should fix Gravity.BOTTOM, can you make a pull request?

I will then test and merge it.

worker8 avatar Jan 12 '16 13:01 worker8