diff --git a/core/res/res/layout/input_method_switch_dialog_title.xml b/core/res/res/layout/input_method_switch_dialog_title.xml
new file mode 100644
index 0000000000000..7032bd358a689
--- /dev/null
+++ b/core/res/res/layout/input_method_switch_dialog_title.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index ca0e91323e9c6..a54bc528a0768 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -85,6 +85,8 @@
+
+
@@ -1042,6 +1044,7 @@
+
@@ -1449,6 +1452,7 @@
+
@@ -1471,6 +1475,7 @@
+
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 44f2ade6e4697..97c023ec07775 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2921,6 +2921,10 @@
Choose input method
Set up input methods
+
+ Physical keyboard
+
+ Hardware
\u0020ABCDEFGHIJKLMNOPQRSTUVWXYZ
\u00200123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_input_methods_panel.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_input_methods_panel.xml
index f6ed8040157ad..b712dba2d317e 100644
--- a/packages/SystemUI/res/layout-sw600dp/status_bar_input_methods_panel.xml
+++ b/packages/SystemUI/res/layout-sw600dp/status_bar_input_methods_panel.xml
@@ -21,7 +21,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:paddingBottom="28dip"
+ android:paddingBottom="7dip"
android:orientation="vertical"
android:visibility="gone">
+ android:background="@drawable/notify_panel_clock_bg">
Set up input methods
- Use physical keyboard
+ Physical keyboard
Allow the app %1$s to access the USB device?
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
index f793af9fb1126..2171329a5e1e1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
@@ -201,7 +201,6 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel,
if (closeKeyboard) {
mImm.hideSoftInputFromWindow(getWindowToken(), 0);
}
- updateHardKeyboardEnabled();
}
private void startActivity(Intent intent) {
@@ -329,6 +328,7 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel,
mHardKeyboardSection.setVisibility(View.VISIBLE);
if (mHardKeyboardSwitch.isChecked() != mHardKeyboardEnabled) {
mHardKeyboardSwitch.setChecked(mHardKeyboardEnabled);
+ updateHardKeyboardEnabled();
}
} else {
mHardKeyboardSection.setVisibility(View.GONE);
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 96ee2f037de83..ca7241c3dfcc3 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -27,6 +27,7 @@ import com.android.internal.view.IInputMethodManager;
import com.android.internal.view.IInputMethodSession;
import com.android.internal.view.InputBindResult;
import com.android.server.EventLogTags;
+import com.android.server.wm.WindowManagerService;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -91,7 +92,10 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import android.widget.ArrayAdapter;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton;
+import android.widget.Switch;
import android.widget.TextView;
import java.io.File;
@@ -134,6 +138,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
static final int MSG_UNBIND_METHOD = 3000;
static final int MSG_BIND_METHOD = 3010;
+ static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000;
+
static final long TIME_TO_RECONNECT = 10*1000;
static final int SECURE_SUGGESTION_SPANS_MAX_SIZE = 20;
@@ -156,6 +162,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
final HandlerCaller mCaller;
private final InputMethodFileManager mFileManager;
private final InputMethodAndSubtypeListManager mImListManager;
+ private final HardKeyboardListener mHardKeyboardListener;
+ private final WindowManagerService mWindowManagerService;
final InputBindResult mNoBinding = new InputBindResult(null, null, -1);
@@ -360,6 +368,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
private AlertDialog.Builder mDialogBuilder;
private AlertDialog mSwitchingDialog;
+ private View mSwitchingDialogTitleView;
private InputMethodInfo[] mIms;
private int[] mSubtypeIds;
@@ -528,7 +537,31 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
}
- public InputMethodManagerService(Context context) {
+ private class HardKeyboardListener
+ implements WindowManagerService.OnHardKeyboardStatusChangeListener {
+ @Override
+ public void onHardKeyboardStatusChange(boolean available, boolean enabled) {
+ mHandler.sendMessage(mHandler.obtainMessage(
+ MSG_HARD_KEYBOARD_SWITCH_CHANGED, available ? 1 : 0, enabled ? 1 : 0));
+ }
+
+ public void handleHardKeyboardStatusChange(boolean available, boolean enabled) {
+ if (DEBUG) {
+ Slog.w(TAG, "HardKeyboardStatusChanged: available = " + available + ", enabled = "
+ + enabled);
+ }
+ synchronized(mMethodMap) {
+ if (mSwitchingDialog != null && mSwitchingDialogTitleView != null
+ && mSwitchingDialog.isShowing()) {
+ mSwitchingDialogTitleView.findViewById(
+ com.android.internal.R.id.hard_keyboard_section).setVisibility(
+ available ? View.VISIBLE : View.GONE);
+ }
+ }
+ }
+ }
+
+ public InputMethodManagerService(Context context, WindowManagerService windowManager) {
mContext = context;
mRes = context.getResources();
mHandler = new Handler(this);
@@ -540,6 +573,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
handleMessage(msg);
}
});
+ mWindowManagerService = windowManager;
+ mHardKeyboardListener = new HardKeyboardListener();
mImeSwitcherNotification = new Notification();
mImeSwitcherNotification.icon = com.android.internal.R.drawable.ic_notification_ime_default;
@@ -633,6 +668,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
updateImeWindowStatusLocked();
mShowOngoingImeSwitcherForPhones = mRes.getBoolean(
com.android.internal.R.bool.show_ongoing_ime_switcher);
+ if (mShowOngoingImeSwitcherForPhones) {
+ mWindowManagerService.setOnHardKeyboardStatusChangeListener(
+ mHardKeyboardListener);
+ }
try {
startInputInnerLocked();
} catch (RuntimeException e) {
@@ -1994,6 +2033,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Slog.w(TAG, "Client died receiving input method " + args.arg2);
}
return true;
+
+ // --------------------------------------------------------------
+ case MSG_HARD_KEYBOARD_SWITCH_CHANGED:
+ mHardKeyboardListener.handleHardKeyboardStatusChange(
+ msg.arg1 == 1, msg.arg2 == 1);
+ return true;
}
return false;
}
@@ -2204,12 +2249,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
}
}
-
final TypedArray a = context.obtainStyledAttributes(null,
com.android.internal.R.styleable.DialogPreference,
com.android.internal.R.attr.alertDialogStyle, 0);
mDialogBuilder = new AlertDialog.Builder(context)
- .setTitle(com.android.internal.R.string.select_input_method)
.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
@@ -2219,6 +2262,29 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
.setIcon(a.getDrawable(
com.android.internal.R.styleable.DialogPreference_dialogTitle));
a.recycle();
+ final LayoutInflater inflater =
+ (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ final View tv = inflater.inflate(
+ com.android.internal.R.layout.input_method_switch_dialog_title, null);
+ mDialogBuilder.setCustomTitle(tv);
+
+ // Setup layout for a toggle switch of the hardware keyboard
+ mSwitchingDialogTitleView = tv;
+ mSwitchingDialogTitleView.findViewById(
+ com.android.internal.R.id.hard_keyboard_section).setVisibility(
+ mWindowManagerService.isHardKeyboardAvailable() ?
+ View.VISIBLE : View.GONE);
+ final Switch hardKeySwitch = ((Switch)mSwitchingDialogTitleView.findViewById(
+ com.android.internal.R.id.hard_keyboard_switch));
+ hardKeySwitch.setChecked(mWindowManagerService.isHardKeyboardEnabled());
+ hardKeySwitch.setOnCheckedChangeListener(
+ new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(
+ CompoundButton buttonView, boolean isChecked) {
+ mWindowManagerService.setHardKeyboardEnabled(isChecked);
+ }
+ });
final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(context,
com.android.internal.R.layout.simple_list_item_2_single_choice, imList,
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 7dd736d15cc1b..ad3cca8064c91 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -274,7 +274,7 @@ class ServerThread extends Thread {
if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
try {
Slog.i(TAG, "Input Method Service");
- imm = new InputMethodManagerService(context);
+ imm = new InputMethodManagerService(context, wm);
ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm);
} catch (Throwable e) {
reportWtf("starting Input Manager Service", e);