This commit is contained in:
Lyndon
2017-11-06 13:13:53 +01:00
parent eb3b7c5864
commit ff088cb2e4
9 changed files with 38 additions and 11 deletions

View File

@@ -114,6 +114,7 @@ dependencies {
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
provided 'javax.annotation:jsr250-api:1.0'
implementation files('libs/sanselan-0_97-android-1.0.0.jar')
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
}
task adp2upload(type: Exec, dependsOn: "build") {

View File

@@ -17,7 +17,6 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:launchMode="singleInstance"
android:name="de.beyondsoft.ownchat.page.splash.SplashActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.FullBackground">
@@ -29,7 +28,6 @@
</activity>
<activity
android:name="de.beyondsoft.ownchat.page.login.LoginActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.FullBackground" />
@@ -70,7 +68,8 @@
android:name="io.fabric.ApiKey"
android:value="1dcc8d0ead50f1b328778876834fea3392c6fc22" />
<service android:name="de.beyondsoft.ownchat.data.firebase.MessagingInstanceIdService">
<service android:name="de.beyondsoft.ownchat.data.firebase.MessagingInstanceIdService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
@@ -78,12 +77,19 @@
<service
android:name="de.beyondsoft.ownchat.utils.AppStoppedService"
android:stopWithTask="false" />
<service android:name="de.beyondsoft.ownchat.data.firebase.HandleMessagesService">
<service
android:name="de.beyondsoft.ownchat.data.firebase.HandleMessagesService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"
/>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"

View File

@@ -8,6 +8,11 @@ import de.beyondsoft.ownchat.di.DaggerApplicationComponent;
import de.beyondsoft.ownchat.di.InjectionHelper;
import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Build;
import io.fabric.sdk.android.Fabric;
import io.realm.Realm;
@@ -31,6 +36,20 @@ public class BewoplanerApplication extends Application {
buildGraphAndInject();
MessagingInstanceIdService.setApplicationContext(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = getString(R.string.default_notification_channel_id);
if(manager != null && manager.getNotificationChannel(channelId) == null) {
NotificationChannel channel = new NotificationChannel(channelId,
getString(R.string.default_notification_channel_id),
NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription(getString(R.string.default_notification_channel_id));
manager.createNotificationChannel(channel);
}
}
}
private void buildGraphAndInject() {

View File

@@ -144,7 +144,7 @@ public class HandleMessagesService extends FirebaseMessagingService {
bitmapToDisplay = BitmapFactory.decodeResource(context.getResources(), R.drawable.avatar);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, getString(R.string.default_notification_channel_id))
.setSmallIcon(getNotificationIcon())
.setContentTitle(setNotificationTitle(message, message.numberOfGroupUsers))
.setContentText(getTextFromNotification(message))
@@ -180,6 +180,7 @@ public class HandleMessagesService extends FirebaseMessagingService {
false,
mUserIdReference.get(),
false);
storeMessageLocally(message);
storeGroupLocally(groupId, message);
}

View File

@@ -1,5 +1,6 @@
package de.beyondsoft.ownchat.data.firebase;
import de.beyondsoft.ownchat.BewoplanerApplication;
import de.beyondsoft.ownchat.R;
import de.beyondsoft.ownchat.data.AppPrefsConstants;
import de.beyondsoft.ownchat.data.api.common.ErrorHandlingResponseConverter;
@@ -99,7 +100,7 @@ public class ReplyNotificationReceiver extends BroadcastReceiver {
private void updateNotificationOnReply(Context context, String replyMessage, int groupId) {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "ownChat")
.setSmallIcon(HandleMessagesService.getNotificationIcon())
.setColor(ContextCompat.getColor(context, R.color.colorDefaultBright))
.setContentTitle(context.getResources().getString(R.string.chat_you_name))

View File

@@ -47,7 +47,6 @@ import io.realm.Realm;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
/**

View File

@@ -39,7 +39,6 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

View File

@@ -88,4 +88,6 @@
<string name="error_file_is_too_large">Die Datei, die Sie versuchen hochzuladen, ist zu groß</string>
<string name="sharing_title">Datei teilen</string>
<string name="default_notification_channel_id">ownChat</string>
</resources>

View File

@@ -3,16 +3,15 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
//classpath 'me.tatarka:gradle-retrolambda:3.3.0'
//classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
classpath 'io.realm:realm-gradle-plugin:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.google.gms:google-services:3.1.1'
}
}