From d6a4d71ecf49089aad39ca6bfaed2492ae81247c Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Tue, 12 Nov 2024 18:00:58 +0300 Subject: [PATCH] feat: made transparent the alert dialog --- .../ly/count/android/sdk/ModuleFeedback.java | 30 ++++--------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/sdk/src/main/java/ly/count/android/sdk/ModuleFeedback.java b/sdk/src/main/java/ly/count/android/sdk/ModuleFeedback.java index 91c9a1992..c65dde56b 100644 --- a/sdk/src/main/java/ly/count/android/sdk/ModuleFeedback.java +++ b/sdk/src/main/java/ly/count/android/sdk/ModuleFeedback.java @@ -2,7 +2,6 @@ import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.os.Handler; import android.os.Looper; import android.webkit.WebSettings; @@ -259,8 +258,6 @@ void presentFeedbackWidgetInternal(@Nullable final CountlyFeedbackWidget widgetI //enable for chrome debugging //WebView.setWebContentsDebuggingEnabled(true); - - final boolean useAlertDialog = true; Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { public void run() { @@ -269,6 +266,7 @@ public void run() { try { ModuleRatings.RatingDialogWebView webView = new ModuleRatings.RatingDialogWebView(context); + webView.getSettings().setJavaScriptEnabled(true); webView.clearCache(true); webView.clearHistory(); @@ -278,8 +276,10 @@ public void run() { webView.loadUrl(preparedWidgetUrl); webView.requestFocus(); - AlertDialog.Builder builder = prepareAlertDialog(context, webView, closeButtonText, widgetInfo, devCallback); - AlertDialog alert = builder.create(); + AlertDialog alert = new AlertDialog.Builder(context).setView(webView).setCancelable(false).create(); + alert.getWindow().setBackgroundDrawableResource(android.R.color.transparent); + alert.getWindow().setDimAmount(0f); + webViewClient.listener = new WebViewUrlListener() { @Override public boolean onUrl(String url, WebView webView) { @@ -319,26 +319,6 @@ public boolean onUrl(String url, WebView webView) { }); } - AlertDialog.Builder prepareAlertDialog(@NonNull final Context context, @NonNull WebView webView, @Nullable String closeButtonText, @NonNull final CountlyFeedbackWidget widgetInfo, @Nullable final FeedbackCallback devCallback) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setView(webView); - builder.setCancelable(false); - String usedCloseButtonText = closeButtonText; - if (closeButtonText == null || closeButtonText.isEmpty()) { - usedCloseButtonText = "Close"; - } - builder.setNeutralButton(usedCloseButtonText, new DialogInterface.OnClickListener() { - @Override public void onClick(DialogInterface dialogInterface, int i) { - L.d("[ModuleFeedback] Cancel button clicked for the feedback widget"); - reportFeedbackWidgetCancelButton(widgetInfo, deviceInfo.mp.getAppVersion(context)); - if (devCallback != null) { - devCallback.onClosed(); - } - } - }); - return builder; - } - void reportFeedbackWidgetCancelButton(@NonNull CountlyFeedbackWidget widgetInfo, @NonNull String appVersion) { L.d("[reportFeedbackWidgetCancelButton] Cancel button event"); if (consentProvider.getConsent(Countly.CountlyFeatureNames.feedback)) {