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