Search in sources :

Example 1 with Session

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;
}
Also used : IWebView(org.mozilla.focus.web.IWebView) View(android.view.View) WebView(android.webkit.WebView) Session(org.mozilla.focus.session.Session)

Example 2 with Session

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();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) BrowserFragment(org.mozilla.focus.fragment.BrowserFragment) Session(org.mozilla.focus.session.Session)

Example 3 with Session

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();
        }
    }
}
Also used : Session(org.mozilla.focus.session.Session)

Example 4 with Session

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());
        }
    });
}
Also used : FloatingEraseButton(org.mozilla.focus.widget.FloatingEraseButton) FloatingSessionsButton(org.mozilla.focus.widget.FloatingSessionsButton) List(java.util.List) NullSession(org.mozilla.focus.session.NullSession) Session(org.mozilla.focus.session.Session)

Example 5 with Session

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();
}
Also used : Session(org.mozilla.focus.session.Session)

Aggregations

Session (org.mozilla.focus.session.Session)5 FragmentManager (android.support.v4.app.FragmentManager)1 View (android.view.View)1 WebView (android.webkit.WebView)1 List (java.util.List)1 BrowserFragment (org.mozilla.focus.fragment.BrowserFragment)1 NullSession (org.mozilla.focus.session.NullSession)1 IWebView (org.mozilla.focus.web.IWebView)1 FloatingEraseButton (org.mozilla.focus.widget.FloatingEraseButton)1 FloatingSessionsButton (org.mozilla.focus.widget.FloatingSessionsButton)1