diff options
Diffstat (limited to 'packages/SystemUI')
16 files changed, 245 insertions, 38 deletions
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_left.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_left.png Binary files differnew file mode 100755 index 0000000..ad9ae23 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_left.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_right.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_right.png Binary files differnew file mode 100755 index 0000000..5324ad9 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_right.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_left.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_left.png Binary files differnew file mode 100755 index 0000000..1f08402 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_left.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_right.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_right.png Binary files differnew file mode 100755 index 0000000..7626499 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_right.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_left.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_left.png Binary files differnew file mode 100755 index 0000000..4183e20 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_left.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_right.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_right.png Binary files differnew file mode 100755 index 0000000..ab1c7b4 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_right.png diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_ime_left.png b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_ime_left.png Binary files differnew file mode 100644 index 0000000..08cbeef --- /dev/null +++ b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_ime_left.png diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_ime_right.png b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_ime_right.png Binary files differnew file mode 100644 index 0000000..db4e888 --- /dev/null +++ b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_ime_right.png diff --git a/packages/SystemUI/res/layout-sw600dp/mid_navigation_bar_land.xml b/packages/SystemUI/res/layout-sw600dp/mid_navigation_bar_land.xml index 3e146ea..6b1184a 100644 --- a/packages/SystemUI/res/layout-sw600dp/mid_navigation_bar_land.xml +++ b/packages/SystemUI/res/layout-sw600dp/mid_navigation_bar_land.xml @@ -31,6 +31,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content" > <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/dpad_left" + android:visibility="gone" + android:layout_width="48dp" + android:layout_height="match_parent" + android:layout_weight="0" + android:scaleType="fitCenter" + systemui:keyRepeat="true" /> + <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/one" android:layout_width="48dp" android:layout_height="match_parent" @@ -88,11 +96,22 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /> - <com.android.systemui.statusbar.policy.KeyButtonView - android:id="@+id/six" - android:layout_width="48dp" - android:layout_height="match_parent" - android:layout_weight="0" - android:scaleType="fitCenter" /> - + <FrameLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/dpad_right" + android:visibility="gone" + android:layout_width="48dp" + android:layout_height="match_parent" + android:layout_weight="0" + android:scaleType="fitCenter" + systemui:keyRepeat="true"/> + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/six" + android:layout_width="48dp" + android:layout_height="match_parent" + android:layout_weight="0" + android:scaleType="fitCenter"/> + </FrameLayout> </LinearLayout> diff --git a/packages/SystemUI/res/layout-sw600dp/mid_navigation_bar_port.xml b/packages/SystemUI/res/layout-sw600dp/mid_navigation_bar_port.xml index 3034280..3253b92 100644 --- a/packages/SystemUI/res/layout-sw600dp/mid_navigation_bar_port.xml +++ b/packages/SystemUI/res/layout-sw600dp/mid_navigation_bar_port.xml @@ -26,12 +26,25 @@ android:clipChildren="false" android:clipToPadding="false" android:id="@+id/nav_buttons"> - <com.android.systemui.statusbar.policy.KeyButtonView - android:id="@+id/one" - android:layout_width="@dimen/navigation_extra_key_width" - android:layout_height="match_parent" - android:layout_weight="0" - android:scaleType="fitCenter" /> + <FrameLayout + android:layout_width="@dimen/navigation_extra_key_width" + android:layout_height="match_parent" + android:layout_weight="0"> + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/dpad_left" + android:visibility="gone" + android:layout_width="48dp" + android:layout_height="match_parent" + android:layout_weight="0" + android:scaleType="fitCenter" + systemui:keyRepeat="true" /> + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/one" + android:layout_width="@dimen/navigation_extra_key_width" + android:layout_height="match_parent" + android:layout_weight="0" + android:scaleType="fitCenter" /> + </FrameLayout> <View android:layout_width="0dp" android:layout_height="match_parent" @@ -94,6 +107,14 @@ android:layout_height="match_parent" android:layout_weight="0" android:scaleType="fitCenter" /> + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/dpad_right" + android:visibility="gone" + android:layout_width="48dp" + android:layout_height="match_parent" + android:layout_weight="0" + android:scaleType="fitCenter" + systemui:keyRepeat="true" /> </FrameLayout> </LinearLayout> diff --git a/packages/SystemUI/res/layout/mid_navigation_bar_land.xml b/packages/SystemUI/res/layout/mid_navigation_bar_land.xml index 95e63bd..137070d 100644 --- a/packages/SystemUI/res/layout/mid_navigation_bar_land.xml +++ b/packages/SystemUI/res/layout/mid_navigation_bar_land.xml @@ -42,6 +42,14 @@ android:layout_height="40dp" android:layout_width="match_parent" android:layout_weight="0" /> + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/dpad_left" + android:visibility="gone" + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_weight="0" + android:scaleType="fitCenter" + systemui:keyRepeat="true"/> </FrameLayout> <LinearLayout android:layout_height="wrap_content" @@ -94,10 +102,23 @@ android:layout_weight="0" systemui:keyRepeat="true" /> </LinearLayout> - <com.android.systemui.statusbar.policy.KeyButtonView - android:id="@+id/six" - android:layout_height="40dp" - android:layout_width="match_parent" - android:layout_weight="0" - systemui:keyRepeat="true" /> + <FrameLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/dpad_right" + android:visibility="gone" + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_weight="0" + android:scaleType="fitCenter" + systemui:keyRepeat="true" /> + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/six" + android:layout_height="40dp" + android:layout_width="match_parent" + android:layout_weight="0" + systemui:keyRepeat="true" /> + </FrameLayout> + </LinearLayout> diff --git a/packages/SystemUI/res/layout/mid_navigation_bar_port.xml b/packages/SystemUI/res/layout/mid_navigation_bar_port.xml index efcda39..284620e 100644 --- a/packages/SystemUI/res/layout/mid_navigation_bar_port.xml +++ b/packages/SystemUI/res/layout/mid_navigation_bar_port.xml @@ -26,12 +26,24 @@ android:clipChildren="false" android:clipToPadding="false" android:id="@+id/nav_buttons"> - <com.android.systemui.statusbar.policy.KeyButtonView - android:id="@+id/one" - android:layout_width="@dimen/navigation_extra_key_width" - android:layout_height="match_parent" - android:layout_weight="0" - android:scaleType="fitCenter" /> + <FrameLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" > + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/dpad_left" + android:visibility="gone" + android:layout_width="40dp" + android:layout_height="match_parent" + android:layout_weight="0" + android:scaleType="fitCenter" + systemui:keyRepeat="true" /> + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/one" + android:layout_width="@dimen/navigation_extra_key_width" + android:layout_height="match_parent" + android:layout_weight="0" + android:scaleType="fitCenter" /> + </FrameLayout> <LinearLayout android:layout_height="match_parent" android:layout_width="0dp" @@ -98,5 +110,13 @@ android:layout_height="match_parent" android:layout_weight="0" android:scaleType="fitCenter" /> + <com.android.systemui.statusbar.policy.KeyButtonView + android:id="@+id/dpad_right" + android:visibility="gone" + android:layout_width="40dp" + android:layout_height="match_parent" + android:layout_weight="0" + android:scaleType="fitCenter" + systemui:keyRepeat="true"/> </FrameLayout> </LinearLayout> diff --git a/packages/SystemUI/res/values/cm_strings.xml b/packages/SystemUI/res/values/cm_strings.xml index cfe9c9f..640b8de 100644 --- a/packages/SystemUI/res/values/cm_strings.xml +++ b/packages/SystemUI/res/values/cm_strings.xml @@ -51,4 +51,6 @@ <string name="navbar_menu_conditional_button">Menu (autoHide) button</string> <string name="navbar_menu_always_button">Menu (alwaysShow) button</string> <string name="navbar_menu_big_button">Menu button</string> + <string name="accessibility_dpad_left">Cursor left</string> + <string name="accessibility_dpad_right">Cursor right</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavbarEditor.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavbarEditor.java index de141db..a03d57e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavbarEditor.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavbarEditor.java @@ -135,6 +135,14 @@ public class NavbarEditor implements View.OnTouchListener { R.string.navbar_menu_big_button, R.string.accessibility_menu, KeyEvent.KEYCODE_MENU, R.drawable.ic_sysbar_menu_big, R.drawable.ic_sysbar_menu_big_land, 0); + public static final ButtonInfo NAVBAR_DPAD_LEFT = new ButtonInfo("dpad_left", + 0, R.string.accessibility_dpad_left, + KeyEvent.KEYCODE_DPAD_LEFT, 0, + 0, R.drawable.ic_sysbar_ime_left); + public static final ButtonInfo NAVBAR_DPAD_RIGHT = new ButtonInfo("dpad_right", + 0, R.string.accessibility_dpad_right, + KeyEvent.KEYCODE_DPAD_RIGHT, 0, + 0, R.drawable.ic_sysbar_ime_right); private static final ButtonInfo[] ALL_BUTTONS = new ButtonInfo[] { NAVBAR_EMPTY, NAVBAR_HOME, NAVBAR_BACK, NAVBAR_SEARCH, @@ -150,9 +158,18 @@ public class NavbarEditor implements View.OnTouchListener { mRtl = isRtl; mButtonViews = new ArrayList<KeyButtonView>(); + + KeyButtonView dpadLeft = (KeyButtonView) mParent.findViewById(R.id.dpad_left); + dpadLeft.setInfo(NAVBAR_DPAD_LEFT, orientation, true); + mButtonViews.add(dpadLeft); + for (int id : BUTTON_IDS) { mButtonViews.add((KeyButtonView) mParent.findViewById(id)); } + + KeyButtonView dpadRight = (KeyButtonView) mParent.findViewById(R.id.dpad_right); + dpadRight.setInfo(NAVBAR_DPAD_RIGHT, orientation, true); + mButtonViews.add(dpadRight); } public void setEditMode(boolean editMode) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 53ccf49..7e1d3ba 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -24,11 +24,13 @@ import android.animation.ValueAnimator; import android.app.ActivityManagerNative; import android.app.StatusBarManager; import android.content.BroadcastReceiver; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.content.res.Resources; +import android.database.ContentObserver; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -36,6 +38,7 @@ import android.os.Handler; import android.os.Message; import android.os.RemoteException; import android.os.UserHandle; +import android.provider.Settings; import android.util.AttributeSet; import android.util.Log; import android.view.Display; @@ -60,6 +63,8 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; +import cyanogenmod.providers.CMSettings; + public class NavigationBarView extends LinearLayout { final static boolean DEBUG = false; final static String TAG = "PhoneStatusBar/NavigationBarView"; @@ -89,6 +94,13 @@ public class NavigationBarView extends LinearLayout { private DeadZone mDeadZone; private final NavigationBarTransitions mBarTransitions; + // Visibility of R.id.one view prior to swapping it for a left arrow key + public int mSlotOneVisibility = -1; + + // Visibility of R.id.six view prior to swapping it for a right arrow key + public int mSlotSixVisibility = -1; + + // workaround for LayoutTransitions leaving the nav buttons in a weird state (bug 5549288) final static boolean WORKAROUND_INVALID_LAYOUT = true; final static int MSG_CHECK_INVALID_LAYOUT = 8686; @@ -103,6 +115,9 @@ public class NavigationBarView extends LinearLayout { private OnTouchListener mHomeSearchActionListener; private OnLongClickListener mRecentsBackListener; + private SettingsObserver mSettingsObserver; + private boolean mShowDpadArrowKeys; + // performs manual animation in sync with layout transitions private final NavTransitionListener mTransitionListener = new NavTransitionListener(); @@ -207,6 +222,7 @@ public class NavigationBarView extends LinearLayout { mNavBarReceiver = new NavBarReceiver(); getContext().registerReceiver(mNavBarReceiver, new IntentFilter(NAVBAR_EDIT_ACTION)); + mSettingsObserver = new SettingsObserver(new Handler()); } @Override @@ -216,6 +232,13 @@ public class NavigationBarView extends LinearLayout { if (root != null) { root.setDrawDuringWindowsAnimating(true); } + mSettingsObserver.observe(); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mSettingsObserver.unobserve(); } public BarTransitions getBarTransitions() { @@ -355,12 +378,39 @@ public class NavigationBarView extends LinearLayout { ((ImageView)getRecentsButton()).setImageDrawable(mVertical ? mRecentLandIcon : mRecentIcon); ((ImageView)getHomeButton()).setImageDrawable(mVertical ? mHomeLandIcon : mHomeIcon); - final boolean showImeButton = ((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0); + final boolean showImeButton = ((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0) + && !mShowDpadArrowKeys; getImeSwitchButton().setVisibility(showImeButton ? View.VISIBLE : View.INVISIBLE); - // Update menu button in case the IME state has changed. - setMenuVisibility(mShowMenu, true); setDisabledFlags(mDisabledFlags, true); + + if (mShowDpadArrowKeys) { // overrides IME button + final boolean showingIme = ((mNavigationIconHints + & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0); + + setVisibleOrGone(getCurrentView().findViewById(R.id.dpad_left), showingIme); + setVisibleOrGone(getCurrentView().findViewById(R.id.dpad_right), showingIme); + + View one = getCurrentView().findViewById(mVertical ? R.id.six : R.id.one); + View six = getCurrentView().findViewById(mVertical ? R.id.one : R.id.six); + if (showingIme) { + mSlotOneVisibility = one.getVisibility(); + mSlotSixVisibility = six.getVisibility(); + setVisibleOrGone(one, false); + setVisibleOrGone(six, false); + } else { + if (mSlotOneVisibility != -1) { + one.setVisibility(mSlotOneVisibility); + mSlotOneVisibility = -1; + } + if (mSlotSixVisibility != -1) { + six.setVisibility(mSlotSixVisibility); + mSlotSixVisibility = -1; + } + } + } + // Update menu button in case the IME state has changed. + setMenuVisibility(mShowMenu, true); } public void setDisabledFlags(int disabledFlags) { @@ -748,8 +798,16 @@ public class NavigationBarView extends LinearLayout { private void setButtonWithTagVisibility(Object tag, boolean visible) { View findView = mCurrentView.findViewWithTag(tag); - if (findView != null) { - findView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE); + if (findView == null) { + return; + } + int visibility = visible ? View.VISIBLE : View.INVISIBLE; + if (mSlotOneVisibility != -1 && findView.getId() == R.id.one) { + mSlotOneVisibility = visibility; + } else if (mSlotSixVisibility != -1 && findView.getId() == R.id.six) { + mSlotSixVisibility = visibility; + } else { + findView.setVisibility(visibility); } } @@ -786,4 +844,34 @@ public class NavigationBarView extends LinearLayout { setDisabledFlags(mDisabledFlags, true /* force */); setMenuVisibility(mShowMenu, true); } + + private class SettingsObserver extends ContentObserver { + + SettingsObserver(Handler handler) { + super(handler); + } + + void observe() { + ContentResolver resolver = getContext().getContentResolver(); + resolver.registerContentObserver( + CMSettings.System.getUriFor(CMSettings.System.NAVIGATION_BAR_MENU_ARROW_KEYS), + false, this); + + // intialize mModlockDisabled + onChange(false); + } + + void unobserve() { + getContext().getContentResolver().unregisterContentObserver(this); + } + + @Override + public void onChange(boolean selfChange) { + mShowDpadArrowKeys = CMSettings.System.getInt(getContext().getContentResolver(), + CMSettings.System.NAVIGATION_BAR_MENU_ARROW_KEYS, 0) != 0; + mSlotOneVisibility = -1; + mSlotSixVisibility = -1; + setNavigationIconHints(mNavigationIconHints, true); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java index 6d5ade7..6d7bd06 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java @@ -49,6 +49,9 @@ import cyanogenmod.power.PerformanceManager; public class KeyButtonView extends ImageView { + public static final int CURSOR_REPEAT_FLAGS = KeyEvent.FLAG_SOFT_KEYBOARD + | KeyEvent.FLAG_KEEP_TOUCH_MODE; + private long mDownTime; private int mCode; private boolean mIsSmall; @@ -65,13 +68,19 @@ public class KeyButtonView extends ImageView { public void run() { if (isPressed()) { // Log.d("KeyButtonView", "longpressed: " + this); - if (isLongClickable()) { + if (mCode == KeyEvent.KEYCODE_DPAD_LEFT || mCode == KeyEvent.KEYCODE_DPAD_RIGHT) { + sendEvent(KeyEvent.ACTION_UP, CURSOR_REPEAT_FLAGS, + System.currentTimeMillis(), false); + sendEvent(KeyEvent.ACTION_DOWN, CURSOR_REPEAT_FLAGS, + System.currentTimeMillis(), false); + postDelayed(mCheckLongPress, ViewConfiguration.getKeyRepeatDelay()); + } else if (mCode != 0) { + sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS); + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); + } else if (isLongClickable()) { // Just an old-fashioned ImageView mPerformedLongClick = true; performLongClick(); - } else if (mSupportsLongpress) { - sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS); - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); } } } @@ -225,7 +234,10 @@ public class KeyButtonView extends ImageView { case MotionEvent.ACTION_DOWN: mDownTime = SystemClock.uptimeMillis(); setPressed(true); - if (mCode != 0) { + if (mCode == KeyEvent.KEYCODE_DPAD_LEFT || mCode == KeyEvent.KEYCODE_DPAD_RIGHT) { + sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_VIRTUAL_HARD_KEY + | KeyEvent.FLAG_KEEP_TOUCH_MODE, mDownTime, false); + } else if (mCode != 0) { sendEvent(KeyEvent.ACTION_DOWN, 0, mDownTime); } else { // Provide the same haptic feedback that the system offers for virtual keys. @@ -239,8 +251,8 @@ public class KeyButtonView extends ImageView { break; case MotionEvent.ACTION_MOVE: - x = (int)ev.getX(); - y = (int)ev.getY(); + x = (int) ev.getX(); + y = (int) ev.getY(); setPressed(x >= -mTouchSlop && x < getWidth() + mTouchSlop && y >= -mTouchSlop @@ -298,10 +310,17 @@ public class KeyButtonView extends ImageView { } void sendEvent(int action, int flags, long when) { + sendEvent(action, flags, when, true); + } + + void sendEvent(int action, int flags, long when, boolean applyDefaultFlags) { final int repeatCount = (flags & KeyEvent.FLAG_LONG_PRESS) != 0 ? 1 : 0; + if (applyDefaultFlags) { + flags |= KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY; + } final KeyEvent ev = new KeyEvent(mDownTime, when, action, mCode, repeatCount, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, - flags | KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY, + flags, InputDevice.SOURCE_KEYBOARD); InputManager.getInstance().injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC); |