Skip to content

Commit

Permalink
Merge pull request #875 from BlueBubblesApp/zach/beta
Browse files Browse the repository at this point in the history
Official v1.0.0 release
  • Loading branch information
zlshames committed Jun 15, 2021
2 parents c0c63c7 + b02f809 commit 9b51e4a
Show file tree
Hide file tree
Showing 171 changed files with 8,577 additions and 6,101 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ pubspeck.lock

#signing
**/android/key.properties
**/android/.settings
**/android/.settings
**/releases
12 changes: 6 additions & 6 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ android {
compileSdkVersion 29

lintOptions {
checkReleaseBuilds false
disable 'InvalidPackage'
}

Expand All @@ -52,13 +53,13 @@ android {
// version code: 1 0114 0 70 64

//noinspection AccidentalOctal
versionCode 10115170
versionCode 11000070
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

// ndk {
// abiFilters 'armeabi-v7a', 'arm64-v8a'
// }
// ndk {
// abiFilters 'armeabi-v7a'
// }
}

compileOptions {
Expand Down Expand Up @@ -118,10 +119,9 @@ dependencies {


// Add the SDK for Firebase Cloud Messaging
implementation 'com.google.firebase:firebase-messaging:20.1.5'
implementation 'com.google.firebase:firebase-messaging:20.1.6'
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'androidx.work:work-runtime:2.1.0'
implementation 'com.google.firebase:firebase-messaging-directboot:20.2.0'

//for json string to map
Expand Down
21 changes: 2 additions & 19 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
Expand All @@ -33,6 +32,7 @@
android:icon="@mipmap/ic_launcher"
android:label="BlueBubbles"
android:requestLegacyExternalStorage="true"
android:debuggable="false"
android:usesCleartextTraffic="true">
<receiver android:name=".services.ReplyReceiver" />

Expand Down Expand Up @@ -72,66 +72,49 @@
android:windowSoftInputMode="adjustResize"
android:allowEmbedded="true"
android:resizeableActivity="true"
>
android:documentLaunchMode="always">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="text/x-vcard" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="application/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="audio/*" />
</intent-filter>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ protected void onNewIntent(Intent intent) {
handleSendMultipleImages(intent);
} else {
if (type.equals("NotificationOpen")) {
Log.d("Notifications", "tapped on notification by id " + intent.getExtras().getInt("id"));
Log.d("Notifications", "Tapped on notification with ID: " + intent.getExtras().getInt("id"));
startingChat = intent.getStringExtra("chatGUID");

Log.d("Notifications", "Opening Chat with GUID: " + startingChat);
new MethodChannel(engine.getDartExecutor().getBinaryMessenger(), CHANNEL).invokeMethod("ChatOpen", intent.getExtras().getString("chatGUID"));
} else if (type.equals(SocketIssueWarning.TYPE)) {
new MethodChannel(engine.getDartExecutor().getBinaryMessenger(), CHANNEL).invokeMethod("socket-error-open", null);
Expand Down Expand Up @@ -269,12 +270,19 @@ protected void onStart() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onDestroy() {
Log.d("MainActivity", "removed from memory");
Log.d("MainActivity", "Removing Activity from memory");
SocketIOManager.getInstance().destroyAllSockets();
engine = null;
super.onDestroy();
}

@RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onStop() {
Log.d("MainActivity", "Stopping Activity (isFinishing: " + isFinishing() + ")");
super.onStop();
}

private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.bluebubbles.messaging.method_call_handler.handlers;

import android.content.Context;
import android.graphics.drawable.Icon;

import androidx.core.app.Person;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat;

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

public class CreateShortcut implements Handler {

public static String TAG = "create-shortcut";

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

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

@Override
public void Handle() {
// Icon contactIcon = Icon.createWithData();
// IconCompat icon = IconCompat.createFromIcon();
// Person.Builder person = new Person.Builder()
// .setName(call.argument("name"))
// .setIcon(call.argument());
//
// ShortcutManagerCompat.pushDynamicShortcut(context, new ShortcutInfoCompat.Builder(context, (String) call.argument("id") )
// .setPerson(person.build())
// .setLongLived(true)
// .build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void Handle() {
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
@Override
public void onComplete(@NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
if (task.getResult() == null || !task.isSuccessful()) {
Log.d("FCM", "getInstanceId failed", task.getException());
try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ public void Handle() {

// Set the style based on if there is already a matching notification
if (style == null) {
style = new NotificationCompat.MessagingStyle(androidx.core.app.Person.fromAndroidPerson(new Person.Builder().setName("You").build()));
androidx.core.app.Person myPerson = androidx.core.app.Person.fromAndroidPerson(
new Person.Builder()
.setName("You")
.setImportant(true)
.build()
);
style = new NotificationCompat.MessagingStyle(myPerson);
if (call.argument("groupConversation")) {
style.setConversationTitle(call.argument("contentTitle"));
}
Expand All @@ -88,14 +94,17 @@ public void Handle() {
}

// Build the sender icon
Icon icon = null;
IconCompat icon = null;
if (call.argument("contactIcon") != null) {
Bitmap bmp = BitmapFactory.decodeByteArray((byte[]) call.argument("contactIcon"), 0, ((byte[]) call.argument("contactIcon")).length);
icon = Icon.createWithBitmap(HelperUtils.getCircleBitmap(bmp));
icon = IconCompat.createWithAdaptiveBitmap(HelperUtils.getCircleBitmap(bmp));
}
Person.Builder person = new Person.Builder().setName(call.argument("name"));

Person.Builder person = new Person.Builder()
.setName(call.argument("name"))
.setImportant(true);
if (icon != null) {
person.setIcon(icon);
person.setIcon(icon.toIcon());
}

// Add the message to the notification
Expand Down Expand Up @@ -150,28 +159,20 @@ public void Handle() {
.setHintDisplayActionInline(true))
.build();

PendingIntent bubbleIntent = PendingIntent.getActivity(
context,
existingNotificationId,
new Intent(context, MainActivity.class)
.putExtra("id", existingNotificationId)
.putExtra("chatGUID",
(String) call.argument("group"))
.setType("NotificationOpen"),
Intent.FILL_IN_ACTION);
NotificationCompat.BubbleMetadata bubbleMetadata = null;
if (call.argument("contactIcon") != null) {
// // Build the metadata
// NotificationCompat.BubbleMetadata.Builder bubbleMetadata = new NotificationCompat.BubbleMetadata.Builder()
// .setIntent(openIntent)
// .setDesiredHeight(600)
// .setAutoExpandBubble(true)
// .setSuppressNotification(false);

Bitmap bmp = BitmapFactory.decodeByteArray((byte[]) call.argument("contactIcon"), 0, ((byte[]) call.argument("contactIcon")).length);
// // Dynamically set the icon
// NotificationCompat.BubbleMetadata bubbleData = null;
// if (icon != null) {
// bubbleMetadata.setIcon(icon);
// bubbleData = bubbleMetadata.build();
// }

bubbleMetadata = new NotificationCompat.BubbleMetadata.Builder()
.setIntent(bubbleIntent)
.setDesiredHeight(600)
.setIcon(IconCompat.createWithAdaptiveBitmap(bmp))
.setAutoExpandBubble(true)
.setSuppressNotification(false)
.build();
}
// Build the actual notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, call.argument("CHANNEL_ID"))
.setSmallIcon(R.mipmap.ic_stat_icon)
Expand All @@ -184,16 +185,12 @@ public void Handle() {
.setStyle(style)
.setShortcutId(call.argument("group"))
.addExtras(extras)
// .setBubbleMetadata(bubbleData)
.setColor(4888294);
// if (bubbleMetadata != null) {
// builder.setBubbleMetadata(bubbleMetadata);
// }

// Send the notification
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
notificationManagerCompat.notify(existingNotificationId, builder.build());
result.success("");
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public Result doWork() {

@Override
public void onStopped() {
Log.d("Stop", "Stopping FCM Worker...");

// When this worker gets cancelled, we need to clean up
destroyHeadlessThread();
super.onStopped();
Expand Down Expand Up @@ -111,12 +113,12 @@ public MethodChannel destroyHeadlessThread() {
new Handler(Looper.getMainLooper()).post(() -> {
if (backgroundView != null) {
try {
Log.d("Destroy", "Destroying FCM Worker isolate...");
backgroundView.destroy();
backgroundView = null;
backgroundChannel = null;
Log.d("Destroy", "Destroyed isolate");
} catch (Exception e) {

Log.d("Destroy", "Failed to destroy FCM Worker isolate!");
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public Result doWork() {

@Override
public void onStopped() {
Log.d("Stop", "Stopping Notification Worker...");

// When this worker gets cancelled, clean up
destroyHeadlessThread();
super.onStopped();
Expand Down Expand Up @@ -111,12 +113,12 @@ public MethodChannel destroyHeadlessThread() {
new Handler(Looper.getMainLooper()).post(() -> {
if (backgroundView != null) {
try {
Log.d("Destroy", "Destroying Notification Worker isolate...");
backgroundView.destroy();
backgroundView = null;
backgroundChannel = null;
Log.d("Destroy", "Destroyed isolate");
} catch (Exception e) {

Log.d("Destroy", "Failed to destroy Notification Worker isolate!");
}
}
});
Expand Down
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx4608M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
android.enableDexingArtifactTransform=false
Loading

0 comments on commit 9b51e4a

Please sign in to comment.