use of org.mozilla.focus.session.Session in project focus-android by mozilla-mobile.
the class WebFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View view = inflateLayout(inflater, container, savedInstanceState);
webView = view.findViewById(R.id.webview);
isWebViewAvailable = true;
webView.setCallback(createCallback());
final Session session = getSession();
if (session != null) {
webView.setBlockingEnabled(session.isBlockingEnabled());
}
if (session == null || !session.hasWebViewState()) {
final String url = getInitialUrl();
if (!TextUtils.isEmpty(url)) {
webView.loadUrl(url);
}
} else {
webView.restoreWebViewState(session);
}
onCreateViewCalled();
return view;
}
use of org.mozilla.focus.session.Session in project focus-android by mozilla-mobile.
the class MainActivity method showBrowserScreenForCurrentSession.
protected void showBrowserScreenForCurrentSession() {
final Session currentSession = getCurrentSessionForActivity();
final FragmentManager fragmentManager = getSupportFragmentManager();
final BrowserFragment fragment = (BrowserFragment) fragmentManager.findFragmentByTag(BrowserFragment.FRAGMENT_TAG);
if (fragment != null && fragment.getSession().isSameAs(currentSession)) {
// There's already a BrowserFragment displaying this session.
return;
}
fragmentManager.beginTransaction().replace(R.id.container, BrowserFragment.createForSession(currentSession), BrowserFragment.FRAGMENT_TAG).commit();
}
use of org.mozilla.focus.session.Session in project focus-android by mozilla-mobile.
the class TelemetrySessionObserver method onValueChanged.
@Override
protected void onValueChanged(@NonNull List<Session> sessions) {
for (final Session session : sessions) {
if (!session.isRecorded()) {
addTelemetryEvent(session);
session.markAsRecorded();
}
}
}
use of org.mozilla.focus.session.Session in project focus-android by mozilla-mobile.
the class BrowserFragment method initialiseNormalBrowserUi.
private void initialiseNormalBrowserUi(@NonNull final View view) {
final FloatingEraseButton eraseButton = view.findViewById(R.id.erase);
eraseButton.setOnClickListener(this);
urlView.setOnClickListener(this);
final FloatingSessionsButton tabsButton = view.findViewById(R.id.tabs);
tabsButton.setOnClickListener(this);
sessionManager.getSessions().observe(this, new NonNullObserver<List<Session>>() {
@Override
protected void onValueChanged(@NonNull List<Session> sessions) {
tabsButton.updateSessionsCount(sessions.size());
eraseButton.updateSessionsCount(sessions.size());
}
});
}
use of org.mozilla.focus.session.Session in project focus-android by mozilla-mobile.
the class WebFragment method onPause.
@Override
public void onPause() {
final Session session = getSession();
if (session != null) {
webView.saveWebViewState(session);
}
webView.onPause();
super.onPause();
}
Aggregations