Skip to content

Commit

Permalink
Merge pull request #117 from droibit/feature/refactoring
Browse files Browse the repository at this point in the history
Rrefactoring
  • Loading branch information
droibit authored Oct 8, 2023
2 parents aad113e + f3eccb1 commit a76aa01
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,30 @@ public void onDetachedFromActivity() {
@SuppressWarnings("unchecked")
@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull final MethodChannel.Result result) {
if ("launch".equals(call.method)) {
launch(((Map<String, Object>) call.arguments), result);
} else if ("closeAllIfPossible".equals(call.method)) {
closeAllIfPossible(result);
} else {
result.notImplemented();
switch (call.method) {
case "launch":
launch(((Map<String, Object>) call.arguments), result);
break;
case "closeAllIfPossible":
closeAllIfPossible(result);
break;
default:
result.notImplemented();
break;
}
}

@SuppressWarnings({"unchecked", "ConstantConditions"})
private void launch(@NonNull Map<String, Object> args, @NonNull MethodChannel.Result result) {
final Activity activity = this.activity;
if (activity == null) {
result.error(CODE_LAUNCH_ERROR, "Launching a CustomTabs requires a foreground activity.", null);
result.error(CODE_LAUNCH_ERROR, "Launching a custom tab requires a foreground activity.", null);
return;
}

final Uri uri = Uri.parse(args.get(KEY_URL).toString());
if (args.containsKey(KEY_PREFERS_DEEP_LINK) && ((Boolean) args.get(KEY_PREFERS_DEEP_LINK))) {
if (NativeLauncher.launch(activity, uri)) {
if (NativeAppLauncher.launch(activity, uri)) {
result.success(null);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import java.util.Set;

/**
* ref. https://developer.chrome.com/docs/android/custom-tabs/howto-custom-tab-native-apps/
* ref. <a href="https://developer.chrome.com/docs/android/custom-tabs/howto-custom-tab-native-apps/">Let native applications handle the content</a>
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
class NativeLauncher {
class NativeAppLauncher {
static boolean launch(@NonNull Context context, @NonNull Uri uri) {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R ?
launchNativeApi30(context, uri) :
Expand Down
4 changes: 2 additions & 2 deletions flutter_custom_tabs_ios/Mintfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
realm/SwiftLint@0.52.4
nicklockwood/[email protected].3
realm/SwiftLint@0.53.0
nicklockwood/[email protected].7

0 comments on commit a76aa01

Please sign in to comment.