Maintenance plugin cleanup
This commit is contained in:
parent
ddff05da75
commit
3bcd656c14
|
@ -190,7 +190,7 @@
|
|||
|
||||
<activity android:name=".activities.SingleFragmentActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity android:name=".logging.LogSettingActivity"></activity>
|
||||
<activity android:name=".plugins.Maintenance.activities.LogSettingActivity"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -49,14 +49,12 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
|
|||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.LogSettingActivity;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
||||
import info.nightscout.androidaps.setupwizard.SetupWizardActivity;
|
||||
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
||||
import info.nightscout.utils.AndroidPermission;
|
||||
import info.nightscout.utils.LocaleHelper;
|
||||
import info.nightscout.utils.LogDialog;
|
||||
import info.nightscout.utils.OKDialog;
|
||||
import info.nightscout.utils.PasswordProtection;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -376,12 +374,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
case R.id.nav_setupwizard:
|
||||
startActivity(new Intent(this, SetupWizardActivity.class));
|
||||
return true;
|
||||
case R.id.nav_show_logcat:
|
||||
LogDialog.showLogcat(this);
|
||||
return true;
|
||||
case R.id.nav_logsettings:
|
||||
startActivity(new Intent(this, LogSettingActivity.class));
|
||||
return true;
|
||||
case R.id.nav_about:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(MainApp.gs(R.string.app_name) + " " + BuildConfig.VERSION);
|
||||
|
|
|
@ -79,7 +79,7 @@ import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
|||
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.LoggerUtils;
|
||||
import info.nightscout.androidaps.plugins.Maintenance.LoggerUtils;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import info.nightscout.utils.SP;
|
|||
public class L {
|
||||
|
||||
public static class LogElement {
|
||||
String name;
|
||||
public String name;
|
||||
boolean defaultValue;
|
||||
boolean enabled;
|
||||
public boolean enabled;
|
||||
boolean requiresRestart = false;
|
||||
|
||||
LogElement(String name, boolean defaultValue) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.utils;
|
||||
package info.nightscout.androidaps.plugins.Maintenance;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
|
@ -28,6 +28,8 @@ import java.util.Map;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.utils.OKDialog;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
/**
|
||||
* Created by mike on 03.07.2016.
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.utils;
|
||||
package info.nightscout.androidaps.plugins.Maintenance;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.Maintenance;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -10,8 +11,8 @@ 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.Maintenance.activities.LogSettingActivity;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.ImportExportPrefs;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -43,39 +44,38 @@ public class MaintenanceFragment extends Fragment {
|
|||
|
||||
view.findViewById(R.id.log_send).setOnClickListener(view1 -> MaintenancePlugin.getPlugin().sendLogs());
|
||||
|
||||
view.findViewById(R.id.log_delete).setOnClickListener(view12 -> MaintenancePlugin.getPlugin().deleteLogs());
|
||||
view.findViewById(R.id.log_delete).setOnClickListener(view1 -> MaintenancePlugin.getPlugin().deleteLogs());
|
||||
|
||||
view.findViewById(R.id.nav_resetdb).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new AlertDialog.Builder(f.getContext())
|
||||
.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();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.nav_resetdb).setOnClickListener(view1 -> new AlertDialog.Builder(f.getContext())
|
||||
.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());
|
||||
|
||||
view.findViewById(R.id.nav_export).setOnClickListener(view13 -> {
|
||||
view.findViewById(R.id.nav_export).setOnClickListener(view1 -> {
|
||||
// start activity for checking permissions...
|
||||
ImportExportPrefs.verifyStoragePermissions(f);
|
||||
ImportExportPrefs.exportSharedPreferences(f);
|
||||
});
|
||||
|
||||
view.findViewById(R.id.nav_import).setOnClickListener(view14 -> {
|
||||
view.findViewById(R.id.nav_import).setOnClickListener(view1 -> {
|
||||
// start activity for checking permissions...
|
||||
ImportExportPrefs.verifyStoragePermissions(f);
|
||||
ImportExportPrefs.importSharedPreferences(f);
|
||||
});
|
||||
|
||||
view.findViewById(R.id.nav_logsettings).setOnClickListener(view1 -> {
|
||||
startActivity(new Intent(getActivity(), LogSettingActivity.class));
|
||||
});
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -13,10 +13,8 @@ import java.io.BufferedOutputStream;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
@ -26,7 +24,6 @@ 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.utils.LoggerUtils;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
public class MaintenancePlugin extends PluginBase {
|
||||
|
@ -60,7 +57,7 @@ public class MaintenancePlugin extends PluginBase {
|
|||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(MaintenanceFragment.class.getName())
|
||||
.alwayVisible(true)
|
||||
.alwayVisible(false)
|
||||
.alwaysEnabled(true)
|
||||
.pluginName(R.string.maintenance)
|
||||
.shortName(R.string.maintenance_shortname)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.logging;
|
||||
package info.nightscout.androidaps.plugins.Maintenance.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
@ -14,6 +14,7 @@ import butterknife.ButterKnife;
|
|||
import butterknife.OnClick;
|
||||
import butterknife.Unbinder;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class LogSettingActivity extends AppCompatActivity {
|
||||
|
|
@ -51,7 +51,7 @@ import info.nightscout.androidaps.setupwizard.elements.SWEditUrl;
|
|||
import info.nightscout.androidaps.setupwizard.events.EventSWLabel;
|
||||
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate;
|
||||
import info.nightscout.utils.AndroidPermission;
|
||||
import info.nightscout.utils.ImportExportPrefs;
|
||||
import info.nightscout.androidaps.plugins.Maintenance.ImportExportPrefs;
|
||||
import info.nightscout.utils.LocaleHelper;
|
||||
import info.nightscout.utils.PasswordProtection;
|
||||
import info.nightscout.utils.SP;
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
package info.nightscout.utils;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.ClipboardManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
/**
|
||||
* Created by mike on 09.02.2017.
|
||||
*/
|
||||
|
||||
public class LogDialog {
|
||||
|
||||
public static void showLogcat(Context context) {
|
||||
String logCat = "no logs";
|
||||
final String processId = Integer.toString(android.os.Process.myPid());
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec("logcat -d " + MainApp.gs(R.string.app_name) + ":D");
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
StringBuilder log = new StringBuilder();
|
||||
String line;
|
||||
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
if (line.contains(processId)) log.append(line + "\n");
|
||||
}
|
||||
logCat = log.toString();
|
||||
|
||||
} catch (IOException e) {
|
||||
logCat = e.getLocalizedMessage();
|
||||
} finally {
|
||||
showAlertText(logCat, context);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showAlertText(final String msg, final Context context) {
|
||||
try {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(context)
|
||||
.setMessage(msg)
|
||||
.setPositiveButton(MainApp.gs(R.string.copy_to_clipboard), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText(null, msg));
|
||||
ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.copied_to_clipboard));
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
|
||||
if (msg.length() > 100) {
|
||||
TextView textView = (TextView) alertDialog.findViewById(android.R.id.message);
|
||||
textView.setTextSize(10);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// crashing on screen rotation
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".logging.LogSettingActivity">
|
||||
tools:context=".plugins.Maintenance.activities.LogSettingActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/logsettings_reset"
|
||||
|
|
|
@ -11,6 +11,19 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
android:id="@+id/nav_logsettings"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_weight="0.5"
|
||||
android:text="@string/nav_logsettings"
|
||||
android:textColor="@color/colorTreatmentButton" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/log_send"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -18,14 +18,6 @@
|
|||
android:id="@+id/nav_setupwizard"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/nav_setupwizard" />
|
||||
<item
|
||||
android:id="@+id/nav_show_logcat"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/nav_show_logcat" />
|
||||
<item
|
||||
android:id="@+id/nav_logsettings"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/nav_logsettings" />
|
||||
<item
|
||||
android:id="@+id/nav_about"
|
||||
app:showAsAction="never"
|
||||
|
|
|
@ -497,10 +497,6 @@
|
|||
<string name="error_field_must_not_be_empty">The field must not be empty</string>
|
||||
<string name="error_phone_not_valid">Phone number not valid</string>
|
||||
<string name="smscommunicator_invalidphonennumber">Invalid SMS phone number</string>
|
||||
<string name="copy_to_clipboard">Copy To Clipboard</string>
|
||||
<string name="copied_to_clipboard">Copied to clipboard</string>
|
||||
<string name="nav_show_logcat">Show log</string>
|
||||
<string name="nav_export_log">Export Logs</string>
|
||||
<string name="overview_calibration">Calibration</string>
|
||||
<string name="send_calibration" formatted="false">Send calibration %.1f to xDrip?</string>
|
||||
<string name="xdripnotinstalled">xDrip+ not installed</string>
|
||||
|
@ -1171,7 +1167,7 @@
|
|||
<string name="invalid_email_message">Invalid Email</string>
|
||||
<string name="key_maintenance_logs_amount" translatable="false">amount of logs to send</string>
|
||||
<string name="maintenance_amount">No of Logs to send</string>
|
||||
<string name="maintenance">Wartung</string>
|
||||
<string name="maintenance">Maintenance</string>
|
||||
<string name="maintenance_shortname">MAINT</string>
|
||||
<string name="description_maintenance">Provides several functions for maintenance (eg. log sending, log deletion).</string>
|
||||
<string name="send_all_logs">Send Logs by Email</string>
|
||||
|
|
|
@ -12,7 +12,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||
import info.nightscout.utils.LoggerUtils;
|
||||
import info.nightscout.androidaps.plugins.Maintenance.LoggerUtils;
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue