aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/services
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-12-31 02:44:46 -0500
committerGitHub <noreply@github.com>2017-12-31 02:44:46 -0500
commit725d6a99a07f91f940a07e6b49dd6224a6aa32d1 (patch)
tree4e0b1b3b9ffe9b5aef3c8d0f154ea9ab1058fd5e /app/src/main/kotlin/com/pitchedapps/frost/services
parent3076d9a97c203497aec1415d8ac6037d10eebb46 (diff)
downloadfrost-725d6a99a07f91f940a07e6b49dd6224a6aa32d1.tar.gz
frost-725d6a99a07f91f940a07e6b49dd6224a6aa32d1.tar.bz2
frost-725d6a99a07f91f940a07e6b49dd6224a6aa32d1.zip
Enhancement/proguard (#589)
* Add error log * Rewrite logger
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt11
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt16
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt2
5 files changed, 23 insertions, 20 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt
index 520d750f..bf6e1329 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt
@@ -54,7 +54,7 @@ class DownloadService : IntentService("FrostVideoDownloader") {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (intent != null && intent.flags == PendingIntent.FLAG_CANCEL_CURRENT) {
- L.i("Cancelling download service")
+ L.i { "Cancelling download service" }
cancelDownload()
return Service.START_NOT_STICKY
}
@@ -84,7 +84,7 @@ class DownloadService : IntentService("FrostVideoDownloader") {
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
- L.e("Video download failed")
+ L.e { "Video download failed" }
toast("Video download failed")
return@use
}
@@ -107,7 +107,8 @@ class DownloadService : IntentService("FrostVideoDownloader") {
private fun getPendingIntent(context: Context, file: File): PendingIntent {
val uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file)
val type = context.contentResolver.getType(uri)
- L.i("DownloadType: retrieved pending intent - $uri $type")
+ L.i { "DownloadType: retrieved pending intent" }
+ L._i { "Contents: $uri $type" }
val intent = Intent(Intent.ACTION_VIEW, uri)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.setDataAndType(uri, type)
@@ -119,7 +120,7 @@ class DownloadService : IntentService("FrostVideoDownloader") {
* Does not show the new notification
*/
private fun finishDownload(url: String) {
- L.i("Video download finished", url)
+ L.i { "Video download finished" }
downloaded.add(url)
notifBuilder.setContentTitle(string(R.string.downloaded_video))
.setProgress(0, 0, false).setOngoing(false).setAutoCancel(true)
@@ -132,7 +133,7 @@ class DownloadService : IntentService("FrostVideoDownloader") {
}
private fun onProgressUpdate(url: String, type: MediaType?, percentage: Float, done: Boolean) {
- L.v("Download request progress $percentage", url)
+ L.v { "Download request progress $percentage for $url" }
notifBuilder.setProgress(MAX_PROGRESS, (percentage * MAX_PROGRESS).toInt(), false)
if (done) finishDownload(url)
notifBuilder.show()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
index 2d9e0803..5e08b363 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
@@ -152,10 +152,10 @@ enum class NotificationType(
val userId = data.id
val prevNotifTime = lastNotificationTime(userId)
val prevLatestEpoch = getTime(prevNotifTime)
- L.v("Notif $name prev epoch $prevLatestEpoch")
+ L.v { "Notif $name prev epoch $prevLatestEpoch" }
var newLatestEpoch = prevLatestEpoch
notifs.forEach { notif ->
- L.v("Notif timestamp ${notif.timestamp}")
+ L.v { "Notif timestamp ${notif.timestamp}" }
if (notif.timestamp <= prevLatestEpoch) return@forEach
createNotification(context, notif, notifCount == 0)
if (notif.timestamp > newLatestEpoch)
@@ -164,7 +164,7 @@ enum class NotificationType(
}
if (newLatestEpoch > prevLatestEpoch)
putTime(prevNotifTime, newLatestEpoch).save()
- L.d("Notif $name new epoch ${getTime(lastNotificationTime(userId))}")
+ L.d { "Notif $name new epoch ${getTime(lastNotificationTime(userId))}" }
summaryNotification(context, userId, notifCount)
}
@@ -195,7 +195,7 @@ enum class NotificationType(
notifBuilder.withDefaults(ringtone())
if (timestamp != -1L) notifBuilder.setWhen(timestamp * 1000)
- L.v("Notif load", context.toString())
+ L.v { "Notif load $content" }
NotificationManagerCompat.from(context).notify(group, notifId, notifBuilder.build())
if (profileUrl != null) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt
index 2b407b7d..d5311fc0 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt
@@ -33,7 +33,7 @@ private enum class FrostRequestCommands : EnumBundle<FrostRequestCommands> {
override fun invoke(auth: RequestAuth, bundle: PersistableBundle) {
val id = bundle.getLong(ARG_0, -1L)
val success = auth.markNotificationRead(id).invoke()
- L.d("Marked notif $id as read: $success")
+ L.d { "Marked notif $id as read: $success" }
}
override fun propagate(bundle: BaseBundle) =
@@ -96,7 +96,7 @@ object FrostRunnable {
fun markNotificationRead(context: Context, id: Long, cookie: String): Boolean {
if (id <= 0) {
- L.d("Invalid notification id $id for marking as read")
+ L.d { "Invalid notification id $id for marking as read" }
return false
}
return schedule(context, FrostRequestCommands.NOTIF_READ,
@@ -107,7 +107,7 @@ object FrostRunnable {
intent?.extras ?: return
val command = FrostRequestCommands[intent] ?: return
intent.removeExtra(ARG_COMMAND) // reset
- L.d("Propagating command ${command.name}")
+ L.d { "Propagating command ${command.name}" }
val builder = command.propagate(intent.extras)
schedule(context, command, builder)
}
@@ -122,7 +122,7 @@ object FrostRunnable {
bundle.putString(ARG_COMMAND, command.name)
if (bundle.getCookie().isNullOrBlank()) {
- L.e("Scheduled frost request with empty cookie)")
+ L.e { "Scheduled frost request with empty cookie" }
return false
}
@@ -136,7 +136,7 @@ object FrostRunnable {
L.eThrow("FrostRequestService scheduler failed for ${command.name}")
return false
}
- L.d("Scheduled ${command.name}")
+ L.d { "Scheduled ${command.name}" }
return true
}
@@ -171,10 +171,12 @@ class FrostRequestService : JobService() {
val now = System.currentTimeMillis()
future = doAsync {
cookie.fbRequest {
- L.d("Requesting frost service for ${command.name}")
+ L.d { "Requesting frost service for ${command.name}" }
command.invoke(this, bundle)
}
- L.d("Finished frost service for ${command.name} in ${System.currentTimeMillis() - now} ms")
+ L.d {
+ "Finished frost service for ${command.name} in ${System.currentTimeMillis()} - now} ms"
+ }
jobFinished(params, false)
}
return true
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
index c1a4ace1..3d19606b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -30,7 +30,7 @@ class NotificationService : JobService() {
override fun onStopJob(params: JobParameters?): Boolean {
val time = System.currentTimeMillis() - startTime
- L.d("Notification service has finished abruptly in $time ms")
+ L.d { "Notification service has finished abruptly in $time ms" }
frostAnswersCustom("NotificationTime",
"Type" to "Service force stop",
"IM Included" to Prefs.notificationsInstantMessages,
@@ -42,7 +42,7 @@ class NotificationService : JobService() {
fun finish(params: JobParameters?) {
val time = System.currentTimeMillis() - startTime
- L.i("Notification service has finished in $time ms")
+ L.i { "Notification service has finished in $time ms" }
frostAnswersCustom("NotificationTime",
"Type" to "Service",
"IM Included" to Prefs.notificationsInstantMessages,
@@ -53,7 +53,7 @@ class NotificationService : JobService() {
}
override fun onStartJob(params: JobParameters?): Boolean {
- L.i("Fetching notifications")
+ L.i { "Fetching notifications" }
future = doAsync {
val context = weakRef.get()
?: return@doAsync L.eThrow("NotificationService had null weakRef to self")
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
index 989ac127..59df9ed7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
@@ -15,7 +15,7 @@ class UpdateReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action != Intent.ACTION_MY_PACKAGE_REPLACED) return
- L.d("Frost has updated")
+ L.d { "Frost has updated" }
context.scheduleNotifications(Prefs.notificationFreq) //Update notifications
}