OSDN Git Service

Update hard keyboard status on closing input methods panel
authorTadashi G. Takaoka <takaoka@google.com>
Mon, 31 Jan 2011 17:57:44 +0000 (02:57 +0900)
committerTadashi G. Takaoka <takaoka@google.com>
Tue, 1 Feb 2011 00:54:54 +0000 (09:54 +0900)
Bug: 3391067
Change-Id: Ib337cea0031020ab7ca019b30cd2ceb47a7664d5

packages/SystemUI/res/layout-xlarge/status_bar_input_methods_panel.xml
packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java

index bb1cf23..efbf359 100644 (file)
@@ -22,7 +22,8 @@
     android:layout_height="match_parent"
     android:layout_width="match_parent"
     android:paddingBottom="28dip"
-    android:orientation="vertical">
+    android:orientation="vertical"
+    android:visibility="gone">
     <View
         android:layout_width="match_parent"
         android:layout_height="0dip"
index 0c2909a..b1e74ad 100644 (file)
@@ -34,7 +34,6 @@ import android.view.View;
 import android.view.inputmethod.InputMethodInfo;
 import android.view.inputmethod.InputMethodManager;
 import android.view.inputmethod.InputMethodSubtype;
-import android.widget.CompoundButton;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.RadioButton;
@@ -48,8 +47,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
 
-public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, View.OnClickListener,
-        CompoundButton.OnCheckedChangeListener {
+public class InputMethodsPanel extends LinearLayout implements StatusBarPanel,
+        View.OnClickListener {
     private static final boolean DEBUG = TabletStatusBar.DEBUG;
     private static final String TAG = "InputMethodsPanel";
 
@@ -86,6 +85,7 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, V
     private View mConfigureImeShortcut;
 
     private class InputMethodComparator implements Comparator<InputMethodInfo> {
+        @Override
         public int compare(InputMethodInfo imi1, InputMethodInfo imi2) {
             if (imi2 == null) return 0;
             if (imi1 == null) return 1;
@@ -142,7 +142,6 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, V
         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.setOnCheckedChangeListener(this);
         mConfigureImeShortcut = findViewById(R.id.ime_settings_shortcut);
         mConfigureImeShortcut.setOnClickListener(this);
         // TODO: If configurations for IME are not changed, do not update
@@ -156,33 +155,16 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, V
     }
 
     @Override
-    protected void onVisibilityChanged(View changedView, int visibility) {
-        super.onVisibilityChanged(changedView, visibility);
-        if (changedView == this) {
-            if (visibility == View.VISIBLE) {
-                updateUiElements();
-                if (mInputMethodSwitchButton != null) {
-                    mInputMethodSwitchButton.setIconImage(R.drawable.ic_sysbar_ime_pressed);
-                }
-            } else {
-                if (mInputMethodSwitchButton != null) {
-                    mInputMethodSwitchButton.setIconImage(R.drawable.ic_sysbar_ime);
-                }
-            }
-        }
-    }
-
-    @Override
     public void onClick(View view) {
         if (view == mConfigureImeShortcut) {
             showConfigureInputMethods();
-            onFinishPanel(true);
+            closePanel(true);
         }
     }
 
-    @Override
-    public void onCheckedChanged(CompoundButton button, boolean checked) {
-        if (button == mHardKeyboardSwitch) {
+    private void updateHardKeyboardEnabled() {
+        if (mHardKeyboardAvailable) {
+            final boolean checked = mHardKeyboardSwitch.isChecked();
             if (mHardKeyboardEnabled != checked) {
                 mHardKeyboardEnabled = checked;
                 if (mHardKeyboardEnabledChangeListener != null)
@@ -191,11 +173,23 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, V
         }
     }
 
-    private void onFinishPanel(boolean closeKeyboard) {
+    public void openPanel() {
+        setVisibility(View.VISIBLE);
+        updateUiElements();
+        if (mInputMethodSwitchButton != null) {
+            mInputMethodSwitchButton.setIconImage(R.drawable.ic_sysbar_ime_pressed);
+        }
+    }
+
+    public void closePanel(boolean closeKeyboard) {
         setVisibility(View.GONE);
+        if (mInputMethodSwitchButton != null) {
+            mInputMethodSwitchButton.setIconImage(R.drawable.ic_sysbar_ime);
+        }
         if (closeKeyboard) {
             mImm.hideSoftInputFromWindow(getWindowToken(), 0);
         }
+        updateHardKeyboardEnabled();
     }
 
     private void startActivity(Intent intent) {
@@ -241,7 +235,7 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, V
                             | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                             | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                     startActivity(intent);
-                    onFinishPanel(true);
+                    closePanel(true);
                 }
             });
         } else {
@@ -256,7 +250,7 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, V
             public void onClick(View v) {
                 Pair<InputMethodInfo, InputMethodSubtype> imiAndSubtype =
                         updateRadioButtonsByView(v);
-                onFinishPanel(false);
+                closePanel(false);
                 setInputMethodAndSubtype(imiAndSubtype.first, imiAndSubtype.second);
             }
         });
index 715bb83..4373dba 100644 (file)
@@ -19,12 +19,9 @@ package com.android.systemui.statusbar.tablet;
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 import java.util.ArrayList;
-import java.util.Map;
-import java.util.IdentityHashMap;
 
 import android.animation.LayoutTransition;
 import android.animation.ObjectAnimator;
-import android.animation.AnimatorSet;
 import android.app.ActivityManagerNative;
 import android.app.PendingIntent;
 import android.app.Notification;
@@ -36,7 +33,6 @@ import android.content.res.Resources;
 import android.inputmethodservice.InputMethodService;
 import android.graphics.PixelFormat;
 import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
 import android.graphics.drawable.LayerDrawable;
 import android.os.Handler;
 import android.os.IBinder;
@@ -45,8 +41,6 @@ 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;
@@ -58,12 +52,10 @@ import android.view.ViewConfiguration;
 import android.view.ViewGroup;
 import android.view.WindowManager;
 import android.view.WindowManagerImpl;
-import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.RemoteViews;
 import android.widget.ScrollView;
-import android.widget.TextSwitcher;
 import android.widget.TextView;
 
 import com.android.internal.statusbar.StatusBarIcon;
@@ -271,7 +263,6 @@ public class TabletStatusBar extends StatusBar implements
         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));
         mInputMethodsPanel.setImeSwitchButton(mInputMethodSwitchButton);
@@ -565,11 +556,11 @@ public class TabletStatusBar extends StatusBar implements
                     break;
                 case MSG_OPEN_INPUT_METHODS_PANEL:
                     if (DEBUG) Slog.d(TAG, "opening input methods panel");
-                    if (mInputMethodsPanel != null) mInputMethodsPanel.setVisibility(View.VISIBLE);
+                    if (mInputMethodsPanel != null) mInputMethodsPanel.openPanel();
                     break;
                 case MSG_CLOSE_INPUT_METHODS_PANEL:
                     if (DEBUG) Slog.d(TAG, "closing input methods panel");
-                    if (mInputMethodsPanel != null) mInputMethodsPanel.setVisibility(View.GONE);
+                    if (mInputMethodsPanel != null) mInputMethodsPanel.closePanel(false);
                     break;
                 case MSG_SHOW_CHROME:
                     if (DEBUG) Slog.d(TAG, "hiding shadows (lights on)");