auto import from //branches/cupcake_rel/...@138607

This commit is contained in:
The Android Open Source Project
2009-03-13 13:04:23 -07:00
parent 0727d22ece
commit d06b097626
3 changed files with 48 additions and 24 deletions

View File

@@ -163,6 +163,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
static final int MSG_CALL_LONG_PRESS_COMPLETE = 4;
static final int MSG_CAMERA_LONG_PRESS = 5;
static final int MSG_CAMERA_LONG_PRESS_COMPLETE = 6;
static final int MSG_SEARCH_LONG_PRESS = 7;
static final int MSG_SEARCH_LONG_PRESS_COMPLETE = 8;
private final Handler mKeycodeMenuTimeoutHandler = new Handler() {
@Override
@@ -197,6 +199,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
mKeycodeMenuTimeoutHandler.sendMessage(newMessage);
break;
}
case MSG_SEARCH_LONG_PRESS: {
if (!mSearchKeyDownReceived) return;
// See above.
Message newMessage = Message.obtain(msg);
newMessage.what = MSG_SEARCH_LONG_PRESS_COMPLETE;
mKeycodeMenuTimeoutHandler.sendMessage(newMessage);
break;
}
case MSG_MENU_LONG_PRESS_COMPLETE: {
if (mPanelChordingKey == 0) return;
mPanelChordingKey = 0;
@@ -231,6 +241,26 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
getContext().sendOrderedBroadcast(intent, null);
sendCloseSystemWindows();
} break;
case MSG_SEARCH_LONG_PRESS_COMPLETE: {
if (getKeyguardManager().inKeyguardRestrictedInputMode() ||
!mSearchKeyDownReceived) {
mSearchKeyDownReceived = false;
return;
}
mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
// launch the search activity
Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
sendCloseSystemWindows();
getContext().startActivity(intent);
// Only clear this if we successfully start the
// activity; otherwise we will allow the normal short
// press action to be performed.
mSearchKeyDownReceived = false;
} catch (ActivityNotFoundException e) {
}
} break;
}
}
};
@@ -1276,6 +1306,19 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
case KeyEvent.KEYCODE_SEARCH: {
if (event.getRepeatCount() == 0) {
mSearchKeyDownReceived = true;
Configuration config = getContext().getResources().getConfiguration();
if (config.keyboard == Configuration.KEYBOARD_NOKEYS
|| config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
// If this device does not have a hardware keyboard,
// or that keyboard is hidden, then we can't use the
// search key for chording to perform shortcuts;
// instead, we will let the user long press,
mKeycodeMenuTimeoutHandler.removeMessages(MSG_SEARCH_LONG_PRESS);
mKeycodeMenuTimeoutHandler.sendMessageDelayed(
mKeycodeMenuTimeoutHandler.obtainMessage(MSG_SEARCH_LONG_PRESS),
ViewConfiguration.getLongPressTimeout());
}
return true;
}
break;
}
@@ -1370,6 +1413,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
*/
if (getKeyguardManager().inKeyguardRestrictedInputMode() ||
!mSearchKeyDownReceived) {
mSearchKeyDownReceived = false;
break;
}
mSearchKeyDownReceived = false;

View File

@@ -260,32 +260,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
class MyOrientationListener extends WindowOrientationListener {
private static final int _LOWER_THRESHOLD = 30;
private static final int _UPPER_THRESHOLD = 60;
MyOrientationListener(Context context) {
super(context);
}
@Override
public void onOrientationChanged(int orientation) {
// ignore orientation changes unless the value is in a range
// When switching from portrait to landscape try to use a lower threshold limit
// Use upper threshold limit when switching from landscape to portrait
// this is to delay the switch as much as we can
int rotation;
int threshold = (mSensorRotation == Surface.ROTATION_90) ? _UPPER_THRESHOLD :
_LOWER_THRESHOLD;
if ((orientation >= 0 && orientation <= _UPPER_THRESHOLD) ||
(orientation >= 270 - _LOWER_THRESHOLD)) {
rotation = (orientation >= 270 - _LOWER_THRESHOLD
&& orientation <= 270 + threshold)
? Surface.ROTATION_90 : Surface.ROTATION_0;
} else {
// ignore orientation value
return;
}
public void onOrientationChanged(int rotation) {
// Send updates based on orientation value
if (rotation != mSensorRotation) {
if(localLOGV) Log.i(TAG, "onOrientationChanged, rotation changed from "+rotation+" to "+mSensorRotation);

View File

@@ -46,7 +46,7 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
private final boolean mCreatedWithKeyboardOpen;
private TextView mHeaderText;
private EditText mPinText;
private TextView mPinText;
private TextView mOkButton;
private TextView mEmergencyCallButton;
@@ -75,7 +75,7 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
}
mHeaderText = (TextView) findViewById(R.id.headerText);
mPinText = (EditText) findViewById(R.id.pinDisplay);
mPinText = (TextView) findViewById(R.id.pinDisplay);
mBackSpaceButton = findViewById(R.id.backspace);
mBackSpaceButton.setOnClickListener(this);
@@ -159,7 +159,7 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
public void onClick(View v) {
if (v == mBackSpaceButton) {
final Editable digits = mPinText.getText();
final Editable digits = mPinText.getEditableText();
final int len = digits.length();
if (len > 0) {
digits.delete(len-1, len);