Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fixes #2490 Dismiss keyboard when clicked outside buttons #2638

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,42 @@
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.mozilla.geckoview.GeckoSession;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.browser.engine.Session;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.browser.engine.Session;
import org.mozilla.vrbrowser.input.CustomKeyboard;
import org.mozilla.vrbrowser.telemetry.GleanMetricsService;
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
import org.mozilla.vrbrowser.ui.keyboards.ChinesePinyinKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.ChineseZhuyinKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.DanishKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.FinnishKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.DutchKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.ItalianKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.EnglishKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.FinnishKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.FrenchKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.GermanKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.ChineseZhuyinKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.ItalianKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.JapaneseKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.KeyboardInterface;
import org.mozilla.vrbrowser.ui.keyboards.KoreanKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.NorwegianKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.PolishKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.RussianKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.KoreanKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.SpanishKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.SwedishKeyboard;
import org.mozilla.vrbrowser.ui.views.AutoCompletionView;
import org.mozilla.vrbrowser.ui.views.CustomKeyboardView;
import org.mozilla.vrbrowser.ui.views.KeyboardSelectorView;
import org.mozilla.vrbrowser.ui.widgets.dialogs.VoiceSearchWidget;
import org.mozilla.vrbrowser.ui.keyboards.ChinesePinyinKeyboard;
import org.mozilla.vrbrowser.ui.keyboards.EnglishKeyboard;
import org.mozilla.vrbrowser.utils.StringUtils;

import java.util.ArrayList;
import java.util.Locale;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


public class KeyboardWidget extends UIWidget implements CustomKeyboardView.OnKeyboardActionListener, AutoCompletionView.Delegate,
GeckoSession.TextInputDelegate, WidgetManagerDelegate.FocusChangeListener, VoiceSearchWidget.VoiceSearchDelegate, TextWatcher, WindowWidget.WindowListener {
Expand Down Expand Up @@ -246,13 +246,19 @@ private void initialize(Context aContext) {
mKeyboardPopupTopMargin = getResources().getDimensionPixelSize(R.dimen.keyboard_key_pressed_padding) * 2;

setOnClickListener(view -> hideOverlays());
mPopupKeyboardLayer.setOnClickListener(view -> hideOverlays());
setOnTouchListener((v, event) -> {
v.performClick();
dismiss();
return true;
});

mKeyboardView.setVisibility(View.VISIBLE);
mKeyboardNumericView.setKeyboard(mKeyboardNumeric);

mPopupKeyboardLayer.setOnClickListener(view -> hideOverlays());
hideOverlays();

mBackHandler = () -> onDismiss();
mBackHandler = this::onDismiss;

mAutoCompletionView = findViewById(R.id.autoCompletionView);
mAutoCompletionView.setExtendedHeight((int)(mWidgetPlacement.height * mWidgetPlacement.density));
Expand Down Expand Up @@ -375,7 +381,7 @@ public void updateFocusedView(View aFocusedView) {
}

public void dismiss() {
exitVoiceInputMode();
exitVoiceInputMode();
if (mFocusedView != null && mFocusedView != mAttachedWindow) {
mFocusedView.clearFocus();
}
Expand Down