From df315a48ab61b65002008becdbe55ff0e6f3da50 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 14 Mar 2019 20:10:31 +0000 Subject: [PATCH] Fix logging to file. --- .../java/com/etesync/syncadapter/NotificationHelper.kt | 2 +- app/src/main/java/com/etesync/syncadapter/log/Logger.kt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/NotificationHelper.kt b/app/src/main/java/com/etesync/syncadapter/NotificationHelper.kt index 14f126ab..6c752eb7 100644 --- a/app/src/main/java/com/etesync/syncadapter/NotificationHelper.kt +++ b/app/src/main/java/com/etesync/syncadapter/NotificationHelper.kt @@ -150,7 +150,7 @@ class NotificationHelper(internal val context: Context, internal val notificatio } companion object { - private val CHANNEL_ID = "EteSync_default" + val CHANNEL_ID = "EteSync_default" } } diff --git a/app/src/main/java/com/etesync/syncadapter/log/Logger.kt b/app/src/main/java/com/etesync/syncadapter/log/Logger.kt index 10d156d6..c336f5d8 100644 --- a/app/src/main/java/com/etesync/syncadapter/log/Logger.kt +++ b/app/src/main/java/com/etesync/syncadapter/log/Logger.kt @@ -21,6 +21,7 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import com.etesync.syncadapter.App import com.etesync.syncadapter.Constants +import com.etesync.syncadapter.NotificationHelper import com.etesync.syncadapter.R import com.etesync.syncadapter.model.ServiceDB import com.etesync.syncadapter.model.Settings @@ -78,7 +79,7 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener { builder.setSmallIcon(R.drawable.ic_sd_storage_light) .setLargeIcon(App.getLauncherBitmap(context)) .setContentTitle(context.getString(R.string.logging_davdroid_file_logging)) - .setLocalOnly(true) + .setChannelId(NotificationHelper.CHANNEL_ID) val logDir = debugDir(context) ?: return val logFile = File(logDir, @@ -97,6 +98,8 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener { .setPriority(NotificationCompat.PRIORITY_HIGH) .setSubText(context.getString(R.string.logging_to_external_storage_warning)) .setContentIntent(PendingIntent.getActivity(context, 0, prefIntent, PendingIntent.FLAG_UPDATE_CURRENT)) + .setStyle(NotificationCompat.BigTextStyle() + .bigText(context.getString(R.string.logging_to_external_storage, logDir.path))) .setOngoing(true) } catch(e: IOException) { log.log(Level.SEVERE, "Couldn't create log file", e) @@ -113,7 +116,7 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener { } private fun debugDir(context: Context): File? { - val dir = File(context.filesDir, "debug") + val dir = File(context.getExternalFilesDir(null), "debug") if (dir.exists() && dir.isDirectory) return dir