summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-08-04 09:40:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-01 16:06:20 +0000
commit8d70ad22a5c821a02685704a3db18ddb7ad07f22 (patch)
tree510906d02a42bb76d321d4f8021e7dcdc882eca1
parente5aa75cabfb6bb4877e1bb20cb0dfe511002c3a4 (diff)
parentd130b803b0787131208bea99926dc655b124f006 (diff)
downloadframeworks_base-8d70ad22a5c821a02685704a3db18ddb7ad07f22.zip
frameworks_base-8d70ad22a5c821a02685704a3db18ddb7ad07f22.tar.gz
frameworks_base-8d70ad22a5c821a02685704a3db18ddb7ad07f22.tar.bz2
Merge "Fix input method picker using Material design language" into lmp-dev
-rw-r--r--core/res/res/layout/input_method_switch_dialog_title.xml21
-rw-r--r--core/res/res/layout/input_method_switch_item.xml63
-rw-r--r--core/res/res/values/symbols.xml1
-rw-r--r--services/core/java/com/android/server/InputMethodManagerService.java122
4 files changed, 132 insertions, 75 deletions
diff --git a/core/res/res/layout/input_method_switch_dialog_title.xml b/core/res/res/layout/input_method_switch_dialog_title.xml
index e11a523..d498d23 100644
--- a/core/res/res/layout/input_method_switch_dialog_title.xml
+++ b/core/res/res/layout/input_method_switch_dialog_title.xml
@@ -33,7 +33,7 @@
<com.android.internal.widget.DialogTitle
android:id="@+id/alertTitle"
- style="@android:style/DialogWindowTitle.Holo"
+ style="@android:style/DialogWindowTitle.DeviceDefault"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
@@ -49,11 +49,6 @@
android:layout_height="wrap_content"
android:orientation="vertical" >
- <View
- android:layout_width="match_parent"
- android:layout_height="2dip"
- android:background="@android:color/holo_blue_light" />
-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -97,12 +92,10 @@
android:layout_gravity="center_vertical"
android:layout_marginEnd="12dip" />
</LinearLayout>
- </LinearLayout>
- <View
- android:id="@+id/titleDivider"
- android:layout_width="match_parent"
- android:layout_height="2dip"
- android:background="@android:drawable/divider_horizontal_dark" />
-
-</LinearLayout> \ No newline at end of file
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="?android:attr/listDividerAlertDialog" />
+ </LinearLayout>
+</LinearLayout>
diff --git a/core/res/res/layout/input_method_switch_item.xml b/core/res/res/layout/input_method_switch_item.xml
new file mode 100644
index 0000000..cfa8b31
--- /dev/null
+++ b/core/res/res/layout/input_method_switch_item.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:paddingStart="16dip"
+ android:paddingEnd="12dip"
+ android:minHeight="?attr/listPreferredItemHeightSmall"
+ android:background="@color/transparent">
+
+ <RadioButton
+ android:id="@+id/radio"
+ android:layout_width="35dip"
+ android:layout_height="wrap_content"
+ android:paddingEnd="12dip"
+ android:gravity="center_vertical"
+ android:focusable="false"
+ android:clickable="false" />
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:orientation="vertical"
+ android:gravity="center_vertical">
+
+ <TextView android:id="@android:id/text1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?attr/textAppearanceListItem"
+ android:textColor="?attr/textColorAlertDialogListItem"
+ android:gravity="center_vertical|start"
+ android:singleLine="true"
+ android:ellipsize="marquee" />
+
+ <TextView android:id="@android:id/text2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?attr/textAppearanceListItemSecondary"
+ android:textColor="?attr/textColorAlertDialogListItem"
+ android:gravity="center_vertical|start"
+ android:singleLine="true"
+ android:ellipsize="marquee" />
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 5c8926e..84bc62c 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1195,6 +1195,7 @@
<java-symbol type="layout" name="icon_menu_layout" />
<java-symbol type="layout" name="input_method" />
<java-symbol type="layout" name="input_method_extract_view" />
+ <java-symbol type="layout" name="input_method_switch_item" />
<java-symbol type="layout" name="input_method_switch_dialog_title" />
<java-symbol type="layout" name="js_prompt" />
<java-symbol type="layout" name="list_content_simple" />
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index d4f141d..74ae812 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -51,6 +51,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
+import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
@@ -91,6 +92,7 @@ import android.util.PrintWriterPrinter;
import android.util.Printer;
import android.util.Slog;
import android.util.Xml;
+import android.view.ContextThemeWrapper;
import android.view.IWindowManager;
import android.view.InputChannel;
import android.view.LayoutInflater;
@@ -2728,6 +2730,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return mKeyguardManager != null
&& mKeyguardManager.isKeyguardLocked() && mKeyguardManager.isKeyguardSecure();
}
+
private void showInputMethodMenuInternal(boolean showSubtypes) {
if (DEBUG) Slog.v(TAG, "Show switching menu");
@@ -2778,84 +2781,81 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
}
}
- final TypedArray a = context.obtainStyledAttributes(null,
+ final Context themedContext = new ContextThemeWrapper(context,
+ android.R.style.Theme_DeviceDefault_Settings);
+ mDialogBuilder = new AlertDialog.Builder(themedContext);
+ final TypedArray a = themedContext.obtainStyledAttributes(null,
com.android.internal.R.styleable.DialogPreference,
com.android.internal.R.attr.alertDialogStyle, 0);
- mDialogBuilder = new AlertDialog.Builder(context)
- .setOnCancelListener(new OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- hideInputMethodMenu();
- }
- })
- .setIcon(a.getDrawable(
- com.android.internal.R.styleable.DialogPreference_dialogTitle));
+ mDialogBuilder.setIcon(a.getDrawable(
+ com.android.internal.R.styleable.DialogPreference_dialogIcon));
a.recycle();
+ mDialogBuilder.setOnCancelListener(new OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ hideInputMethodMenu();
+ }
+ });
final LayoutInflater inflater =
- (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ (LayoutInflater)themedContext.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));
+ 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);
- // Ensure that the input method dialog is dismissed when changing
- // the hardware keyboard state.
- hideInputMethodMenu();
+ hardKeySwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mWindowManagerService.setHardKeyboardEnabled(isChecked);
+ // Ensure that the input method dialog is dismissed when changing
+ // the hardware keyboard state.
+ hideInputMethodMenu();
+ }
+ });
+
+ final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(themedContext,
+ com.android.internal.R.layout.input_method_switch_item, imList, checkedItem);
+ final OnClickListener choiceListener = new OnClickListener() {
+ @Override
+ public void onClick(final DialogInterface dialog, final int which) {
+ synchronized (mMethodMap) {
+ if (mIms == null || mIms.length <= which || mSubtypeIds == null
+ || mSubtypeIds.length <= which) {
+ return;
}
- });
-
- final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(context,
- com.android.internal.R.layout.simple_list_item_2_single_choice, imList,
- checkedItem);
-
- mDialogBuilder.setSingleChoiceItems(adapter, checkedItem,
- new AlertDialog.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- synchronized (mMethodMap) {
- if (mIms == null || mIms.length <= which
- || mSubtypeIds == null || mSubtypeIds.length <= which) {
- return;
- }
- InputMethodInfo im = mIms[which];
- int subtypeId = mSubtypeIds[which];
- adapter.mCheckedItem = which;
- adapter.notifyDataSetChanged();
- hideInputMethodMenu();
- if (im != null) {
- if ((subtypeId < 0)
- || (subtypeId >= im.getSubtypeCount())) {
- subtypeId = NOT_A_SUBTYPE_ID;
- }
- setInputMethodLocked(im.getId(), subtypeId);
- }
+ final InputMethodInfo im = mIms[which];
+ int subtypeId = mSubtypeIds[which];
+ adapter.mCheckedItem = which;
+ adapter.notifyDataSetChanged();
+ hideInputMethodMenu();
+ if (im != null) {
+ if (subtypeId < 0 || subtypeId >= im.getSubtypeCount()) {
+ subtypeId = NOT_A_SUBTYPE_ID;
}
+ setInputMethodLocked(im.getId(), subtypeId);
}
- });
+ }
+ }
+ };
+ mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, choiceListener);
if (showSubtypes && !isScreenLocked) {
+ final OnClickListener positiveListener = new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int whichButton) {
+ showConfigureInputMethods();
+ }
+ };
mDialogBuilder.setPositiveButton(
- com.android.internal.R.string.configure_input_methods,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int whichButton) {
- showConfigureInputMethods();
- }
- });
+ com.android.internal.R.string.configure_input_methods, positiveListener);
}
mSwitchingDialog = mDialogBuilder.create();
mSwitchingDialog.setCanceledOnTouchOutside(true);