Skip to content

Commit

Permalink
chore(deps): Update lint packages and run fmt (#7710)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Oct 10, 2024
1 parent d3bdeb4 commit 09d99ba
Show file tree
Hide file tree
Showing 101 changed files with 1,280 additions and 3,437 deletions.
44 changes: 0 additions & 44 deletions .eslintrc.js

This file was deleted.

9 changes: 7 additions & 2 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,13 @@ public void restoreInstanceState(Bundle savedInstanceState) {
try {
JSObject options = new JSObject(lastOptionsJson);

pluginCallForLastActivity =
new PluginCall(msgHandler, lastPluginId, PluginCall.CALLBACK_ID_DANGLING, lastPluginCallMethod, options);
pluginCallForLastActivity = new PluginCall(
msgHandler,
lastPluginId,
PluginCall.CALLBACK_ID_DANGLING,
lastPluginCallMethod,
options
);
} catch (JSONException ex) {
Logger.error("Unable to restore plugin call, unable to parse persisted JSON object", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ protected void load(Bundle savedInstanceState) {
startDir = getArguments().getString(ARG_START_DIR);
}

bridge =
new Bridge.Builder(this)
.setInstanceState(savedInstanceState)
.setPlugins(initialPlugins)
.setConfig(config)
.addWebViewListeners(webViewListeners)
.create();
bridge = new Bridge.Builder(this)
.setInstanceState(savedInstanceState)
.setPlugins(initialPlugins)
.setConfig(config)
.addWebViewListeners(webViewListeners)
.create();

if (startDir != null) {
bridge.setServerAssetPath(startDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,11 @@ public BridgeWebChromeClient(Bridge bridge) {
};

permissionLauncher = bridge.registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), permissionCallback);
activityLauncher =
bridge.registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
if (activityListener != null) {
activityListener.onActivityResult(result);
}
}
);
activityLauncher = bridge.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
if (activityListener != null) {
activityListener.onActivityResult(result);
}
});
}

/**
Expand Down Expand Up @@ -114,14 +110,13 @@ public void onPermissionRequest(final PermissionRequest request) {
}
if (!permissionList.isEmpty()) {
String[] permissions = permissionList.toArray(new String[0]);
permissionListener =
isGranted -> {
if (isGranted) {
request.grant(request.getResources());
} else {
request.deny();
}
};
permissionListener = isGranted -> {
if (isGranted) {
request.grant(request.getResources());
} else {
request.deny();
}
};
permissionLauncher.launch(permissions);
} else {
request.grant(request.getResources());
Expand All @@ -145,19 +140,14 @@ public boolean onJsAlert(WebView view, String url, String message, final JsResul
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder
.setMessage(message)
.setPositiveButton(
"OK",
(dialog, buttonIndex) -> {
dialog.dismiss();
result.confirm();
}
)
.setOnCancelListener(
dialog -> {
dialog.dismiss();
result.cancel();
}
);
.setPositiveButton("OK", (dialog, buttonIndex) -> {
dialog.dismiss();
result.confirm();
})
.setOnCancelListener(dialog -> {
dialog.dismiss();
result.cancel();
});

AlertDialog dialog = builder.create();

Expand All @@ -184,26 +174,18 @@ public boolean onJsConfirm(WebView view, String url, String message, final JsRes

builder
.setMessage(message)
.setPositiveButton(
"OK",
(dialog, buttonIndex) -> {
dialog.dismiss();
result.confirm();
}
)
.setNegativeButton(
"Cancel",
(dialog, buttonIndex) -> {
dialog.dismiss();
result.cancel();
}
)
.setOnCancelListener(
dialog -> {
dialog.dismiss();
result.cancel();
}
);
.setPositiveButton("OK", (dialog, buttonIndex) -> {
dialog.dismiss();
result.confirm();
})
.setNegativeButton("Cancel", (dialog, buttonIndex) -> {
dialog.dismiss();
result.cancel();
})
.setOnCancelListener(dialog -> {
dialog.dismiss();
result.cancel();
});

AlertDialog dialog = builder.create();

Expand Down Expand Up @@ -233,28 +215,20 @@ public boolean onJsPrompt(WebView view, String url, String message, String defau
builder
.setMessage(message)
.setView(input)
.setPositiveButton(
"OK",
(dialog, buttonIndex) -> {
dialog.dismiss();

String inputText1 = input.getText().toString().trim();
result.confirm(inputText1);
}
)
.setNegativeButton(
"Cancel",
(dialog, buttonIndex) -> {
dialog.dismiss();
result.cancel();
}
)
.setOnCancelListener(
dialog -> {
dialog.dismiss();
result.cancel();
}
);
.setPositiveButton("OK", (dialog, buttonIndex) -> {
dialog.dismiss();

String inputText1 = input.getText().toString().trim();
result.confirm(inputText1);
})
.setNegativeButton("Cancel", (dialog, buttonIndex) -> {
dialog.dismiss();
result.cancel();
})
.setOnCancelListener(dialog -> {
dialog.dismiss();
result.cancel();
});

AlertDialog dialog = builder.create();

Expand All @@ -275,22 +249,21 @@ public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermiss
final String[] geoPermissions = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION };

if (!PermissionHelper.hasPermissions(bridge.getContext(), geoPermissions)) {
permissionListener =
isGranted -> {
if (isGranted) {
permissionListener = isGranted -> {
if (isGranted) {
callback.invoke(origin, true, false);
} else {
final String[] coarsePermission = { Manifest.permission.ACCESS_COARSE_LOCATION };
if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
PermissionHelper.hasPermissions(bridge.getContext(), coarsePermission)
) {
callback.invoke(origin, true, false);
} else {
final String[] coarsePermission = { Manifest.permission.ACCESS_COARSE_LOCATION };
if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
PermissionHelper.hasPermissions(bridge.getContext(), coarsePermission)
) {
callback.invoke(origin, true, false);
} else {
callback.invoke(origin, false, false);
}
callback.invoke(origin, false, false);
}
};
}
};
permissionLauncher.launch(geoPermissions);
} else {
// permission is already granted
Expand All @@ -313,15 +286,14 @@ public boolean onShowFileChooser(
if (isMediaCaptureSupported()) {
showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
} else {
permissionListener =
isGranted -> {
if (isGranted) {
showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
} else {
Logger.warn(Logger.tags("FileChooser"), "Camera permission not granted");
filePathCallback.onReceiveValue(null);
}
};
permissionListener = isGranted -> {
if (isGranted) {
showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
} else {
Logger.warn(Logger.tags("FileChooser"), "Camera permission not granted");
filePathCallback.onReceiveValue(null);
}
};
final String[] camPermission = { Manifest.permission.CAMERA };
permissionLauncher.launch(camPermission);
}
Expand Down Expand Up @@ -373,14 +345,13 @@ private boolean showImageCapturePicker(final ValueCallback<Uri[]> filePathCallba
return false;
}
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileUri);
activityListener =
activityResult -> {
Uri[] result = null;
if (activityResult.getResultCode() == Activity.RESULT_OK) {
result = new Uri[] { imageFileUri };
}
filePathCallback.onReceiveValue(result);
};
activityListener = activityResult -> {
Uri[] result = null;
if (activityResult.getResultCode() == Activity.RESULT_OK) {
result = new Uri[] { imageFileUri };
}
filePathCallback.onReceiveValue(result);
};
activityLauncher.launch(takePictureIntent);

return true;
Expand All @@ -393,14 +364,13 @@ private boolean showVideoCapturePicker(final ValueCallback<Uri[]> filePathCallba
return false;
}

activityListener =
activityResult -> {
Uri[] result = null;
if (activityResult.getResultCode() == Activity.RESULT_OK) {
result = new Uri[] { activityResult.getData().getData() };
}
filePathCallback.onReceiveValue(result);
};
activityListener = activityResult -> {
Uri[] result = null;
if (activityResult.getResultCode() == Activity.RESULT_OK) {
result = new Uri[] { activityResult.getData().getData() };
}
filePathCallback.onReceiveValue(result);
};
activityLauncher.launch(takeVideoIntent);

return true;
Expand All @@ -419,21 +389,20 @@ private void showFilePicker(final ValueCallback<Uri[]> filePathCallback, FileCho
}
}
try {
activityListener =
activityResult -> {
Uri[] result;
Intent resultIntent = activityResult.getData();
if (activityResult.getResultCode() == Activity.RESULT_OK && resultIntent.getClipData() != null) {
final int numFiles = resultIntent.getClipData().getItemCount();
result = new Uri[numFiles];
for (int i = 0; i < numFiles; i++) {
result[i] = resultIntent.getClipData().getItemAt(i).getUri();
}
} else {
result = WebChromeClient.FileChooserParams.parseResult(activityResult.getResultCode(), resultIntent);
activityListener = activityResult -> {
Uri[] result;
Intent resultIntent = activityResult.getData();
if (activityResult.getResultCode() == Activity.RESULT_OK && resultIntent.getClipData() != null) {
final int numFiles = resultIntent.getClipData().getItemCount();
result = new Uri[numFiles];
for (int i = 0; i < numFiles; i++) {
result[i] = resultIntent.getClipData().getItemAt(i).getUri();
}
filePathCallback.onReceiveValue(result);
};
} else {
result = WebChromeClient.FileChooserParams.parseResult(activityResult.getResultCode(), resultIntent);
}
filePathCallback.onReceiveValue(result);
};
activityLauncher.launch(intent);
} catch (ActivityNotFoundException e) {
filePathCallback.onReceiveValue(null);
Expand Down
Loading

0 comments on commit 09d99ba

Please sign in to comment.