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

Commit 47f333af authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev
Browse files

Custom pointer icon for DatePicker and TimePicker

Bug: 31652821
Change-Id: I512693a48c8c2f8ca96983efaaae3af138827ee7
parent feef9897
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.widget;

import android.view.PointerIcon;
import com.android.internal.R;
import com.android.internal.widget.ExploreByTouchHelper;

@@ -1052,6 +1053,18 @@ public class RadialTimePickerView extends View {
        invalidate();
    }

    @Override
    public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
        if (!isEnabled()) {
            return null;
        }
        final int degrees = getDegreesFromXY(event.getX(), event.getY(), false);
        if (degrees != -1) {
            return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND);
        }
        return super.onResolvePointerIcon(event, pointerIndex);
    }

    private class RadialPickerTouchHelper extends ExploreByTouchHelper {
        private final Rect mTempRect = new Rect();

+16 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.widget;

import android.view.PointerIcon;
import com.android.internal.R;
import com.android.internal.widget.ExploreByTouchHelper;

@@ -1025,6 +1026,21 @@ class SimpleMonthView extends View {
        return true;
    }

    @Override
    public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
        if (!isEnabled()) {
            return null;
        }
        // Add 0.5f to event coordinates to match the logic in onTouchEvent.
        final int x = (int) (event.getX() + 0.5f);
        final int y = (int) (event.getY() + 0.5f);
        final int dayUnderPointer = getDayAtLocation(x, y);
        if (dayUnderPointer >= 0) {
            return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND);
        }
        return super.onResolvePointerIcon(event, pointerIndex);
    }

    /**
     * Provides a virtual view hierarchy for interfacing with an accessibility
     * service.
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@
                android:ellipsize="none"
                android:gravity="right"
                android:focusable="true"
                android:pointerIcon="hand"
                android:nextFocusForward="@+id/minutes" />

            <TextView
@@ -83,6 +84,7 @@
                android:ellipsize="none"
                android:gravity="left"
                android:focusable="true"
                android:pointerIcon="hand"
                android:nextFocusForward="@+id/am_label" />
        </LinearLayout>

+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
            android:padding="8dp"
            android:background="?attr/selectableItemBackground"
            android:textAppearance="@style/TextAppearance.Material.DatePicker.YearLabel"
            android:pointerIcon="hand"
            android:nextFocusForward="@+id/prev" />

        <TextView
@@ -55,6 +56,7 @@
            android:includeFontPadding="false"
            android:gravity="start"
            android:maxLines="@integer/date_picker_header_max_lines_material"
            android:pointerIcon="hand"
            android:ellipsize="none" />
    </LinearLayout>
</LinearLayout>
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
        android:ellipsize="none"
        android:gravity="right"
        android:focusable="true"
        android:pointerIcon="hand"
        android:nextFocusForward="@+id/minutes" />

    <TextView
@@ -64,6 +65,7 @@
        android:ellipsize="none"
        android:gravity="left"
        android:focusable="true"
        android:pointerIcon="hand"
        android:nextFocusForward="@+id/am_label" />

    <!-- The layout alignment of this view will switch between toRightOf