diff options
12 files changed, 99 insertions, 13 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 6089013..c0743cf 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -1296,7 +1296,7 @@ public class InputMethodService extends AbstractInputMethodService { mInShowWindow = false; } } - + void showWindowInner(boolean showInput) { boolean doShowInput = false; boolean wasVisible = mWindowVisible; @@ -1311,7 +1311,7 @@ public class InputMethodService extends AbstractInputMethodService { } else { showInput = true; } - + if (DEBUG) Log.v(TAG, "showWindow: updating UI"); initialize(); updateFullscreenMode(); @@ -1343,14 +1343,15 @@ public class InputMethodService extends AbstractInputMethodService { if (doShowInput) { startExtractingText(false); } - + if (!wasVisible) { if (DEBUG) Log.v(TAG, "showWindow: showing!"); + mImm.setIMEButtonVisible(mToken, true); onWindowShown(); mWindow.show(); } } - + public void hideWindow() { if (mInputViewStarted) { if (DEBUG) Log.v(TAG, "CALL: onFinishInputView"); @@ -1364,11 +1365,12 @@ public class InputMethodService extends AbstractInputMethodService { if (mWindowVisible) { mWindow.hide(); mWindowVisible = false; + mImm.setIMEButtonVisible(mToken, false); onWindowHidden(); mWindowWasVisible = false; } } - + /** * Called when the input method window has been shown to the user, after * previously not being visible. This is done after all of the UI setup diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 7cb6291..033ee7c 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -519,6 +519,15 @@ public final class InputMethodManager { } /** @hide */ + public void setIMEButtonVisible(IBinder imeToken, boolean visible) { + try { + mService.setIMEButtonVisible(imeToken, visible); + } catch (RemoteException e) { + throw new RuntimeException(e); + } + } + + /** @hide */ public void setFullscreenMode(boolean fullScreen) { mFullscreenMode = fullScreen; } diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index 34a5b11..f87ca3e 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -32,5 +32,6 @@ oneway interface IStatusBar void animateCollapse(); void setLightsOn(boolean on); void setMenuKeyVisible(boolean visible); + void setIMEButtonVisible(boolean visible); } diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index 90f4d48..d5ae1f0 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -32,6 +32,7 @@ interface IStatusBarService void removeIcon(String slot); void setActiveWindowIsFullscreen(boolean fullscreen); void setMenuKeyVisible(boolean visible); + void setIMEButtonVisible(boolean visible); // ---- Methods below are for use by the status bar policy services ---- // You need the STATUS_BAR_SERVICE permission diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl index 49ae2bc..ca1cd59 100644 --- a/core/java/com/android/internal/view/IInputMethodManager.aidl +++ b/core/java/com/android/internal/view/IInputMethodManager.aidl @@ -55,6 +55,7 @@ interface IInputMethodManager { void hideMySoftInput(in IBinder token, int flags); void showMySoftInput(in IBinder token, int flags); void updateStatusIcon(in IBinder token, String packageName, int iconId); + void setIMEButtonVisible(in IBinder token, boolean visible); InputMethodSubtype getCurrentInputMethodSubtype(); boolean setInputMethodEnabled(String id, boolean enabled); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java index c164eb4..ed2ed1c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java @@ -55,6 +55,7 @@ public class CommandQueue extends IStatusBar.Stub { private static final int MSG_SET_LIGHTS_ON = 0x00070000; private static final int MSG_SHOW_MENU = 0x00080000; + private static final int MSG_SHOW_IME_BUTTON = 0x00090000; private StatusBarIconList mList; private Callbacks mCallbacks; @@ -81,6 +82,7 @@ public class CommandQueue extends IStatusBar.Stub { public void animateCollapse(); public void setLightsOn(boolean on); public void setMenuKeyVisible(boolean visible); + public void setIMEButtonVisible(boolean visible); } public CommandQueue(Callbacks callbacks, StatusBarIconList list) { @@ -163,6 +165,13 @@ public class CommandQueue extends IStatusBar.Stub { } } + public void setIMEButtonVisible(boolean visible) { + synchronized (mList) { + mHandler.removeMessages(MSG_SHOW_IME_BUTTON); + mHandler.obtainMessage(MSG_SHOW_IME_BUTTON, visible ? 1 : 0, 0, null).sendToTarget(); + } + } + private final class H extends Handler { public void handleMessage(Message msg) { final int what = msg.what & MSG_MASK; @@ -223,6 +232,9 @@ public class CommandQueue extends IStatusBar.Stub { case MSG_SHOW_MENU: mCallbacks.setMenuKeyVisible(msg.arg1 != 0); break; + case MSG_SHOW_IME_BUTTON: + mCallbacks.setIMEButtonVisible(msg.arg1 != 0); + break; } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java index bf58b37..b174973 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java @@ -1014,6 +1014,7 @@ public class PhoneStatusBarService extends StatusBarService { // Not supported public void setMenuKeyVisible(boolean visible) { } + public void setIMEButtonVisible(boolean visible) { } private class Launcher implements View.OnClickListener { private PendingIntent mIntent; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java index ae1fdbd..256386b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java @@ -65,7 +65,7 @@ public abstract class StatusBarService extends SystemUI implements CommandQueue. mCommandQueue = new CommandQueue(this, iconList); mBarService = IStatusBarService.Stub.asInterface( ServiceManager.getService(Context.STATUS_BAR_SERVICE)); - boolean[] switches = new boolean[2]; + boolean[] switches = new boolean[3]; try { mBarService.registerStatusBar(mCommandQueue, iconList, notificationKeys, notifications, switches); @@ -75,6 +75,7 @@ public abstract class StatusBarService extends SystemUI implements CommandQueue. setLightsOn(switches[0]); setMenuKeyVisible(switches[1]); + setIMEButtonVisible(switches[2]); // Set up the initial icon state int N = iconList.size(); @@ -119,6 +120,7 @@ public abstract class StatusBarService extends SystemUI implements CommandQueue. + " icons=" + iconList.size() + " lights=" + (switches[0]?"on":"off") + " menu=" + (switches[1]?"visible":"invisible") + + " imeButton=" + (switches[2]?"visible":"invisible") ); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java index 56b4f24..c52bd4d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java @@ -16,7 +16,10 @@ package com.android.systemui.statusbar.tablet; +import android.content.BroadcastReceiver; import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.provider.Settings; @@ -32,7 +35,9 @@ import android.widget.ImageView; import com.android.server.InputMethodManagerService; import com.android.systemui.R; +import java.util.Calendar; import java.util.List; +import java.util.TimeZone; public class InputMethodButton extends ImageView { @@ -61,8 +66,10 @@ public class InputMethodButton extends ImageView { }); } + @Override protected void onAttachedToWindow() { mIcon = (ImageView) findViewById(R.id.imeButton); + refreshStatusIcon(mKeyboardShown); } @@ -127,13 +134,8 @@ public class InputMethodButton extends ImageView { }); } - public void showSoftInput() { - mKeyboardShown = true; - postRefreshStatusIcon(); - } - - public void hideSoftInput() { - mKeyboardShown = false; + public void setIMEButtonVisible(boolean visible) { + mKeyboardShown = visible; postRefreshStatusIcon(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java index 6e9b456..9dc7850 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java @@ -95,6 +95,8 @@ public class TabletStatusBarService extends StatusBarService { View mMenuButton; View mRecentButton; + InputMethodButton mInputMethodButton; + NotificationPanel mNotificationPanel; SystemPanel mSystemPanel; NotificationPanel mNotificationPeekWindow; @@ -305,6 +307,9 @@ public class TabletStatusBarService extends StatusBarService { mNavigationArea = sb.findViewById(R.id.navigationArea); mMenuButton = mNavigationArea.findViewById(R.id.menu); + // The bar contents buttons + mInputMethodButton = (InputMethodButton) mBarContents.findViewById(R.id.imeButton); + // set the initial view visibility setAreThereNotifications(); refreshNotificationTrigger(); @@ -690,6 +695,14 @@ public class TabletStatusBarService extends StatusBarService { visible ? R.anim.navigation_in : R.anim.navigation_out); } + public void setIMEButtonVisible(boolean visible) { + + if (DEBUG) { + Slog.d(TAG, (visible?"showing":"hiding") + " the IME button"); + } + mInputMethodButton.setIMEButtonVisible(visible); + } + private void setAreThereNotifications() { final boolean hasClearable = mNotns.hasClearableItems(); diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index 3f378e1..07da0fa 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -940,6 +940,23 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } + public void setIMEButtonVisible(IBinder token, boolean visible) { + int uid = Binder.getCallingUid(); + long ident = Binder.clearCallingIdentity(); + try { + if (token == null || mCurToken != token) { + Slog.w(TAG, "Ignoring setIMEButtonVisible of uid " + uid + " token: " + token); + return; + } + + synchronized (mMethodMap) { + mStatusBar.setIMEButtonVisible(visible); + } + } finally { + Binder.restoreCallingIdentity(ident); + } + } + void updateFromSettingsLocked() { // We are assuming that whoever is changing DEFAULT_INPUT_METHOD and // ENABLED_INPUT_METHODS is taking care of keeping them correctly in diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java index 400b31f..95d2b65 100644 --- a/services/java/com/android/server/StatusBarManagerService.java +++ b/services/java/com/android/server/StatusBarManagerService.java @@ -74,6 +74,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub boolean mMenuVisible = false; + boolean mIMEButtonVisible = false; + private class DisableRecord implements IBinder.DeathRecipient { String pkg; int what; @@ -257,6 +259,28 @@ public class StatusBarManagerService extends IStatusBarService.Stub } } + public void setIMEButtonVisible(final boolean visible) { + enforceStatusBar(); + + if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " IME Button"); + + synchronized(mLock) { + if (mIMEButtonVisible != visible) { + mIMEButtonVisible = visible; + mHandler.post(new Runnable() { + public void run() { + if (mBar != null) { + try { + mBar.setIMEButtonVisible(visible); + } catch (RemoteException ex) { + } + } + } + }); + } + } + } + /** * This is used for the automatic version of lights-out mode. Only call this from * the window manager. @@ -345,6 +369,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub synchronized (mLock) { switches[0] = mLightsOn; switches[1] = mMenuVisible; + switches[2] = mIMEButtonVisible; } } |
