1
0
mirror of https://github.com/etesync/android synced 2024-12-23 23:18:46 +00:00

Fix logging to file.

This commit is contained in:
Tom Hacohen 2019-03-14 20:10:31 +00:00
parent 17b6e69c86
commit df315a48ab
2 changed files with 6 additions and 3 deletions

View File

@ -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"
}
}

View File

@ -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