Updated layout of NumpadTimePickerDialog

This commit is contained in:
Phillip Hsu 2016-08-17 16:51:40 -07:00
parent 3732246bb7
commit abd1551bc3
7 changed files with 46 additions and 35 deletions

View File

@ -64,7 +64,7 @@ public class ExpandedAlarmViewHolder extends BaseAlarmViewHolder {
super.bindLabel(true, label); super.bindLabel(true, label);
} }
@OnClick(R.id.save) @OnClick(R.id.ok)
void save() { void save() {
// TODO // TODO
} }

View File

@ -4,13 +4,12 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText; import android.widget.TextView;
import com.philliphsu.clock2.R; import com.philliphsu.clock2.R;
import butterknife.Bind; import butterknife.Bind;
import butterknife.OnClick; import butterknife.OnClick;
import butterknife.OnTouch;
/** /**
* Created by Phillip Hsu on 7/12/2016. * Created by Phillip Hsu on 7/12/2016.
@ -39,9 +38,9 @@ public class NumpadTimePickerDialog extends BaseTimePickerDialog
private int[] mInputtedDigits; private int[] mInputtedDigits;
// Don't need to keep a reference to the dismiss ImageButton // Don't need to keep a reference to the dismiss ImageButton
@Bind(R.id.input_time) EditText mInputField; @Bind(R.id.input_time) TextView mInputField;
@Bind(R.id.number_grid) NumpadTimePicker mNumpad; @Bind(R.id.number_grid) NumpadTimePicker mNumpad;
@Bind(R.id.focus_grabber) View mFocusGrabber; // @Bind(R.id.focus_grabber) View mFocusGrabber;
// TODO: We don't need to pass in an initial hour and minute for a new instance. // TODO: We don't need to pass in an initial hour and minute for a new instance.
@Deprecated @Deprecated
@ -84,7 +83,7 @@ public class NumpadTimePickerDialog extends BaseTimePickerDialog
mNumpad.setOnInputChangeListener(this); mNumpad.setOnInputChangeListener(this);
mNumpad.insertDigits(mInputtedDigits); // TOneverDO: before mNumpad.setOnInputChangeListener(this); mNumpad.insertDigits(mInputtedDigits); // TOneverDO: before mNumpad.setOnInputChangeListener(this);
// Show the cursor immediately // Show the cursor immediately
mInputField.requestFocus(); // mInputField.requestFocus();
// TODO: Disabled color // TODO: Disabled color
//updateInputText(""); // Primarily to disable 'OK' //updateInputText(""); // Primarily to disable 'OK'
return view; return view;
@ -122,14 +121,14 @@ public class NumpadTimePickerDialog extends BaseTimePickerDialog
@Override @Override
public void onInputDisabled() { public void onInputDisabled() {
// Steals the focus from the EditText // Steals the focus from the EditText
mFocusGrabber.requestFocus(); // mFocusGrabber.requestFocus();
} }
@OnTouch(R.id.input_time) // @OnTouch(R.id.input_time)
boolean captureTouchOnEditText() { // boolean captureTouchOnEditText() {
// Capture touch events on the EditText field, because we want it to do nothing. // // Capture touch events on the EditText field, because we want it to do nothing.
return true; // return true;
} // }
// The FAB is not defined directly in this dialog's layout, but rather in the layout // The FAB is not defined directly in this dialog's layout, but rather in the layout
// of the NumpadTimePicker. We can always reference a child of a ViewGroup that is // of the NumpadTimePicker. We can always reference a child of a ViewGroup that is
@ -144,11 +143,11 @@ public class NumpadTimePickerDialog extends BaseTimePickerDialog
private void updateInputText(String inputText) { private void updateInputText(String inputText) {
TimeTextUtils.setText(inputText, mInputField); TimeTextUtils.setText(inputText, mInputField);
// Move the cursor // // Move the cursor
mInputField.setSelection(mInputField.length()); // mInputField.setSelection(mInputField.length());
if (mFocusGrabber.isFocused()) { // if (mFocusGrabber.isFocused()) {
// Return focus to the EditText // // Return focus to the EditText
mInputField.requestFocus(); // mInputField.requestFocus();
} // }
} }
} }

View File

@ -20,11 +20,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_gravity="center" app:layout_gravity="center"
app:layout_column="1" app:layout_column="1"
android:src="@drawable/ic_done_24dp"/> android:src="@drawable/ic_done_24dp"
android:layout_marginBottom="@dimen/numeric_keypad_fab_bottom_margin"/>
<ImageButton <ImageButton
android:id="@+id/backspace" android:id="@+id/backspace"
android:src="@drawable/ic_backspace_24dp" android:src="@drawable/ic_backspace_24dp"
android:layout_height="@dimen/numeric_keypad_backspace_height"
style="@style/GridLayoutNumpadElement" style="@style/GridLayoutNumpadElement"
app:layout_column="2"/> app:layout_column="2"/>

View File

@ -7,30 +7,29 @@ doesn't work. -->
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<EditText <TextView
android:id="@+id/input_time" android:id="@+id/input_time"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="@dimen/numeric_keypad_output_box_height"
android:gravity="center" android:gravity="center"
android:textSize="@dimen/time_input_text_size" android:textSize="@dimen/text_size_display_3"
android:background="@android:color/transparent"/> android:fontFamily="sans-serif-light"
style="@style/TextAppearance.AppCompat"/>
<View style="@style/FocusGrabber" <!--<View style="@style/FocusGrabber"
android:id="@+id/focus_grabber"/> android:id="@+id/focus_grabber"/>-->
<View style="@style/Divider.Horizontal" <View style="@style/Divider.Horizontal"
android:id="@+id/header_divider" android:id="@+id/header_divider"
android:layout_below="@id/input_time"/> android:layout_below="@id/input_time"/>
<!-- TODO: Adjust margins -->
<com.philliphsu.clock2.editalarm.NumpadTimePicker <com.philliphsu.clock2.editalarm.NumpadTimePicker
android:id="@+id/number_grid" android:id="@+id/number_grid"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="310dp" android:layout_height="@dimen/numeric_keypad_height"
android:layout_below="@id/header_divider" android:layout_below="@id/header_divider"
android:layout_marginTop="@dimen/bottom_sheet_vertical_space" android:layout_marginTop="@dimen/bottom_sheet_vertical_space"
android:layout_marginStart="@dimen/bottom_sheet_edge_margin" android:layout_marginStart="@dimen/bottom_sheet_edge_margin"
android:layout_marginEnd="@dimen/bottom_sheet_edge_margin" android:layout_marginEnd="@dimen/bottom_sheet_edge_margin"/>
android:paddingBottom="@dimen/bottom_sheet_edge_margin"/>
</RelativeLayout> </RelativeLayout>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 4 x (numeric_keypad_cell_height) + 56dp FAB height + 16dp FAB bottom margin -->
<dimen name="numeric_keypad_height">328dp</dimen>
<dimen name="numeric_keypad_backspace_height">56dp</dimen> <!-- Same as FAB height -->
<dimen name="numeric_keypad_fab_bottom_margin">16dp</dimen>
</resources>

View File

@ -17,10 +17,12 @@
<dimen name="half_day_text_size">17sp</dimen> <dimen name="half_day_text_size">17sp</dimen>
<!-- NumpadTimePickerDialog --> <!-- NumpadTimePickerDialog -->
<dimen name="numpad_height">300dp</dimen> <dimen name="numpad_height">300dp</dimen> <!-- TODO: Deprecated -->
<dimen name="time_input_text_size">45sp</dimen> <dimen name="numeric_keypad_cell_height">64dp</dimen>
<dimen name="viewpager_bottom_padding">88dp <dimen name="numeric_keypad_output_box_height">80dp</dimen>
</dimen> <!-- 56dp fab size + 16dp top margin + 16dp bottom margin --> <dimen name="numeric_keypad_height">344dp</dimen> <!-- 4 x (numeric_keypad_cell_height) + 88dp pre-21 FAB height -->
<dimen name="numeric_keypad_backspace_height">88dp</dimen> <!-- Same as pre-21 FAB height -->
<dimen name="numeric_keypad_fab_bottom_margin">0dp</dimen> <!-- 88dp height already big enough -->
<!-- Bottom sheet specs --> <!-- Bottom sheet specs -->
<dimen name="bottom_sheet_edge_margin">24dp</dimen> <dimen name="bottom_sheet_edge_margin">24dp</dimen>

View File

@ -35,14 +35,16 @@
Leave off the namespace to reference a custom attribute. Leave off the namespace to reference a custom attribute.
Here, we are referencing the "grid:" namespace --> Here, we are referencing the "grid:" namespace -->
<item name="layout_columnWeight">1</item> <item name="layout_columnWeight">1</item>
<item name="layout_rowWeight">1</item> <!--<item name="layout_rowWeight">1</item>-->
<item name="android:layout_height">@dimen/numeric_keypad_cell_height</item>
<item name="android:background">?android:attr/selectableItemBackground</item> <item name="android:background">?android:attr/selectableItemBackground</item>
<item name="android:gravity">center</item> <item name="android:gravity">center</item>
</style> </style>
<!-- TODO: Rename to GridLayout[Text/Button/TextView]? --> <!-- TODO: Rename to GridLayout[Text/Button/TextView]? -->
<style name="GridLayoutNumpadButton" parent="GridLayoutNumpadElement"> <style name="GridLayoutNumpadButton" parent="GridLayoutNumpadElement">
<item name="android:textSize">@dimen/grid_element_text_size</item> <item name="android:textSize">@dimen/text_size_display_1</item>
<item name="android:fontFamily">sans-serif-light</item>
</style> </style>
<!-- TODO: Replace and Delete --> <!-- TODO: Replace and Delete -->