- 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,7 +37,8 @@ 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(
PluginDescription()
.mainType(PluginType.GENERAL) .mainType(PluginType.GENERAL)
.fragmentClass(MaintenanceFragment::class.java.name) .fragmentClass(MaintenanceFragment::class.java.name)
.alwaysVisible(false) .alwaysVisible(false)
@ -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,7 +215,8 @@ 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 =
preferenceFragment.findPreference(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs)) as SwitchPreference?
?: return ?: return
encryptSwitch.isVisible = buildHelper.isEngineeringMode() encryptSwitch.isVisible = buildHelper.isEngineeringMode()
encryptSwitch.isEnabled = buildHelper.isEngineeringMode() encryptSwitch.isEnabled = buildHelper.isEngineeringMode()