Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c05b54f authored by satok's avatar satok Committed by Android (Google) Code Review
Browse files

Merge "Update package manager when panel is loaded." into honeycomb

parents ca0f49ed 913f42d2
Loading
Loading
Loading
Loading
−510 B (1.41 KiB)
Loading image diff...
+6 −0
Original line number Original line Diff line number Diff line
@@ -188,6 +188,12 @@ public class InputMethodButton extends ImageView {
                Settings.Secure.INPUT_METHOD_SELECTOR_VISIBILITY, ID_IME_BUTTON_VISIBILITY_AUTO);
                Settings.Secure.INPUT_METHOD_SELECTOR_VISIBILITY, ID_IME_BUTTON_VISIBILITY_AUTO);
    }
    }


    public void setIconImage(int resId) {
        if (mIcon != null) {
            mIcon.setImageResource(resId);
        }
    }

    public void setIMEButtonVisible(IBinder token, boolean keyboardVisible) {
    public void setIMEButtonVisible(IBinder token, boolean keyboardVisible) {
        mToken = token;
        mToken = token;
        mKeyboardVisible = keyboardVisible;
        mKeyboardVisible = keyboardVisible;
+24 −6
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.systemui.statusbar.tablet;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.os.IBinder;
import android.os.IBinder;
import android.provider.Settings;
import android.provider.Settings;
@@ -53,11 +52,12 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
                    new HashMap<InputMethodInfo, List<InputMethodSubtype>>();
                    new HashMap<InputMethodInfo, List<InputMethodSubtype>>();
    private final HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>> mRadioViewAndImiMap =
    private final HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>> mRadioViewAndImiMap =
            new HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>>();
            new HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>>();
    private final PackageManager mPackageManager;


    private Context mContext;
    private Context mContext;
    private IBinder mToken;
    private IBinder mToken;
    private InputMethodButton mInputMethodSwitchButton;
    private LinearLayout mInputMethodMenuList;
    private LinearLayout mInputMethodMenuList;
    private PackageManager mPackageManager;
    private String mEnabledInputMethodAndSubtypesCacheStr;
    private String mEnabledInputMethodAndSubtypesCacheStr;
    private View mConfigureImeShortcut;
    private View mConfigureImeShortcut;


@@ -69,7 +69,6 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
        super(context, attrs, defStyle);
        super(context, attrs, defStyle);
        mContext = context;
        mContext = context;
        mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        mPackageManager = context.getPackageManager();
    }
    }


    @Override
    @Override
@@ -90,8 +89,17 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
    @Override
    @Override
    protected void onVisibilityChanged(View changedView, int visibility) {
    protected void onVisibilityChanged(View changedView, int visibility) {
        super.onVisibilityChanged(changedView, visibility);
        super.onVisibilityChanged(changedView, visibility);
        if (visibility == View.VISIBLE && changedView == this) {
        if (changedView == this) {
            if (visibility == View.VISIBLE) {
                updateUiElements();
                updateUiElements();
                if (mInputMethodSwitchButton != null) {
                    mInputMethodSwitchButton.setIconImage(R.drawable.ic_sysbar_ime_pressed);
                }
            } else {
                if (mInputMethodSwitchButton != null) {
                    mInputMethodSwitchButton.setIconImage(R.drawable.ic_sysbar_ime);
                }
            }
        }
        }
    }
    }


@@ -180,6 +188,8 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
        // TODO: Reuse subtype views.
        // TODO: Reuse subtype views.
        mInputMethodMenuList.removeAllViews();
        mInputMethodMenuList.removeAllViews();
        mRadioViewAndImiMap.clear();
        mRadioViewAndImiMap.clear();
        mPackageManager = mContext.getPackageManager();

        HashMap<InputMethodInfo, List<InputMethodSubtype>> enabledIMIs
        HashMap<InputMethodInfo, List<InputMethodSubtype>> enabledIMIs
                = getEnabledInputMethodAndSubtypeList();
                = getEnabledInputMethodAndSubtypeList();
        // TODO: Sort by alphabet and mode.
        // TODO: Sort by alphabet and mode.
@@ -198,10 +208,14 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
        updateRadioButtons();
        updateRadioButtons();
    }
    }


    public void setIMEToken(IBinder token) {
    public void setImeToken(IBinder token) {
        mToken = token;
        mToken = token;
    }
    }


    public void setImeSwitchButton(InputMethodButton imb) {
        mInputMethodSwitchButton = imb;
    }

    private void setInputMethodAndSubtype(InputMethodInfo imi, InputMethodSubtype subtype) {
    private void setInputMethodAndSubtype(InputMethodInfo imi, InputMethodSubtype subtype) {
        if (mToken != null) {
        if (mToken != null) {
            mImm.setInputMethodAndSubtype(mToken, imi.getId(), subtype);
            mImm.setInputMethodAndSubtype(mToken, imi.getId(), subtype);
@@ -308,6 +322,10 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O


    private CharSequence getSubtypeName(InputMethodInfo imi, InputMethodSubtype subtype) {
    private CharSequence getSubtypeName(InputMethodInfo imi, InputMethodSubtype subtype) {
        if (imi == null || subtype == null) return null;
        if (imi == null || subtype == null) return null;
        if (DEBUG) {
            Log.d(TAG, "Get text from: " + imi.getPackageName() + subtype.getNameResId()
                    + imi.getServiceInfo().applicationInfo);
        }
        // TODO: Change the language of subtype name according to subtype's locale.
        // TODO: Change the language of subtype name according to subtype's locale.
        return mPackageManager.getText(
        return mPackageManager.getText(
                imi.getPackageName(), subtype.getNameResId(), imi.getServiceInfo().applicationInfo);
                imi.getPackageName(), subtype.getNameResId(), imi.getServiceInfo().applicationInfo);
+2 −1
Original line number Original line Diff line number Diff line
@@ -272,6 +272,7 @@ public class TabletStatusBar extends StatusBar implements
        mInputMethodsPanel.setVisibility(View.GONE);
        mInputMethodsPanel.setVisibility(View.GONE);
        mInputMethodsPanel.setOnTouchListener(new TouchOutsideListener(
        mInputMethodsPanel.setOnTouchListener(new TouchOutsideListener(
                MSG_CLOSE_INPUT_METHODS_PANEL, mInputMethodsPanel));
                MSG_CLOSE_INPUT_METHODS_PANEL, mInputMethodsPanel));
        mInputMethodsPanel.setImeSwitchButton(mInputMethodSwitchButton);
        mStatusBarView.setIgnoreChildren(3, mInputMethodSwitchButton, mInputMethodsPanel);
        mStatusBarView.setIgnoreChildren(3, mInputMethodSwitchButton, mInputMethodsPanel);
        lp = new WindowManager.LayoutParams(
        lp = new WindowManager.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT,
@@ -853,7 +854,7 @@ public class TabletStatusBar extends StatusBar implements
        if (oldVisibility != mInputMethodSwitchButton.getVisibility()) {
        if (oldVisibility != mInputMethodSwitchButton.getVisibility()) {
            updateNotificationIcons();
            updateNotificationIcons();
        }
        }
        mInputMethodsPanel.setIMEToken(token);
        mInputMethodsPanel.setImeToken(token);
        mBackButton.setImageResource(
        mBackButton.setImageResource(
                visible ? R.drawable.ic_sysbar_back_ime : R.drawable.ic_sysbar_back);
                visible ? R.drawable.ic_sysbar_back_ime : R.drawable.ic_sysbar_back);
        if (FAKE_SPACE_BAR) {
        if (FAKE_SPACE_BAR) {