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:
parent
17b6e69c86
commit
df315a48ab
@ -150,7 +150,7 @@ class NotificationHelper(internal val context: Context, internal val notificatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val CHANNEL_ID = "EteSync_default"
|
val CHANNEL_ID = "EteSync_default"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import androidx.core.app.NotificationCompat
|
|||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import com.etesync.syncadapter.App
|
import com.etesync.syncadapter.App
|
||||||
import com.etesync.syncadapter.Constants
|
import com.etesync.syncadapter.Constants
|
||||||
|
import com.etesync.syncadapter.NotificationHelper
|
||||||
import com.etesync.syncadapter.R
|
import com.etesync.syncadapter.R
|
||||||
import com.etesync.syncadapter.model.ServiceDB
|
import com.etesync.syncadapter.model.ServiceDB
|
||||||
import com.etesync.syncadapter.model.Settings
|
import com.etesync.syncadapter.model.Settings
|
||||||
@ -78,7 +79,7 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
builder.setSmallIcon(R.drawable.ic_sd_storage_light)
|
builder.setSmallIcon(R.drawable.ic_sd_storage_light)
|
||||||
.setLargeIcon(App.getLauncherBitmap(context))
|
.setLargeIcon(App.getLauncherBitmap(context))
|
||||||
.setContentTitle(context.getString(R.string.logging_davdroid_file_logging))
|
.setContentTitle(context.getString(R.string.logging_davdroid_file_logging))
|
||||||
.setLocalOnly(true)
|
.setChannelId(NotificationHelper.CHANNEL_ID)
|
||||||
|
|
||||||
val logDir = debugDir(context) ?: return
|
val logDir = debugDir(context) ?: return
|
||||||
val logFile = File(logDir,
|
val logFile = File(logDir,
|
||||||
@ -97,6 +98,8 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
.setSubText(context.getString(R.string.logging_to_external_storage_warning))
|
.setSubText(context.getString(R.string.logging_to_external_storage_warning))
|
||||||
.setContentIntent(PendingIntent.getActivity(context, 0, prefIntent, PendingIntent.FLAG_UPDATE_CURRENT))
|
.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)
|
.setOngoing(true)
|
||||||
} catch(e: IOException) {
|
} catch(e: IOException) {
|
||||||
log.log(Level.SEVERE, "Couldn't create log file", e)
|
log.log(Level.SEVERE, "Couldn't create log file", e)
|
||||||
@ -113,7 +116,7 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun debugDir(context: Context): File? {
|
private fun debugDir(context: Context): File? {
|
||||||
val dir = File(context.filesDir, "debug")
|
val dir = File(context.getExternalFilesDir(null), "debug")
|
||||||
if (dir.exists() && dir.isDirectory)
|
if (dir.exists() && dir.isDirectory)
|
||||||
return dir
|
return dir
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user