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