1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 20:12:39 +01:00

Enhancement/notifications (#416)

* Update notification defaults

* Setup initial channel test
This commit is contained in:
Allan Wang 2017-10-15 15:07:23 -04:00 committed by GitHub
parent a4b3e99022
commit d08fd6f8d2
5 changed files with 23 additions and 7 deletions

View File

@ -16,6 +16,7 @@ import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
import com.mikepenz.materialdrawer.util.DrawerImageLoader
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.services.scheduleNotifications
import com.pitchedapps.frost.services.setupNotificationChannels
import com.pitchedapps.frost.utils.FrostPglAdBlock
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
@ -61,6 +62,8 @@ class FrostApp : Application() {
applicationContext.scheduleNotifications(Prefs.notificationFreq)
setupNotificationChannels(applicationContext)
/**
* Drawer profile loading logic
* Reload the image on every version update

View File

@ -1,14 +1,20 @@
package com.pitchedapps.frost.services
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.job.JobInfo
import android.app.job.JobScheduler
import android.content.ComponentName
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Color
import android.net.Uri
import android.os.Build
import android.support.annotation.RequiresApi
import android.support.v4.app.NotificationCompat
import android.support.v4.app.NotificationManagerCompat
import ca.allanwang.kau.utils.color
@ -33,7 +39,14 @@ import org.jetbrains.anko.runOnUiThread
*
* Logic for build notifications, scheduling notifications, and showing notifications
*/
fun setupNotificationChannels(c: Context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
val manager = c.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val mainChannel = NotificationChannel(BuildConfig.APPLICATION_ID, c.getString(R.string.frost_name), NotificationManager.IMPORTANCE_DEFAULT)
mainChannel.lightColor = c.color(R.color.facebook_blue)
mainChannel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
manager.createNotificationChannel(mainChannel)
}
val Context.frostNotification: NotificationCompat.Builder
get() = NotificationCompat.Builder(this, BuildConfig.APPLICATION_ID).apply {
@ -161,8 +174,8 @@ data class NotificationContent(val data: CookieModel,
val text: String,
val timestamp: Long,
val profileUrl: String) {
constructor(data:CookieModel, thread: FrostThread)
:this(data, thread.id, thread.url, thread.title, thread.content ?: "", thread.time, thread.img)
constructor(data: CookieModel, thread: FrostThread)
: this(data, thread.id, thread.url, thread.title, thread.content ?: "", thread.time, thread.img)
}
const val NOTIFICATION_PERIODIC_JOB = 7

View File

@ -39,7 +39,7 @@ object Prefs : KPref() {
var exitConfirmation: Boolean by kpref("exit_confirmation", true)
var notificationFreq: Long by kpref("notification_freq", -1L)
var notificationFreq: Long by kpref("notification_freq", 60L)
var versionCode: Int by kpref("version_code", -1)
@ -104,7 +104,7 @@ object Prefs : KPref() {
var notificationAllAccounts: Boolean by kpref("notification_all_accounts", true)
var notificationsInstantMessages: Boolean by kpref("notification_im", false)
var notificationsInstantMessages: Boolean by kpref("notification_im", true)
var notificationsImAllAccounts: Boolean by kpref("notification_im_all_accounts", false)

View File

@ -7,7 +7,7 @@ buildscript {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta7'
classpath 'com.android.tools.build:gradle:3.0.0-rc1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${KOTLIN}"
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'

View File

@ -17,7 +17,7 @@ MIN_SDK=21
TARGET_SDK=26
BUILD_TOOLS=26.0.2
KAU=afc1a02
KAU=7513227
KOTLIN=1.1.51
COMMONS_TEXT=1.1