verify plugins after import

This commit is contained in:
Milos Kozak 2018-08-07 21:45:35 +02:00
parent d793135339
commit 60d5567c91
2 changed files with 60 additions and 58 deletions

View file

@ -100,6 +100,8 @@ public class ConfigBuilderPlugin extends PluginBase {
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Storing settings from: " + from);
verifySelectionInCategories();
for (PluginBase p : pluginList) {
PluginType type = p.getType();
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwayVisible)
@ -113,7 +115,6 @@ public class ConfigBuilderPlugin extends PluginBase {
}
}
}
verifySelectionInCategories();
}
}
@ -287,6 +288,8 @@ public class ConfigBuilderPlugin extends PluginBase {
if (activeInsulin == null) {
activeInsulin = InsulinOrefRapidActingPlugin.getPlugin();
InsulinOrefRapidActingPlugin.getPlugin().setPluginEnabled(PluginType.INSULIN, true);
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Defaulting InsulinOrefRapidActingPlugin");
}
this.setFragmentVisiblities(((PluginBase) activeInsulin).getName(), pluginsInCategory, PluginType.INSULIN);
@ -296,6 +299,8 @@ public class ConfigBuilderPlugin extends PluginBase {
if (activeSensitivity == null) {
activeSensitivity = SensitivityOref0Plugin.getPlugin();
SensitivityOref0Plugin.getPlugin().setPluginEnabled(PluginType.SENSITIVITY, true);
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Defaulting SensitivityOref0Plugin");
}
this.setFragmentVisiblities(((PluginBase) activeSensitivity).getName(), pluginsInCategory, PluginType.SENSITIVITY);
@ -311,6 +316,8 @@ public class ConfigBuilderPlugin extends PluginBase {
if (activePump == null) {
activePump = VirtualPumpPlugin.getPlugin();
VirtualPumpPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true);
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Defaulting VirtualPumpPlugin");
}
this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP);

View file

@ -28,6 +28,7 @@ import java.util.Map;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.OKDialog;
import info.nightscout.utils.ToastUtils;
@ -79,8 +80,7 @@ public class ImportExportPrefs {
new AlertDialog.Builder(c)
.setMessage(MainApp.gs(R.string.export_to) + " " + file + " ?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
try {
@ -99,7 +99,6 @@ public class ImportExportPrefs {
} catch (IOException e) {
log.error("Unhandled exception", e);
}
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
@ -112,8 +111,7 @@ public class ImportExportPrefs {
public static void importSharedPreferences(final Context context) {
new AlertDialog.Builder(context)
.setMessage(MainApp.gs(R.string.import_from) + " " + file + " ?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
@ -136,9 +134,8 @@ public class ImportExportPrefs {
}
reader.close();
editor.commit();
OKDialog.show(context, MainApp.gs(R.string.setting_imported), MainApp.gs(R.string.restartingapp), new Runnable() {
@Override
public void run() {
ConfigBuilderPlugin.getPlugin().storeSettings("importSharedPreferences"); // process potentially missing plugins
OKDialog.show(context, MainApp.gs(R.string.setting_imported), MainApp.gs(R.string.restartingapp), () -> {
log.debug("Exiting");
MainApp.instance().stopKeepAliveService();
MainApp.bus().post(new EventAppExit());
@ -148,7 +145,6 @@ public class ImportExportPrefs {
}
System.runFinalization();
System.exit(0);
}
});
} catch (FileNotFoundException e) {
ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.filenotfound) + " " + file);
@ -156,7 +152,6 @@ public class ImportExportPrefs {
} catch (IOException e) {
log.error("Unhandled exception", e);
}
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();