diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index fe66b95ab0..c863f9f2b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -374,29 +374,6 @@ public class MainActivity extends AppCompatActivity { case R.id.nav_setupwizard: startActivity(new Intent(this, SetupWizardActivity.class)); return true; - case R.id.nav_resetdb: - new AlertDialog.Builder(this) - .setTitle(R.string.nav_resetdb) - .setMessage(R.string.reset_db_confirm) - .setNegativeButton(android.R.string.cancel, null) - .setPositiveButton(android.R.string.ok, (dialog, which) -> { - MainApp.getDbHelper().resetDatabases(); - // should be handled by Plugin-Interface and - // additional service interface and plugin registry - FoodPlugin.getPlugin().getService().resetFood(); - TreatmentsPlugin.getPlugin().getService().resetTreatments(); - }) - .create() - .show(); - return true; - case R.id.nav_export: - ImportExportPrefs.verifyStoragePermissions(this); - ImportExportPrefs.exportSharedPreferences(this); - return true; - case R.id.nav_import: - ImportExportPrefs.verifyStoragePermissions(this); - ImportExportPrefs.importSharedPreferences(this); - return true; case R.id.nav_show_logcat: LogDialog.showLogcat(this); return true; diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 55dbb37447..dd96be6866 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -10,7 +10,6 @@ import android.support.v4.content.LocalBroadcastManager; import com.crashlytics.android.Crashlytics; import com.crashlytics.android.answers.Answers; -import com.crashlytics.android.answers.CustomEvent; import com.j256.ormlite.android.apptools.OpenHelperManager; import com.squareup.otto.Bus; import com.squareup.otto.LoggingBus; @@ -24,7 +23,6 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.util.ArrayList; -import ch.qos.logback.classic.LoggerContext; import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.data.ConstraintChecker; import info.nightscout.androidaps.db.DatabaseHelper; @@ -41,7 +39,7 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin; import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin; import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; -import info.nightscout.androidaps.plugins.LogShipper.LogShipperPlugin; +import info.nightscout.androidaps.plugins.Maintenance.MaintenancePlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver; @@ -191,7 +189,7 @@ public class MainApp extends Application { pluginsList.add(StatuslinePlugin.initPlugin(this)); pluginsList.add(PersistentNotificationPlugin.getPlugin()); pluginsList.add(NSClientPlugin.getPlugin()); - pluginsList.add(LogShipperPlugin.initPlugin(this)); + pluginsList.add(MaintenancePlugin.initPlugin(this)); pluginsList.add(sConfigBuilder = ConfigBuilderPlugin.getPlugin()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/LogShipper/LogShipperFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Maintenance/MaintenanceFragment.java similarity index 51% rename from app/src/main/java/info/nightscout/androidaps/plugins/LogShipper/LogShipperFragment.java rename to app/src/main/java/info/nightscout/androidaps/plugins/Maintenance/MaintenanceFragment.java index c893af0c4d..a38b69d683 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/LogShipper/LogShipperFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Maintenance/MaintenanceFragment.java @@ -1,34 +1,45 @@ -package info.nightscout.androidaps.plugins.LogShipper; +package info.nightscout.androidaps.plugins.Maintenance; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.Food.FoodPlugin; +import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; /** * */ -public class LogShipperFragment extends Fragment { +public class MaintenanceFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.logshipper_fragment, container, false); + View view = inflater.inflate(R.layout.maintenance_fragment, container, false); view.findViewById(R.id.log_send).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - LogShipperPlugin.getPlugin().sendLogs(); + MaintenancePlugin.getPlugin().sendLogs(); } }); view.findViewById(R.id.log_delete).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - LogShipperPlugin.getPlugin().deleteLogs(); + MaintenancePlugin.getPlugin().deleteLogs(); + } + }); + + view.findViewById(R.id.nav_resetdb).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + } }); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/LogShipper/LogShipperPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Maintenance/MaintenancePlugin.java similarity index 75% rename from app/src/main/java/info/nightscout/androidaps/plugins/LogShipper/LogShipperPlugin.java rename to app/src/main/java/info/nightscout/androidaps/plugins/Maintenance/MaintenancePlugin.java index 8553fbe720..d8ca65e8fb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/LogShipper/LogShipperPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Maintenance/MaintenancePlugin.java @@ -1,9 +1,10 @@ -package info.nightscout.androidaps.plugins.LogShipper; +package info.nightscout.androidaps.plugins.Maintenance; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.support.v4.content.FileProvider; +import android.support.v7.app.AlertDialog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,50 +23,54 @@ import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.plugins.Food.FoodPlugin; +import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; +import info.nightscout.utils.ImportExportPrefs; import info.nightscout.utils.LoggerUtils; import info.nightscout.utils.SP; -public class LogShipperPlugin extends PluginBase { +public class MaintenancePlugin extends PluginBase { - private static final Logger LOG = LoggerFactory.getLogger(LogShipperPlugin.class); + private static final Logger LOG = LoggerFactory.getLogger(MaintenancePlugin.class); private final Context ctx; - private static LogShipperPlugin logShipperPlugin; + private static MaintenancePlugin maintenancePlugin; - public static LogShipperPlugin getPlugin() { - return logShipperPlugin; + public static MaintenancePlugin getPlugin() { + return maintenancePlugin; } - public static LogShipperPlugin initPlugin(Context ctx) { + public static MaintenancePlugin initPlugin(Context ctx) { - if (logShipperPlugin == null) { - logShipperPlugin = new LogShipperPlugin(ctx); + if (maintenancePlugin == null) { + maintenancePlugin = new MaintenancePlugin(ctx); } - return logShipperPlugin; + return maintenancePlugin; } - public LogShipperPlugin() { + public MaintenancePlugin() { // required for testing super(null); this.ctx = null; } - LogShipperPlugin(Context ctx) { + MaintenancePlugin(Context ctx) { super(new PluginDescription() .mainType(PluginType.GENERAL) - .fragmentClass(LogShipperFragment.class.getName()) + .fragmentClass(MaintenanceFragment.class.getName()) .alwayVisible(true) .alwaysEnabled(true) - .pluginName(R.string.logshipper) - .shortName(R.string.logship_shortname) - .preferencesId(R.xml.pref_logshipper) - .description(R.string.description_logship) + .pluginName(R.string.maintenance) + .shortName(R.string.maintenance_shortname) + .preferencesId(R.xml.pref_maintenance) + .description(R.string.description_maintenance) ); this.ctx = ctx; } @@ -81,8 +86,8 @@ public class LogShipperPlugin extends PluginBase { } public void sendLogs() { - String recipient = SP.getString("key_logshipper_email", "logs@androidaps.org"); - int amount = SP.getInt("key_logshipper_amount", 2); + String recipient = SP.getString("key_maintenance_logs_email", "logs@androidaps.org"); + int amount = SP.getInt("key_maintenance_logs_amount", 2); String logDirectory = LoggerUtils.getLogDirectory(); List logs = this.getLogfiles(logDirectory, amount); @@ -141,6 +146,32 @@ public class LogShipperPlugin extends PluginBase { } } + public void resetDb() { +// new AlertDialog.Builder(this) +// .setTitle(R.string.nav_resetdb) +// .setMessage(R.string.reset_db_confirm) +// .setNegativeButton(android.R.string.cancel, null) +// .setPositiveButton(android.R.string.ok, (dialog, which) -> { +// MainApp.getDbHelper().resetDatabases(); +// // should be handled by Plugin-Interface and +// // additional service interface and plugin registry +// FoodPlugin.getPlugin().getService().resetFood(); +// TreatmentsPlugin.getPlugin().getService().resetTreatments(); +// }) +// .create() +// .show(); + } + + public void exportSettings() { +// ImportExportPrefs.verifyStoragePermissions(this); +// ImportExportPrefs.exportSharedPreferences(this); + } + + public void importSettings() { +// ImportExportPrefs.verifyStoragePermissions(this); +// ImportExportPrefs.importSharedPreferences(this); + } + /** * returns a list of log files. The number of returned logs is given via the amount * parameter. The log files are sorted by the name descending. diff --git a/app/src/main/res/layout/logshipper_fragment.xml b/app/src/main/res/layout/logshipper_fragment.xml deleted file mode 100644 index d3cbad8181..0000000000 --- a/app/src/main/res/layout/logshipper_fragment.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - -