@Override
  public void setOnKeyboardActionListener(OnKeyboardActionListener keyboardActionListener) {
    FrameKeyboardViewClickListener frameKeyboardViewClickListener =
        new FrameKeyboardViewClickListener(keyboardActionListener);
    frameKeyboardViewClickListener.registerOnViews(this);

    final Context context = getContext();
    final List<QuickTextKey> list = new ArrayList<>();
    // always starting with Recent
    final HistoryQuickTextKey historyQuickTextKey =
        new HistoryQuickTextKey(context, mQuickKeyHistoryRecords);
    list.add(historyQuickTextKey);
    // then all the rest
    list.addAll(AnyApplication.getQuickTextKeyFactory(context).getEnabledAddOns());

    final QuickTextUserPrefs quickTextUserPrefs = new QuickTextUserPrefs(context);

    final ViewPagerWithDisable pager = findViewById(R.id.quick_text_keyboards_pager);
    final QuickKeysKeyboardPagerAdapter adapter =
        new QuickKeysKeyboardPagerAdapter(
            context,
            pager,
            list,
            new RecordHistoryKeyboardActionListener(historyQuickTextKey, keyboardActionListener),
            mDefaultSkinTonePrefTracker,
            mDefaultGenderPrefTracker,
            mKeyboardTheme,
            mBottomPadding);

    final ImageView clearEmojiHistoryIcon =
        findViewById(R.id.quick_keys_popup_delete_recently_used_smileys);
    ViewPager.SimpleOnPageChangeListener onPageChangeListener =
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            super.onPageSelected(position);
            QuickTextKey selectedKey = list.get(position);
            quickTextUserPrefs.setLastSelectedAddOnId(selectedKey.getId());
            // if this is History, we need to show clear icon
            // else, hide the clear icon
            clearEmojiHistoryIcon.setVisibility(position == 0 ? View.VISIBLE : View.GONE);
          }
        };
    int startPageIndex = quickTextUserPrefs.getStartPageIndex(list);
    setupSlidingTab(
        this,
        mTabTitleTextSize,
        mTabTitleTextColor,
        pager,
        adapter,
        onPageChangeListener,
        startPageIndex);

    // setting up icons from theme
    ((ImageView) findViewById(R.id.quick_keys_popup_close)).setImageDrawable(mCloseKeyboardIcon);
    ((ImageView) findViewById(R.id.quick_keys_popup_backspace)).setImageDrawable(mBackspaceIcon);
    ((ImageView) findViewById(R.id.quick_keys_popup_quick_keys_insert_media))
        .setImageDrawable(mMediaInsertionDrawable);
    clearEmojiHistoryIcon.setImageDrawable(mDeleteRecentlyUsedDrawable);
    ((ImageView) findViewById(R.id.quick_keys_popup_quick_keys_settings))
        .setImageDrawable(mSettingsIcon);
    final View actionsLayout = findViewById(R.id.quick_text_actions_layout);
    actionsLayout.setPadding(
        actionsLayout.getPaddingLeft(),
        actionsLayout.getPaddingTop(),
        actionsLayout.getPaddingRight(),
        // this will support the case were we have navigation-bar offset
        actionsLayout.getPaddingBottom() + mBottomPadding);
  }
@Test
  public void testShowClearEmojiOnlyOnHistory() throws Exception {
    // setting up the listener since that is what sets up the adapter
    OnKeyboardActionListener listener = Mockito.mock(OnKeyboardActionListener.class);
    mUnderTest.setOnKeyboardActionListener(listener);

    ViewPagerWithDisable pager = mUnderTest.findViewById(R.id.quick_text_keyboards_pager);
    Assert.assertNotNull(pager);
    pager.setCurrentItem(0, false);
    TestRxSchedulers.foregroundFlushAllJobs();
    Assert.assertEquals(0, pager.getCurrentItem());

    Assert.assertEquals(
        View.VISIBLE,
        mUnderTest
            .findViewById(R.id.quick_keys_popup_delete_recently_used_smileys)
            .getVisibility());

    pager.setCurrentItem(1, false);
    TestRxSchedulers.foregroundFlushAllJobs();
    Assert.assertEquals(1, pager.getCurrentItem());

    Assert.assertEquals(
        View.GONE,
        mUnderTest
            .findViewById(R.id.quick_keys_popup_delete_recently_used_smileys)
            .getVisibility());

    pager.setCurrentItem(0);
    TestRxSchedulers.foregroundFlushAllJobs();
    Assert.assertEquals(0, pager.getCurrentItem());

    Assert.assertEquals(
        View.VISIBLE,
        mUnderTest
            .findViewById(R.id.quick_keys_popup_delete_recently_used_smileys)
            .getVisibility());
  }