Search in sources :

Example 1 with TabView

use of org.mozilla.focus.tabs.TabView in project Rocket by mozilla-tw.

the class InfoFragment method createTabViewClient.

@Override
public TabViewClient createTabViewClient() {
    return new TabViewClient() {

        @Override
        public void onPageStarted(final String url) {
            progressView.announceForAccessibility(getString(R.string.accessibility_announcement_loading));
            progressView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished(boolean isSecure) {
            progressView.announceForAccessibility(getString(R.string.accessibility_announcement_loading_finished));
            progressView.setVisibility(View.INVISIBLE);
            if (webView.getVisibility() != View.VISIBLE) {
                webView.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public boolean handleExternalUrl(final String url) {
            final TabView tabView = getTabView();
            return tabView != null && IntentUtils.handleExternalUri(getContext(), tabView, url);
        }
    };
}
Also used : TabView(org.mozilla.focus.tabs.TabView) TabViewClient(org.mozilla.focus.tabs.TabViewClient)

Example 2 with TabView

use of org.mozilla.focus.tabs.TabView in project Rocket by mozilla-tw.

the class InfoActivity method onCreateView.

@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
    if (name.equals(TabView.class.getName())) {
        final View view = WebViewProvider.create(this, attrs);
        final TabView webView = (TabView) view;
        webView.setContentBlockingEnabled(false);
        return view;
    }
    return super.onCreateView(name, context, attrs);
}
Also used : TabView(org.mozilla.focus.tabs.TabView) TabView(org.mozilla.focus.tabs.TabView) View(android.view.View)

Example 3 with TabView

use of org.mozilla.focus.tabs.TabView in project Rocket by mozilla-tw.

the class WebFragment method onCreateView.

@Override
public final View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = inflateLayout(inflater, container, savedInstanceState);
    webViewSlot = (ViewGroup) view.findViewById(R.id.webview_slot);
    tabView = (TabView) WebViewProvider.create(getContext(), null);
    webViewSlot.addView(tabView.getView());
    isWebViewAvailable = true;
    tabView.setViewClient(createTabViewClient());
    tabView.setChromeClient(createTabChromeClient());
    return view;
}
Also used : TabView(org.mozilla.focus.tabs.TabView) View(android.view.View) WebView(android.webkit.WebView)

Example 4 with TabView

use of org.mozilla.focus.tabs.TabView in project Rocket by mozilla-tw.

the class WebFragment method loadUrl.

/**
 * Let WebView to open the url
 *
 * @param url the url to open. It should be a valid url otherwise WebView won't load anything.
 */
public void loadUrl(@NonNull final String url) {
    final TabView webView = getTabView();
    if (webView != null) {
        if (UrlUtils.isUrl(url)) {
            // clear pending url
            this.pendingUrl = null;
            // in case of any unexpected path to here, to normalize URL in beta/release build
            final String target = AppConstants.isDevBuild() ? url : UrlUtils.normalize(url);
            webView.loadUrl(target);
        } else if (AppConstants.isDevBuild()) {
            // throw exception to highlight this issue, except release build.
            throw new RuntimeException("trying to open a invalid url: " + url);
        }
    } else {
        this.pendingUrl = url;
    }
}
Also used : TabView(org.mozilla.focus.tabs.TabView)

Example 5 with TabView

use of org.mozilla.focus.tabs.TabView in project Rocket by mozilla-tw.

the class BrowserFragment method goBack.

public void goBack() {
    final TabView current = tabsSession.getFocusTab().getTabView();
    if (current != null) {
        WebBackForwardList webBackForwardList = ((WebView) current).copyBackForwardList();
        WebHistoryItem item = webBackForwardList.getItemAtIndex(webBackForwardList.getCurrentIndex() - 1);
        updateURL(item.getUrl());
        current.goBack();
    }
}
Also used : WebHistoryItem(android.webkit.WebHistoryItem) TabView(org.mozilla.focus.tabs.TabView) WebView(android.webkit.WebView) WebBackForwardList(android.webkit.WebBackForwardList)

Aggregations

TabView (org.mozilla.focus.tabs.TabView)7 WebView (android.webkit.WebView)4 View (android.view.View)2 WebBackForwardList (android.webkit.WebBackForwardList)2 WebHistoryItem (android.webkit.WebHistoryItem)2 Bitmap (android.graphics.Bitmap)1 TabViewClient (org.mozilla.focus.tabs.TabViewClient)1