Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove Modals plugin #3569

Merged
merged 3 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.getcapacitor.plugin.Geolocation;
import com.getcapacitor.plugin.Keyboard;
import com.getcapacitor.plugin.LocalNotifications;
import com.getcapacitor.plugin.Modals;
import com.getcapacitor.plugin.PushNotifications;
import com.getcapacitor.plugin.SplashScreen;
import com.getcapacitor.plugin.StatusBar;
Expand Down Expand Up @@ -381,7 +380,6 @@ private void registerAllPlugins() {
this.registerPlugin(LocalNotifications.class);
this.registerPlugin(Geolocation.class);
this.registerPlugin(Keyboard.class);
this.registerPlugin(Modals.class);
this.registerPlugin(PushNotifications.class);
this.registerPlugin(SplashScreen.class);
this.registerPlugin(StatusBar.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
Expand All @@ -18,6 +19,7 @@
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import java.io.File;
Expand Down Expand Up @@ -122,17 +124,27 @@ public boolean onJsAlert(WebView view, String url, String message, final JsResul
return true;
}

Dialogs.alert(
view.getContext(),
message,
(value, didCancel, inputValue) -> {
if (value) {
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder
.setMessage(message)
.setTitle("Alert")
.setPositiveButton(
"OK",
(dialog, buttonIndex) -> {
dialog.dismiss();
result.confirm();
} else {
}
)
.setOnCancelListener(
dialog -> {
dialog.dismiss();
result.cancel();
}
}
);
);

AlertDialog dialog = builder.create();

dialog.show();

return true;
}
Expand All @@ -151,17 +163,35 @@ public boolean onJsConfirm(WebView view, String url, String message, final JsRes
return true;
}

Dialogs.confirm(
view.getContext(),
message,
(value, didCancel, inputValue) -> {
if (value) {
final AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());

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

AlertDialog dialog = builder.create();

dialog.show();

return true;
}
Expand All @@ -181,17 +211,39 @@ public boolean onJsPrompt(WebView view, String url, String message, String defau
return true;
}

Dialogs.prompt(
view.getContext(),
message,
(value, didCancel, inputValue) -> {
if (value) {
result.confirm(inputValue);
} else {
final AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
final EditText input = new EditText(view.getContext());

builder
.setMessage(message)
.setTitle("Prompt")
.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();
}
);

AlertDialog dialog = builder.create();

dialog.show();

return true;
}
Expand Down
225 changes: 0 additions & 225 deletions android/capacitor/src/main/java/com/getcapacitor/Dialogs.java

This file was deleted.

Loading