Add firebase messaging (#740)

This commit is contained in:
Rafał Borcz 2020-04-02 22:43:03 +02:00 committed by GitHub
parent 502a98b70a
commit 394e3bb79c
14 changed files with 59 additions and 5 deletions

View File

@ -169,7 +169,7 @@ dependencies {
implementation "eu.davidea:flexible-adapter-ui:1.0.0"
implementation "com.aurelhubert:ahbottomnavigation:2.3.4"
implementation "com.ncapdevi:frag-nav:3.3.0"
implementation "com.github.YarikSOffice:lingver:1.1.0"
implementation "com.github.YarikSOffice:lingver:1.2.1"
implementation "com.github.pwittchen:reactivenetwork-rx2:3.0.6"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
@ -182,11 +182,14 @@ dependencies {
implementation "fr.bipi.treessence:treessence:0.3.2"
implementation "com.mikepenz:aboutlibraries-core:$about_libraries"
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
implementation "io.coil-kt:coil:0.9.5"
implementation("io.coil-kt:coil:0.9.5")
playImplementation "com.google.firebase:firebase-core:17.3.0"
playImplementation 'com.google.firebase:firebase-analytics:17.3.0'
playImplementation 'com.google.firebase:firebase-inappmessaging-display-ktx:19.0.4'
playImplementation "com.google.firebase:firebase-inappmessaging-ktx:19.0.4"
playImplementation "com.google.firebase:firebase-messaging:20.1.0"
playImplementation "com.crashlytics.sdk.android:crashlytics:2.10.1"
playImplementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
releaseImplementation "com.github.ChuckerTeam.Chucker:library-no-op:$chucker"

View File

@ -22,7 +22,8 @@
<activity
android:name=".ui.modules.splash.SplashActivity"
android:screenOrientation="portrait"
android:theme="@style/WulkanowyTheme.SplashScreen">
android:theme="@style/WulkanowyTheme.SplashScreen"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -112,5 +113,13 @@
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="${crashlytics_enabled}" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_push" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="push_channel" />
</application>
</manifest>

View File

@ -15,6 +15,7 @@ import io.github.wulkanowy.services.sync.channels.LuckyNumberChannel
import io.github.wulkanowy.services.sync.channels.NewGradesChannel
import io.github.wulkanowy.services.sync.channels.NewMessagesChannel
import io.github.wulkanowy.services.sync.channels.NewNotesChannel
import io.github.wulkanowy.services.sync.channels.PushChannel
import io.github.wulkanowy.services.sync.works.AttendanceSummaryWork
import io.github.wulkanowy.services.sync.works.AttendanceWork
import io.github.wulkanowy.services.sync.works.CompletedLessonWork
@ -126,4 +127,8 @@ abstract class ServicesModule {
@Binds
@IntoSet
abstract fun provideNewNotesChannel(channel: NewNotesChannel): Channel
@Binds
@IntoSet
abstract fun providePushChannel(channel: PushChannel): Channel
}

View File

@ -0,0 +1,32 @@
package io.github.wulkanowy.services.sync.channels
import android.annotation.TargetApi
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import androidx.core.app.NotificationManagerCompat
import io.github.wulkanowy.R
import javax.inject.Inject
@TargetApi(26)
class PushChannel @Inject constructor(
private val notificationManager: NotificationManagerCompat,
private val context: Context
) : Channel {
companion object {
const val CHANNEL_ID = "push_channel"
}
override fun create() {
notificationManager.createNotificationChannel(
NotificationChannel(CHANNEL_ID, context.getString(R.string.channel_push), NotificationManager.IMPORTANCE_HIGH)
.apply {
enableLights(true)
enableVibration(true)
lockscreenVisibility = Notification.VISIBILITY_PUBLIC
}
)
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -357,6 +357,7 @@
<string name="channel_lucky_number">Glückliche Nummer</string>
<string name="channel_new_message">Neue Nachrichten</string>
<string name="channel_new_notes">Neue Eintragen</string>
<string name="channel_push">Push-Benachrichtigungen</string>
<string name="channel_debug">Debuggen</string>

View File

@ -385,6 +385,7 @@
<string name="channel_new_grades">Nowe oceny</string>
<string name="channel_new_message">Nowe wiadomości</string>
<string name="channel_new_notes">Nowe uwagi</string>
<string name="channel_push">Powiadomienia push</string>
<string name="channel_debug">Debugowanie</string>

View File

@ -382,6 +382,7 @@
<string name="channel_lucky_number">Счастливый номер</string>
<string name="channel_new_message">Новые сообщения</string>
<string name="channel_new_notes">Новые заметки</string>
<string name="channel_push">Push-уведомления</string>
<string name="channel_debug">Дебаг</string>

View File

@ -383,6 +383,7 @@
<string name="channel_new_grades">Нові оцінки</string>
<string name="channel_new_message">Нові повідомлення</string>
<string name="channel_new_notes">Нові нотатки</string>
<string name="channel_push">Повідомлення pushs</string>
<string name="channel_debug">Дебаг</string>

View File

@ -368,6 +368,7 @@
<string name="channel_lucky_number">Lucky number</string>
<string name="channel_new_message">New messages</string>
<string name="channel_new_notes">New notes</string>
<string name="channel_push">Push notifications</string>
<string name="channel_debug">Debug</string>