Skip to content

Commit

Permalink
Merge pull request #2138 from BlueBubblesApp/zach/v1.9.1
Browse files Browse the repository at this point in the history
Zach/v1.9.1
  • Loading branch information
zlshames authored Jun 14, 2022
2 parents f069dbe + 214dfb2 commit 0b72b91
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.bluebubbles.messaging.method_call_handler.handlers.NewMessageNotification;
import com.bluebubbles.messaging.method_call_handler.handlers.OpenCamera;
import com.bluebubbles.messaging.method_call_handler.handlers.OpenFile;
import com.bluebubbles.messaging.method_call_handler.handlers.OpenLink;
import com.bluebubbles.messaging.method_call_handler.handlers.PickFile;
import com.bluebubbles.messaging.method_call_handler.handlers.PushShareTargets;
import com.bluebubbles.messaging.method_call_handler.handlers.SaveToFile;
Expand Down Expand Up @@ -65,6 +66,8 @@ public static void methodCallHandler(MethodCall call, MethodChannel.Result resul
new ClearSocketIssue(context, call, result).Handle();
} else if (call.method.equals(OpenFile.TAG)) {
new OpenFile(context, call, result).Handle();
} else if (call.method.equals(OpenLink.TAG)) {
new OpenLink(context, call, result).Handle();
} else if (call.method.equals(ClearChatNotifs.TAG)) {
new ClearChatNotifs(context, call, result).Handle();
} else if (call.method.equals(GetLastLocation.TAG)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.bluebubbles.messaging.method_call_handler.handlers;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

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

public class OpenLink implements Handler {
public static String TAG = "open-link";

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

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

@Override
public void Handle() {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(call.argument("link")));
if ((Boolean) call.argument("forceBrowser")) {
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setPackage("com.android.chrome");
try {
context.startActivity(i);
} catch (ActivityNotFoundException e) {
// Chrome is probably not installed
// Try with the default browser
i.setPackage(null);
context.startActivity(i);
}
} else {
context.startActivity(i);
}
result.success("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.bluebubbles.messaging.method_call_handler.handlers.NewMessageNotification;
import com.bluebubbles.messaging.method_call_handler.handlers.OpenCamera;
import com.bluebubbles.messaging.method_call_handler.handlers.OpenFile;
import com.bluebubbles.messaging.method_call_handler.handlers.OpenLink;
import com.bluebubbles.messaging.method_call_handler.handlers.PickFile;
import com.bluebubbles.messaging.method_call_handler.handlers.PushShareTargets;
import com.bluebubbles.messaging.method_call_handler.handlers.SaveToFile;
Expand Down Expand Up @@ -111,6 +112,8 @@ public void onMethodCall(MethodCall call, @NonNull Result result) {
new ClearSocketIssue(context, call, result).Handle();
} else if (call.method.equals(OpenFile.TAG)) {
new OpenFile(context, call, result).Handle();
} else if (call.method.equals(OpenLink.TAG)) {
new OpenLink(context, call, result).Handle();
} else if (call.method.equals(ClearChatNotifs.TAG)) {
new ClearChatNotifs(context, call, result).Handle();
} else if (call.method.equals(GetLastLocation.TAG)) {
Expand Down
5 changes: 2 additions & 3 deletions lib/layouts/widgets/message_widget/message_details_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:metadata_fetch/metadata_fetch.dart';
import 'package:sprung/sprung.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';

class MessageDetailsPopup extends StatefulWidget {
Expand Down Expand Up @@ -485,8 +484,8 @@ class MessageDetailsPopupState extends State<MessageDetailsPopup> {
color: Colors.transparent,
child: InkWell(
onTap: () async {
Metadata? data = await MetadataHelper.fetchMetadata(widget.message);
await launchUrl(Uri.parse(data?.url ?? widget.message.text ?? ''), mode: LaunchMode.externalApplication);
String? url = widget.message.getUrl();
MethodChannelInterface().invokeMethod("open-link", {"link": url ?? widget.message.text, "forceBrowser": true});
popDetails();
},
child: ListTile(
Expand Down

0 comments on commit 0b72b91

Please sign in to comment.