From aebac7c79ba2817e44cb8df917357dadf9c4c8d3 Mon Sep 17 00:00:00 2001 From: Phillip Hsu Date: Wed, 9 Nov 2016 15:29:54 -0800 Subject: [PATCH] Modify pull request #7 --- .../numberpad/NumberPadTimePickerDialog.java | 70 ++++++++++++------- .../layout-land/dialog_time_picker_numpad.xml | 28 ++++---- .../res/layout/dialog_time_picker_numpad.xml | 26 +++---- 3 files changed, 69 insertions(+), 55 deletions(-) diff --git a/bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerDialog.java b/bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerDialog.java index 463cbe3..5cbd21e 100644 --- a/bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerDialog.java +++ b/bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerDialog.java @@ -17,6 +17,7 @@ package com.philliphsu.bottomsheetpickers.time.numberpad; import android.os.Bundle; +import android.support.annotation.StringRes; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; import android.util.TypedValue; @@ -27,9 +28,9 @@ import android.widget.TextView; import com.philliphsu.bottomsheetpickers.R; +import com.philliphsu.bottomsheetpickers.Utils; import com.philliphsu.bottomsheetpickers.time.BottomSheetTimePickerDialog; import com.philliphsu.bottomsheetpickers.time.TimeTextUtils; -import com.philliphsu.bottomsheetpickers.Utils; /** * Dialog to type in a time. @@ -45,7 +46,7 @@ public class NumberPadTimePickerDialog extends BottomSheetTimePickerDialog private static final String KEY_THEME_SET_AT_RUNTIME = "theme_set_at_runtime"; private boolean mIs24HourMode; - /** + /* * The digits stored in the numpad from the last time onSaveInstanceState() was called. * * Why not have the NumberPadTimePicker class save state itself? Because it's a lot more @@ -54,14 +55,14 @@ public class NumberPadTimePickerDialog extends BottomSheetTimePickerDialog * depends on the dialog to save its state. */ private int[] mInputtedDigits; - private int mAmPmState = NumberPadTimePicker.UNSPECIFIED; // TOneverDO: zero initial value, b/c 0 == AM + private int mAmPmState = NumberPadTimePicker.UNSPECIFIED; private boolean mThemeDark; private boolean mThemeSetAtRuntime; - - private TextView mInputField; private String mHint; - private int mTextSize = 0; + private int mTextSize; + private int mHintResId; + private TextView mInputField; private NumberPadTimePicker mNumpad; /** @@ -139,22 +140,21 @@ public void onClick(View v) { // Set background color of entire view view.setBackgroundColor(mThemeDark? darkGray : white); - TextView inputTime = (TextView) view.findViewById(R.id.input_time); - inputTime.setTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); - inputTime.setHintTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); - + FrameLayout inputTimeContainer = (FrameLayout) view.findViewById(R.id.input_time_container); + inputTimeContainer.setBackgroundColor(mThemeDark? lightGray : accentColor); - if(mHint != null) { - inputTime.setHint(mHint); + if (mHint != null || mHintResId != 0) { + if (mHint != null) { + mInputField.setHint(mHint); + } else { + mInputField.setHint(mHintResId); + } } - if(mTextSize != 0) { - inputTime.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); + if (mTextSize != 0) { + mInputField.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } - FrameLayout inputTimeContainer = (FrameLayout) view.findViewById(R.id.input_time_container); - inputTimeContainer.setBackgroundColor(mThemeDark? lightGray : accentColor); - mNumpad.setTheme(getContext()/*DO NOT GIVE THE APPLICATION CONTEXT, OR ELSE THE NUMPAD CAN'T GET THE CORRECT ACCENT COLOR*/, mThemeDark); @@ -177,26 +177,42 @@ public void onSaveInstanceState(Bundle outState) { } } + /** + * Sets the hint of the input time TextView. + */ public void setHint(String hint) { - mHint = hint; - - if(mInputField != null) { + if (mInputField != null) { mInputField.setHint(mHint); } - + mHint = hint; + mHintResId = 0; } - public void setTextSize(int textSize) { - - mTextSize = textSize; + /** + * Sets the hint of the input time TextView. + */ + public void setHint(@StringRes int resid) { + if (mInputField != null) { + mInputField.setHint(resid); + } + mHintResId = resid; + mHint = null; + } - if(mInputField != null) { + /** + * Sets the text size in px of the input time TextView. + */ + public void setInputTextSize(int textSize) { + if (mInputField != null) { mInputField.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } - + mTextSize = textSize; } - public TextView getTextView() { + /** + * @return The TextView that stores the inputted time. + */ + public TextView getInputTextView() { return mInputField; } diff --git a/bottomsheetpickers/src/main/res/layout-land/dialog_time_picker_numpad.xml b/bottomsheetpickers/src/main/res/layout-land/dialog_time_picker_numpad.xml index e729fe4..f0ed94a 100644 --- a/bottomsheetpickers/src/main/res/layout-land/dialog_time_picker_numpad.xml +++ b/bottomsheetpickers/src/main/res/layout-land/dialog_time_picker_numpad.xml @@ -14,27 +14,29 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - - + android:layout_height="match_parent"> + + - + - - android:layout_width="match_parent" android:layout_height="@dimen/numeric_keypad_output_box_height"> - + + - -