Gboard like search bar in Android IME
Asked Answered
T

1

6

I want to create a search bar like Gboard inside keyboard (Android IME) as shown in picture.

Gboard Sample :

Gboard Sample

I have implemented an edittext on Keyboardview.xml as shown in picture.

My Implementation :

My Implementation

main_keyboard_frame.xml

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="120dp"
    android:background="#cf060610"
    android:id="@+id/search_panel"
    android:visibility="invisible">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:hint="sdsddsd"
        android:id="@+id/ed"/>



</RelativeLayout>

But the problem is when i press the edittext 2 (that is outside my ime) then my ime is open that contains edittext 1 as shown in above picture now when i write some thing from my ime it writes on edittext 2 instead of edittext 1 so i want to know whats the problem behind this? is it with focus? or something else?

Thirtyone answered 15/3, 2019 at 5:35 Comment(4)
abdul did y find any solution?Seamanship
Please share if you find any solution?Natheless
yes, you can stop commit typed character when this search panel is open, and vice versa.Thirtyone
@AbdulWajid can you make snippet code of the solutions?Yearly
Y
1

So, I got a clue to solve this, from Abdul Wajid's comment above.

I use this LatinIME. Just need to update this line

public void onEvent(final Event event) {
        final InputTransaction completeInputTransaction =
                mInputLogic.onCodeInput(mSettings.getCurrent(), event);
        updateStateAfterInputTransaction(completeInputTransaction);
        mKeyboardSwitcher.onEvent(event, getCurrentAutoCapsState(), getCurrentRecapitalizeState());
}

stop commit the event key pressed with some logical case,

public void onEvent(final Event event) {
    if (mEditField.isFocused()){
        Log.d("LatinIME : field focused", "On Event: " + event.getTextToCommit() );
        mEditField.append(event.getTextToCommit());
    } else {
        final InputTransaction completeInputTransaction =
                mInputLogic.onCodeInput(mSettings.getCurrent(), event);
        updateStateAfterInputTransaction(completeInputTransaction);
        mKeyboardSwitcher.onEvent(event, getCurrentAutoCapsState(), getCurrentRecapitalizeState());
    }
}

and done, you can control the event type that pressed.

Yearly answered 29/10, 2021 at 3:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.