Search in sources :

Example 1 with Browsers

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);
}
Also used : Browsers(org.mozilla.focus.utils.Browsers)

Example 2 with Browsers

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);
    }
}
Also used : Browsers(org.mozilla.focus.utils.Browsers)

Example 3 with Browsers

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);
    }
}
Also used : Resources(android.content.res.Resources) Browsers(org.mozilla.focus.utils.Browsers)

Example 4 with Browsers

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);
}
Also used : Context(android.content.Context) Browsers(org.mozilla.focus.utils.Browsers)

Example 5 with Browsers

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()));
    }
}
Also used : Browsers(org.mozilla.focus.utils.Browsers)

Aggregations

Browsers (org.mozilla.focus.utils.Browsers)6 Activity (android.app.Activity)1 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ActivityInfo (android.content.pm.ActivityInfo)1 Resources (android.content.res.Resources)1 DialogFragment (android.support.v4.app.DialogFragment)1 Fragment (android.support.v4.app.Fragment)1 InstallFirefoxActivity (org.mozilla.focus.activity.InstallFirefoxActivity)1 MainActivity (org.mozilla.focus.activity.MainActivity)1 LocaleAwareAppCompatActivity (org.mozilla.focus.locale.LocaleAwareAppCompatActivity)1 BrowserMenu (org.mozilla.focus.menu.browser.BrowserMenu)1 OpenWithFragment (org.mozilla.focus.open.OpenWithFragment)1 SessionsSheetFragment (org.mozilla.focus.session.ui.SessionsSheetFragment)1 IWebView (org.mozilla.focus.web.IWebView)1