Skip to content

Commit 2086a06

Browse files
committed
Bugfixes
1 parent a1ce938 commit 2086a06

File tree

22 files changed

+274
-28
lines changed

22 files changed

+274
-28
lines changed

android/app/src/main/aidl/com/bluebubbles/messaging/IMessageViewHandle.aidl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import com.bluebubbles.messaging.ITaskCompleteCallback;
88
interface IMessageViewHandle {
99
void updateMessage(in MadridMessage message, in ITaskCompleteCallback callback);
1010

11+
void setSuppressNotifications(boolean suppress);
12+
1113
void lock();
1214
void unlock();
1315
}

android/app/src/main/kotlin/com/bluebubbles/messaging/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Constants {
2020
const val pendingIntentDeclineFaceTimeOffset = -200000
2121
const val pendingIntentOpenFaceTimeOffset = -300000
2222
const val notificationListenerRequestCode = 1000
23+
const val documentSaveRequestCode = 2000
2324
const val dartWorkerNotificationId = 1000000
2425
}
2526
}

android/app/src/main/kotlin/com/bluebubbles/messaging/MainActivity.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ import com.bluebubbles.messaging.services.foreground.ForegroundServiceBroadcastR
1212
import com.bluebubbles.messaging.Constants
1313
import com.bluebubbles.messaging.services.extension.KeyboardViewFactory
1414
import com.bluebubbles.messaging.services.extension.LiveExtensionFactory
15+
import com.bluebubbles.messaging.services.extension.MessageViewHandle
1516
import com.bluebubbles.messaging.services.rustpush.APNService
17+
import com.bluebubbles.messaging.services.system.CreateDocumentHandler
1618
import io.flutter.embedding.android.FlutterFragmentActivity
1719
import io.flutter.embedding.engine.FlutterEngine
1820
import io.flutter.plugin.common.MethodChannel
21+
import java.io.FileInputStream
1922

2023
class MainActivity : FlutterFragmentActivity(), ComponentCallbacks2 {
2124
companion object {
@@ -90,5 +93,25 @@ class MainActivity : FlutterFragmentActivity(), ComponentCallbacks2 {
9093
if (requestCode == Constants.notificationListenerRequestCode) {
9194
MethodCallHandler.getNotificationListenerResult?.success(resultCode == Activity.RESULT_OK)
9295
}
96+
if (requestCode == Constants.documentSaveRequestCode) {
97+
var result = CreateDocumentHandler.savedResult!!
98+
CreateDocumentHandler.savedResult = null
99+
val uri = data?.data
100+
if (uri == null) {
101+
result.success(null)
102+
return
103+
}
104+
105+
try {
106+
val output = contentResolver.openOutputStream(uri)!!
107+
val input = FileInputStream(CreateDocumentHandler.savedPath!!)
108+
input.copyTo(output)
109+
output.close()
110+
input.close()
111+
result.success(null)
112+
} catch (e: Exception) {
113+
result.error("FILE_WRITE_ERROR", e.message, null)
114+
}
115+
}
93116
}
94117
}

android/app/src/main/kotlin/com/bluebubbles/messaging/services/backend_ui_interop/MethodCallHandler.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.bluebubbles.messaging.services.foreground.StopForegroundServiceHandle
4040
import com.bluebubbles.messaging.services.notifications.CreateMissedFaceTimeNotification
4141
import com.bluebubbles.messaging.services.rustpush.GetNativeHandleHandler
4242
import com.bluebubbles.messaging.services.system.ConversationExemptHandler
43+
import com.bluebubbles.messaging.services.system.CreateDocumentHandler
4344
import com.bluebubbles.messaging.services.system.GetFullResolution
4445
import com.bluebubbles.messaging.services.system.GetZenMode
4546
import com.bluebubbles.messaging.services.system.HeifDecoder
@@ -122,6 +123,7 @@ class MethodCallHandler {
122123
HeifDecoder.tag -> HeifDecoder().handleMethodCall(call, result, context)
123124
GetFullResolution.tag -> GetFullResolution().handleMethodCall(call, result, context)
124125
OpenSMSAppHandler.tag -> OpenSMSAppHandler().handleMethodCall(call, result, context)
126+
CreateDocumentHandler.tag -> CreateDocumentHandler().handleMethodCall(call, result, context)
125127
"ready" -> { MainActivity.engine_ready = true }
126128
else -> {
127129
val error = "Could not find method call handler for ${call.method}!"

android/app/src/main/kotlin/com/bluebubbles/messaging/services/extension/MessageViewHandle.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@ class MessageViewHandle(val context: Context, val session: String, val appId: In
1212

1313
var locked = false
1414
var alive = false
15+
var suppressing = false
16+
17+
override fun setSuppressNotifications(suppress: Boolean) {
18+
if (suppress && !locked) {
19+
throw Exception("Trying to suppress notifications for unlocked handle! ")
20+
}
21+
suppressing = suppress
22+
Handler(context.mainLooper).post {
23+
val myMsg = hashMapOf(
24+
"appId" to appId,
25+
"session" to session,
26+
"suppress" to suppress,
27+
)
28+
MethodCallHandler.invokeMethod(
29+
"extension-set-suppress",
30+
myMsg)
31+
}
32+
}
1533

1634
override fun updateMessage(
1735
message: MadridMessage?,
@@ -51,6 +69,9 @@ class MessageViewHandle(val context: Context, val session: String, val appId: In
5169

5270
override fun unlock() {
5371
locked = false
72+
if (suppressing) {
73+
setSuppressNotifications(false)
74+
}
5475
if (!alive) {
5576
destroy()
5677
MessageViewRegistry.registered.remove(session)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.bluebubbles.messaging.services.system
2+
3+
import android.content.Context
4+
import android.content.Intent
5+
import android.net.Uri
6+
import android.provider.CalendarContract
7+
import androidx.activity.result.ActivityResultLauncher
8+
import androidx.activity.result.contract.ActivityResultContract
9+
import androidx.activity.result.contract.ActivityResultContracts
10+
import com.bluebubbles.messaging.Constants
11+
import com.bluebubbles.messaging.MainActivity
12+
import com.bluebubbles.messaging.models.MethodCallHandlerImpl
13+
import io.flutter.plugin.common.MethodCall
14+
import io.flutter.plugin.common.MethodChannel
15+
import java.io.FileInputStream
16+
17+
/// Create a new event in the calendar
18+
class CreateDocumentHandler: MethodCallHandlerImpl() {
19+
companion object {
20+
const val tag = "create-document"
21+
22+
var savedResult: MethodChannel.Result? = null
23+
var savedPath: String? = null
24+
}
25+
26+
override fun handleMethodCall(
27+
call: MethodCall,
28+
result: MethodChannel.Result,
29+
context: Context
30+
) {
31+
val path: String = call.argument("path")!!
32+
val mime: String = call.argument("mime")!!
33+
val name: String = call.argument("name")!!
34+
35+
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
36+
addCategory(Intent.CATEGORY_OPENABLE)
37+
type = mime
38+
putExtra(Intent.EXTRA_TITLE, name)
39+
}
40+
savedPath = path
41+
savedResult = result
42+
(context as MainActivity).startActivityForResult(intent, Constants.documentSaveRequestCode)
43+
}
44+
}

lib/app/layouts/conversation_view/widgets/message/interactive/supported_interactive.dart

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,29 @@ class _SupportedInteractiveState extends OptimizedState<SupportedInteractive> wi
3030
iMessageAppData get data => widget.data;
3131
dynamic get file => File(widget.content.path!);
3232

33+
static List<_SupportedInteractiveState> aliveExtensions = [];
34+
35+
bool forcedDead = false;
36+
37+
@override
38+
void initState() {
39+
super.initState();
40+
aliveExtensions.add(this);
41+
if (aliveExtensions.length > 20) {
42+
var oldExt = aliveExtensions.removeAt(0);
43+
oldExt.forcedDead = true;
44+
oldExt.setState(() { });
45+
}
46+
}
47+
48+
@override
49+
void dispose() {
50+
super.dispose();
51+
if (aliveExtensions.contains(this)) {
52+
aliveExtensions.remove(this);
53+
}
54+
}
55+
3356
@override
3457
bool get wantKeepAlive => true;
3558

@@ -41,7 +64,7 @@ class _SupportedInteractiveState extends OptimizedState<SupportedInteractive> wi
4164
data["messageGuid"] = widget.guid;
4265
return SizedBox(
4366
height: 250,
44-
child: RepaintBoundary(
67+
child: forcedDead ? const SizedBox.shrink() : RepaintBoundary(
4568
child: AndroidView(
4669
viewType: "extension-live",
4770
layoutDirection: TextDirection.ltr,

lib/app/layouts/conversation_view/widgets/message/popup/message_popup.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class _MessagePopupState extends OptimizedState<MessagePopup> with SingleTickerP
333333
child: reactions.isNotEmpty ? ReactionDetails(reactions: reactions) : const SizedBox.shrink(),
334334
),
335335
),
336-
if (ss.settings.enablePrivateAPI.value && isSent && minSierra && chat.isIMessage && message.dateScheduled == null)
336+
if (ss.settings.enablePrivateAPI.value && isSent && minSierra && message.dateScheduled == null)
337337
Positioned(
338338
bottom: (iOS ? itemHeight * numberToShow + 35 + widget.size.height : context.height - materialOffset)
339339
.clamp(0, context.height - (narrowScreen ? 200 : 125)),
@@ -458,7 +458,7 @@ class _MessagePopupState extends OptimizedState<MessagePopup> with SingleTickerP
458458
),
459459
),
460460
),
461-
if (ss.settings.enablePrivateAPI.value && isSent && minSierra && chat.isIMessage && message.dateScheduled == null)
461+
if (ss.settings.enablePrivateAPI.value && isSent && minSierra && message.dateScheduled == null)
462462
Positioned(
463463
bottom: (iOS ? itemHeight * numberToShow + 5 + widget.size.height : context.height - materialOffset - 30)
464464
.clamp(0, context.height - (narrowScreen ? 200 : 125)),

lib/app/layouts/settings/pages/profile/profile_panel.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ class _ProfilePanelState extends OptimizedState<ProfilePanel> with WidgetsBindin
693693
},
694694
initialVal: ss.settings.isSmsRouter.value,
695695
title: "Text message forwarding (BETA)",
696-
subtitle: "Forward your Android SMS messages to your other Apple devices",
696+
subtitle: "See your Android SMS messages on your other Apple devices",
697697
backgroundColor: tileColor,
698698
isThreeLine: true,
699699
)),

lib/app/layouts/settings/pages/profile/profile_scaffold.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ class ProfileScaffoldState
6969
bool appBarVisible = false;
7070
bool _shouldDisplay = false;
7171

72+
StreamSubscription<String?>? registration;
73+
74+
@override
75+
void dispose() {
76+
super.dispose();
77+
registration?.cancel();
78+
}
79+
7280
@override
7381
void initState() {
7482
super.initState();
@@ -78,6 +86,10 @@ class ProfileScaffoldState
7886
setState(() {});
7987
});
8088
}
89+
registration = ss.settings.userAvatarPath.listen((event) {
90+
updatePoster();
91+
setState(() {});
92+
});
8193
iosScrollController.addListener(() {
8294
var meets = poster != null ? iosScrollController.offset > 500 : iosScrollController.offset > 200;
8395
if (meets != track) {

0 commit comments

Comments
 (0)