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);
}
};
}
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);
}
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;
}
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;
}
}
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();
}
}
Aggregations