Changed picker header
This commit is contained in:
parent
ae83786b3c
commit
a8f3fafafa
@ -56,6 +56,8 @@ public abstract class BaseTimePickerDialog extends BottomSheetDialogFragment {
|
|||||||
// While it is true by default, BottomSheetDialogs override this default height.
|
// While it is true by default, BottomSheetDialogs override this default height.
|
||||||
// See http://stackoverflow.com/a/35634293/5055032 for an alternative solution involving
|
// See http://stackoverflow.com/a/35634293/5055032 for an alternative solution involving
|
||||||
// defining a style that overrides the attribute.
|
// defining a style that overrides the attribute.
|
||||||
|
// TODO: If the sheet is dragged out of view, then the screen remains darkened until
|
||||||
|
// a subsequent touch on the screen. Consider doing the alt. soln.?
|
||||||
behavior.setPeekHeight(0);
|
behavior.setPeekHeight(0);
|
||||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import android.widget.EditText;
|
|||||||
import com.philliphsu.clock2.R;
|
import com.philliphsu.clock2.R;
|
||||||
|
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.OnClick;
|
|
||||||
import butterknife.OnTouch;
|
import butterknife.OnTouch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,10 +142,12 @@ public class NumpadTimePickerDialog extends BaseTimePickerDialog
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@OnClick(R.id.cancel)
|
@OnClick(R.id.cancel)
|
||||||
void cancel() {
|
void cancel() {
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private void updateInputText(String inputText) {
|
private void updateInputText(String inputText) {
|
||||||
TimeTextUtils.setText(inputText, mInputField);
|
TimeTextUtils.setText(inputText, mInputField);
|
||||||
|
|||||||
@ -1,70 +1,31 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- TOneverDO: Use LinearLayout, because it doesn't obey LWM -->
|
<!-- TOneverDO: Use LinearLayout, because it doesn't obey LWM -->
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- We want this to be a FrameLayout so we can make the EditText
|
<!-- TODO: Consider TextView, because we might not want the cursor? -->
|
||||||
field LWM, because that solves all of our cursor issues, and so we
|
|
||||||
can put the ImageButton on top (z-level) -->
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/header"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/header_height"
|
|
||||||
android:background="@color/colorPrimary"
|
|
||||||
android:layout_alignParentTop="true">
|
|
||||||
|
|
||||||
<!-- We want this to be an EditText because the cursor indicates
|
|
||||||
where the user's input will go. Otherwise, when the dialog first
|
|
||||||
opens, the user sees the header view as just an appbar that has
|
|
||||||
a single navigation icon, with no indication that the dialog
|
|
||||||
actually displays input. -->
|
|
||||||
<!-- If we were to use LWW, we would have issues with the cursor.
|
|
||||||
(1) It won't show initially, because the view is not big enough to
|
|
||||||
accommodate the cursor drawable. A hacky solution is to set the hint
|
|
||||||
to a single whitespace character.
|
|
||||||
(2) Additionally, when text is inputted, the cursor gets cut off
|
|
||||||
as it advances in position, probably because the text rendered at
|
|
||||||
the set text size is bigger than the view bounds. A satisfactory
|
|
||||||
solution has not been found. We tried adding padding to the end,
|
|
||||||
but that ended up decentralizing the view.
|
|
||||||
-->
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/input_time"
|
android:id="@+id/input_time"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="@dimen/time_input_text_size"
|
android:textSize="@dimen/time_input_text_size"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"/>
|
||||||
style="@style/TextAppearance.AppCompat.Inverse"/>
|
|
||||||
|
|
||||||
<!-- We need both focusable attrs for requestFocus() to succeed -->
|
<View style="@style/FocusGrabber"
|
||||||
<View
|
android:id="@+id/focus_grabber"/>
|
||||||
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 -->
|
<View style="@style/Divider"/>
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/cancel"
|
|
||||||
android:layout_width="@dimen/cancel_icon_size"
|
|
||||||
android:layout_height="@dimen/cancel_icon_size"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:background="?selectableItemBackground"
|
|
||||||
android:src="@android:drawable/ic_menu_close_clear_cancel"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<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="@dimen/numpad_height"
|
android:layout_height="@dimen/numpad_height"
|
||||||
android:layout_below="@id/header"
|
|
||||||
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:layout_marginBottom="@dimen/bottom_sheet_vertical_space"/>
|
android:layout_marginBottom="@dimen/bottom_sheet_vertical_space"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</LinearLayout>
|
||||||
@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Wrapped in a LL so the divider is full width.
|
||||||
|
The RelativeLayout defines padding for all children, so the
|
||||||
|
divider would be padded too. -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -74,10 +77,7 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<View
|
<View style="@style/Divider"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?android:listDivider"
|
|
||||||
android:layout_marginTop="@dimen/item_margin_between_elements"/>
|
android:layout_marginTop="@dimen/item_margin_between_elements"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@ -52,4 +52,18 @@
|
|||||||
<item name="layout_gravity">center</item>
|
<item name="layout_gravity">center</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Divider">
|
||||||
|
<item name="android:layout_width">match_parent</item>
|
||||||
|
<item name="android:layout_height">1dp</item>
|
||||||
|
<item name="android:background">?android:attr/listDivider</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="FocusGrabber">
|
||||||
|
<item name="android:layout_width">0dp</item>
|
||||||
|
<item name="android:layout_height">0dp</item>
|
||||||
|
<!-- We need both focusable attrs for requestFocus() to succeed -->
|
||||||
|
<item name="android:focusable">true</item>
|
||||||
|
<item name="android:focusableInTouchMode">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user