Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
rockchip_frameworks_opt_datetimepicker
Commits
541b40d9
Commit
541b40d9
authored
12 years ago
by
Sam Blitzstein
Committed by
Android (Google) Code Review
12 years ago
Browse files
Options
Download
Plain Diff
Merge "Add pulsating effect to header label when switching view." into jb-mr2-dev
parents
561d8381
b612bb94
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
26 deletions
+112
-26
res/layout-land/time_picker_dialog.xml
res/layout-land/time_picker_dialog.xml
+3
-3
res/layout/time_header_label.xml
res/layout/time_header_label.xml
+53
-14
res/layout/time_picker_dialog.xml
res/layout/time_picker_dialog.xml
+2
-2
res/values-sw600dp/dimens.xml
res/values-sw600dp/dimens.xml
+1
-0
res/values/dimens.xml
res/values/dimens.xml
+1
-0
src/com/android/datetimepicker/Utils.java
src/com/android/datetimepicker/Utils.java
+25
-0
src/com/android/datetimepicker/time/TimePickerDialog.java
src/com/android/datetimepicker/time/TimePickerDialog.java
+27
-7
No files found.
res/layout-land/time_picker_dialog.xml
View file @
541b40d9
...
...
@@ -25,18 +25,18 @@
android:layout_marginTop=
"@dimen/minimum_margin_top_bottom"
android:layout_marginBottom=
"@dimen/minimum_margin_top_bottom"
>
<LinearLayout
android:layout_width=
"
wrap_content
"
android:layout_width=
"
@dimen/left_side_width
"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<FrameLayout
android:layout_width=
"
@dimen/left_side_width
"
android:layout_width=
"
match_parent
"
android:layout_height=
"0dip"
android:layout_weight=
"1"
android:background=
"@color/white"
>
<include
layout=
"@layout/time_header_label"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_conten
t"
android:layout_height=
"
@dimen/header_heigh
t"
android:layout_gravity=
"center"
/>
</FrameLayout>
<View
...
...
This diff is collapsed.
Click to expand it.
res/layout/time_header_label.xml
View file @
541b40d9
...
...
@@ -16,23 +16,43 @@
-->
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
>
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:background=
"@color/white"
>
<View
android:id=
"@+id/empty_view"
android:layout_width=
"1dp"
android:layout_height=
"1dp"
android:background=
"#00000000"
android:layout_centerInParent=
"true"
/>
<
com.android.datetimepicker.FakeButton
android:id=
"@+id/hour
s
"
<
TextView
android:id=
"@+id/hour
_space
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/time_placeholder"
android:textColor=
"@color/blue"
android:layout_toLeftOf=
"@+id/separator"
android:layout_centerVertical=
"true"
style=
"@style/time_label"
/>
android:visibility=
"invisible"
style=
"@style/time_label"
android:importantForAccessibility=
"no"
/>
<FrameLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_alignRight=
"@+id/hour_space"
android:layout_alignLeft=
"@+id/hour_space"
android:layout_marginLeft=
"@dimen/extra_time_label_margin"
android:layout_marginRight=
"@dimen/extra_time_label_margin"
android:layout_centerVertical=
"true"
>
<com.android.datetimepicker.FakeButton
android:id=
"@+id/hours"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/time_placeholder"
android:textColor=
"@color/blue"
android:gravity=
"center_horizontal"
android:layout_gravity=
"center"
style=
"@style/time_label"
/>
</FrameLayout>
<TextView
android:id=
"@+id/separator"
android:layout_width=
"wrap_content"
...
...
@@ -44,20 +64,39 @@
android:layout_centerVertical=
"true"
style=
"@style/time_label"
android:importantForAccessibility=
"no"
/>
<
com.android.datetimepicker.FakeButton
android:id=
"@+id/minutes"
<
TextView
android:id=
"@+id/minutes
_space
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/time_placeholder"
android:layout_toRightOf=
"@+id/separator"
android:layout_centerVertical=
"true"
style=
"@style/time_label"
/>
android:visibility=
"invisible"
style=
"@style/time_label"
android:importantForAccessibility=
"no"
/>
<FrameLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_alignRight=
"@+id/minutes_space"
android:layout_alignLeft=
"@+id/minutes_space"
android:layout_marginLeft=
"@dimen/extra_time_label_margin"
android:layout_marginRight=
"@dimen/extra_time_label_margin"
android:layout_centerVertical=
"true"
>
<com.android.datetimepicker.FakeButton
android:id=
"@+id/minutes"
style=
"@style/time_label"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_horizontal"
android:text=
"@string/time_placeholder"
android:layout_gravity=
"center"
/>
</FrameLayout>
<com.android.datetimepicker.FakeButton
android:id=
"@+id/ampm_hitspace"
android:layout_width=
"@dimen/ampm_label_size"
android:layout_height=
"wrap_content"
android:layout_align
Top=
"@+id/minutes
"
android:layout_alignBottom=
"
@+id/minutes
"
android:layout_align
ParentTop=
"true
"
android:layout_align
Parent
Bottom=
"
true
"
android:layout_alignLeft=
"@+id/ampm_label"
android:layout_alignRight=
"@+id/ampm_label"
/>
<TextView
...
...
@@ -67,8 +106,8 @@
android:text=
"@string/time_placeholder"
android:paddingLeft=
"@dimen/ampm_left_padding"
android:paddingRight=
"@dimen/ampm_left_padding"
android:layout_toRightOf=
"@+id/minutes"
android:layout_alignBaseline=
"@+id/
minutes
"
android:layout_toRightOf=
"@+id/minutes
_space
"
android:layout_alignBaseline=
"@+id/
separator
"
style=
"@style/ampm_label"
android:importantForAccessibility=
"no"
/>
</RelativeLayout>
\ No newline at end of file
</RelativeLayout>
This diff is collapsed.
Click to expand it.
res/layout/time_picker_dialog.xml
View file @
541b40d9
...
...
@@ -23,12 +23,12 @@
android:focusable=
"true"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"
@dimen/header_heigh
t"
android:layout_height=
"
wrap_conten
t"
android:background=
"@color/white"
>
<include
layout=
"@layout/time_header_label"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_conten
t"
android:layout_height=
"
@dimen/header_heigh
t"
android:layout_gravity=
"center"
/>
</FrameLayout>
<com.android.datetimepicker.time.RadialPickerLayout
...
...
This diff is collapsed.
Click to expand it.
res/values-sw600dp/dimens.xml
View file @
541b40d9
...
...
@@ -40,6 +40,7 @@
<dimen
name=
"month_day_label_text_size"
>
15sp
</dimen>
<dimen
name=
"time_label_size"
>
75sp
</dimen>
<dimen
name=
"extra_time_label_margin"
>
-50dp
</dimen>
<dimen
name=
"ampm_label_size"
>
20sp
</dimen>
<dimen
name=
"ampm_left_padding"
>
8dip
</dimen>
<dimen
name=
"separator_padding"
>
5dip
</dimen>
...
...
This diff is collapsed.
Click to expand it.
res/values/dimens.xml
View file @
541b40d9
...
...
@@ -30,6 +30,7 @@
<dimen
name=
"time_label_size"
>
60sp
</dimen>
<dimen
name=
"extra_time_label_margin"
>
-30dp
</dimen>
<dimen
name=
"ampm_label_size"
>
16sp
</dimen>
<dimen
name=
"done_label_size"
>
16sp
</dimen>
<dimen
name=
"ampm_left_padding"
>
6dip
</dimen>
...
...
This diff is collapsed.
Click to expand it.
src/com/android/datetimepicker/Utils.java
View file @
541b40d9
...
...
@@ -16,8 +16,12 @@
package
com.android.datetimepicker
;
import
android.animation.Keyframe
;
import
android.animation.ObjectAnimator
;
import
android.animation.PropertyValuesHolder
;
import
android.os.Build
;
import
android.text.format.Time
;
import
android.view.View
;
import
java.util.Calendar
;
...
...
@@ -27,6 +31,7 @@ import java.util.Calendar;
public
class
Utils
{
public
static
final
int
MONDAY_BEFORE_JULIAN_EPOCH
=
Time
.
EPOCH_JULIAN_DAY
-
3
;
public
static
final
int
PULSE_ANIMATOR_DURATION
=
600
;
static
final
String
SHARED_PREFS_NAME
=
"com.android.calendar_preferences"
;
...
...
@@ -92,4 +97,24 @@ public class Utils {
int
refDay
=
Time
.
EPOCH_JULIAN_DAY
-
diff
;
return
(
julianDay
-
refDay
)
/
7
;
}
/**
* Render an animator to pulsate a view in place.
* @param labelToAnimate the view to pulsate.
* @return The animator object. Use .start() to begin.
*/
public
static
ObjectAnimator
getPulseAnimator
(
View
labelToAnimate
)
{
Keyframe
k0
=
Keyframe
.
ofFloat
(
0
f
,
1
f
);
Keyframe
k1
=
Keyframe
.
ofFloat
(
0.25f
,
0.85f
);
Keyframe
k2
=
Keyframe
.
ofFloat
(
0.625f
,
1.1f
);
Keyframe
k3
=
Keyframe
.
ofFloat
(
1
f
,
1
f
);
PropertyValuesHolder
scaleX
=
PropertyValuesHolder
.
ofKeyframe
(
"scaleX"
,
k0
,
k1
,
k2
,
k3
);
PropertyValuesHolder
scaleY
=
PropertyValuesHolder
.
ofKeyframe
(
"scaleY"
,
k0
,
k1
,
k2
,
k3
);
ObjectAnimator
pulseAnimator
=
ObjectAnimator
.
ofPropertyValuesHolder
(
labelToAnimate
,
scaleX
,
scaleY
);
pulseAnimator
.
setDuration
(
PULSE_ANIMATOR_DURATION
);
return
pulseAnimator
;
}
}
This diff is collapsed.
Click to expand it.
src/com/android/datetimepicker/time/TimePickerDialog.java
View file @
541b40d9
...
...
@@ -16,6 +16,7 @@
package
com.android.datetimepicker.time
;
import
android.animation.ObjectAnimator
;
import
android.annotation.SuppressLint
;
import
android.app.ActionBar.LayoutParams
;
import
android.app.DialogFragment
;
...
...
@@ -65,11 +66,16 @@ public class TimePickerDialog extends DialogFragment implements OnValueSelectedL
public
static
final
int
AM
=
0
;
public
static
final
int
PM
=
1
;
// Delay before starting the pulse animation, in ms.
private
static
final
int
PULSE_ANIMATOR_DELAY
=
300
;
private
OnTimeSetListener
mCallback
;
private
TextView
mDoneButton
;
private
TextView
mHourView
;
private
TextView
mHourSpaceView
;
private
TextView
mMinuteView
;
private
TextView
mMinuteSpaceView
;
private
TextView
mAmPmTextView
;
private
View
mAmPmHitspace
;
private
RadialPickerLayout
mTimePicker
;
...
...
@@ -181,6 +187,8 @@ public class TimePickerDialog extends DialogFragment implements OnValueSelectedL
mHourView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
hours
);
mHourView
.
setOnKeyListener
(
keyboardListener
);
mHourSpaceView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
hour_space
);
mMinuteSpaceView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
minutes_space
);
mMinuteView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
minutes
);
mMinuteView
.
setOnKeyListener
(
keyboardListener
);
mAmPmTextView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
ampm_label
);
...
...
@@ -198,20 +206,20 @@ public class TimePickerDialog extends DialogFragment implements OnValueSelectedL
savedInstanceState
.
containsKey
(
KEY_CURRENT_ITEM_SHOWING
))
{
currentItemShowing
=
savedInstanceState
.
getInt
(
KEY_CURRENT_ITEM_SHOWING
);
}
setCurrentItemShowing
(
currentItemShowing
,
false
,
true
);
setCurrentItemShowing
(
currentItemShowing
,
false
,
true
,
true
);
mTimePicker
.
invalidate
();
mHourView
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
setCurrentItemShowing
(
HOUR_INDEX
,
true
,
true
);
setCurrentItemShowing
(
HOUR_INDEX
,
true
,
false
,
true
);
mTimePicker
.
tryVibrate
();
}
});
mMinuteView
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
setCurrentItemShowing
(
MINUTE_INDEX
,
true
,
true
);
setCurrentItemShowing
(
MINUTE_INDEX
,
true
,
false
,
true
);
mTimePicker
.
tryVibrate
();
}
});
...
...
@@ -320,7 +328,7 @@ public class TimePickerDialog extends DialogFragment implements OnValueSelectedL
setHour
(
newValue
,
false
);
String
announcement
=
String
.
format
(
"%d"
,
newValue
);
if
(
mAllowAutoAdvance
&&
autoAdvance
)
{
setCurrentItemShowing
(
MINUTE_INDEX
,
true
,
false
);
setCurrentItemShowing
(
MINUTE_INDEX
,
true
,
true
,
false
);
announcement
+=
". "
+
mSelectMinutes
;
}
tryAccessibilityAnnounce
(
announcement
);
...
...
@@ -350,6 +358,7 @@ public class TimePickerDialog extends DialogFragment implements OnValueSelectedL
CharSequence
text
=
String
.
format
(
format
,
value
);
mHourView
.
setText
(
text
);
mHourSpaceView
.
setText
(
text
);
if
(
announce
)
{
tryAccessibilityAnnounce
(
text
);
}
...
...
@@ -362,12 +371,15 @@ public class TimePickerDialog extends DialogFragment implements OnValueSelectedL
CharSequence
text
=
String
.
format
(
Locale
.
getDefault
(),
"%02d"
,
value
);
tryAccessibilityAnnounce
(
text
);
mMinuteView
.
setText
(
text
);
mMinuteSpaceView
.
setText
(
text
);
}
// Show either Hours or Minutes.
private
void
setCurrentItemShowing
(
int
index
,
boolean
animate
,
boolean
announce
)
{
mTimePicker
.
setCurrentItemShowing
(
index
,
animate
);
private
void
setCurrentItemShowing
(
int
index
,
boolean
animateCircle
,
boolean
delayLabelAnimate
,
boolean
announce
)
{
mTimePicker
.
setCurrentItemShowing
(
index
,
animateCircle
);
TextView
labelToAnimate
;
if
(
index
==
HOUR_INDEX
)
{
int
hours
=
mTimePicker
.
getHours
();
if
(!
mIs24HourMode
)
{
...
...
@@ -377,18 +389,26 @@ public class TimePickerDialog extends DialogFragment implements OnValueSelectedL
if
(
announce
)
{
tryAccessibilityAnnounce
(
mSelectHours
);
}
labelToAnimate
=
mHourView
;
}
else
{
int
minutes
=
mTimePicker
.
getMinutes
();
mTimePicker
.
setContentDescription
(
mMinutePickerDescription
+
": "
+
minutes
);
if
(
announce
)
{
tryAccessibilityAnnounce
(
mSelectMinutes
);
}
labelToAnimate
=
mMinuteView
;
}
int
hourColor
=
(
index
==
HOUR_INDEX
)?
mBlue
:
mBlack
;
int
minuteColor
=
(
index
==
MINUTE_INDEX
)?
mBlue
:
mBlack
;
mHourView
.
setTextColor
(
hourColor
);
mMinuteView
.
setTextColor
(
minuteColor
);
ObjectAnimator
pulseAnimator
=
Utils
.
getPulseAnimator
(
labelToAnimate
);
if
(
delayLabelAnimate
)
{
pulseAnimator
.
setStartDelay
(
PULSE_ANIMATOR_DELAY
);
}
pulseAnimator
.
start
();
}
/**
...
...
@@ -581,7 +601,7 @@ public class TimePickerDialog extends DialogFragment implements OnValueSelectedL
if
(!
mIs24HourMode
)
{
updateAmPmDisplay
(
hour
<
12
?
AM
:
PM
);
}
setCurrentItemShowing
(
mTimePicker
.
getCurrentItemShowing
(),
true
,
true
);
setCurrentItemShowing
(
mTimePicker
.
getCurrentItemShowing
(),
true
,
true
,
true
);
mDoneButton
.
setEnabled
(
true
);
}
else
{
Boolean
[]
enteredZeros
=
{
false
,
false
};
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment