Increased tap target size of buttons
This commit is contained in:
parent
1162e9177c
commit
e2df1aef28
@ -45,6 +45,8 @@ import java.util.Locale;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static com.philliphsu.clock2.util.ConversionUtils.dpToPx;
|
||||
|
||||
//import com.android.datetimepicker.HapticFeedbackController;
|
||||
//import com.android.datetimepicker.R;
|
||||
//import com.android.datetimepicker.Utils;
|
||||
@ -129,8 +131,10 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog /*DialogFra
|
||||
private static final int[] HOURS_24_HALF_DAY_1 = {0,1,2,3,4,5,6,7,8,9,10,11};
|
||||
private static final int[] HOURS_24_HALF_DAY_2 = {12,13,14,15,16,17,18,19,20,21,22,23};
|
||||
private static final int[] MINUTES = {0,5,10,15,20,25,30,35,40,45,50,55};
|
||||
// The delay before a OnLongClick on a TwentyFourHourGridItem defers to OnClick
|
||||
// The delay in ms before a OnLongClick on a TwentyFourHourGridItem defers to OnClick
|
||||
private static final int LONG_CLICK_RESULT_LEEWAY = 150;
|
||||
// The padding in dp for the half day icon compound drawable
|
||||
public static final int HALF_DAY_ICON_PADDING = 8;
|
||||
|
||||
// TODO: Private?
|
||||
// Describes both AM/PM in the 12-hour clock and the half-days of the 24-hour clock.
|
||||
@ -267,15 +271,16 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog /*DialogFra
|
||||
((TwentyFourHourGridItem) v).swapTexts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Verify the corresponding TwentyFourHourGridItem retains its indicator
|
||||
if (amOrPm == HALF_DAY_1) {
|
||||
mSelectedHourOfDay -= 12;
|
||||
mSelectedHourOfDay %= 12;
|
||||
} else if (amOrPm == HALF_DAY_2) {
|
||||
mSelectedHourOfDay += 12;
|
||||
mSelectedHourOfDay = (mSelectedHourOfDay % 12) + 12;
|
||||
}
|
||||
onValueSelected(HOUR_INDEX, mSelectedHourOfDay, false);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Break this into two OnClickListeners instead--one for normal TextViews and
|
||||
// the other for TwentyFourHourGridItem.
|
||||
@ -458,9 +463,11 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog /*DialogFra
|
||||
// Intrinsic bounds meaning the drawable's own bounds? So 24dp box.
|
||||
tv1.setCompoundDrawablesWithIntrinsicBounds(
|
||||
R.drawable.ic_half_day_1_black_24dp, 0, 0, 0);
|
||||
tv1.setCompoundDrawablePadding((int) dpToPx(getActivity(), HALF_DAY_ICON_PADDING));
|
||||
tv2.setText("12 - 23");
|
||||
tv2.setCompoundDrawablesWithIntrinsicBounds(
|
||||
R.drawable.ic_half_day_2_black_24dp, 0, 0, 0);
|
||||
tv2.setCompoundDrawablePadding((int) dpToPx(getActivity(), HALF_DAY_ICON_PADDING));
|
||||
} else {
|
||||
tv1.setText(mAmText);
|
||||
tv2.setText(mPmText);
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package com.philliphsu.clock2.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.TypedValue;
|
||||
|
||||
/**
|
||||
* Created by Phillip Hsu on 4/21/2016.
|
||||
*/
|
||||
public final class ConversionUtils {
|
||||
|
||||
public static float dpToPx(@NonNull final Context context, final float dp) {
|
||||
return toPx(context, TypedValue.COMPLEX_UNIT_DIP, dp);
|
||||
}
|
||||
|
||||
public static float spToPx(@NonNull final Context context, final float sp) {
|
||||
return toPx(context, TypedValue.COMPLEX_UNIT_SP, sp);
|
||||
}
|
||||
|
||||
private static float toPx(@NonNull final Context context, final int unit, final float val) {
|
||||
// This always returns a floating point value, i.e. pixels.
|
||||
return TypedValue.applyDimension(unit, val, context.getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
private ConversionUtils() {}
|
||||
|
||||
}
|
||||
@ -3,17 +3,11 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<!-- TODO: Use fixed width and height -->
|
||||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/GridLayoutNumpadElement"
|
||||
android:src="@drawable/ic_minus_circle_24dp"
|
||||
app:layout_gravity="center"
|
||||
app:layout_column="1"/>
|
||||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/GridLayoutNumpadElement"
|
||||
android:src="@drawable/ic_add_circle_24dp"
|
||||
app:layout_gravity="center"
|
||||
app:layout_column="2"/>
|
||||
</merge>
|
||||
@ -52,7 +52,6 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="8dp"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
style="@style/TextAppearance.AppCompat.Button"
|
||||
@ -70,7 +69,6 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="8dp"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
style="@style/TextAppearance.AppCompat.Button"
|
||||
|
||||
@ -4,9 +4,6 @@
|
||||
|
||||
<!-- TODO: Define a grid item style with the first 3 attrs-->
|
||||
<com.philliphsu.clock2.editalarm.TwentyFourHourGridItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_gravity="center"
|
||||
style="@style/GridLayoutNumpadElement"/>
|
||||
|
||||
</merge>
|
||||
@ -2,12 +2,9 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<!-- TODO: Define another style with LWW and LHW -->
|
||||
<!-- TODO: Use a fixed height so the circular indicator doesn't stretch into an oval. -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/GridLayoutNumpadButton"
|
||||
app:layout_gravity="center"/>
|
||||
<!-- Or measure the text dimensions and use the larger of its width and height, plus some
|
||||
small integer extra, and use that as the diameter of the circle indicator. -->
|
||||
<TextView style="@style/GridLayoutNumpadButton"/>
|
||||
|
||||
</merge>
|
||||
@ -34,6 +34,7 @@
|
||||
<item name="layout_columnWeight">1</item>
|
||||
<item name="layout_rowWeight">1</item>
|
||||
<item name="android:background">?android:attr/selectableItemBackground</item>
|
||||
<item name="android:gravity">center</item>
|
||||
</style>
|
||||
|
||||
<!-- TODO: Rename to GridLayout[Text/Button/TextView]? -->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user