summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2010-02-12 16:02:32 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2010-02-12 16:02:32 -0800
commit7ac5037acc8e5811a825bac554e5376d8d7eee43 (patch)
tree6a3f83f8212d86f378c20811d73fb9d1c1eaf3b1 /src
parent6a35157a2bb7dceaa1d34555de5776161290d325 (diff)
parentc44706064341f02a14d61091492a5fc6dc6efd2d (diff)
downloadandroid_packages_apps_Trebuchet-7ac5037acc8e5811a825bac554e5376d8d7eee43.tar.gz
android_packages_apps_Trebuchet-7ac5037acc8e5811a825bac554e5376d8d7eee43.tar.bz2
android_packages_apps_Trebuchet-7ac5037acc8e5811a825bac554e5376d8d7eee43.zip
am c4470606: am b8fc9e7d: Merge "Launcher changes to handle UTS test mode." into eclair
Merge commit 'c44706064341f02a14d61091492a5fc6dc6efd2d' * commit 'c44706064341f02a14d61091492a5fc6dc6efd2d': Launcher changes to handle UTS test mode.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/Launcher.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 089e5512b..3e21d1e33 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -44,11 +44,14 @@ import android.graphics.Rect;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ColorDrawable;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.os.SystemProperties;
+import android.provider.ContactsContract;
import android.provider.LiveFolders;
+import android.telephony.PhoneNumberUtils;
import android.text.Selection;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
@@ -199,6 +202,8 @@ public final class Launcher extends Activity
private ImageView mPreviousView;
private ImageView mNextView;
+ private boolean mUtsTestMode;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -406,6 +411,7 @@ public final class Launcher extends Activity
super.onResume();
mPaused = false;
+ mUtsTestMode = SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1;
if (mRestoring) {
mWorkspaceLoading = true;
@@ -462,6 +468,10 @@ public final class Launcher extends Activity
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (mUtsTestMode) {
+ return handleUtsTestModeKeyDown(keyCode, event);
+ }
+
boolean handled = super.onKeyDown(keyCode, event);
if (!handled && acceptFilter() && keyCode != KeyEvent.KEYCODE_ENTER) {
boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb,
@@ -485,6 +495,52 @@ public final class Launcher extends Activity
return handled;
}
+ public boolean handleUtsTestModeKeyDown(int keyCode, KeyEvent event) {
+ Log.d(TAG, "UTS-TEST-MODE");
+ boolean handled = super.onKeyDown(keyCode, event);
+ if (!handled && acceptFilter() && keyCode != KeyEvent.KEYCODE_ENTER) {
+ boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb,
+ keyCode, event);
+ if (gotKey && mDefaultKeySsb != null && mDefaultKeySsb.length() > 0) {
+ // something usable has been typed - dispatch it now.
+ final String str = mDefaultKeySsb.toString();
+
+ boolean isDialable = true;
+ final int count = str.length();
+ for (int i = 0; i < count; i++) {
+ if (!PhoneNumberUtils.isReallyDialable(str.charAt(i))) {
+ isDialable = false;
+ break;
+ }
+ }
+ Intent intent;
+ if (isDialable) {
+ intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", str, null));
+ } else {
+ intent = new Intent(ContactsContract.Intents.UI.FILTER_CONTACTS_ACTION);
+ intent.putExtra(ContactsContract.Intents.UI.FILTER_TEXT_EXTRA_KEY, str);
+ }
+
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+
+ try {
+ startActivity(intent);
+ } catch (android.content.ActivityNotFoundException ex) {
+ // Oh well... no one knows how to filter/dial. Life goes on.
+ }
+
+ mDefaultKeySsb.clear();
+ mDefaultKeySsb.clearSpans();
+ Selection.setSelection(mDefaultKeySsb, 0);
+
+ return true;
+ }
+ }
+
+ return handled;
+ }
+
private String getTypedText() {
return mDefaultKeySsb.toString();
}