Skip to content

Commit

Permalink
Merge pull request #2609 from BlueBubblesApp/development
Browse files Browse the repository at this point in the history
v1.12.7
  • Loading branch information
zlshames committed Dec 4, 2023
2 parents d57bcd9 + d978411 commit 5c0c2d7
Show file tree
Hide file tree
Showing 28 changed files with 786 additions and 459 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ public ClearChatNotifs(Context context, MethodCall call, MethodChannel.Result r
@Override
public void Handle() {
String chatGuid = (String) call.argument("chatGuid");
Log.d(TAG, "Clearing notifications for chat: " + chatGuid);
HelperUtils.tryCancelNotifications(context, null, chatGuid);
Integer existingId = (Integer) call.argument("id");
if (existingId != null) {
Log.d(TAG, "Clearing notifications for id: " + existingId.toString());
HelperUtils.tryCancelNotifications(context, existingId, null);
} else {
Log.d(TAG, "Clearing notifications for chat: " + chatGuid);
HelperUtils.tryCancelNotifications(context, null, chatGuid);
}
result.success("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

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

private Context context;
private MethodCall call;
Expand Down Expand Up @@ -85,14 +85,44 @@ public void Handle() {
Bundle extras = new Bundle();
extras.putString("callUuid", callUuid);

// Create intent for opening the conversation in the app
PendingIntent openIntent = PendingIntent.getBroadcast(
// Create intent when notification is tapped
PendingIntent tapIntent = PendingIntent.getActivity(
context,
notificationId,
new Intent(context, MainActivity.class)
.putExtra("callUuid", callUuid)
.putExtra("answer", "false")
.putExtra("caller", caller)
.setType("NotificationOpen"),
PendingIntent.FLAG_MUTABLE | Intent.FILL_IN_ACTION);

// Create intent for opening the facetime link
PendingIntent openIntent = PendingIntent.getActivity(
context,
notificationId,
new Intent(context, ReplyReceiver.class)
new Intent(context, MainActivity.class)
.putExtra("callUuid", callUuid)
.setType("answerFaceTime"),
PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
.putExtra("answer", "true")
.putExtra("caller", caller)
.setType("AnswerFaceTime"),
PendingIntent.FLAG_MUTABLE | Intent.FILL_IN_ACTION);

// Create intent for dismissing the notification (mark as read)
PendingIntent dismissIntent = PendingIntent.getBroadcast(
context,
notificationId,
new Intent(context, ReplyReceiver.class)
.putExtra("id", notificationId)
.setType("swipeAway"),
PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Action dismissAction = new NotificationCompat.Action.Builder(0, "Ignore", dismissIntent)
.setShowsUserInterface(false)
.build();

NotificationCompat.Action answerAction = new NotificationCompat.Action.Builder(0, "Answer", openIntent)
.setShowsUserInterface(true)
.build();

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, channelId)
// Set the status bar notification icon
Expand All @@ -114,7 +144,11 @@ public void Handle() {

if (callUuid != null) {
// Sets the intent for when it's clicked
notificationBuilder.setContentIntent(openIntent);
notificationBuilder.setContentIntent(tapIntent);
notificationBuilder.addAction(dismissAction);
notificationBuilder.addAction(answerAction);
// clear after 30 seconds in case we didn't get an event from the server
notificationBuilder.setTimeoutAfter(30000);
}

Log.d(TAG, "Creating notification for FaceTime: " + callUuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,6 @@ 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
146 changes: 83 additions & 63 deletions lib/app/layouts/conversation_list/pages/conversation_list.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:bluebubbles/app/layouts/chat_creator/chat_creator.dart';
import 'package:bluebubbles/app/layouts/conversation_list/widgets/conversation_list_fab.dart';
import 'package:bluebubbles/app/layouts/conversation_list/widgets/footer/samsung_footer.dart';
Expand Down Expand Up @@ -95,29 +97,48 @@ class ConversationListController extends StatefulController {
}

class ConversationList extends CustomStateful<ConversationListController> {
ConversationList({
Key? key,
required bool showArchivedChats,
required bool showUnknownSenders
}) : super(key: key, parentController: Get.put(ConversationListController(
showArchivedChats: showArchivedChats,
showUnknownSenders: showUnknownSenders,
), tag: showArchivedChats ? "Archived" : showUnknownSenders ? "Unknown" : "Messages"));
ConversationList({Key? key, required bool showArchivedChats, required bool showUnknownSenders})
: super(
key: key,
parentController: Get.put(
ConversationListController(
showArchivedChats: showArchivedChats,
showUnknownSenders: showUnknownSenders,
),
tag: showArchivedChats
? "Archived"
: showUnknownSenders
? "Unknown"
: "Messages"));

@override
State<StatefulWidget> createState() => _ConversationListState();
}

class _ConversationListState extends CustomState<ConversationList, void, ConversationListController> {

@override
void initState() {
super.initState();
tag = controller.showArchivedChats
? "Archived"
: controller.showUnknownSenders
? "Unknown"
: "Messages";
? "Unknown"
: "Messages";

if (!ss.settings.reachedConversationList.value) {
Timer.periodic(const Duration(seconds: 1), (Timer t) {
bool notInSettings = ns.isTabletMode(context)
? !Get.keys.containsKey(3) || Get.keys[3]?.currentContext == null
: Get.rawRoute?.settings.name == "/";
// This only runs once
if (notInSettings) {
ss.settings.reachedConversationList.value = true;
ss.saveSettings();
ss.getServerDetails(refresh: true);
t.cancel();
}
});
}

// Extra safety check to make sure Android doesn't open the last chat when opening the app
if (kIsDesktop || kIsWeb) {
Expand All @@ -132,9 +153,9 @@ class _ConversationListState extends CustomState<ConversationList, void, Convers
ns.pushAndRemoveUntil(
context,
ConversationView(
chat: kIsWeb
? (await Chat.findOneWeb(guid: ss.prefs.getString('lastOpenedChat')))!
: Chat.findOne(guid: ss.prefs.getString('lastOpenedChat'))!),
chat: kIsWeb
? (await Chat.findOneWeb(guid: ss.prefs.getString('lastOpenedChat')))!
: Chat.findOne(guid: ss.prefs.getString('lastOpenedChat'))!),
(route) => route.isFirst,
);
});
Expand All @@ -154,8 +175,7 @@ class _ConversationListState extends CustomState<ConversationList, void, Convers

return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
systemNavigationBarColor: ss.settings.immersiveMode.value
? Colors.transparent : context.theme.colorScheme.background, // navigation bar color
systemNavigationBarColor: ss.settings.immersiveMode.value ? Colors.transparent : context.theme.colorScheme.background, // navigation bar color
systemNavigationBarIconBrightness: brightness,
statusBarColor: Colors.transparent, // status bar color
statusBarIconBrightness: brightness.opposite,
Expand All @@ -166,54 +186,54 @@ class _ConversationListState extends CustomState<ConversationList, void, Convers
minRatio: kIsDesktop || kIsWeb ? 0.1 : 0.33,
maxRatio: 0.5,
allowResize: true,
left: !showAltLayout ? child : LayoutBuilder(
builder: (context, constraints) {
ns.maxWidthLeft = constraints.maxWidth;
return WillPopScope(
onWillPop: () async {
Get.until((route) {
bool id2result = false;
// check if we should pop the left side first
Get.until((route) {
if (route.settings.name != "initial") {
Get.back(id: 2);
id2result = true;
}
if (!(Get.global(2).currentState?.canPop() ?? true)) {
if (cm.activeChat != null) {
cvc(cm.activeChat!.chat).close();
left: !showAltLayout
? child
: LayoutBuilder(builder: (context, constraints) {
ns.maxWidthLeft = constraints.maxWidth;
return WillPopScope(
onWillPop: () async {
Get.until((route) {
bool id2result = false;
// check if we should pop the left side first
Get.until((route) {
if (route.settings.name != "initial") {
Get.back(id: 2);
id2result = true;
}
if (!(Get.global(2).currentState?.canPop() ?? true)) {
if (cm.activeChat != null) {
cvc(cm.activeChat!.chat).close();
}
eventDispatcher.emit('update-highlight', null);
}
return true;
}, id: 2);
if (!id2result) {
if (route.settings.name == "initial") {
SystemNavigator.pop();
} else {
Get.back(id: 1);
}
}
eventDispatcher.emit('update-highlight', null);
}
return true;
}, id: 2);
if (!id2result) {
if (route.settings.name == "initial") {
SystemNavigator.pop();
} else {
Get.back(id: 1);
}
}
return true;
}, id: 1);
return false;
},
child: Navigator(
key: Get.nestedKey(1),
requestFocus: false,
onPopPage: (route, _) {
return false;
},
pages: [
CupertinoPage(
name: "initial",
child: child,
)
],
),
);
}
),
return true;
}, id: 1);
return false;
},
child: Navigator(
key: Get.nestedKey(1),
requestFocus: false,
onPopPage: (route, _) {
return false;
},
pages: [
CupertinoPage(
name: "initial",
child: child,
)
],
),
);
}),
right: LayoutBuilder(
builder: (context, constraints) {
ns.maxWidthRight = constraints.maxWidth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class ConversationTextFieldState extends CustomState<ConversationTextField, void
controller.emojiMatches.value = [];
controller.emojiSelectedIndex.value = 0;
}
} else if (!subject && newEmojiText.contains("@")) {
} else if (ss.settings.enablePrivateAPI.value && !subject && newEmojiText.contains("@")) {
oldEmojiText = newEmojiText;
final regExp = RegExp(r"(?<=^|[^a-zA-Z\d])@(?:[^@ \n]+|$)(?=[ \n]|$)", multiLine: true);
final matches = regExp.allMatches(newEmojiText);
Expand Down
Loading

0 comments on commit 5c0c2d7

Please sign in to comment.