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

Commit abdd1543 authored by Craig Stout's avatar Craig Stout
Browse files

Fix timepicker double done buttons.

Leanback theme uses a legacy layout with a done button, but
apps won't necessarily have target apilevel L.

Change-Id: Ib38b08df1fe07bd8fb4e64e93633ce0b7eb12567
parent 0048da21
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -113,7 +113,6 @@ public class TimePickerDialog extends AlertDialog
        if (targetSdkVersion < Build.VERSION_CODES.L) {
            setIcon(0);
            setTitle(R.string.time_picker_dialog_title);
            setButton(BUTTON_POSITIVE, themeContext.getText(R.string.date_time_done), this);
        }

        final LayoutInflater inflater = LayoutInflater.from(themeContext);
@@ -122,6 +121,11 @@ public class TimePickerDialog extends AlertDialog

        mTimePicker = (TimePicker) view.findViewById(R.id.timePicker);
        mTimePicker.setShowDoneButton(true);
        // If time picker layout has no done button, add a dialog button.
        if (!mTimePicker.isShowDoneButton()) {
            setButton(BUTTON_POSITIVE, themeContext.getText(R.string.date_time_done), this);
        }

        mTimePicker.setDismissCallback(new TimePicker.TimePickerDismissCallback() {
            @Override
            public void dismiss(TimePicker view, boolean isCancel, int hourOfDay, int minute) {
+6 −3
Original line number Diff line number Diff line
@@ -429,11 +429,14 @@ class LegacyTimePickerDelegate extends TimePicker.AbstractTimePickerDelegate {

    @Override
    public void setShowDoneButton(boolean showDoneButton) {
        if (mDoneButton != null) {
            mShowDoneButton = showDoneButton;
            updateDoneButton();
        }
    }

    private boolean isShowDoneButton() {
    @Override
    public boolean isShowDoneButton() {
        return mShowDoneButton;
    }

+8 −0
Original line number Diff line number Diff line
@@ -160,6 +160,13 @@ public class TimePicker extends FrameLayout {
        mDelegate.setShowDoneButton(showDoneButton);
    }

    /**
     * @hide
     */
    public boolean isShowDoneButton() {
        return mDelegate.isShowDoneButton();
    }

    /**
     * @hide
     */
@@ -234,6 +241,7 @@ public class TimePicker extends FrameLayout {
        void setEnabled(boolean enabled);
        boolean isEnabled();

        boolean isShowDoneButton();
        void setShowDoneButton(boolean showDoneButton);
        void setDismissCallback(TimePickerDismissCallback callback);

+2 −1
Original line number Diff line number Diff line
@@ -564,7 +564,8 @@ class TimePickerDelegate extends TimePicker.AbstractTimePickerDelegate implement
        return mRadialTimePickerView.getCurrentItemShowing();
    }

    private boolean isShowDoneButton() {
    @Override
    public boolean isShowDoneButton() {
        return mShowDoneButton;
    }