-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2138 from BlueBubblesApp/zach/v1.9.1
Zach/v1.9.1
- Loading branch information
Showing
4 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...id/app/src/main/java/com/bluebubbles/messaging/method_call_handler/handlers/OpenLink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters