Created focus grabber for time input field
This commit is contained in:
parent
a6c8076255
commit
0a7c007da4
@ -66,7 +66,7 @@ public abstract class GridLayoutNumpad extends GridLayout implements View.OnClic
|
||||
/**
|
||||
* @return the number of digits we can input
|
||||
*/
|
||||
protected abstract int capacity();
|
||||
public abstract int capacity();
|
||||
|
||||
/**
|
||||
* @return the layout resource that defines the children for this numpad
|
||||
@ -102,7 +102,7 @@ public abstract class GridLayoutNumpad extends GridLayout implements View.OnClic
|
||||
/**
|
||||
* @return the number of digits inputted
|
||||
*/
|
||||
protected final int count() {
|
||||
public final int count() {
|
||||
return mCount;
|
||||
}
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ public class NumpadTimePicker extends GridLayoutNumpad implements TimePicker {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int capacity() {
|
||||
public int capacity() {
|
||||
return MAX_DIGITS;
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ public class NumpadTimePickerDialog extends DialogFragment implements NumpadTime
|
||||
// Don't need to keep a reference to the dismiss ImageButton
|
||||
@Bind(R.id.input_time) EditText mInputField;
|
||||
@Bind(R.id.number_grid) NumpadTimePicker mNumpad;
|
||||
@Bind(R.id.focus_grabber) View mFocusGrabber;
|
||||
|
||||
public NumpadTimePickerDialog() {
|
||||
// Empty constructor required for dialog fragment.
|
||||
@ -156,5 +157,8 @@ public class NumpadTimePickerDialog extends DialogFragment implements NumpadTime
|
||||
mInputField.setText(inputText);
|
||||
// Move the cursor
|
||||
mInputField.setSelection(mInputField.length());
|
||||
if (mNumpad.count() == mNumpad.capacity()) {
|
||||
mFocusGrabber.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,14 @@
|
||||
android:background="@android:color/transparent"
|
||||
style="@style/TextAppearance.AppCompat.Inverse"/>
|
||||
|
||||
<!-- We need both focusable attrs for requestFocus() to succeed -->
|
||||
<View
|
||||
android:id="@+id/focus_grabber"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"/>
|
||||
|
||||
<!-- TOneverDO: Before the EditText, because we need this on top -->
|
||||
<ImageButton
|
||||
android:id="@+id/cancel"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user