use of org.mozilla.focus.utils.Browsers in project Rocket by mozilla-tw.
the class TelemetryWrapper method updateDefaultBrowserStatus.
private static void updateDefaultBrowserStatus(Context context) {
boolean isDefaultBrowser = new Browsers(context, "http://www.mozilla.org").isDefaultBrowser(context);
Settings.updatePrefDefaultBrowserIfNeeded(context, isDefaultBrowser);
}
use of org.mozilla.focus.utils.Browsers in project Rocket by mozilla-tw.
the class DefaultBrowserPreference method update.
public void update() {
if (switchView != null) {
final Browsers browsers = new Browsers(getContext(), "http://www.mozilla.org");
final boolean isDefaultBrowser = browsers.isDefaultBrowser(getContext());
switchView.setChecked(isDefaultBrowser);
Settings.updatePrefDefaultBrowserIfNeeded(getContext(), isDefaultBrowser);
}
}
use of org.mozilla.focus.utils.Browsers in project focus-android by mozilla-mobile.
the class BrowserMenuAdapter method initializeMenu.
private void initializeMenu(String url, @Nullable final CustomTabConfig customTabConfig) {
final Resources resources = context.getResources();
final Browsers browsers = new Browsers(context, url);
this.items = new ArrayList<>();
if (customTabConfig == null || customTabConfig.showShareMenuItem) {
items.add(new MenuItem(R.id.share, resources.getString(R.string.menu_share)));
}
items.add(new MenuItem(R.id.add_to_homescreen, resources.getString(R.string.menu_add_to_home_screen)));
if (browsers.hasMultipleThirdPartyBrowsers(context)) {
items.add(new MenuItem(R.id.open_select_browser, resources.getString(R.string.menu_open_with_a_browser2)));
}
if (customTabConfig != null) {
// "Open in Firefox Focus" to switch from a custom tab to the full-featured browser
items.add(new MenuItem(R.id.open_in_firefox_focus, resources.getString(R.string.menu_open_with_default_browser2, resources.getString(R.string.app_name))));
}
if (browsers.hasThirdPartyDefaultBrowser(context)) {
items.add(new MenuItem(R.id.open_default, resources.getString(R.string.menu_open_with_default_browser2, browsers.getDefaultBrowser().loadLabel(context.getPackageManager()))));
}
if (customTabConfig == null) {
// There’s no need for Settings in a custom tab. The user can go to the browser app itself in order to do this.
items.add(new MenuItem(R.id.settings, resources.getString(R.string.menu_settings)));
}
if (customTabConfig != null) {
addCustomTabMenuItems(items, customTabConfig);
}
}
use of org.mozilla.focus.utils.Browsers in project focus-android by mozilla-mobile.
the class TelemetrySettingsProvider method getValue.
@Override
public java.lang.Object getValue(String key) {
if (key.equals(prefKeyDefaultBrowser)) {
// The default browser is not actually a setting. We determine if we are the
// default and then inject this into telemetry.
final Context context = TelemetryHolder.get().getConfiguration().getContext();
final Browsers browsers = new Browsers(context, Browsers.TRADITIONAL_BROWSER_URL);
return Boolean.toString(browsers.isDefaultBrowser(context));
}
if (key.equals(prefKeySearchEngine)) {
java.lang.Object value = super.getValue(key);
if (value == null) {
// If the user has never selected a search engine then this value is null.
// However we still want to report the current search engine of the user.
// Therefore we inject this value at runtime.
value = SearchEngineManager.getInstance().getDefaultSearchEngine(context).getName();
} else if (SearchEngineManager.getInstance().isCustomSearchEngine((String) value, context)) {
// Don't collect possibly sensitive info for custom search engines, send "custom" instead
value = SearchEngineManager.ENGINE_TYPE_CUSTOM;
}
return value;
}
return super.getValue(key);
}
use of org.mozilla.focus.utils.Browsers in project focus-android by mozilla-mobile.
the class DefaultBrowserPreference method update.
public void update() {
if (switchView != null) {
final Browsers browsers = new Browsers(getContext(), Browsers.TRADITIONAL_BROWSER_URL);
switchView.setChecked(browsers.isDefaultBrowser(getContext()));
}
}
Aggregations