Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8449aeaf authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adding tooltip for Select button." into ub-launcher3-rvc-dev

parents 6fd62fde da727bbb
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -60,6 +60,5 @@
        android:elevation="2dp"
        android:layout_width="10dp"
        android:layout_height="8dp"
        android:layout_marginTop="-2dp"
        android:layout_gravity="center_horizontal"/>
        android:layout_marginTop="-2dp"/>
</merge>
+26 −2
Original line number Diff line number Diff line
@@ -125,11 +125,35 @@ public class ArrowTipView extends AbstractFloatingView {
     * Show Tip with specified string and Y location
     */
    public ArrowTipView show(String text, int top) {
        return show(text, Gravity.CENTER_HORIZONTAL, 0, top);
    }

    /**
     * Show the ArrowTipView (tooltip) center, start, or end aligned.
     *
     * @param text The text to be shown in the tooltip.
     * @param gravity The gravity aligns the tooltip center, start, or end.
     * @param arrowMarginStart The margin from start to place arrow (ignored if center)
     * @param top  The Y coordinate of the bottom of tooltip.
     * @return The tooltip.
     */
    public ArrowTipView show(String text, int gravity, int arrowMarginStart, int top) {
        ((TextView) findViewById(R.id.text)).setText(text);
        mActivity.getDragLayer().addView(this);
        ViewGroup parent = mActivity.getDragLayer();
        parent.addView(this);

        DragLayer.LayoutParams params = (DragLayer.LayoutParams) getLayoutParams();
        params.gravity = Gravity.CENTER_HORIZONTAL;
        params.gravity = gravity;
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) findViewById(
                R.id.arrow).getLayoutParams();
        lp.gravity = gravity;
        if (gravity == Gravity.END) {
            lp.setMarginEnd(parent.getMeasuredWidth() - arrowMarginStart);
        } else if (gravity == Gravity.START) {
            lp.setMarginStart(arrowMarginStart);
        }
        requestLayout();

        params.leftMargin = mActivity.getDeviceProfile().workspacePadding.left;
        params.rightMargin = mActivity.getDeviceProfile().workspacePadding.right;
        post(() -> setY(top - getHeight()));