Search in sources :

Example 6 with BrowserFragment

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

the class BrowserMediator method setInForeground.

void setInForeground(final boolean isForeground) {
    final FragmentManager fragmentManager = this.activity.getSupportFragmentManager();
    final BrowserFragment fragment = findBrowserFragment(fragmentManager);
    if (isForeground) {
        fragment.goForeground();
    } else {
        fragment.goBackground();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) BrowserFragment(org.mozilla.focus.fragment.BrowserFragment)

Example 7 with BrowserFragment

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

the class MainActivity method onBackPressed.

@Override
public void onBackPressed() {
    if (!safeForFragmentTransactions) {
        return;
    }
    BrowserFragment browserFragment = getVisibleBrowserFragment();
    if (browserFragment != null && browserFragment.onBackPressed()) {
        return;
    }
    super.onBackPressed();
}
Also used : BrowserFragment(org.mozilla.focus.fragment.BrowserFragment)

Example 8 with BrowserFragment

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

the class MainActivity method updateMenu.

private void updateMenu() {
    final BrowserFragment browserFragment = getVisibleBrowserFragment();
    final boolean canGoForward = browserFragment != null && browserFragment.canGoForward();
    setEnable(nextButton, canGoForward);
    setLoadingButton(browserFragment);
    setEnable(shareButton, browserFragment != null);
    setEnable(pinShortcut, browserFragment != null);
}
Also used : BrowserFragment(org.mozilla.focus.fragment.BrowserFragment)

Example 9 with BrowserFragment

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

the class MainActivity method onMenuBrowsingItemClicked.

public void onMenuBrowsingItemClicked(View v) {
    final BrowserFragment browserFragment = getVisibleBrowserFragment();
    if (browserFragment == null) {
        return;
    }
    switch(v.getId()) {
        case R.id.action_next:
            onNextClicked(browserFragment);
            TelemetryWrapper.clickToolbarForward();
            break;
        case R.id.action_loading:
            if ((boolean) v.getTag()) {
                onStopClicked(browserFragment);
            } else {
                onRefreshClicked(browserFragment);
            }
            TelemetryWrapper.clickToolbarReload();
            break;
        case R.id.action_share:
            onShraeClicked(browserFragment);
            TelemetryWrapper.clickToolbarShare();
            break;
        case R.id.action_pin_shortcut:
            onAddToHomeClicked();
            TelemetryWrapper.clickAddToHome();
            break;
        default:
            throw new RuntimeException("Unknown id in menu, onMenuBrowsingItemClicked() is" + " only for known ids");
    }
}
Also used : BrowserFragment(org.mozilla.focus.fragment.BrowserFragment)

Example 10 with BrowserFragment

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

the class MainActivity method onSharedPreferenceChanged.

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    // Only refresh when disabling turbo mode
    if (this.getResources().getString(R.string.pref_key_turbo_mode).equals(key)) {
        final boolean turboEnabled = isTurboEnabled();
        BrowserFragment browserFragment = getBrowserFragment();
        if (browserFragment != null) {
            browserFragment.setContentBlockingEnabled(turboEnabled);
        }
        menu.findViewById(R.id.menu_turbomode).setSelected(turboEnabled);
    } else if (this.getResources().getString(R.string.pref_key_performance_block_images).equals(key)) {
        final boolean blockingImages = isBlockingImages();
        BrowserFragment browserFragment = getBrowserFragment();
        if (browserFragment != null) {
            browserFragment.setImageBlockingEnabled(blockingImages);
        }
        menu.findViewById(R.id.menu_blockimg).setSelected(blockingImages);
    }
// For turbo mode, a automatic refresh is done when we disable block image.
}
Also used : 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