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