Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10163c68 authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Experimental: Tapping on the status bar sends a space key.

While any IME is showing, taps on the empty region in the
center of the status bar will inject a KEYCODE_SPACE (62)
KeyEvent. This gives a huge Fitts' Law boost to LatinIME's
spacebar, which is easy to miss when typing quickly.

This is sort of a hack; a better solution would be to
translate the tap vertically until it enters the IME's
window and then hand the motion event back to the IME
(thereby accommodating IMEs that have something other than a
spacebar in their bottom row).

Bug: 3114340
Change-Id: Iabbfb5ca0000101074932304bce44eb6f7dca85d
parent 65dd62a3
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -264,5 +264,17 @@
                android:visibility="gone"
                />
        </RelativeLayout>

        <!-- fake space bar zone -->
        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/fake_space_bar"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:paddingLeft="8dip"
            android:paddingRight="8dip"
            android:layout_toRightOf="@+id/navigationArea"
            android:layout_toLeftOf="@+id/notificationArea"
            android:visibility="gone"
            systemui:keyCode="62"
            />
    </RelativeLayout>
</com.android.systemui.statusbar.tablet.TabletStatusBarView>
+28 −0
Original line number Diff line number Diff line
@@ -40,11 +40,14 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.text.TextUtils;
import android.util.Slog;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.Gravity;
import android.view.IWindowManager;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -84,6 +87,9 @@ public class TabletStatusBar extends StatusBar {
    public static final int MSG_SHOW_SHADOWS = 1031;
    public static final int MSG_RESTORE_SHADOWS = 1032;

    // Fitts' Law assistance for LatinIME; TODO: replace with a more general approach
    private static final boolean FAKE_SPACE_BAR = true;

    private static final int MAX_IMAGE_LEVEL = 10000;
    private static final boolean USE_2D_RECENTS = true;

@@ -93,6 +99,8 @@ public class TabletStatusBar extends StatusBar {

    H mHandler = new H();

    IWindowManager mWindowManager;

    // tracking all current notifications
    private NotificationData mNotns = new NotificationData();

@@ -134,6 +142,9 @@ public class TabletStatusBar extends StatusBar {

    TabletTicker mTicker;

    View mFakeSpaceBar;
    KeyEvent mSpaceBarKeyEvent = null;

    // for disabling the status bar
    int mDisabled = 0;

@@ -253,6 +264,9 @@ public class TabletStatusBar extends StatusBar {
        final Context context = mContext;
        final Resources res = context.getResources();
        
        mWindowManager = IWindowManager.Stub.asInterface(
                ServiceManager.getService(Context.WINDOW_SERVICE));

        mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);

        final TabletStatusBarView sb = (TabletStatusBarView)View.inflate(
@@ -304,6 +318,9 @@ public class TabletStatusBar extends StatusBar {
        // The bar contents buttons
        mInputMethodSwitchButton = (InputMethodButton) sb.findViewById(R.id.imeSwitchButton);

        // for redirecting errant bar taps to the IME
        mFakeSpaceBar = sb.findViewById(R.id.fake_space_bar);

        // "shadows" of the status bar features, for lights-out mode
        mBackShadow = sb.findViewById(R.id.back_shadow);
        mHomeShadow = sb.findViewById(R.id.home_shadow);
@@ -698,6 +715,9 @@ public class TabletStatusBar extends StatusBar {
        mInputMethodSwitchButton.setIMEButtonVisible(token, visible);
        mBackButton.setImageResource(
                visible ? R.drawable.ic_sysbar_back_ime : R.drawable.ic_sysbar_back);
        if (FAKE_SPACE_BAR) {
            mFakeSpaceBar.setVisibility(visible ? View.VISIBLE : View.GONE);
        }
    }

    private boolean isImmersive() {
@@ -739,6 +759,14 @@ public class TabletStatusBar extends StatusBar {
        }
    }

    private void sendKey(KeyEvent key) {
        try {
            if (DEBUG) Slog.d(TAG, "injecting key event: " + key);
            mWindowManager.injectInputEventNoWait(key);
        } catch (RemoteException ex) {
        }
    }

    private View.OnClickListener mOnClickListener = new View.OnClickListener() {
        public void onClick(View v) {
            if (v == mNotificationTrigger) {