How to customize AOSP keyboard?

56
July 16, 2019, at 11:30 AM

I can try to add tab layout in AOSP keybord but tab click doesn't work and also whatsapp edittext hide behind tab so please help me how to add tab functionality in AOSP keyboard ?

Thanks

Make keyboard like below image.

CODE

    //Added new
    mSearchView = (SearchView) mCurrentInputView.findViewById(R.id.view_search_view);
    mSickersView = (StickersView) mCurrentInputView.findViewById(R.id.stickers_view);
    slideUpAnimation = AnimationUtils.loadAnimation(mThemeContext, R.anim.slide_up_animation);
    slideDownAnimation = AnimationUtils.loadAnimation(mThemeContext, R.anim.slide_down_animation);
    mTabDisplayKbView = mCurrentInputView.findViewById(R.id.tab_display_kbview);
    mTabDisplayKbView.setVisibility(View.GONE);
    mTab0 = mCurrentInputView.findViewById(R.id.tab_0);
    mTab1 = mCurrentInputView.findViewById(R.id.tab_1);
    mTab2 = mCurrentInputView.findViewById(R.id.tab_2);
    mTab3 = mCurrentInputView.findViewById(R.id.tab_3);
    mTab4 = mCurrentInputView.findViewById(R.id.tab_4);
    mTab5 = mCurrentInputView.findViewById(R.id.tab_5);
    mTab6 = mCurrentInputView.findViewById(R.id.tab_6);
    mTabSwitchKb = mCurrentInputView.findViewById(R.id.tab_switch_kb);
    final LinearLayout mllMain = mCurrentInputView.findViewById(R.id.ll_main);
    setSelect("");
    mTab0.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mTab0.isSelected()) {
                mTabDisplayKbView.setVisibility(View.VISIBLE);
                if (mSickersView.getVisibility() == View.INVISIBLE) {
                    mSickersView.startAnimation(slideUpAnimation);
                }
                mSickersView.setVisibility(View.VISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                // mKeyboardView.startAnimation(slideDownAnimation);
                setSelect("0");
            } else {
                // mKeyboardView.startAnimation(slideUpAnimation);
                mTabDisplayKbView.setVisibility(View.GONE);
                mSickersView.setVisibility(View.INVISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("");
                mSickersView.startAnimation(slideDownAnimation);
            }
        }
    });
    mTab1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mTab1.isSelected()) {
                mTabDisplayKbView.setVisibility(View.VISIBLE);
                if (mSickersView.getVisibility() == View.INVISIBLE) {
                    mSickersView.startAnimation(slideUpAnimation);
                }
                // mKeyboardView.startAnimation(slideDownAnimation);
                mSickersView.setVisibility(View.VISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("1");
            } else {
                mTabDisplayKbView.setVisibility(View.GONE);
                // mKeyboardView.startAnimation(slideUpAnimation);
                mSickersView.setVisibility(View.INVISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("");
                mSickersView.startAnimation(slideDownAnimation);
            }
        }
    });
    mTab2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mTab2.isSelected()) {
                mTabDisplayKbView.setVisibility(View.VISIBLE);
                if (mSickersView.getVisibility() == View.INVISIBLE) {
                    mSickersView.startAnimation(slideUpAnimation);
                }
                // mKeyboardView.startAnimation(slideDownAnimation);
                mSickersView.setVisibility(View.VISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("2");
            } else {
                mTabDisplayKbView.setVisibility(View.GONE);
                // mKeyboardView.startAnimation(slideUpAnimation);
                mSickersView.setVisibility(View.INVISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("");
                mSickersView.startAnimation(slideDownAnimation);
            }
        }
    });
    mTab3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mTab3.isSelected()) {
                mTabDisplayKbView.setVisibility(View.VISIBLE);
                if (mSickersView.getVisibility() == View.INVISIBLE) {
                    mSickersView.startAnimation(slideUpAnimation);
                }
                // mKeyboardView.startAnimation(slideDownAnimation);
                mSickersView.setVisibility(View.VISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("3");
            } else {
                mTabDisplayKbView.setVisibility(View.GONE);
                // mKeyboardView.startAnimation(slideUpAnimation);
                mSickersView.setVisibility(View.INVISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("");
                mSickersView.startAnimation(slideDownAnimation);
            }
        }
    });
    mTab4.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mTab4.isSelected()) {
                mTabDisplayKbView.setVisibility(View.VISIBLE);
                if (mSickersView.getVisibility() == View.INVISIBLE) {
                    mSickersView.startAnimation(slideUpAnimation);
                }
                // mKeyboardView.startAnimation(slideDownAnimation);
                mSickersView.setVisibility(View.VISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("4");
            } else {
                mTabDisplayKbView.setVisibility(View.GONE);
                // mKeyboardView.startAnimation(slideUpAnimation);
                mSickersView.setVisibility(View.INVISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("");
                mSickersView.startAnimation(slideDownAnimation);
            }
        }
    });
    mTab5.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mTab5.isSelected()) {
                mTabDisplayKbView.setVisibility(View.VISIBLE);
                if (mSickersView.getVisibility() == View.INVISIBLE) {
                    mSickersView.startAnimation(slideUpAnimation);
                }
                // mKeyboardView.startAnimation(slideDownAnimation);
                mSickersView.setVisibility(View.VISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("5");
            } else {
                mTabDisplayKbView.setVisibility(View.GONE);
                // mKeyboardView.startAnimation(slideUpAnimation);
                mSickersView.setVisibility(View.INVISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("");
                mSickersView.startAnimation(slideDownAnimation);
            }
        }
    });
    mTab6.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mTab6.isSelected()) {
                mTabDisplayKbView.setVisibility(View.VISIBLE);
                if (mSickersView.getVisibility() == View.INVISIBLE) {
                    mSickersView.startAnimation(slideUpAnimation);
                }
                // mKeyboardView.startAnimation(slideDownAnimation);
                mSickersView.setVisibility(View.VISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("6");
            } else {
                mTabDisplayKbView.setVisibility(View.GONE);
                // mKeyboardView.startAnimation(slideUpAnimation);
                mSickersView.setVisibility(View.INVISIBLE);
                mKeyboardView.setVisibility(View.VISIBLE);
                setSelect("");
                mSickersView.startAnimation(slideDownAnimation);
            }
        }
    });
    mTabDisplayKbView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // mKeyboardView.startAnimation(slideUpAnimation);
            mTabDisplayKbView.setVisibility(View.GONE);
            mSickersView.setVisibility(View.INVISIBLE);
            mKeyboardView.setVisibility(View.VISIBLE);
            setSelect("");
            mSickersView.startAnimation(slideDownAnimation);
        }
    });
    return mCurrentInputView;
}
private void setSelect(String mPosition) {
    if (mPosition.equalsIgnoreCase("0")) {
        mTab0.setSelected(true);
        mTab1.setSelected(false);
        mTab2.setSelected(false);
        mTab3.setSelected(false);
        mTab4.setSelected(false);
        mTab5.setSelected(false);
        mTab6.setSelected(false);
        setBackgroundTint("0");
    } else if (mPosition.equalsIgnoreCase("1")) {
        mTab0.setSelected(false);
        mTab1.setSelected(true);
        mTab2.setSelected(false);
        mTab3.setSelected(false);
        mTab4.setSelected(false);
        mTab5.setSelected(false);
        mTab6.setSelected(false);
        setBackgroundTint("1");
    } else if (mPosition.equalsIgnoreCase("2")) {
        mTab0.setSelected(false);
        mTab1.setSelected(false);
        mTab2.setSelected(true);
        mTab3.setSelected(false);
        mTab4.setSelected(false);
        mTab5.setSelected(false);
        mTab6.setSelected(false);
        setBackgroundTint("2");
    } else if (mPosition.equalsIgnoreCase("3")) {
        mTab0.setSelected(false);
        mTab1.setSelected(false);
        mTab2.setSelected(false);
        mTab3.setSelected(true);
        mTab4.setSelected(false);
        mTab5.setSelected(false);
        mTab6.setSelected(false);
        setBackgroundTint("3");
    } else if (mPosition.equalsIgnoreCase("4")) {
        mTab0.setSelected(false);
        mTab1.setSelected(false);
        mTab2.setSelected(false);
        mTab3.setSelected(false);
        mTab4.setSelected(true);
        mTab5.setSelected(false);
        mTab6.setSelected(false);
        setBackgroundTint("4");
    } else if (mPosition.equalsIgnoreCase("5")) {
        mTab0.setSelected(false);
        mTab1.setSelected(false);
        mTab2.setSelected(false);
        mTab3.setSelected(false);
        mTab4.setSelected(false);
        mTab5.setSelected(true);
        mTab6.setSelected(false);
        setBackgroundTint("5");
    } else if (mPosition.equalsIgnoreCase("6")) {
        mTab0.setSelected(false);
        mTab1.setSelected(false);
        mTab2.setSelected(false);
        mTab3.setSelected(false);
        mTab4.setSelected(false);
        mTab5.setSelected(false);
        mTab6.setSelected(true);
        setBackgroundTint("6");
    } else {
        mTab0.setSelected(false);
        mTab1.setSelected(false);
        mTab2.setSelected(false);
        mTab3.setSelected(false);
        mTab4.setSelected(false);
        mTab5.setSelected(false);
        mTab6.setSelected(false);
        setBackgroundTint("");
    }
}

private void setBackgroundTint(String mPosition) {
    if (mPosition.equalsIgnoreCase("0")) {
        mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.yellow));
        mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
    } else if (mPosition.equalsIgnoreCase("1")) {
        mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.blink));
        mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
    } else if (mPosition.equalsIgnoreCase("2")) {
        mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.red));
        mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
    } else if (mPosition.equalsIgnoreCase("3")) {
        mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.blue));
        mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
    } else if (mPosition.equalsIgnoreCase("4")) {
        mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.green));
        mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
    } else if (mPosition.equalsIgnoreCase("5")) {
        mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.colorPrimaryDark));
        mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
    } else if (mPosition.equalsIgnoreCase("6")) {
        mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.highlight_color_lxx_light));
    } else {
        mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
        mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
    }
}

}

READ ALSO
Showing error while routing from one screen to another in flutter

Showing error while routing from one screen to another in flutter

I'm moving from one screen to another screen but it shows error in routingMy First screen named as VenueOption and the second one is PlayerOption

66
How to change “Battery Saver -> Allow Background Running” by programming on OPPO A3S with ColorOs

How to change “Battery Saver -> Allow Background Running” by programming on OPPO A3S with ColorOs

I want to my app always running In-Background, but it did not work with OPPO Device ColorOs Version

45
In flutter, How to add tflite as a dependency in pubspec.yaml ?file?

In flutter, How to add tflite as a dependency in pubspec.yaml ?file?

I am little bit confused with thisNow I have

83
Android double socket connection issue

Android double socket connection issue

I have implemented socket connection on singleton classBut whenever I remove the app from Android Recent, on the next launch of the app, the socket is getting connected twice

55