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

Commit d8cc45ac authored by Frank Preel's avatar Frank Preel Committed by Nishith Khanna
Browse files

fix: show mic icon when suggestions are disabled

parent 9b70398e
Loading
Loading
Loading
Loading
+28 −6
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.InputMethodService;
@@ -51,6 +52,7 @@ import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
@@ -218,7 +220,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen

    public final UIHandler mHandler = new UIHandler(this);

    private ImageButton floatingButton;
    private ImageButton mFloatingButton;
    private final Rect mFloatingButtonTouchableBounds = new Rect();

    public static final class UIHandler extends LeakGuardHandlerWrapper<LatinIME> {
        private static final int MSG_UPDATE_SHIFT_STATE = 0;
@@ -895,8 +898,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
            mSuggestionStripView.setListener(this, view);
        }

        floatingButton = mInputView.findViewById(R.id.floating_button);
        floatingButton.setOnClickListener(new View.OnClickListener() {
        mFloatingButton = mInputView.findViewById(R.id.floating_button);
        mFloatingButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switchToSttIme();
@@ -909,9 +912,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        final SettingsValues currentSettingsValues = mSettings.getCurrent();
        if (shouldShowFloatingButton()
                && currentSettingsValues.mInputAttributes.mShouldShowSuggestions) {
            floatingButton.setVisibility(View.VISIBLE);
            mFloatingButton.setVisibility(View.VISIBLE);
        } else {
            floatingButton.setVisibility(View.GONE);
            mFloatingButton.setVisibility(View.GONE);
        }
    }

@@ -935,7 +938,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        mHandler.onStartInputView(editorInfo, restarting);
        mStatsUtilsManager.onStartInputView();

        if (floatingButton != null) {
        if (mFloatingButton != null) {
            manageFloatingButtonVisibility();
        }
    }
@@ -1336,12 +1339,31 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
            final int touchBottom = inputHeight;
            outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
            outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom);
            extendTouchableRegionForFloatingButton(outInsets);
        }
        outInsets.contentTopInsets = visibleTopY;
        outInsets.visibleTopInsets = visibleTopY;
        mInsetsUpdater.setInsets(outInsets);
    }

    private void extendTouchableRegionForFloatingButton(final InputMethodService.Insets outInsets) {
        if (mFloatingButton == null || mFloatingButton.getVisibility() != View.VISIBLE) {
            return;
        }
        if (!(mInputView instanceof ViewGroup)) {
            return;
        }
        final int width = mFloatingButton.getWidth();
        final int height = mFloatingButton.getHeight();
        if (width <= 0 || height <= 0) {
            return;
        }
        mFloatingButtonTouchableBounds.set(0, 0, width, height);
        ((ViewGroup) mInputView).offsetDescendantRectToMyCoords(
                mFloatingButton, mFloatingButtonTouchableBounds);
        outInsets.touchableRegion.union(mFloatingButtonTouchableBounds);
    }

    public void startShowingInputView(final boolean needsToLoadKeyboard) {
        mIsExecutingStartShowingInputView = true;
        // This {@link #showWindow(boolean)} will eventually call back