This commit is contained in:
Chumva 2019-09-24 11:50:36 +03:00
parent 9de8fe59a7
commit a3b82e0b51
3 changed files with 18 additions and 1 deletions

View file

@ -1852,6 +1852,7 @@ public class OsmandAidlApi {
public void loadConnectedApps() {
try {
connectedApps.clear();
JSONArray array = new JSONArray(app.getSettings().API_CONNECTED_APPS_JSON.get());
for (int i = 0; i < array.length(); i++) {
JSONObject obj = array.getJSONObject(i);

View file

@ -170,6 +170,22 @@ public abstract class OsmandPlugin {
}
}
public static void updateActivatedPlugins(OsmandApplication app, Set<String> enabledPlugins) {
for (OsmandPlugin plugin : allPlugins) {
if (enabledPlugins.contains(plugin.getId())) {
try {
if (plugin.init(app, null)) {
plugin.setActive(true);
}
} catch (Exception e) {
LOG.error("Plugin initialization failed " + plugin.getId(), e);
}
} else if (plugin.isActive()) {
plugin.setActive(false);
}
}
}
private static void checkMarketPlugin(@NonNull OsmandApplication app, @NonNull Set<String> enabledPlugins,
@NonNull OsmandPlugin plugin, boolean paid, String id, String id2) {
boolean marketEnabled = Version.isMarketEnabled(app);

View file

@ -370,7 +370,7 @@ public class OsmandSettings {
OsmandAidlApi aidlApi = ctx.getAidlApi();
if (aidlApi != null) {
aidlApi.loadConnectedApps();
OsmandPlugin.initPlugins(ctx);
OsmandPlugin.updateActivatedPlugins(ctx, getEnabledPlugins());
}
fireEvent(oldMode);