forked from mirrors/gecko-dev
Bug 1474925 - TimePicker swipe not possible in landscape; r=jchen
MozReview-Commit-ID: DVp6d40OLE3 --HG-- extra : rebase_source : 29ae6312d79cbed0cea128a7e42e38d769be7eab
This commit is contained in:
parent
dc2a4a2d84
commit
178925493d
2 changed files with 52 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ import org.mozilla.gecko.util.GeckoBundle;
|
|||
import org.mozilla.gecko.widget.AllCapsTextView;
|
||||
import org.mozilla.gecko.widget.FocusableDatePicker;
|
||||
import org.mozilla.gecko.widget.DateTimePicker;
|
||||
import org.mozilla.gecko.widget.FocusableTimePicker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
|
|
@ -210,7 +211,8 @@ public abstract class PromptInput {
|
|||
DateTimePicker.PickersState.WEEK, mMinValue, mMaxValue);
|
||||
mView = (View)input;
|
||||
} else if (mType.equals("time")) {
|
||||
TimePicker input = new TimePicker(context);
|
||||
// FocusableDatePicker allow us to have priority in responding to scroll events.
|
||||
TimePicker input = new FocusableTimePicker(context);
|
||||
input.setIs24HourView(DateFormat.is24HourFormat(context));
|
||||
|
||||
GregorianCalendar calendar = new GregorianCalendar();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.widget;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
/**
|
||||
* This is based on the platform's {@link TimePicker}.<br>
|
||||
* The only difference is that it will prevent it's parent from receiving touch events.
|
||||
*/
|
||||
public class FocusableTimePicker extends TimePicker {
|
||||
public FocusableTimePicker(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public FocusableTimePicker(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public FocusableTimePicker(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public FocusableTimePicker(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
ViewParent parentView = getParent();
|
||||
|
||||
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
if (parentView != null) {
|
||||
parentView.requestDisallowInterceptTouchEvent(true);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue