summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2015-01-27 01:01:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-01-27 01:02:00 +0000
commit5229be05b439cf24b7028adbb64d05ecc23184ac (patch)
tree1caf4dc0f9f1d5669bdbea430a6c4266888ff5de /core
parent09dff843b8ed402564c4c89d7e1cabceb715e458 (diff)
parent5efe0d199e9a6133af355ace6e4b52b82a65af6e (diff)
downloadframeworks_base-5229be05b439cf24b7028adbb64d05ecc23184ac.zip
frameworks_base-5229be05b439cf24b7028adbb64d05ecc23184ac.tar.gz
frameworks_base-5229be05b439cf24b7028adbb64d05ecc23184ac.tar.bz2
Merge "Convert getHourForDegrees result to 12-hour format when needed" into lmp-mr1-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/android/widget/RadialTimePickerView.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/core/java/android/widget/RadialTimePickerView.java b/core/java/android/widget/RadialTimePickerView.java
index 7b64cf5..11fda2c 100644
--- a/core/java/android/widget/RadialTimePickerView.java
+++ b/core/java/android/widget/RadialTimePickerView.java
@@ -1381,11 +1381,19 @@ public class RadialTimePickerView extends View implements View.OnTouchListener {
@Override
protected int getVirtualViewAt(float x, float y) {
final int id;
+
+ // Calling getDegreesXY() has side-effects, so we need to cache the
+ // current inner circle value and restore after the call.
+ final boolean wasOnInnerCircle = mIsOnInnerCircle;
final int degrees = getDegreesFromXY(x, y);
+ final boolean isOnInnerCircle = mIsOnInnerCircle;
+ mIsOnInnerCircle = wasOnInnerCircle;
+
if (degrees != -1) {
final int snapDegrees = snapOnly30s(degrees, 0) % 360;
if (mShowHours) {
- final int hour = getHourForDegrees(snapDegrees, mIsOnInnerCircle);
+ final int hour24 = getHourForDegrees(snapDegrees, isOnInnerCircle);
+ final int hour = mIs24HourMode ? hour24 : hour24To12(hour24);
id = makeId(TYPE_HOUR, hour);
} else {
final int current = getCurrentMinute();
@@ -1514,6 +1522,16 @@ public class RadialTimePickerView extends View implements View.OnTouchListener {
return hour24;
}
+ private int hour24To12(int hour24) {
+ if (hour24 == 0) {
+ return 12;
+ } else if (hour24 > 12) {
+ return hour24 - 12;
+ } else {
+ return hour24;
+ }
+ }
+
private void getBoundsForVirtualView(int virtualViewId, Rect bounds) {
final float radius;
final int type = getTypeFromId(virtualViewId);