summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-06-09 12:56:34 -0700
committerRomain Guy <romainguy@android.com>2009-06-09 22:58:46 -0700
commit0e1ca5749a96778869ef62f939542a61c034209b (patch)
tree0eb7fef5f9151e679088aa13db8c428a7ce7198e /core
parentfaf410443f0c2ab2d30a1c8ce90f83157b5e593b (diff)
downloadframeworks_base-0e1ca5749a96778869ef62f939542a61c034209b.zip
frameworks_base-0e1ca5749a96778869ef62f939542a61c034209b.tar.gz
frameworks_base-0e1ca5749a96778869ef62f939542a61c034209b.tar.bz2
Add support for gestures in Home.
Adds a new animation style for the gestures pad, and de-normalize the scores in the recognition engine.
Diffstat (limited to 'core')
-rwxr-xr-xcore/java/android/gesture/GestureOverlayView.java8
-rw-r--r--core/java/android/gesture/InstanceLearner.java38
-rw-r--r--core/java/android/widget/ViewSwitcher.java2
-rw-r--r--core/res/res/anim/slide_in_up.xml23
-rw-r--r--core/res/res/anim/slide_out_down.xml23
-rw-r--r--core/res/res/values/styles.xml6
6 files changed, 80 insertions, 20 deletions
diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java
index 98e7dcd..1e81780 100755
--- a/core/java/android/gesture/GestureOverlayView.java
+++ b/core/java/android/gesture/GestureOverlayView.java
@@ -274,6 +274,14 @@ public class GestureOverlayView extends FrameLayout {
return mCurrentGesture;
}
+ public long getFadeOffset() {
+ return mFadeOffset;
+ }
+
+ public void setFadeOffset(long fadeOffset) {
+ mFadeOffset = fadeOffset;
+ }
+
public void setGesture(Gesture gesture) {
if (mCurrentGesture != null) {
clear(false);
diff --git a/core/java/android/gesture/InstanceLearner.java b/core/java/android/gesture/InstanceLearner.java
index 00cdadc..b93b76f 100644
--- a/core/java/android/gesture/InstanceLearner.java
+++ b/core/java/android/gesture/InstanceLearner.java
@@ -26,6 +26,20 @@ import java.util.TreeMap;
*/
class InstanceLearner extends Learner {
+ private static final Comparator<Prediction> sComparator = new Comparator<Prediction>() {
+ public int compare(Prediction object1, Prediction object2) {
+ double score1 = object1.score;
+ double score2 = object2.score;
+ if (score1 > score2) {
+ return -1;
+ } else if (score1 < score2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ };
+
@Override
ArrayList<Prediction> classify(int sequenceType, float[] vector) {
ArrayList<Prediction> predictions = new ArrayList<Prediction>();
@@ -55,31 +69,19 @@ class InstanceLearner extends Learner {
}
}
- double sum = 0;
+// double sum = 0;
for (String name : label2score.keySet()) {
double score = label2score.get(name);
- sum += score;
+// sum += score;
predictions.add(new Prediction(name, score));
}
// normalize
- for (Prediction prediction : predictions) {
- prediction.score /= sum;
- }
+// for (Prediction prediction : predictions) {
+// prediction.score /= sum;
+// }
- Collections.sort(predictions, new Comparator<Prediction>() {
- public int compare(Prediction object1, Prediction object2) {
- double score1 = object1.score;
- double score2 = object2.score;
- if (score1 > score2) {
- return -1;
- } else if (score1 < score2) {
- return 1;
- } else {
- return 0;
- }
- }
- });
+ Collections.sort(predictions, sComparator);
return predictions;
}
diff --git a/core/java/android/widget/ViewSwitcher.java b/core/java/android/widget/ViewSwitcher.java
index f4f23a8..0dcaf95 100644
--- a/core/java/android/widget/ViewSwitcher.java
+++ b/core/java/android/widget/ViewSwitcher.java
@@ -16,8 +16,6 @@
package android.widget;
-import java.util.Map;
-
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
diff --git a/core/res/res/anim/slide_in_up.xml b/core/res/res/anim/slide_in_up.xml
new file mode 100644
index 0000000..bf471c3
--- /dev/null
+++ b/core/res/res/anim/slide_in_up.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<translate
+ xmlns:android="http://schemas.android.com/apk/res/android"
+
+ android:fromYDelta="100%p"
+ android:toYDelta="0"
+
+ android:duration="@android:integer/config_longAnimTime" />
diff --git a/core/res/res/anim/slide_out_down.xml b/core/res/res/anim/slide_out_down.xml
new file mode 100644
index 0000000..9b8d5b7
--- /dev/null
+++ b/core/res/res/anim/slide_out_down.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<translate
+ xmlns:android="http://schemas.android.com/apk/res/android"
+
+ android:fromYDelta="0"
+ android:toYDelta="100%p"
+
+ android:duration="@android:integer/config_longAnimTime" />
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 72402d0..648a7dd 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -124,6 +124,12 @@
<item name="windowExitAnimation">@anim/shrink_fade_out_from_bottom</item>
</style>
+ <!-- {@hide} -->
+ <style name="Animation.SlidingCard">
+ <item name="windowEnterAnimation">@anim/slide_in_up</item>
+ <item name="windowExitAnimation">@anim/slide_out_down</item>
+ </style>
+
<!-- Window animations that are applied to input method overlay windows.
{@hide Pending API council approval} -->
<style name="Animation.InputMethod">