Skip to content

Commit

Permalink
Merge pull request #2589 from BlueBubblesApp/development
Browse files Browse the repository at this point in the history
v1.12.5
  • Loading branch information
zlshames authored Dec 1, 2023
2 parents 6051d0e + 737eec0 commit d142bcf
Show file tree
Hide file tree
Showing 119 changed files with 4,608 additions and 3,458 deletions.
23 changes: 10 additions & 13 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "com.bluebubbles.messaging"
compileSdkVersion 33

lintOptions {
Expand Down Expand Up @@ -143,14 +144,14 @@ configurations.all {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.firebase:firebase-analytics:21.2.0'
implementation 'com.google.firebase:firebase-analytics:21.3.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.core:core:1.9.0"
implementation "androidx.core:core:1.10.1"
implementation 'androidx.core:core-google-shortcuts:1.1.0'
implementation "androidx.sharetarget:sharetarget:1.2.0"

Expand All @@ -161,18 +162,15 @@ dependencies {
implementation 'androidx.palette:palette:1.0.0'

// Add the SDK for Firebase Cloud Messaging
implementation 'com.google.firebase:firebase-messaging:23.1.1'
implementation 'com.google.firebase:firebase-analytics:21.2.0'
implementation 'com.google.firebase:firebase-database:20.1.0'
implementation 'com.google.firebase:firebase-messaging-directboot:23.1.1'
implementation 'com.google.firebase:firebase-messaging:23.2.1'
implementation 'com.google.firebase:firebase-analytics:21.3.0'
implementation 'com.google.firebase:firebase-database:20.2.2'
implementation 'com.google.firebase:firebase-messaging-directboot:23.2.1'
implementation 'com.google.firebase:firebase-iid:21.1.0'
implementation 'com.google.firebase:firebase-firestore:24.5.0'
implementation 'com.google.firebase:firebase-firestore:24.7.0'

//for json string to map
implementation 'com.google.code.gson:gson:2.8.9'

//for crash reporting
// implementation 'io.sentry:sentry-android:2.2.2'
implementation 'com.google.code.gson:gson:2.9.0'

implementation 'com.google.mlkit:smart-reply:17.0.2'
implementation 'com.google.mlkit:entity-extraction:16.0.0-beta4'
Expand All @@ -182,5 +180,4 @@ dependencies {

// Why won't it fucking compile
implementation 'com.google.guava:guava:27.0.1-android'

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import androidx.core.app.NotificationManagerCompat;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
Expand Down Expand Up @@ -59,6 +61,28 @@ public static Bitmap getCircleBitmap(Bitmap bitmap) {
return output;
}

public static Bitmap getCircularBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getWidth(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff000000;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(),
bitmap.getWidth());
final RectF rectF = new RectF(rect);

final float roundPx = (bitmap.getWidth()) / 2;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setColor(color);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
// paint.setStyle(Style.STROKE);
// paint.setStrokeWidth(2);
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}

public static void tryCancelNotifications(Context context, Integer existingId, String existingGuid) {
Log.d(HelperUtils.TAG, "Attempting to cancel notifications...");
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.bluebubbles.messaging.method_call_handler.handlers.GetServerUrl;
import com.bluebubbles.messaging.method_call_handler.handlers.InitializeBackgroundHandle;
import com.bluebubbles.messaging.method_call_handler.handlers.MediaSessionListener;
import com.bluebubbles.messaging.method_call_handler.handlers.IncomingFaceTimeNotification;
import com.bluebubbles.messaging.method_call_handler.handlers.NewMessageNotification;
import com.bluebubbles.messaging.method_call_handler.handlers.OpenLink;
import com.bluebubbles.messaging.method_call_handler.handlers.PushShareTargets;
Expand Down Expand Up @@ -51,6 +52,8 @@ public static void methodCallHandler(MethodCall call, MethodChannel.Result resul
result.success("");
} else if (call.method.equals(CreateNotificationChannel.TAG)) {
new CreateNotificationChannel(context, call, result).Handle();
} else if (call.method.equals(IncomingFaceTimeNotification.TAG)) {
new IncomingFaceTimeNotification(context, call, result).Handle();
} else if (call.method.equals(NewMessageNotification.TAG)) {
new NewMessageNotification(context, call, result).Handle();
} else if (call.method.equals(OpenLink.TAG)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public void Handle() {
public void onComplete(Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
result.success(document.getData().get("serverUrl"));
if (document.getData() != null) {
result.success(document.getData().get("serverUrl"));
} else {
result.success(null);
}
} else {
result.success(null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package com.bluebubbles.messaging.method_call_handler.handlers;

import android.util.Log;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.os.Bundle;
import android.net.Uri;
import android.service.notification.StatusBarNotification;

import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.graphics.drawable.IconCompat;
import androidx.core.app.Person;

import com.bluebubbles.messaging.MainActivity;
import com.bluebubbles.messaging.BubbleActivity;
import com.bluebubbles.messaging.R;
import com.bluebubbles.messaging.helpers.HelperUtils;
import com.bluebubbles.messaging.services.ReplyReceiver;
import com.bluebubbles.messaging.sharing.Contact;
import com.bluebubbles.messaging.sharing.ShareShortcutManager;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;

import java.util.Arrays;

public class IncomingFaceTimeNotification implements Handler {
public static String TAG = "incoming-facetime-notification";
public static String notificationTag = "incoming-facetime";

private Context context;
private MethodCall call;
private MethodChannel.Result result;

public IncomingFaceTimeNotification(Context context, MethodCall call, MethodChannel.Result result) {
this.context = context;
this.call = call;
this.result = result;
}

@SuppressLint("RestrictedApi")
@RequiresApi(api = Build.VERSION_CODES.P)
@Override
public void Handle() {
// Channel stuff
String channelId = (String) call.argument("CHANNEL_ID");

Integer notificationId = (Integer) call.argument("notificationId");
String title = (String) call.argument("title");
String body = (String) call.argument("body");
byte[] avatar = (byte[]) call.argument("avatar");
String caller = (String) call.argument("caller");
String callUuid = (String) call.argument("callUuid");
Long time = (Long) call.argument("time");

// Build a "Person" for the sender
Person.Builder sender = new Person.Builder()
.setName(caller)
.setImportant(true);

// Load the group avatar
Bitmap bmp = null;
if (avatar != null) {
bmp = HelperUtils.getCircularBitmap(BitmapFactory.decodeByteArray(avatar, 0, avatar.length));
}

// Create a bundle with some extra information in it
Bundle extras = new Bundle();
extras.putString("callUuid", callUuid);

// Create intent for opening the conversation in the app
PendingIntent openIntent = PendingIntent.getBroadcast(
context,
notificationId,
new Intent(context, ReplyReceiver.class)
.putExtra("callUuid", callUuid)
.setType("answerFaceTime"),
PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, channelId)
// Set the status bar notification icon
.setSmallIcon(R.mipmap.ic_stat_icon)
// Let's the notification dismiss itself when it's tapped
.setAutoCancel(true)
// Tell android that it's a message/conversation
.setCategory(NotificationCompat.CATEGORY_CALL)
// Set the priority to high since it's a message they should see
.setPriority(NotificationCompat.PRIORITY_MAX)
// Sets the intent for when it's clicked
.setContentIntent(openIntent)
// Set the content for the notification
.setContentTitle(title)
.setContentText(body)
.setLargeIcon(bmp)
// Add in any extra info we may want
.addExtras(extras)
// Set the color. This is the blue primary color
.setColor(4888294);

Log.d(TAG, "Creating notification for FaceTime: " + callUuid);
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);

// Create the actual notification
notificationManagerCompat.notify(notificationTag, notificationId, notificationBuilder.build());
result.success("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.bluebubbles.messaging.method_call_handler.handlers.CreateNotificationChannel;
import com.bluebubbles.messaging.method_call_handler.handlers.DownloadHandler;
import com.bluebubbles.messaging.method_call_handler.handlers.FirebaseAuth;
import com.bluebubbles.messaging.method_call_handler.handlers.IncomingFaceTimeNotification;
import com.bluebubbles.messaging.method_call_handler.handlers.GetServerUrl;
import com.bluebubbles.messaging.method_call_handler.handlers.InitializeBackgroundHandle;
import com.bluebubbles.messaging.method_call_handler.handlers.NewMessageNotification;
Expand Down Expand Up @@ -93,6 +94,8 @@ public void onMethodCall(MethodCall call, @NonNull Result result) {
new CreateNotificationChannel(context, call, result).Handle();
} else if (call.method.equals(NewMessageNotification.TAG)) {
new NewMessageNotification(context, call, result).Handle();
} else if (call.method.equals(IncomingFaceTimeNotification.TAG)) {
new IncomingFaceTimeNotification(context, call, result).Handle();
} else if (call.method.equals(OpenLink.TAG)) {
new OpenLink(context, call, result).Handle();
} else if (call.method.equals(ClearChatNotifs.TAG)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ public void onReceive(Context context, Intent intent) {
} else {
NotificationWorker.createWorker(context.getApplicationContext(), "markAsRead", params);

}
} else if (intent.getType().equals("answerFaceTime")) {
String callUuid = intent.getExtras().getString("callUuid");
Log.d(TAG, "Answering FaceTime Call: " + callUuid);

// HelperUtils.tryCancelNotifications(context, existingId, null);

// Build params to send to Dart for it to handle whatever it needs
Map<String, Object> params = new HashMap<>();
params.put("callUuid", callUuid);

// Invoke the Dart isolate to clear the notification from that side
if (engine != null) {
new MethodChannel(engine.getDartExecutor().getBinaryMessenger(), CHANNEL).invokeMethod("answer-facetime", params);
} else {
NotificationWorker.createWorker(context.getApplicationContext(), "answer-facetime", params);

}
} else if(intent.getType().equals("alarm")) {

Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.7.21'
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-all.zip
Loading

0 comments on commit d142bcf

Please # to comment.