diff options
| -rw-r--r-- | packages/SystemUI/res/layout-xlarge/status_bar.xml | 20 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/KeyButtonView.java | 33 |
2 files changed, 37 insertions, 16 deletions
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml index a0c2c95..65db981 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml @@ -106,15 +106,6 @@ android:layout_centerInParent="true" /> - <com.android.systemui.statusbar.KeyButtonView android:id="@+id/back" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_toLeftOf="@+id/menu" - android:paddingLeft="4dip" - android:paddingRight="4dip" - android:src="@drawable/status_bar_back" - systemui:keyCode="4" - /> <com.android.systemui.statusbar.KeyButtonView android:id="@+id/menu" android:layout_width="wrap_content" android:layout_height="match_parent" @@ -136,11 +127,20 @@ <com.android.systemui.statusbar.KeyButtonView android:id="@+id/home" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_alignParentRight="true" android:paddingLeft="4dip" android:paddingRight="4dip" + android:layout_toLeftOf="@+id/back" android:src="@drawable/status_bar_home" systemui:keyCode="3" /> + <com.android.systemui.statusbar.KeyButtonView android:id="@+id/back" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_alignParentRight="true" + android:paddingLeft="4dip" + android:paddingRight="4dip" + android:src="@drawable/status_bar_back" + systemui:keyCode="4" + /> </RelativeLayout> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyButtonView.java index b0508b8..fe29dea 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyButtonView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyButtonView.java @@ -25,10 +25,12 @@ import android.os.SystemClock; import android.os.ServiceManager; import android.util.AttributeSet; import android.util.Slog; +import android.view.HapticFeedbackConstants; import android.view.IWindowManager; import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; +import android.view.ViewConfiguration; import android.widget.ImageView; import android.widget.RemoteViews.RemoteView; @@ -37,9 +39,22 @@ import com.android.systemui.R; public class KeyButtonView extends ImageView { IWindowManager mWindowManager; long mDownTime; - boolean mSending; + boolean mSending, mLongPressed; int mCode; int mRepeat; + Runnable mCheckLongPress = new Runnable() { + public void run() { + Slog.d("KeyButtonView", "longpress"); + if (isPressed()) { + mLongPressed = true; + mRepeat++; + sendEvent(KeyEvent.ACTION_DOWN, + KeyEvent.FLAG_FROM_SYSTEM + | KeyEvent.FLAG_VIRTUAL_HARD_KEY + | KeyEvent.FLAG_LONG_PRESS); + } + } + }; public KeyButtonView(Context context, AttributeSet attrs) { this(context, attrs, 0); @@ -69,12 +84,16 @@ public class KeyButtonView extends ImageView { switch (action) { case MotionEvent.ACTION_DOWN: + Slog.d("KeyButtonView", "press"); mDownTime = SystemClock.uptimeMillis(); mRepeat = 0; mSending = true; + mLongPressed = false; sendEvent(KeyEvent.ACTION_DOWN, - KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_SOFT_KEYBOARD, mDownTime); + KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY, mDownTime); setPressed(true); + removeCallbacks(mCheckLongPress); + postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout()); break; case MotionEvent.ACTION_MOVE: if (mSending) { @@ -83,19 +102,21 @@ public class KeyButtonView extends ImageView { if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight()) { mSending = false; sendEvent(KeyEvent.ACTION_UP, - KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_SOFT_KEYBOARD + KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY | KeyEvent.FLAG_CANCELED); setPressed(false); + removeCallbacks(mCheckLongPress); } } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: - if (mSending) { + setPressed(false); + if (mSending && !mLongPressed) { mSending = false; sendEvent(KeyEvent.ACTION_UP, - KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_SOFT_KEYBOARD); - setPressed(false); + KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY); + removeCallbacks(mCheckLongPress); } break; } |
