- changed/reverted change

This commit is contained in:
Andy Rozman 2021-06-26 22:00:29 +01:00
parent 3288eb2966
commit d5a8838cab

View file

@ -37,16 +37,17 @@ class MaintenancePlugin @Inject constructor(
private val config: Config, private val config: Config,
private val fileListProvider: PrefFileListProvider, private val fileListProvider: PrefFileListProvider,
private val loggerUtils: LoggerUtils private val loggerUtils: LoggerUtils
) : PluginBase(PluginDescription() ) : PluginBase(
.mainType(PluginType.GENERAL) PluginDescription()
.fragmentClass(MaintenanceFragment::class.java.name) .mainType(PluginType.GENERAL)
.alwaysVisible(false) .fragmentClass(MaintenanceFragment::class.java.name)
.alwaysEnabled(true) .alwaysVisible(false)
.pluginIcon(R.drawable.ic_maintenance) .alwaysEnabled(true)
.pluginName(R.string.maintenance) .pluginIcon(R.drawable.ic_maintenance)
.shortName(R.string.maintenance_shortname) .pluginName(R.string.maintenance)
.preferencesId(R.xml.pref_maintenance) .shortName(R.string.maintenance_shortname)
.description(R.string.description_maintenance), .preferencesId(R.xml.pref_maintenance)
.description(R.string.description_maintenance),
aapsLogger, resourceHelper, injector aapsLogger, resourceHelper, injector
) { ) {
@ -58,7 +59,8 @@ class MaintenancePlugin @Inject constructor(
val zipFile = File(zipDir, constructName()) val zipFile = File(zipDir, constructName())
aapsLogger.debug("zipFile: ${zipFile.absolutePath}") aapsLogger.debug("zipFile: ${zipFile.absolutePath}")
val zip = zipLogs(zipFile, logs) val zip = zipLogs(zipFile, logs)
val attachmentUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", zip) val attachmentUri =
FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", zip)
val emailIntent: Intent = this.sendMail(attachmentUri, recipient, "Log Export") val emailIntent: Intent = this.sendMail(attachmentUri, recipient, "Log Export")
aapsLogger.debug("sending emailIntent") aapsLogger.debug("sending emailIntent")
context.startActivity(emailIntent) context.startActivity(emailIntent)
@ -67,10 +69,6 @@ class MaintenancePlugin @Inject constructor(
//todo replace this with a call on startup of the application, specifically to remove //todo replace this with a call on startup of the application, specifically to remove
// unnecessary garbage from the log exports // unnecessary garbage from the log exports
fun deleteLogs(keep: Int) { fun deleteLogs(keep: Int) {
if (true)
return
val logDir = File(loggerUtils.logDirectory) val logDir = File(loggerUtils.logDirectory)
val files = logDir.listFiles { _: File?, name: String -> val files = logDir.listFiles { _: File?, name: String ->
(name.startsWith("AndroidAPS") && name.endsWith(".zip")) (name.startsWith("AndroidAPS") && name.endsWith(".zip"))
@ -197,7 +195,12 @@ class MaintenancePlugin @Inject constructor(
* *
* @return * @return
*/ */
private fun sendMail(attachmentUri: Uri, recipient: String, subject: String, body: String): Intent { private fun sendMail(
attachmentUri: Uri,
recipient: String,
subject: String,
body: String
): Intent {
aapsLogger.debug("sending email to $recipient with subject $subject") aapsLogger.debug("sending email to $recipient with subject $subject")
val emailIntent = Intent(Intent.ACTION_SEND) val emailIntent = Intent(Intent.ACTION_SEND)
emailIntent.type = "text/plain" emailIntent.type = "text/plain"
@ -212,8 +215,9 @@ class MaintenancePlugin @Inject constructor(
override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) { override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {
super.preprocessPreferences(preferenceFragment) super.preprocessPreferences(preferenceFragment)
val encryptSwitch = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs)) as SwitchPreference? val encryptSwitch =
?: return preferenceFragment.findPreference(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs)) as SwitchPreference?
?: return
encryptSwitch.isVisible = buildHelper.isEngineeringMode() encryptSwitch.isVisible = buildHelper.isEngineeringMode()
encryptSwitch.isEnabled = buildHelper.isEngineeringMode() encryptSwitch.isEnabled = buildHelper.isEngineeringMode()
} }