diff options
Diffstat (limited to 'packages/SystemUI')
11 files changed, 151 insertions, 92 deletions
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_input_methods_panel.xml b/packages/SystemUI/res/layout-xlarge/status_bar_input_methods_panel.xml index c4bca61..bb1cf23 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar_input_methods_panel.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar_input_methods_panel.xml @@ -38,6 +38,47 @@ android:layout_marginLeft="20dip" android:orientation="vertical" android:background="@*android:drawable/dialog_full_holo_dark"> + <!-- Hard keyboard switch --> + <LinearLayout + android:id="@+id/hard_keyboard_section" + android:layout_height="wrap_content" + android:layout_width="match_parent" + android:orientation="vertical"> + <LinearLayout + android:layout_height="wrap_content" + android:layout_width="match_parent" + android:orientation="horizontal"> + <TextView + android:id="@+id/use_physical_keyboard_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:minHeight="?android:attr/listPreferredItemHeight" + android:background="?android:attr/selectableItemBackground" + android:orientation="vertical" + android:paddingRight="6dip" + android:paddingLeft="30dip" + android:paddingTop="5dip" + android:paddingBottom="5dip" + android:gravity="center_vertical" + android:singleLine="true" + android:text="@string/status_bar_use_physical_keyboard" + android:textAppearance="?android:attr/textAppearanceMedium" + android:ellipsize="marquee" /> + <Switch + android:id="@+id/hard_keyboard_switch" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_marginRight="16dip" /> + </LinearLayout> + <View + android:layout_width="match_parent" + android:layout_height="1dip" + android:background="@android:drawable/divider_horizontal_dark" /> + </LinearLayout> + + <!-- Input method list --> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -50,6 +91,8 @@ android:layout_height="wrap_content" android:orientation="vertical" /> </ScrollView> + + <!-- Configure input methods --> <TextView android:id="@+id/ime_settings_shortcut" android:layout_width="match_parent" diff --git a/packages/SystemUI/res/values-es-rUS/strings.xml b/packages/SystemUI/res/values-es-rUS/strings.xml index a550a0b..c38abdd 100644 --- a/packages/SystemUI/res/values-es-rUS/strings.xml +++ b/packages/SystemUI/res/values-es-rUS/strings.xml @@ -43,4 +43,5 @@ <!-- outdated translation 5550538721034982973 --> <string name="recent_tasks_app_label" msgid="3796483981246752469">"Google Apps"</string> <!-- outdated translation 8017158699581472359 --> <string name="bluetooth_tethered" msgid="7094101612161133267">"Bluetooth anclado"</string> <!-- outdated translation 3875357213648023768 --> <string name="status_bar_input_method_settings_configure_input_methods" msgid="737483394044014246">"Configurar métodos de entrada"</string> + <string name="status_bar_use_physical_keyboard">"Usar un teclado externo"</string> </resources> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 53d06c0..0923570 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -112,4 +112,7 @@ <string name="bluetooth_tethered">Bluetooth tethered</string> <!-- Title of a button to open the settings for input methods [CHAR LIMIT=30] --> <string name="status_bar_input_method_settings_configure_input_methods">Configure input methods</string> + + <!-- Label of a toggle switch to disable use of the physical keyboard in favor of the IME. [CHAR LIMIT=25] --> + <string name="status_bar_use_physical_keyboard">Use physical keyboard</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java index 76aa793..d55a7c2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java @@ -56,6 +56,7 @@ public class CommandQueue extends IStatusBar.Stub { private static final int MSG_SHOW_MENU = 0x00080000; private static final int MSG_SHOW_IME_BUTTON = 0x00090000; + private static final int MSG_SET_HARD_KEYBOARD_STATUS = 0x000a0000; private StatusBarIconList mList; private Callbacks mCallbacks; @@ -83,6 +84,7 @@ public class CommandQueue extends IStatusBar.Stub { public void setLightsOn(boolean on); public void setMenuKeyVisible(boolean visible); public void setImeWindowStatus(IBinder token, int vis, int backDisposition); + public void setHardKeyboardStatus(boolean available, boolean enabled); } public CommandQueue(Callbacks callbacks, StatusBarIconList list) { @@ -173,6 +175,14 @@ public class CommandQueue extends IStatusBar.Stub { } } + public void setHardKeyboardStatus(boolean available, boolean enabled) { + synchronized (mList) { + mHandler.removeMessages(MSG_SET_HARD_KEYBOARD_STATUS); + mHandler.obtainMessage(MSG_SET_HARD_KEYBOARD_STATUS, + available ? 1 : 0, enabled ? 1 : 0).sendToTarget(); + } + } + private final class H extends Handler { public void handleMessage(Message msg) { final int what = msg.what & MSG_MASK; @@ -236,6 +246,9 @@ public class CommandQueue extends IStatusBar.Stub { case MSG_SHOW_IME_BUTTON: mCallbacks.setImeWindowStatus((IBinder)msg.obj, msg.arg1, msg.arg2); break; + case MSG_SET_HARD_KEYBOARD_STATUS: + mCallbacks.setHardKeyboardStatus(msg.arg1 != 0, msg.arg2 != 0); + break; } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java index da8e831..23ae823 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java @@ -67,7 +67,7 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac mCommandQueue = new CommandQueue(this, iconList); mBarService = IStatusBarService.Stub.asInterface( ServiceManager.getService(Context.STATUS_BAR_SERVICE)); - int[] switches = new int[5]; + int[] switches = new int[7]; ArrayList<IBinder> binders = new ArrayList<IBinder>(); try { mBarService.registerStatusBar(mCommandQueue, iconList, notificationKeys, notifications, @@ -81,6 +81,7 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac setMenuKeyVisible(switches[2] != 0); // StatusBarManagerService has a back up of IME token and it's restored here. setImeWindowStatus(binders.get(0), switches[3], switches[4]); + setHardKeyboardStatus(switches[5] != 0, switches[6] != 0); // Set up the initial icon state int N = iconList.size(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 9505391..1e46246 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1021,6 +1021,8 @@ public class PhoneStatusBar extends StatusBar { // Not supported public void setMenuKeyVisible(boolean visible) { } public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { } + @Override + public void setHardKeyboardStatus(boolean available, boolean enabled) { } private class Launcher implements View.OnClickListener { private PendingIntent mIntent; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java index 136f4a94..6ab03e1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java @@ -20,6 +20,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.text.format.DateFormat; import android.util.AttributeSet; import android.util.Slog; import android.widget.TextView; @@ -27,7 +28,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewParent; -import java.text.DateFormat; import java.util.Date; public final class DateView extends TextView { @@ -86,8 +86,11 @@ public final class DateView extends TextView { } private final void updateClock() { + final Context context = getContext(); Date now = new Date(); - setText(DateFormat.getDateInstance(DateFormat.FULL).format(now)); + CharSequence dow = DateFormat.format("EEEE", now); + CharSequence date = DateFormat.getMediumDateFormat(getContext()).format(now); + setText(dow + "\n" + date); } private boolean isVisible() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java index d3f4703..a4c153f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java @@ -146,6 +146,7 @@ public class NetworkController extends BroadcastReceiver { filter.addAction(Telephony.Intents.SPN_STRINGS_UPDATED_ACTION); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); filter.addAction(ConnectivityManager.INET_CONDITION_ACTION); + filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); context.registerReceiver(this, filter); // yuck @@ -197,6 +198,8 @@ public class NetworkController extends BroadcastReceiver { action.equals(ConnectivityManager.INET_CONDITION_ACTION)) { updateConnectivity(intent); refreshViews(); + } else if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) { + refreshViews(); } } 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 f131111..100ed55 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java @@ -17,32 +17,23 @@ package com.android.systemui.statusbar.tablet; import android.content.Context; -import android.content.pm.PackageManager; -import android.graphics.drawable.Drawable; import android.os.IBinder; import android.provider.Settings; -import android.util.Log; import android.util.AttributeSet; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; -import android.view.inputmethod.InputMethodSubtype; import android.view.View; import android.widget.ImageView; import com.android.systemui.R; import java.util.List; -import java.util.Map; public class InputMethodButton extends ImageView { private static final String TAG = "StatusBar/InputMethodButton"; private static final boolean DEBUG = false; - private static final int ID_IME_SWITCH_BUTTON = R.id.imeSwitchButton; - // IME shortcut button is disabled. - private static final int ID_IME_SHORTCUT_BUTTON = 0; - // These values are defined in Settings application. private static final int ID_IME_BUTTON_VISIBILITY_AUTO = 0; private static final int ID_IME_BUTTON_VISIBILITY_ALWAYS_SHOW = 1; @@ -55,8 +46,7 @@ public class InputMethodButton extends ImageView { private IBinder mToken; private boolean mShowButton = false; private boolean mScreenLocked = false; - private InputMethodInfo mShortcutInfo; - private InputMethodSubtype mShortcutSubtype; + private boolean mHardKeyboardAvailable; public InputMethodButton(Context context, AttributeSet attrs) { super(context, attrs); @@ -65,26 +55,6 @@ public class InputMethodButton extends ImageView { mId = getId(); // IME hookup mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); - // TODO: read the current icon & visibility state directly from the service - - // TODO: register for notifications about changes to visibility & subtype from service - - setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - switch (mId) { - case ID_IME_SWITCH_BUTTON: - mImm.showInputMethodPicker(); - break; - case ID_IME_SHORTCUT_BUTTON: - if (mToken != null && mShortcutInfo != null) { - mImm.setInputMethodAndSubtype( - mToken, mShortcutInfo.getId(), mShortcutSubtype); - } - break; - } - } - }); } @Override @@ -94,57 +64,17 @@ public class InputMethodButton extends ImageView { refreshStatusIcon(); } - // TODO: Need to show an appropriate drawable for this shortcut button, - // if there are two or more shortcut input methods contained in this button. - // And need to add other methods to handle multiple shortcuts as appropriate. - private Drawable getShortcutInputMethodAndSubtypeDrawable() { - Map<InputMethodInfo, List<InputMethodSubtype>> shortcuts = - mImm.getShortcutInputMethodsAndSubtypes(); - if (shortcuts.size() > 0) { - for (InputMethodInfo imi: shortcuts.keySet()) { - List<InputMethodSubtype> subtypes = shortcuts.get(imi); - // TODO: Returns the first found IMI for now. Should handle all shortcuts as - // appropriate. - mShortcutInfo = imi; - // TODO: Pick up the first found subtype for now. Should handle all subtypes - // as appropriate. - mShortcutSubtype = subtypes.size() > 0 ? subtypes.get(0) : null; - return getSubtypeIcon(mShortcutInfo, mShortcutSubtype); - } - } - return null; - } - - private Drawable getSubtypeIcon(InputMethodInfo imi, InputMethodSubtype subtype) { - final PackageManager pm = getContext().getPackageManager(); - if (imi != null) { - if (DEBUG) { - Log.d(TAG, "Update icons of IME: " + imi.getPackageName()); - } - if (subtype != null) { - return pm.getDrawable(imi.getPackageName(), subtype.getIconResId(), - imi.getServiceInfo().applicationInfo); - } else if (imi.getSubtypeCount() > 0) { - return pm.getDrawable(imi.getPackageName(), - imi.getSubtypeAt(0).getIconResId(), - imi.getServiceInfo().applicationInfo); - } else { - try { - return pm.getApplicationInfo(imi.getPackageName(), 0).loadIcon(pm); - } catch (PackageManager.NameNotFoundException e) { - Log.w(TAG, "IME can't be found: " + imi.getPackageName()); - } - } - } - return null; - } - // Display IME switcher icon only when all of the followings are true: // * There is only one enabled IME on the device. (Note that the IME should be the system IME) // * There are no explicitly enabled (by the user) subtypes of the IME, or the IME doesn't have // its subtypes at all private boolean needsToShowIMEButton() { if (!mShowButton || mScreenLocked) return false; + + if (mHardKeyboardAvailable) { + return true; + } + List<InputMethodInfo> imis = mImm.getEnabledInputMethodList(); final int size = imis.size(); final int visibility = loadInputMethodSelectorVisibility(); @@ -170,17 +100,7 @@ public class InputMethodButton extends ImageView { } else { setVisibility(View.VISIBLE); } - Drawable icon = null; - switch (mId) { - case ID_IME_SHORTCUT_BUTTON: - icon = getShortcutInputMethodAndSubtypeDrawable(); - break; - } - if (icon == null) { - mIcon.setImageResource(R.drawable.ic_sysbar_ime); - } else { - mIcon.setImageDrawable(icon); - } + mIcon.setImageResource(R.drawable.ic_sysbar_ime); } private int loadInputMethodSelectorVisibility() { @@ -200,6 +120,13 @@ public class InputMethodButton extends ImageView { refreshStatusIcon(); } + public void setHardKeyboardStatus(boolean available) { + if (mHardKeyboardAvailable != available) { + mHardKeyboardAvailable = available; + refreshStatusIcon(); + } + } + public void setScreenLocked(boolean locked) { mScreenLocked = locked; refreshStatusIcon(); 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 474ef45..502e0fe 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java @@ -23,11 +23,13 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.os.IBinder; +import android.os.RemoteException; import android.provider.Settings; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.util.Pair; +import android.util.Slog; import android.view.View; import android.view.View.OnClickListener; import android.view.inputmethod.InputMethodInfo; @@ -36,6 +38,7 @@ import android.view.inputmethod.InputMethodSubtype; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RadioButton; +import android.widget.Switch; import android.widget.TextView; import java.util.Comparator; @@ -45,6 +48,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; +import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.R; public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, OnClickListener { @@ -73,6 +77,11 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O private IBinder mToken; private InputMethodButton mInputMethodSwitchButton; private LinearLayout mInputMethodMenuList; + private boolean mHardKeyboardAvailable; + private boolean mHardKeyboardEnabled; + private OnHardKeyboardEnabledChangeListener mHardKeyboardEnabledChangeListener; + private LinearLayout mHardKeyboardSection; + private Switch mHardKeyboardSwitch; private PackageManager mPackageManager; private String mEnabledInputMethodAndSubtypesCacheStr; private String mLastSystemLocaleString; @@ -107,6 +116,11 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O mIntentFilter.addDataScheme("package"); } + public void setHardKeyboardEnabledChangeListener( + OnHardKeyboardEnabledChangeListener listener) { + mHardKeyboardEnabledChangeListener = listener; + } + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); @@ -128,6 +142,9 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O @Override public void onFinishInflate() { mInputMethodMenuList = (LinearLayout) findViewById(R.id.input_method_menu_list); + mHardKeyboardSection = (LinearLayout) findViewById(R.id.hard_keyboard_section); + mHardKeyboardSwitch = (Switch) findViewById(R.id.hard_keyboard_switch); + mHardKeyboardSwitch.setOnClickListener(this); mConfigureImeShortcut = ((View) findViewById(R.id.ime_settings_shortcut)); mConfigureImeShortcut.setOnClickListener(this); // TODO: If configurations for IME are not changed, do not update @@ -162,7 +179,9 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O if (view == mConfigureImeShortcut) { showConfigureInputMethods(); onFinishPanel(true); - return; + } else if (view == mHardKeyboardSwitch) { + mHardKeyboardEnabled = mHardKeyboardSwitch.isChecked(); + mHardKeyboardEnabledChangeListener.onHardKeyboardEnabledChange(mHardKeyboardEnabled); } } @@ -239,6 +258,8 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O } private void updateUiElements() { + updateHardKeyboardSection(); + // TODO: Reuse subtype views. mInputMethodMenuList.removeAllViews(); mRadioViewAndImiMap.clear(); @@ -278,6 +299,23 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O } } + public void setHardKeyboardStatus(boolean available, boolean enabled) { + if (mHardKeyboardAvailable != available || mHardKeyboardEnabled != enabled) { + mHardKeyboardAvailable = available; + mHardKeyboardEnabled = enabled; + updateHardKeyboardSection(); + } + } + + private void updateHardKeyboardSection() { + if (mHardKeyboardAvailable) { + mHardKeyboardSection.setVisibility(View.VISIBLE); + mHardKeyboardSwitch.setChecked(mHardKeyboardEnabled); + } else { + mHardKeyboardSection.setVisibility(View.GONE); + } + } + // Turn on the selected radio button when the user chooses the item private Pair<InputMethodInfo, InputMethodSubtype> updateRadioButtonsByView(View selectedView) { Pair<InputMethodInfo, InputMethodSubtype> selectedImiAndSubtype = null; @@ -423,4 +461,8 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O } mPackageChanged = true; } + + public interface OnHardKeyboardEnabledChangeListener { + public void onHardKeyboardEnabledChange(boolean enabled); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index 1ac16de..715bb83 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -76,7 +76,8 @@ import com.android.systemui.statusbar.policy.NetworkController; import com.android.systemui.recent.RecentApplicationsActivity; public class TabletStatusBar extends StatusBar implements - HeightReceiver.OnBarHeightChangedListener { + HeightReceiver.OnBarHeightChangedListener, + InputMethodsPanel.OnHardKeyboardEnabledChangeListener { public static final boolean DEBUG = false; public static final String TAG = "TabletStatusBar"; @@ -269,6 +270,7 @@ public class TabletStatusBar extends StatusBar implements // Input methods Panel mInputMethodsPanel = (InputMethodsPanel) View.inflate(context, R.layout.status_bar_input_methods_panel, null); + mInputMethodsPanel.setHardKeyboardEnabledChangeListener(this); mInputMethodsPanel.setVisibility(View.GONE); mInputMethodsPanel.setOnTouchListener(new TouchOutsideListener( MSG_CLOSE_INPUT_METHODS_PANEL, mInputMethodsPanel)); @@ -909,6 +911,25 @@ public class TabletStatusBar extends StatusBar implements } } + @Override + public void setHardKeyboardStatus(boolean available, boolean enabled) { + if (DEBUG) { + Slog.d(TAG, "Set hard keyboard status: available=" + available + + ", enabled=" + enabled); + } + mInputMethodSwitchButton.setHardKeyboardStatus(available); + updateNotificationIcons(); + mInputMethodsPanel.setHardKeyboardStatus(available, enabled); + } + + @Override + public void onHardKeyboardEnabledChange(boolean enabled) { + try { + mBarService.setHardKeyboardEnabled(enabled); + } catch (RemoteException ex) { + } + } + private boolean isImmersive() { try { return ActivityManagerNative.getDefault().isTopActivityImmersive(); |