Search in sources :

Example 1 with BrowserFragment

use of org.mozilla.focus.fragment.BrowserFragment in project Rocket by mozilla-tw.

the class MainActivity method dismissAllMenus.

private void dismissAllMenus() {
    if (menu != null) {
        menu.dismiss();
    }
    BrowserFragment browserFragment = getVisibleBrowserFragment();
    if (browserFragment != null) {
        browserFragment.dismissWebContextMenu();
        browserFragment.dismissGeoDialog();
    }
    if (mDialogFragment != null) {
        mDialogFragment.dismissAllowingStateLoss();
    }
}
Also used : BrowserFragment(org.mozilla.focus.fragment.BrowserFragment)

Example 2 with BrowserFragment

use of org.mozilla.focus.fragment.BrowserFragment 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 BrowserFragment

use of org.mozilla.focus.fragment.BrowserFragment in project focus-android by mozilla-mobile.

the class MainActivity method onBackPressed.

@Override
public void onBackPressed() {
    final FragmentManager fragmentManager = getSupportFragmentManager();
    final SessionsSheetFragment sessionsSheetFragment = (SessionsSheetFragment) fragmentManager.findFragmentByTag(SessionsSheetFragment.FRAGMENT_TAG);
    if (sessionsSheetFragment != null && sessionsSheetFragment.isVisible() && sessionsSheetFragment.onBackPressed()) {
        // SessionsSheetFragment handles back presses itself (custom animations).
        return;
    }
    final UrlInputFragment urlInputFragment = (UrlInputFragment) fragmentManager.findFragmentByTag(UrlInputFragment.FRAGMENT_TAG);
    if (urlInputFragment != null && urlInputFragment.isVisible() && urlInputFragment.onBackPressed()) {
        // we do not try to remove it from outside.
        return;
    }
    final BrowserFragment browserFragment = (BrowserFragment) fragmentManager.findFragmentByTag(BrowserFragment.FRAGMENT_TAG);
    if (browserFragment != null && browserFragment.isVisible() && browserFragment.onBackPressed()) {
        // in the browsing history.
        return;
    }
    super.onBackPressed();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) SessionsSheetFragment(org.mozilla.focus.session.ui.SessionsSheetFragment) BrowserFragment(org.mozilla.focus.fragment.BrowserFragment) UrlInputFragment(org.mozilla.focus.fragment.UrlInputFragment)

Example 4 with BrowserFragment

use of org.mozilla.focus.fragment.BrowserFragment in project focus-android by mozilla-mobile.

the class MainActivity method showUrlInputScreen.

private void showUrlInputScreen() {
    final FragmentManager fragmentManager = getSupportFragmentManager();
    final BrowserFragment browserFragment = (BrowserFragment) fragmentManager.findFragmentByTag(BrowserFragment.FRAGMENT_TAG);
    final boolean isShowingBrowser = browserFragment != null;
    if (isShowingBrowser) {
        ViewUtils.showBrandedSnackbar(findViewById(android.R.id.content), R.string.feedback_erase, getResources().getInteger(R.integer.erase_snackbar_delay));
    }
    // We add the url input fragment to the layout if it doesn't exist yet.
    final FragmentTransaction transaction = fragmentManager.beginTransaction();
    // We only want to play the animation if a browser fragment is added and resumed.
    // If it is not resumed then the application is currently in the process of resuming
    // and the session was removed while the app was in the background (e.g. via the
    // notification). In this case we do not want to show the content and remove the
    // browser fragment immediately.
    boolean shouldAnimate = isShowingBrowser && browserFragment.isResumed();
    if (shouldAnimate) {
        transaction.setCustomAnimations(0, R.anim.erase_animation);
    }
    transaction.replace(R.id.container, UrlInputFragment.createWithoutSession(), UrlInputFragment.FRAGMENT_TAG).commit();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction) BrowserFragment(org.mozilla.focus.fragment.BrowserFragment)

Example 5 with BrowserFragment

use of org.mozilla.focus.fragment.BrowserFragment in project Rocket by mozilla-tw.

the class CaptureRunnable method run.

@Override
public void run() {
    BrowserFragment browserFragment = refBrowserFragment.get();
    if (browserFragment == null) {
        return;
    }
    if (browserFragment.capturePage(this)) {
    // onCaptureComplete called
    } else {
        // Capture failed
        ScreenCaptureDialogFragment screenCaptureDialogFragment = refScreenCaptureDialogFragment.get();
        if (screenCaptureDialogFragment != null) {
            screenCaptureDialogFragment.dismiss();
        }
        promptScreenshotResult(false);
    }
}
Also used : ScreenCaptureDialogFragment(org.mozilla.focus.fragment.ScreenCaptureDialogFragment) BrowserFragment(org.mozilla.focus.fragment.BrowserFragment)

Aggregations

BrowserFragment (org.mozilla.focus.fragment.BrowserFragment)11 FragmentManager (android.support.v4.app.FragmentManager)4 Context (android.content.Context)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 ScreenCaptureDialogFragment (org.mozilla.focus.fragment.ScreenCaptureDialogFragment)1 UrlInputFragment (org.mozilla.focus.fragment.UrlInputFragment)1 Session (org.mozilla.focus.session.Session)1 SessionsSheetFragment (org.mozilla.focus.session.ui.SessionsSheetFragment)1