Skip to content

Commit

Permalink
Modify pull request #7
Browse files Browse the repository at this point in the history
  • Loading branch information
philliphsu committed Nov 9, 2016
1 parent de0271f commit aebac7c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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);

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,29 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!-- TOneverDO: Use LinearLayout as root container when the
dialog is a DialogFragment (or a subclass of), or else LWM
doesn't work. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/input_time"
<FrameLayout
android:id="@+id/input_time_container"
android:layout_width="@dimen/left_side_width"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="@dimen/text_size_display_3"
android:fontFamily="sans-serif"
style="@style/TextAppearance.AppCompat"/>
android:layout_height="match_parent">

<TextView
android:id="@+id/input_time"
android:layout_width="@dimen/left_side_width"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="@dimen/text_size_display_3"
android:fontFamily="sans-serif"
android:textColor="@color/text_color_primary_dark"
android:textColorHint="@color/text_color_disabled_dark"
style="@style/TextAppearance.AppCompat"/>

<!--<View style="@style/FocusGrabber"
android:id="@+id/focus_grabber"/>-->
</FrameLayout>

<com.philliphsu.bottomsheetpickers.time.numberpad.NumberPadTimePicker
android:id="@+id/number_grid"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!-- TOneverDO: Use LinearLayout as root container when the
dialog is a DialogFragment (or a subclass of), or else LWM
doesn't work. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
Expand All @@ -29,20 +25,20 @@ doesn't work. -->
android:layout_width="match_parent"
android:layout_height="@dimen/numeric_keypad_output_box_height">

<TextView
android:id="@+id/input_time"
android:layout_width="match_parent"
android:layout_height="@dimen/numeric_keypad_output_box_height"
android:gravity="center"
android:textSize="@dimen/text_size_display_3"
android:fontFamily="sans-serif"
style="@style/TextAppearance.AppCompat"/>
<!-- TODO: Create a style for this instead and remove duplicated code in landscape layout.-->
<TextView
android:id="@+id/input_time"
android:layout_width="match_parent"
android:layout_height="@dimen/numeric_keypad_output_box_height"
android:gravity="center"
android:textSize="@dimen/text_size_display_3"
android:fontFamily="sans-serif"
android:textColor="@color/text_color_primary_dark"
android:textColorHint="@color/text_color_disabled_dark"
style="@style/TextAppearance.AppCompat"/>

</FrameLayout>

<!--<View style="@style/FocusGrabber"
android:id="@+id/focus_grabber"/>-->

<com.philliphsu.bottomsheetpickers.time.numberpad.NumberPadTimePicker
android:id="@+id/number_grid"
android:layout_width="match_parent"
Expand Down

0 comments on commit aebac7c

Please sign in to comment.