LED leuchtet wieder
Gruppenbenachrichtigungen werden beim öffnen der betreffenden Gruppe gelöscht
This commit is contained in:
@@ -17,7 +17,6 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'io.fabric'
|
||||
|
||||
|
||||
|
||||
repositories {
|
||||
maven { url 'https://maven.fabric.io/public' }
|
||||
maven { url "https://dl.bintray.com/hani-momanii/maven" }
|
||||
@@ -28,7 +27,7 @@ apply plugin: 'realm-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion '26.0.2'
|
||||
buildToolsVersion '27.0.3'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "de.beyondsoft.ownchat"
|
||||
@@ -78,8 +77,8 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
// Android support libraries
|
||||
@@ -90,7 +89,7 @@ dependencies {
|
||||
// OkHttp
|
||||
// Glide
|
||||
// Circle ImageView
|
||||
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
|
||||
implementation('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
|
||||
transitive = true
|
||||
}
|
||||
// Secure Preferences
|
||||
@@ -98,31 +97,32 @@ dependencies {
|
||||
// emojis
|
||||
// circle progress
|
||||
// event bus
|
||||
compile 'com.android.support:appcompat-v7:26.1.0'
|
||||
compile 'com.android.support:design:26.1.0'
|
||||
compile 'com.jakewharton:butterknife:8.4.0'
|
||||
compile 'com.google.dagger:dagger:2.7'
|
||||
compile 'io.reactivex:rxjava:1.1.6'
|
||||
compile 'io.reactivex:rxandroid:1.2.1'
|
||||
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
|
||||
compile 'com.squareup.retrofit2:retrofit:2.1.0'
|
||||
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
|
||||
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.7.0'
|
||||
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
|
||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
||||
compile 'de.hdodenhof:circleimageview:2.1.0'
|
||||
compile 'com.scottyab:secure-preferences-lib:0.1.4'
|
||||
compile 'com.google.firebase:firebase-messaging:11.6.2'
|
||||
compile 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
|
||||
compile 'com.github.lzyzsd:circleprogress:1.2.1'
|
||||
compile 'org.greenrobot:eventbus:3.0.0'
|
||||
testCompile 'junit:junit:4.12'
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
implementation 'com.android.support:design:26.1.0'
|
||||
implementation 'com.jakewharton:butterknife:8.4.0'
|
||||
implementation 'com.google.dagger:dagger:2.7'
|
||||
implementation 'io.reactivex:rxjava:1.1.6'
|
||||
implementation 'io.reactivex:rxandroid:1.2.1'
|
||||
implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.7.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
|
||||
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
||||
implementation 'de.hdodenhof:circleimageview:2.1.0'
|
||||
implementation 'com.scottyab:secure-preferences-lib:0.1.4'
|
||||
implementation 'com.google.firebase:firebase-messaging:17.0.0'
|
||||
implementation 'com.google.firebase:firebase-core:16.0.0'
|
||||
implementation 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
|
||||
implementation 'com.github.lzyzsd:circleprogress:1.2.1'
|
||||
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
|
||||
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
|
||||
provided 'javax.annotation:jsr250-api:1.0'
|
||||
compileOnly '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'
|
||||
implementation 'com.firebase:firebase-jobdispatcher:0.5.2'
|
||||
}
|
||||
|
||||
task adp2upload(type: Exec, dependsOn: "build") {
|
||||
|
||||
@@ -91,11 +91,6 @@
|
||||
</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"
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.beyondsoft.ownchat;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import de.beyondsoft.ownchat.data.firebase.MessagingInstanceIdService;
|
||||
import de.beyondsoft.ownchat.data.firebase.NotificationUtils;
|
||||
import de.beyondsoft.ownchat.di.ApplicationComponent;
|
||||
import de.beyondsoft.ownchat.di.ApplicationModule;
|
||||
import de.beyondsoft.ownchat.di.DaggerApplicationComponent;
|
||||
@@ -24,6 +25,8 @@ public class BewoplanerApplication extends Application {
|
||||
private ApplicationComponent mApplicationComponent;
|
||||
private static Context mContext;
|
||||
|
||||
private static NotificationUtils mNotificationUtils;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
@@ -38,18 +41,6 @@ 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_HIGH);
|
||||
channel.setDescription(getString(R.string.default_notification_channel_id));
|
||||
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildGraphAndInject() {
|
||||
@@ -75,4 +66,12 @@ public class BewoplanerApplication extends Application {
|
||||
public static Context getAppContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
public static NotificationUtils getNotificationUtils() {
|
||||
if(mNotificationUtils == null) {
|
||||
mNotificationUtils = new NotificationUtils(mContext);
|
||||
}
|
||||
|
||||
return mNotificationUtils;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.beyondsoft.ownchat.data.firebase;
|
||||
import com.google.firebase.messaging.FirebaseMessagingService;
|
||||
import com.google.firebase.messaging.RemoteMessage;
|
||||
|
||||
import de.beyondsoft.ownchat.BewoplanerApplication;
|
||||
import de.beyondsoft.ownchat.R;
|
||||
import de.beyondsoft.ownchat.data.AppPrefsConstants;
|
||||
import de.beyondsoft.ownchat.data.api.common.ErrorHandlingResponseConverter;
|
||||
@@ -132,39 +133,65 @@ public class HandleMessagesService extends FirebaseMessagingService {
|
||||
int numberOfUsers = message.numberOfGroupUsers;
|
||||
intent = MainActivity.createIntent(context, bundle, numberOfUsers, groupId);
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context,
|
||||
groupId,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
NotificationCompat.Action action = createAction(context, numberOfUsers, groupId, bundle);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, groupId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
Bitmap bitmapToDisplay = bitmap;
|
||||
if (bitmapToDisplay == null) {
|
||||
bitmapToDisplay = BitmapFactory.decodeResource(context.getResources(), R.drawable.avatar);
|
||||
}
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, getString(R.string.default_notification_channel_id))
|
||||
.setSmallIcon(getNotificationIcon())
|
||||
.setContentTitle(setNotificationTitle(message, message.numberOfGroupUsers))
|
||||
.setContentText(getTextFromNotification(message))
|
||||
.setAutoCancel(true)
|
||||
.setStyle(new NotificationCompat.BigTextStyle().bigText(getTextFromNotification(message)))
|
||||
.setPriority(Notification.PRIORITY_MAX)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setLargeIcon(getCircleBitmap(bitmapToDisplay))
|
||||
.setGroup(String.valueOf(groupId))
|
||||
.setGroupSummary(true)
|
||||
.setDefaults(Notification.DEFAULT_ALL)
|
||||
.setColor(ContextCompat.getColor(context, R.color.colorDefaultBright));
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationUtils notificationUtils = BewoplanerApplication.getNotificationUtils();
|
||||
|
||||
if (action != null) {
|
||||
builder.addAction(action);
|
||||
if(notificationUtils.getManager() != null) {
|
||||
Notification.Builder nb = new Notification.Builder(context, context.getString(R.string.default_notification_channel_id)).setSmallIcon(HandleMessagesService.getNotificationIcon())
|
||||
.setSmallIcon(getNotificationIcon())
|
||||
.setContentTitle(setNotificationTitle(message, message.numberOfGroupUsers))
|
||||
.setContentText(getTextFromNotification(message))
|
||||
.setAutoCancel(false)
|
||||
.setStyle(new Notification.BigTextStyle().bigText(getTextFromNotification(message)))
|
||||
.setContentIntent(pendingIntent)
|
||||
.setLargeIcon(getCircleBitmap(bitmapToDisplay))
|
||||
.setGroup(String.valueOf(groupId))
|
||||
.setGroupSummary(true)
|
||||
.setColor(ContextCompat.getColor(context, R.color.colorDefaultBright));
|
||||
|
||||
Notification.Action action2 = createAction2(context, numberOfUsers, groupId, bundle);
|
||||
|
||||
if(action2 != null) {
|
||||
nb.addAction(action2);
|
||||
}
|
||||
|
||||
notificationUtils.getManager().notify(groupId, nb.build());
|
||||
}
|
||||
} else {
|
||||
NotificationCompat.Action action = createAction(context, numberOfUsers, groupId, bundle);
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, getString(R.string.default_notification_channel_id))
|
||||
.setSmallIcon(getNotificationIcon())
|
||||
.setContentTitle(setNotificationTitle(message, message.numberOfGroupUsers))
|
||||
.setContentText(getTextFromNotification(message))
|
||||
.setAutoCancel(false)
|
||||
.setStyle(new NotificationCompat.BigTextStyle().bigText(getTextFromNotification(message)))
|
||||
.setPriority(Notification.PRIORITY_MAX)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setLargeIcon(getCircleBitmap(bitmapToDisplay))
|
||||
.setGroup(String.valueOf(groupId))
|
||||
.setGroupSummary(true)
|
||||
.setDefaults(Notification.DEFAULT_ALL)
|
||||
.setColor(ContextCompat.getColor(context, R.color.colorDefaultBright));
|
||||
|
||||
if (action != null) {
|
||||
builder.addAction(action);
|
||||
}
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
if(notificationManager != null) {
|
||||
notificationManager.notify(groupId, builder.build());
|
||||
}
|
||||
}
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(groupId, builder.build());
|
||||
|
||||
Message message = new Message(bundle.getString(Constants.MESSAGE_ID),
|
||||
groupId,
|
||||
bundle.getLong(Constants.CREATED_AT),
|
||||
@@ -193,8 +220,7 @@ public class HandleMessagesService extends FirebaseMessagingService {
|
||||
}
|
||||
|
||||
private Bitmap getCircleBitmap(Bitmap bitmap) {
|
||||
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
|
||||
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
final Canvas canvas = new Canvas(output);
|
||||
|
||||
final int color = Color.RED;
|
||||
@@ -237,25 +263,40 @@ public class HandleMessagesService extends FirebaseMessagingService {
|
||||
}
|
||||
|
||||
private NotificationCompat.Action createAction(Context context, int noOfUsers, int groupId, Bundle bundle) {
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Intent replyIntent = ReplyNotificationReceiver.createReplyIntent(context, bundle, noOfUsers, groupId);
|
||||
|
||||
PendingIntent replyPendingIntent = PendingIntent.getBroadcast(getApplicationContext(),
|
||||
groupId,
|
||||
replyIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
PendingIntent replyPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), groupId, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
String replyLabel = getResources().getString(R.string.chat_reply_label);
|
||||
RemoteInput remoteInput = new RemoteInput.Builder(Constants.KEY_TEXT_REPLY)
|
||||
.setLabel(replyLabel)
|
||||
.build();
|
||||
|
||||
return new NotificationCompat.Action.Builder(R.drawable.send_enabled,
|
||||
getString(R.string.chat_reply_label), replyPendingIntent)
|
||||
return new NotificationCompat.Action.Builder(R.drawable.send_enabled, getString(R.string.chat_reply_label), replyPendingIntent)
|
||||
.addRemoteInput(remoteInput)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Notification.Action createAction2(Context context, int noOfUsers, int groupId, Bundle bundle) {
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Intent replyIntent = ReplyNotificationReceiver.createReplyIntent(context, bundle, noOfUsers, groupId);
|
||||
|
||||
PendingIntent replyPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), groupId, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
String replyLabel = getResources().getString(R.string.chat_reply_label);
|
||||
|
||||
android.app.RemoteInput remoteInput = new android.app.RemoteInput.Builder(Constants.KEY_TEXT_REPLY)
|
||||
.setLabel(replyLabel)
|
||||
.build();
|
||||
|
||||
return new Notification.Action.Builder(R.drawable.send_enabled, getString(R.string.chat_reply_label), replyPendingIntent)
|
||||
.addRemoteInput(remoteInput)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package de.beyondsoft.ownchat.data.firebase;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
|
||||
import de.beyondsoft.ownchat.R;
|
||||
|
||||
public class NotificationUtils extends ContextWrapper {
|
||||
private NotificationManager mManager;
|
||||
|
||||
public NotificationUtils(Context base) {
|
||||
super(base);
|
||||
|
||||
createNotificationChannel();
|
||||
}
|
||||
|
||||
public void createNotificationChannel() {
|
||||
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
NotificationChannel androidChannel = new NotificationChannel(getString(R.string.default_notification_channel_id), getString(R.string.default_notification_channel_name), NotificationManager.IMPORTANCE_HIGH);
|
||||
androidChannel.enableLights(true);
|
||||
androidChannel.enableVibration(true);
|
||||
androidChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
|
||||
|
||||
getManager().createNotificationChannel(androidChannel);
|
||||
}
|
||||
}
|
||||
|
||||
public NotificationManager getManager() {
|
||||
if(mManager == null) {
|
||||
mManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
return mManager;
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,11 @@ import de.beyondsoft.ownchat.page.chat.ChatPresenter;
|
||||
import de.beyondsoft.ownchat.utils.Constants;
|
||||
import de.beyondsoft.ownchat.utils.rx.RxUtils;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
@@ -38,6 +40,8 @@ import javax.inject.Named;
|
||||
import rx.Observable;
|
||||
import rx.Subscriber;
|
||||
|
||||
import static android.support.v4.app.NotificationCompat.DEFAULT_ALL;
|
||||
import static android.support.v4.app.NotificationCompat.PRIORITY_MAX;
|
||||
import static de.beyondsoft.ownchat.utils.Constants.GROUP_ID;
|
||||
|
||||
/**
|
||||
@@ -82,6 +86,7 @@ public class ReplyNotificationReceiver extends BroadcastReceiver {
|
||||
intent.putExtra(GROUP_ID, groupId);
|
||||
intent.putExtra(BUNDLE, bundle);
|
||||
intent.putExtra(Constants.GROUP_NR_USERS, numberOfUsers);
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
@@ -93,21 +98,40 @@ public class ReplyNotificationReceiver extends BroadcastReceiver {
|
||||
Bundle bundle = intent.getBundleExtra(BUNDLE);
|
||||
long groupId = bundle.getLong(Constants.GROUP_ID);
|
||||
|
||||
if (replyMessage != null && replyMessage instanceof String) {
|
||||
if(replyMessage != null && replyMessage instanceof String) {
|
||||
sendMessage(context, (String) replyMessage, (int) groupId);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNotificationOnReply(Context context, String replyMessage, int groupId) {
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(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))
|
||||
.setContentText(replyMessage);
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationUtils notificationUtils = BewoplanerApplication.getNotificationUtils();
|
||||
|
||||
notificationManager.notify(groupId, builder.build());
|
||||
Observable.timer(2, TimeUnit.SECONDS).subscribe(aLong -> notificationManager.cancel(groupId));
|
||||
Notification.Builder nb = new Notification.Builder(context, context.getString(R.string.default_notification_channel_id))
|
||||
.setSmallIcon(HandleMessagesService.getNotificationIcon())
|
||||
.setColor(ContextCompat.getColor(context, R.color.colorDefaultBright))
|
||||
.setContentTitle(context.getResources().getString(R.string.chat_you_name))
|
||||
.setContentText(replyMessage);
|
||||
|
||||
if(notificationUtils.getManager() != null) {
|
||||
notificationUtils.getManager().notify(groupId, nb.build());
|
||||
|
||||
Observable.timer(2, TimeUnit.SECONDS).subscribe(aLong -> notificationUtils.getManager().cancel(groupId));
|
||||
}
|
||||
} else {
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, context.getString(R.string.default_notification_channel_id))
|
||||
.setSmallIcon(HandleMessagesService.getNotificationIcon())
|
||||
.setColor(ContextCompat.getColor(context, R.color.colorDefaultBright))
|
||||
.setContentTitle(context.getResources().getString(R.string.chat_you_name))
|
||||
.setPriority(PRIORITY_MAX)
|
||||
.setDefaults(DEFAULT_ALL)
|
||||
.setContentText(replyMessage);
|
||||
|
||||
notificationManager.notify(groupId, builder.build());
|
||||
Observable.timer(2, TimeUnit.SECONDS).subscribe(aLong -> notificationManager.cancel(groupId));
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(Context context, String replyMessage, int groupId) {
|
||||
@@ -140,8 +164,14 @@ public class ReplyNotificationReceiver extends BroadcastReceiver {
|
||||
storeMessageLocally(message);
|
||||
storeGroupLocally(groupId, message);
|
||||
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||
notificationManager.cancel(groupId);
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationUtils notificationUtils = BewoplanerApplication.getNotificationUtils();
|
||||
notificationUtils.getManager().cancel(groupId);
|
||||
} else {
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||
notificationManager.cancel(groupId);
|
||||
}
|
||||
|
||||
Toast.makeText(context, R.string.error_message_not_sent, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package de.beyondsoft.ownchat.page.chat;
|
||||
|
||||
import de.beyondsoft.ownchat.BewoplanerApplication;
|
||||
import de.beyondsoft.ownchat.R;
|
||||
import de.beyondsoft.ownchat.data.AppPrefsConstants;
|
||||
import de.beyondsoft.ownchat.data.events.InvalidTokenEvent;
|
||||
import de.beyondsoft.ownchat.data.events.LogoutDirectlyEvent;
|
||||
import de.beyondsoft.ownchat.data.firebase.NotificationUtils;
|
||||
import de.beyondsoft.ownchat.data.prefs.BooleanPreference;
|
||||
import de.beyondsoft.ownchat.data.prefs.LongPreference;
|
||||
import de.beyondsoft.ownchat.data.prefs.StringPreference;
|
||||
@@ -32,6 +34,7 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.media.MediaRecorder;
|
||||
@@ -172,7 +175,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
if (!getIntent().hasExtra(GROUP_ARG) && !getIntent().hasExtra(MESSAGE_ARG)) {
|
||||
if(!getIntent().hasExtra(GROUP_ARG) && !getIntent().hasExtra(MESSAGE_ARG)) {
|
||||
throw new RuntimeException("Arguments are missing. Please use createIntentMethodInstead;");
|
||||
}
|
||||
|
||||
@@ -209,9 +212,10 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
mEndlessScrollListener = new EndlessScrollListener(VISIBLE_THRESHOLD, linearLayoutManager) {
|
||||
@Override
|
||||
public boolean onLoad() {
|
||||
if (mCallback == null || mCallback.isLoading()) {
|
||||
if(mCallback == null || mCallback.isLoading()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mCallback.fetchMoreMessagesByGroupId();
|
||||
return true;
|
||||
}
|
||||
@@ -240,7 +244,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
@Override
|
||||
public void messagesLoaded(ArrayList<Message> messages, boolean isFirstPage) {
|
||||
if (isFirstPage) {
|
||||
if(isFirstPage) {
|
||||
mEndlessScrollListener.reset();
|
||||
mBaseChatAdapter.setMessages(messages);
|
||||
mRecyclerView.scrollToPosition(0);
|
||||
@@ -261,18 +265,18 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
mSelectedFilePath.delete();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
if(Build.VERSION.SDK_INT >= 19) {
|
||||
final int takeFlags = (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
|
||||
try {
|
||||
//noinspection WrongConstant
|
||||
getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mChatPresenter.isAttached()) {
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
}
|
||||
|
||||
@@ -289,7 +293,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
@Override
|
||||
public void showError(@StringRes int errorRes) {
|
||||
if (mSnackbar == null) {
|
||||
if(mSnackbar == null) {
|
||||
mSnackbar = Snackbar.make(mCoordinatorLayout, errorRes, Snackbar.LENGTH_LONG);
|
||||
mSnackbar.setActionTextColor(ContextCompat.getColor(this, R.color.colorDefault));
|
||||
}
|
||||
@@ -418,7 +422,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
try {
|
||||
dialog.dismiss();
|
||||
mMediaRecorder.stop();
|
||||
} catch (IllegalStateException e) {
|
||||
} catch(IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -456,7 +460,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
mMediaRecorder.setMaxFileSize(mUploadMaxSize.get());
|
||||
mMediaRecorder.prepare();
|
||||
mMediaRecorder.start();
|
||||
} catch (IllegalStateException | IOException e) {
|
||||
} catch(IllegalStateException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -468,7 +472,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
try {
|
||||
mMediaRecorder.stop();
|
||||
} catch (IllegalStateException e) {
|
||||
} catch(IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -488,7 +492,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mChatPresenter.isAttached()) {
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
}
|
||||
|
||||
@@ -527,7 +531,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
dialog.dismiss();
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
@@ -555,36 +559,36 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (resultCode != Activity.RESULT_OK) {
|
||||
if(resultCode != Activity.RESULT_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (null == data) {
|
||||
if(null == data) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> var1 = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA);
|
||||
ArrayList<String> var2 = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS);
|
||||
|
||||
if ((requestCode == SELECT_IMAGE_FILE || requestCode == SELECT_DOC_FILE) && ((var1 != null && var1.size() > 0) || (var2 != null && var2.size() > 0))) {
|
||||
if((requestCode == SELECT_IMAGE_FILE || requestCode == SELECT_DOC_FILE) && ((var1 != null && var1.size() > 0) || (var2 != null && var2.size() > 0))) {
|
||||
String filePath = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA) != null ?
|
||||
data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA).get(0) :
|
||||
data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS).get(0);
|
||||
|
||||
final Uri uri = Uri.fromFile(new File(filePath));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
if(Build.VERSION.SDK_INT >= 19) {
|
||||
final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
|
||||
try {
|
||||
//noinspection WrongConstant
|
||||
getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mChatPresenter.isAttached()) {
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
}
|
||||
|
||||
@@ -603,7 +607,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
String filePath = data.getStringExtra(Constants.FILE_PATH);
|
||||
String fileMessageText = data.getStringExtra(Constants.FILE_MESSAGE_TEXT);
|
||||
|
||||
if (!mChatPresenter.isAttached()) {
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
}
|
||||
|
||||
@@ -624,7 +628,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
@Override
|
||||
public void fileClicked(Message message, int itemPosition) {
|
||||
if (!mChatPresenter.isAttached()) {
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
}
|
||||
|
||||
@@ -632,7 +636,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
String fileName = split[split.length - 1];
|
||||
File file = getExternalFilesDir(null);
|
||||
|
||||
if (file != null) {
|
||||
if(file != null) {
|
||||
mCallback.downloadFile(message, file + "/" + fileName, itemPosition);
|
||||
return;
|
||||
}
|
||||
@@ -652,7 +656,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
@Override
|
||||
public void resendMessage(Message message) {
|
||||
if (!mChatPresenter.isAttached()) {
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
}
|
||||
|
||||
@@ -703,7 +707,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
intent.setDataAndType(uri, fileType);
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
// Verify the original intent will resolve to at least one activity
|
||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||
if(intent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(intent);
|
||||
} else {
|
||||
showToastMessage(R.string.error_could_not_open_file);
|
||||
@@ -725,7 +729,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
protected void onDestroy() {
|
||||
mChatOpenedPref.set(false);
|
||||
|
||||
if (mEndlessScrollListener != null) {
|
||||
if(mEndlessScrollListener != null) {
|
||||
mRecyclerView.removeOnScrollListener(mEndlessScrollListener);
|
||||
}
|
||||
|
||||
@@ -743,7 +747,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
public void addOneMessage(Message message) {
|
||||
mBaseChatAdapter.addMessage(message);
|
||||
|
||||
if (mEndlessScrollListener.getVisibleItem() == 0) {
|
||||
if(mEndlessScrollListener.getVisibleItem() == 0) {
|
||||
mBaseChatAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@@ -764,12 +768,16 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
}
|
||||
|
||||
protected void cancelNotification() {
|
||||
if (mGroup == null) {
|
||||
if(mGroup == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
|
||||
notificationManager.cancel((int) mGroup.id);
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
BewoplanerApplication.getNotificationUtils().getManager().cancel((int) mGroup.id);
|
||||
} else {
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
|
||||
notificationManager.cancel((int) mGroup.id);
|
||||
}
|
||||
}
|
||||
|
||||
private ViewTreeObserver.OnGlobalLayoutListener mKeyboardListener = new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@@ -786,7 +794,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
// if keypad is shown, the r.bottom is smaller than that before.
|
||||
int keypadHeight = screenHeight - r.bottom;
|
||||
|
||||
if (keypadHeight > screenHeight * 0.15 && !mKeyboardShown) { // 0.15 ratio is perhaps enough to determine keypad height.
|
||||
if(keypadHeight > screenHeight * 0.15 && !mKeyboardShown) { // 0.15 ratio is perhaps enough to determine keypad height.
|
||||
// keyboard is opened
|
||||
mRecyclerView.scrollToPosition(0);
|
||||
mKeyboardShown = true;
|
||||
|
||||
@@ -931,9 +931,11 @@ public class ChatPresenter extends MVPAbstractPresenter<ChatView> implements Cha
|
||||
getView().setGroup(group);
|
||||
return;
|
||||
}
|
||||
|
||||
loadGroups();
|
||||
}
|
||||
});
|
||||
|
||||
addSubscription(subscription);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,32 +20,66 @@ import android.view.View;
|
||||
*/
|
||||
public class GroupChatActivity extends BaseChatActivity {
|
||||
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Bundle bundle = intent.getBundleExtra(Constants.MESSAGE);
|
||||
if(mCallback == null) {
|
||||
mChatPresenter.attachView(GroupChatActivity.this);
|
||||
}
|
||||
if(mCallback.getGroupId() == bundle.getLong(Constants.GROUP_ID)) {
|
||||
Message message = new Message(bundle.getString(Constants.MESSAGE_ID),
|
||||
bundle.getLong(Constants.GROUP_ID),
|
||||
bundle.getLong(Constants.CREATED_AT),
|
||||
bundle.getString(Constants.MESSAGE_TEXT),
|
||||
bundle.getString(Constants.FILE),
|
||||
bundle.getString(Constants.SMALLER_IMAGE),
|
||||
bundle.getString(Constants.FILENAME),
|
||||
null,
|
||||
bundle.getLong(Constants.USER_ID),
|
||||
bundle.getString(Constants.USERNAME),
|
||||
bundle.getString(Constants.USER_AVATAR),
|
||||
Message.Status.DELIVERED,
|
||||
true,
|
||||
mUserIdPreference.get(),
|
||||
false);
|
||||
mCallback.saveMessage(message);
|
||||
Bundle results = getResultExtras(true);
|
||||
results.putBoolean(Constants.CHAT_IS_ALREADY_OPEN, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static Intent createIntent(Context context, Group group) {
|
||||
Intent intent = new Intent(context, GroupChatActivity.class);
|
||||
intent.putExtra(GROUP_ARG, group);
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static Intent createIntent(Context context, Bundle groupId) {
|
||||
public static Intent createIntent(Context context, Bundle bundle) {
|
||||
Intent intent = new Intent(context, GroupChatActivity.class);
|
||||
intent.putExtra(MESSAGE_ARG, groupId);
|
||||
intent.putExtra(MESSAGE_ARG, bundle);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mChatPresenter.attachView(this);
|
||||
mCallback.resetMessages();
|
||||
if (getIntent().hasExtra(MESSAGE_ARG)) {
|
||||
|
||||
if(getIntent().hasExtra(MESSAGE_ARG)) {
|
||||
Bundle bundle = getIntent().getBundleExtra(MESSAGE_ARG);
|
||||
long groupId = bundle.getLong(Constants.GROUP_ID);
|
||||
if (mSystemUtils.isNetworkUnavailable()) {
|
||||
|
||||
if(mSystemUtils.isNetworkUnavailable()) {
|
||||
mCallback.loadMessagesFromDBByGroupId(groupId, true);
|
||||
showError(R.string.error_no_internet_connection);
|
||||
} else {
|
||||
mCallback.loadMessagesFromServerByGroupId(groupId);
|
||||
}
|
||||
|
||||
mCallback.findGroupById();
|
||||
} else {
|
||||
setGroupFromArguments();
|
||||
@@ -54,19 +88,21 @@ public class GroupChatActivity extends BaseChatActivity {
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
if (!mChatPresenter.isAttached()) {
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
mBaseChatAdapter.resetItemsProgress();
|
||||
if (mSystemUtils.isNetworkUnavailable()) {
|
||||
|
||||
if(mSystemUtils.isNetworkUnavailable()) {
|
||||
mCallback.loadMessagesFromDBByGroupId(mGroup.id, true);
|
||||
showError(R.string.error_no_internet_connection);
|
||||
} else {
|
||||
if (mGroup == null) {
|
||||
if (getIntent().hasExtra(MESSAGE_ARG)) {
|
||||
if(mGroup == null) {
|
||||
if(getIntent().hasExtra(MESSAGE_ARG)) {
|
||||
long groupId = getIntent().getBundleExtra(MESSAGE_ARG).getLong(Constants.GROUP_ID);
|
||||
mCallback.fetchNewMessages(groupId);
|
||||
return;
|
||||
}
|
||||
|
||||
setGroupFromArguments();
|
||||
mCallback.fetchNewMessages(mGroup.id);
|
||||
} else {
|
||||
@@ -74,6 +110,7 @@ public class GroupChatActivity extends BaseChatActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cancelNotification();
|
||||
IntentFilter filter = new IntentFilter(Constants.NOTIFICATION_BROADCAST);
|
||||
registerReceiver(mReceiver, filter);
|
||||
@@ -82,7 +119,7 @@ public class GroupChatActivity extends BaseChatActivity {
|
||||
|
||||
@Override
|
||||
protected void loadMessages() {
|
||||
if (mSystemUtils.isNetworkUnavailable()) {
|
||||
if(mSystemUtils.isNetworkUnavailable()) {
|
||||
mCallback.loadMessagesFromDBByGroupId(mGroup.id, true);
|
||||
showError(R.string.error_no_internet_connection);
|
||||
} else {
|
||||
@@ -131,35 +168,7 @@ public class GroupChatActivity extends BaseChatActivity {
|
||||
public void setGroup(Group group) {
|
||||
mGroup = group;
|
||||
setToolbar();
|
||||
}
|
||||
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Bundle bundle = intent.getBundleExtra(Constants.MESSAGE);
|
||||
if (mCallback == null) {
|
||||
mChatPresenter.attachView(GroupChatActivity.this);
|
||||
}
|
||||
if (mCallback.getGroupId() == bundle.getLong(Constants.GROUP_ID)) {
|
||||
Message message = new Message(bundle.getString(Constants.MESSAGE_ID),
|
||||
bundle.getLong(Constants.GROUP_ID),
|
||||
bundle.getLong(Constants.CREATED_AT),
|
||||
bundle.getString(Constants.MESSAGE_TEXT),
|
||||
bundle.getString(Constants.FILE),
|
||||
bundle.getString(Constants.SMALLER_IMAGE),
|
||||
bundle.getString(Constants.FILENAME),
|
||||
null,
|
||||
bundle.getLong(Constants.USER_ID),
|
||||
bundle.getString(Constants.USERNAME),
|
||||
bundle.getString(Constants.USER_AVATAR),
|
||||
Message.Status.DELIVERED,
|
||||
true,
|
||||
mUserIdPreference.get(),
|
||||
false);
|
||||
mCallback.saveMessage(message);
|
||||
Bundle results = getResultExtras(true);
|
||||
results.putBoolean(Constants.CHAT_IS_ALREADY_OPEN, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
cancelNotification();
|
||||
}
|
||||
}
|
||||
@@ -42,14 +42,14 @@ public class SingleChatActivity extends BaseChatActivity {
|
||||
mChatPresenter.attachView(this);
|
||||
mCallback.resetMessages();
|
||||
|
||||
if (getIntent().hasExtra(MESSAGE_ARG)) {
|
||||
if(getIntent().hasExtra(MESSAGE_ARG)) {
|
||||
Bundle bundle = getIntent().getBundleExtra(MESSAGE_ARG);
|
||||
mGroup = new Group();
|
||||
mGroup.id = bundle.getLong(Constants.GROUP_ID);
|
||||
mGroup.name = bundle.getString(Constants.USERNAME);
|
||||
mGroup.avatar = bundle.getString(Constants.USER_AVATAR);
|
||||
|
||||
if (mSystemUtils.isNetworkUnavailable()) {
|
||||
if(mSystemUtils.isNetworkUnavailable()) {
|
||||
mCallback.loadMessagesFromDBByGroupId(mGroup.id, true);
|
||||
showError(de.beyondsoft.ownchat.R.string.error_no_internet_connection);
|
||||
} else {
|
||||
@@ -64,11 +64,11 @@ public class SingleChatActivity extends BaseChatActivity {
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
if (!mChatPresenter.isAttached()) {
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
mBaseChatAdapter.resetItemsProgress();
|
||||
|
||||
if (mSystemUtils.isNetworkUnavailable()) {
|
||||
if(mSystemUtils.isNetworkUnavailable()) {
|
||||
mCallback.loadMessagesFromDBByGroupId(mGroup.id, true);
|
||||
showError(de.beyondsoft.ownchat.R.string.error_no_internet_connection);
|
||||
} else {
|
||||
@@ -122,9 +122,7 @@ public class SingleChatActivity extends BaseChatActivity {
|
||||
|
||||
@Override
|
||||
protected void extraImageClicked() {
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel",
|
||||
mGroup.mobile,
|
||||
null));
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", mGroup.mobile, null));
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@@ -145,11 +143,11 @@ public class SingleChatActivity extends BaseChatActivity {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Bundle bundle = intent.getBundleExtra(Constants.MESSAGE);
|
||||
|
||||
if (mCallback == null) {
|
||||
if(mCallback == null) {
|
||||
mChatPresenter.attachView(SingleChatActivity.this);
|
||||
}
|
||||
|
||||
if (mCallback.getGroupId() == bundle.getLong(Constants.GROUP_ID)) {
|
||||
if(mCallback.getGroupId() == bundle.getLong(Constants.GROUP_ID)) {
|
||||
Message message = new Message(bundle.getString(Constants.MESSAGE_ID),
|
||||
bundle.getLong(Constants.GROUP_ID),
|
||||
bundle.getLong(Constants.CREATED_AT),
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.graphics.Typeface;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -178,6 +179,11 @@ class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
void onClickContact() {
|
||||
int type = getItemViewType();
|
||||
|
||||
if(mGroups.size() < getAdapterPosition()) {
|
||||
Log.e("Error", "index out of bounds! group count: " + mGroups.size() + "; adapter position: " + getAdapterPosition());
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == GROUP_TYPE) {
|
||||
mItemClickListener.onOpenGroupMessage(mGroups.get(getAdapterPosition()));
|
||||
return;
|
||||
|
||||
@@ -157,6 +157,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
|
||||
finish();
|
||||
}
|
||||
|
||||
//TODO: change defaultValue: null to defaultValue: ""
|
||||
private void decryptPreference() {
|
||||
for (Map.Entry<String, ?> entry : mSecuredPrefs.getAll().entrySet()) {
|
||||
final String key = entry.getKey();
|
||||
|
||||
@@ -372,8 +372,6 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
||||
mStatus = serviceObject.get("Status").getAsInt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Observable.just(false);
|
||||
})
|
||||
.compose(RxUtils.provideDefaultTransformer())
|
||||
|
||||
@@ -1223,6 +1223,7 @@ public class FileUtils {
|
||||
}
|
||||
|
||||
Bitmap bitmap = Bitmap.createScaledBitmap(bitmapToScale, newWidth, newHeight, false);
|
||||
|
||||
tmpFile = new File(tmpFileLocation);
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
tmpFile.createNewFile();
|
||||
@@ -1240,6 +1241,8 @@ public class FileUtils {
|
||||
|
||||
Utils.copyExifData(image, tmpFile, null);
|
||||
|
||||
Log.i("COMPRESSING IMAGE", "file size after compression: " + tmpFile.length() + " bytes. Before compression: " + image.length());
|
||||
|
||||
return tmpFile;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<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>
|
||||
<string name="default_notification_channel_id">de.beyondsoft.ownchat.notification_channel</string>
|
||||
<string name="default_notification_channel_name">ownChat notification channel</string>
|
||||
|
||||
</resources>
|
||||
@@ -6,12 +6,12 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
classpath 'com.android.tools.build:gradle:3.1.2'
|
||||
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.1.1'
|
||||
classpath 'com.google.gms:google-services:4.0.1'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Thu Oct 26 10:33:36 CEST 2017
|
||||
#Tue Apr 10 11:16:46 CEST 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||
|
||||
Reference in New Issue
Block a user