aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt13
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt11
2 files changed, 13 insertions, 11 deletions
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 3f3805a9..d357ff68 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -18,6 +18,7 @@ import com.pitchedapps.frost.facebook.FACEBOOK_COM
import com.pitchedapps.frost.facebook.FB_URL_BASE
import com.pitchedapps.frost.facebook.FbTab
import com.pitchedapps.frost.utils.L
+import com.pitchedapps.frost.utils.frostNotification
import org.jetbrains.anko.doAsync
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
@@ -90,11 +91,9 @@ class NotificationService : JobService() {
private fun Context.debugNotification(text: String) {
if (BuildConfig.DEBUG) {
- val notifBuilder = NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.frost_f_24)
+ val notifBuilder = frostNotification
.setContentTitle(string(R.string.app_name))
.setContentText(text)
- .setAutoCancel(true)
NotificationManagerCompat.from(this).notify(999, notifBuilder.build())
}
@@ -106,15 +105,13 @@ class NotificationService : JobService() {
intent.data = Uri.parse("$FB_URL_BASE$href")
val group = "frost_${data.id}"
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
- val notifBuilder = NotificationCompat.Builder(context)
- .setSmallIcon(R.drawable.frost_f_24)
+ val notifBuilder = context.frostNotification
.setContentTitle(context.string(R.string.app_name))
.setContentText(text)
.setContentIntent(pendingIntent)
.setCategory(Notification.CATEGORY_SOCIAL)
.setSubText(data.name)
.setGroup(group)
- .setAutoCancel(true)
if (timestamp != -1L) notifBuilder.setWhen(timestamp * 1000)
@@ -124,13 +121,11 @@ class NotificationService : JobService() {
fun summaryNotification(userId: Long, count: Int) {
if (count <= 1) return
- val notifBuilder = NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.frost_f_24)
+ val notifBuilder = frostNotification
.setContentTitle(string(R.string.app_name))
.setContentText("$count notifications")
.setGroup("frost_$userId")
.setGroupSummary(true)
- .setAutoCancel(true)
NotificationManagerCompat.from(this).notify("frost_$userId", userId.toInt(), notifBuilder.build())
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index 52922822..fe56d6d6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -8,12 +8,14 @@ import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
+import android.support.v4.app.NotificationCompat
import android.support.v4.content.ContextCompat
import android.support.v7.widget.Toolbar
import android.view.View
import android.widget.TextView
import ca.allanwang.kau.utils.*
import com.afollestad.materialdialogs.MaterialDialog
+import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.LoginActivity
import com.pitchedapps.frost.R
import com.pitchedapps.frost.WebOverlayActivity
@@ -53,9 +55,7 @@ fun Context.launchWebOverlay(url: String) {
val argUrl = url.formattedFbUrl
L.i("Launch web overlay: $argUrl")
val intent = Intent(this, WebOverlayActivity::class.java)
-// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
intent.putExtra(ARG_URL, argUrl)
-// val bundle = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.slide_in_right, R.anim.slide_out_right).toBundle()
ContextCompat.startActivity(this, intent, null)
}
@@ -63,6 +63,13 @@ fun WebOverlayActivity.url(): String {
return intent.extras?.getString(ARG_URL) ?: FbTab.FEED.url
}
+val Context.frostNotification: NotificationCompat.Builder
+ get() = NotificationCompat.Builder(this, BuildConfig.APPLICATION_ID).apply {
+ setSmallIcon(R.drawable.frost_f_24)
+ setAutoCancel(true)
+ color = color(R.color.frost_notification_accent)
+ }
+
fun Activity.materialDialogThemed(action: MaterialDialog.Builder.() -> Unit): MaterialDialog {
val builder = MaterialDialog.Builder(this).theme()