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

Commit 912ab850 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Revamp of the NumberPicker widget.

1. The number picker no longer shows up and down arrows, it
   has only three touch targets which are the currently selected number
   in the middle with a lesser one above and greater below, now what
   you touch is what you get, flingability and long press are still
   supported.

2. Removed the restriction for a View with an AccessibilityNodeProvider
   to not have any concrete children. If the View has a provider, then
   this provider is responsible for creating the AccessibilityNodeInfos
   for all its descendants, concrete and virtual. The number picker is
   a good example for such a case - it has a concrete input view and
   two virtual buttons as its children. This is a safe change since
   this behavior has not been released.

3. This patch also fixes bug where the number picker is stretched too
   much in the Theme theme.

bug:6177794
bug:5728294

Change-Id: Id8c0b3549174b9599f971d6e3086ca427cfbaa39
parent 958ec9d0
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -26924,7 +26924,6 @@ package android.widget {
    method public void setOnValueChangedListener(android.widget.NumberPicker.OnValueChangeListener);
    method public void setValue(int);
    method public void setWrapSelectorWheel(boolean);
    field public static final int SELECTOR_WHEEL_ITEM_COUNT = 5; // 0x5
  }
  public static abstract interface NumberPicker.Formatter {
+0 −14
Original line number Diff line number Diff line
@@ -2679,15 +2679,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        return child.draw(canvas, this, drawingTime);
    }

    @Override
    public void requestLayout() {
        if (mChildrenCount > 0 && getAccessibilityNodeProvider() != null) {
            throw new IllegalStateException("Views with AccessibilityNodeProvider"
                    + " can't have children.");
        }
        super.requestLayout();
    }

    /**
     * 
     * @param enabled True if children should be drawn with layers, false otherwise.
@@ -3109,11 +3100,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
    private void addViewInner(View child, int index, LayoutParams params,
            boolean preventRequestLayout) {

        if (getAccessibilityNodeProvider() != null) {
            throw new IllegalStateException("Views with AccessibilityNodeProvider"
                    + " can't have children.");
        }

        if (mTransition != null) {
            // Don't prevent other add transitions from completing, but cancel remove
            // transitions to let them complete the process before we add to the container
+21 −16
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
@@ -280,10 +280,8 @@ public class DatePicker extends FrameLayout {
        reorderSpinners();

        // set content descriptions
        if (AccessibilityManager.getInstance(mContext).isEnabled()) {
        setContentDescriptions();
    }
    }

    /**
     * Gets the minimal date supported by this {@link DatePicker} in
@@ -717,20 +715,27 @@ public class DatePicker extends FrameLayout {

    private void setContentDescriptions() {
        // Day
        String text = mContext.getString(R.string.date_picker_increment_day_button);
        mDaySpinner.findViewById(R.id.increment).setContentDescription(text);
        text = mContext.getString(R.string.date_picker_decrement_day_button);
        mDaySpinner.findViewById(R.id.decrement).setContentDescription(text);
        trySetContentDescription(mDaySpinner, R.id.increment,
                R.string.date_picker_increment_day_button);
        trySetContentDescription(mDaySpinner, R.id.decrement,
                R.string.date_picker_decrement_day_button);
        // Month
        text = mContext.getString(R.string.date_picker_increment_month_button);
        mMonthSpinner.findViewById(R.id.increment).setContentDescription(text);
        text = mContext.getString(R.string.date_picker_decrement_month_button);
        mMonthSpinner.findViewById(R.id.decrement).setContentDescription(text);
        trySetContentDescription(mMonthSpinner, R.id.increment,
                R.string.date_picker_increment_month_button);
        trySetContentDescription(mMonthSpinner, R.id.decrement,
                R.string.date_picker_decrement_month_button);
        // Year
        text = mContext.getString(R.string.date_picker_increment_year_button);
        mYearSpinner.findViewById(R.id.increment).setContentDescription(text);
        text = mContext.getString(R.string.date_picker_decrement_year_button);
        mYearSpinner.findViewById(R.id.decrement).setContentDescription(text);
        trySetContentDescription(mYearSpinner, R.id.increment,
                R.string.date_picker_increment_year_button);
        trySetContentDescription(mYearSpinner, R.id.decrement,
                R.string.date_picker_decrement_year_button);
    }

    private void trySetContentDescription(View root, int viewId, int contDescResId) {
        View target = root.findViewById(viewId);
        if (target != null) {
            target.setContentDescription(mContext.getString(contDescResId));
        }
    }

    private void updateInputState() {
+723 −577

File changed.

Preview size limit exceeded, changes collapsed.

+19 −12
Original line number Diff line number Diff line
@@ -532,21 +532,28 @@ public class TimePicker extends FrameLayout {

    private void setContentDescriptions() {
        // Minute
        String text = mContext.getString(R.string.time_picker_increment_minute_button);
        mMinuteSpinner.findViewById(R.id.increment).setContentDescription(text);
        text = mContext.getString(R.string.time_picker_decrement_minute_button);
        mMinuteSpinner.findViewById(R.id.decrement).setContentDescription(text);
        trySetContentDescription(mMinuteSpinner, R.id.increment,
                R.string.time_picker_increment_minute_button);
        trySetContentDescription(mMinuteSpinner, R.id.decrement,
                R.string.time_picker_decrement_minute_button);
        // Hour
        text = mContext.getString(R.string.time_picker_increment_hour_button);
        mHourSpinner.findViewById(R.id.increment).setContentDescription(text);
        text = mContext.getString(R.string.time_picker_decrement_hour_button);
        mHourSpinner.findViewById(R.id.decrement).setContentDescription(text);
        trySetContentDescription(mHourSpinner, R.id.increment,
                R.string.time_picker_increment_hour_button);
        trySetContentDescription(mHourSpinner, R.id.decrement,
                R.string.time_picker_decrement_hour_button);
        // AM/PM
        if (mAmPmSpinner != null) {
            text = mContext.getString(R.string.time_picker_increment_set_pm_button);
            mAmPmSpinner.findViewById(R.id.increment).setContentDescription(text);
            text = mContext.getString(R.string.time_picker_decrement_set_am_button);
            mAmPmSpinner.findViewById(R.id.decrement).setContentDescription(text);
            trySetContentDescription(mAmPmSpinner, R.id.increment,
                    R.string.time_picker_increment_set_pm_button);
            trySetContentDescription(mAmPmSpinner, R.id.decrement,
                    R.string.time_picker_decrement_set_am_button);
        }
    }

    private void trySetContentDescription(View root, int viewId, int contDescResId) {
        View target = root.findViewById(viewId);
        if (target != null) {
            target.setContentDescription(mContext.getString(contDescResId));
        }
    }

Loading