Search in sources :

Example 1 with FindInPageFunnel

use of org.wikipedia.analytics.FindInPageFunnel in project apps-android-wikipedia by wikimedia.

the class PageFragment method showFindInPage.

public void showFindInPage() {
    if (model.getPage() == null) {
        return;
    }
    final FindInPageFunnel funnel = new FindInPageFunnel(app, model.getTitle().getWikiSite(), model.getPage().getPageProperties().getPageId());
    final FindInWebPageActionProvider findInPageActionProvider = new FindInWebPageActionProvider(this, funnel);
    startSupportActionMode(new ActionMode.Callback() {

        private final String actionModeTag = "actionModeFindInPage";

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            findInPageActionMode = mode;
            MenuItem menuItem = menu.add(R.string.menu_page_find_in_page);
            menuItem.setActionProvider(findInPageActionProvider);
            menuItem.expandActionView();
            setToolbarElevationEnabled(false);
            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            mode.setTag(actionModeTag);
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
            if (webView == null || !isAdded()) {
                return;
            }
            findInPageActionMode = null;
            funnel.setPageHeight(webView.getContentHeight());
            funnel.logDone();
            webView.clearMatches();
            showToolbar();
            hideSoftKeyboard();
            setToolbarElevationEnabled(true);
        }
    });
}
Also used : FindInPageFunnel(org.wikipedia.analytics.FindInPageFunnel) ActionMode(android.view.ActionMode) MenuItem(android.view.MenuItem) ReadingListBookmarkMenu(org.wikipedia.readinglist.ReadingListBookmarkMenu) Menu(android.view.Menu)

Aggregations

ActionMode (android.view.ActionMode)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 FindInPageFunnel (org.wikipedia.analytics.FindInPageFunnel)1 ReadingListBookmarkMenu (org.wikipedia.readinglist.ReadingListBookmarkMenu)1