Skip to content

Commit

Permalink
chore: Remove Modals plugin (#3569)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Sep 24, 2020
1 parent 4e629c4 commit 8782b78
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 820 deletions.
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

0 comments on commit 8782b78

Please sign in to comment.