Search in sources :

Example 1 with OsmandPlugin

use of net.osmand.plus.plugins.OsmandPlugin in project Osmand by osmandapp.

the class CommonPreference method get.

@Override
public T get() {
    OsmandPlugin relatedPlugin = getRelatedPlugin();
    if (relatedPlugin != null && !relatedPlugin.isActive()) {
        return getDefaultValue();
    }
    if (cache && cachedValue != null && cachedPreference == getPreferences()) {
        return cachedValue;
    }
    cachedPreference = getPreferences();
    cachedValue = getValue(cachedPreference, getDefaultValue());
    return cachedValue;
}
Also used : OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin)

Example 2 with OsmandPlugin

use of net.osmand.plus.plugins.OsmandPlugin in project Osmand by osmandapp.

the class DashPluginsFragment method addPluginsToLimit.

private void addPluginsToLimit(Iterator<OsmandPlugin> it, int l) {
    while (plugins.size() < l && it.hasNext()) {
        OsmandPlugin plugin = it.next();
        if (plugin instanceof OsmandDevelopmentPlugin) {
            continue;
        }
        plugins.add(plugin);
    }
}
Also used : OsmandDevelopmentPlugin(net.osmand.plus.plugins.development.OsmandDevelopmentPlugin) OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin)

Example 3 with OsmandPlugin

use of net.osmand.plus.plugins.OsmandPlugin in project Osmand by osmandapp.

the class ConfigureProfileFragment method setupOsmandPluginsPref.

private void setupOsmandPluginsPref(PreferenceCategory preferenceCategory) {
    Context ctx = getContext();
    if (ctx == null) {
        return;
    }
    List<OsmandPlugin> plugins = OsmandPlugin.getEnabledSettingsScreenPlugins();
    if (plugins.size() != 0) {
        for (OsmandPlugin plugin : plugins) {
            Preference preference = new Preference(ctx);
            preference.setPersistent(false);
            preference.setKey(plugin.getId());
            preference.setTitle(plugin.getName());
            preference.setSummary(plugin.getPrefsDescription());
            preference.setIcon(getContentIcon(plugin.getLogoResourceId()));
            preference.setLayoutResource(R.layout.preference_with_descr);
            preference.setFragment(plugin.getSettingsScreenType().fragmentName);
            preferenceCategory.addPreference(preference);
        }
    }
}
Also used : Context(android.content.Context) Preference(androidx.preference.Preference) OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin)

Example 4 with OsmandPlugin

use of net.osmand.plus.plugins.OsmandPlugin in project Osmand by osmandapp.

the class InAppPurchaseHelperImpl method purchaseContourLines.

@Override
public void purchaseContourLines(@NonNull Activity activity) throws UnsupportedOperationException {
    OsmandPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
    if (plugin == null || plugin.getInstallURL() == null) {
        Toast.makeText(activity.getApplicationContext(), activity.getString(R.string.activate_srtm_plugin), Toast.LENGTH_LONG).show();
    } else {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()));
        AndroidUtils.startActivityIfSafe(activity, intent);
    }
}
Also used : Intent(android.content.Intent) OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin)

Example 5 with OsmandPlugin

use of net.osmand.plus.plugins.OsmandPlugin in project Osmand by osmandapp.

the class ProfileSettingsItem method updatePluginResPrefs.

private void updatePluginResPrefs() {
    String pluginId = getPluginId();
    if (Algorithms.isEmpty(pluginId)) {
        return;
    }
    OsmandPlugin plugin = OsmandPlugin.getPlugin(pluginId);
    if (plugin instanceof CustomOsmandPlugin) {
        CustomOsmandPlugin customPlugin = (CustomOsmandPlugin) plugin;
        String resDirPath = IndexConstants.PLUGINS_DIR + pluginId + "/" + customPlugin.getResourceDirName();
        for (Iterator<String> it = additionalPrefsJson.keys(); it.hasNext(); ) {
            try {
                String prefId = it.next();
                Object value = additionalPrefsJson.get(prefId);
                if (value instanceof JSONObject) {
                    JSONObject jsonObject = (JSONObject) value;
                    for (Iterator<String> iterator = jsonObject.keys(); iterator.hasNext(); ) {
                        String key = iterator.next();
                        Object val = jsonObject.get(key);
                        if (val instanceof String) {
                            val = checkPluginResPath((String) val, resDirPath);
                        }
                        jsonObject.put(key, val);
                    }
                } else if (value instanceof String) {
                    value = checkPluginResPath((String) value, resDirPath);
                    additionalPrefsJson.put(prefId, value);
                }
            } catch (JSONException e) {
                SettingsHelper.LOG.error(e);
            }
        }
    }
}
Also used : JSONObject(org.json.JSONObject) CustomOsmandPlugin(net.osmand.plus.plugins.CustomOsmandPlugin) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) CustomOsmandPlugin(net.osmand.plus.plugins.CustomOsmandPlugin) OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin)

Aggregations

OsmandPlugin (net.osmand.plus.plugins.OsmandPlugin)7 Context (android.content.Context)1 Intent (android.content.Intent)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 Preference (androidx.preference.Preference)1 CustomOsmandPlugin (net.osmand.plus.plugins.CustomOsmandPlugin)1 OsmandDevelopmentPlugin (net.osmand.plus.plugins.development.OsmandDevelopmentPlugin)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1