Skip to content

Commit

Permalink
Merge branch 'jackunderwood93-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
philliphsu committed Nov 9, 2016
2 parents 610fbfd + aebac7c commit 348afda
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@
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;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
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 @@ -43,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 @@ -52,9 +55,12 @@ 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 String mHint;
private int mTextSize;
private int mHintResId;

private TextView mInputField;
private NumberPadTimePicker mNumpad;
Expand Down Expand Up @@ -134,9 +140,20 @@ 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.setBackgroundColor(mThemeDark? lightGray : accentColor);
inputTime.setTextColor(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 || mHintResId != 0) {
if (mHint != null) {
mInputField.setHint(mHint);
} else {
mInputField.setHint(mHintResId);
}
}

if (mTextSize != 0) {
mInputField.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
}

mNumpad.setTheme(getContext()/*DO NOT GIVE THE APPLICATION CONTEXT, OR ELSE THE NUMPAD
CAN'T GET THE CORRECT ACCENT COLOR*/, mThemeDark);
Expand All @@ -160,6 +177,45 @@ public void onSaveInstanceState(Bundle outState) {
}
}

/**
* Sets the hint of the input time TextView.
*/
public void setHint(String hint) {
if (mInputField != null) {
mInputField.setHint(mHint);
}
mHint = hint;
mHintResId = 0;
}

/**
* Sets the hint of the input time TextView.
*/
public void setHint(@StringRes int resid) {
if (mInputField != null) {
mInputField.setHint(resid);
}
mHintResId = resid;
mHint = 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;
}

/**
* @return The TextView that stores the inputted time.
*/
public TextView getInputTextView() {
return mInputField;
}

@Override
public void onDigitInserted(String newStr) {
updateInputText(newStr);
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,27 +14,30 @@
~ 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="vertical">

<TextView
android:id="@+id/input_time"
<FrameLayout
android:id="@+id/input_time_container"
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"/>
android:layout_height="@dimen/numeric_keypad_output_box_height">

<!-- 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"/>

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

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

0 comments on commit 348afda

Please sign in to comment.