am 75dc3a9d: DO NOT MERGE; Add back support for uts testing.
Merge commit '75dc3a9d28a184358127390329b36a5a520c212c' into eclair-plus-aosp * commit '75dc3a9d28a184358127390329b36a5a520c212c': DO NOT MERGE; Add back support for uts testing.
This commit is contained in:
commit
4baee90d22
1 file changed
+55
@@ -42,11 +42,14 @@ import android.graphics.Rect;
|
|||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.provider.ContactsContract;
|
||||||
import android.provider.LiveFolders;
|
import android.provider.LiveFolders;
|
||||||
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.text.Selection;
|
import android.text.Selection;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -201,6 +204,7 @@ public final class Launcher extends Activity
|
|||||||
|
|
||||||
private ImageView mPreviousView;
|
private ImageView mPreviousView;
|
||||||
private ImageView mNextView;
|
private ImageView mNextView;
|
||||||
|
private boolean mUtsTestMode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -409,6 +413,7 @@ public final class Launcher extends Activity
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
|
mUtsTestMode = SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1;
|
||||||
|
|
||||||
if (mRestoring) {
|
if (mRestoring) {
|
||||||
mWorkspaceLoading = true;
|
mWorkspaceLoading = true;
|
||||||
@@ -480,6 +485,10 @@ public final class Launcher extends Activity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
if (mUtsTestMode) {
|
||||||
|
return handleUtsTestModeKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
boolean handled = super.onKeyDown(keyCode, event);
|
boolean handled = super.onKeyDown(keyCode, event);
|
||||||
if (!handled && acceptFilter() && keyCode != KeyEvent.KEYCODE_ENTER) {
|
if (!handled && acceptFilter() && keyCode != KeyEvent.KEYCODE_ENTER) {
|
||||||
boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb,
|
boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb,
|
||||||
@@ -503,6 +512,52 @@ public final class Launcher extends Activity
|
|||||||
return handled;
|
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() {
|
private String getTypedText() {
|
||||||
return mDefaultKeySsb.toString();
|
return mDefaultKeySsb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user