Skip to content

Commit

Permalink
feat: made transparent the alert dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
arifBurakDemiray committed Nov 12, 2024
1 parent df97478 commit d6a4d71
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions sdk/src/main/java/ly/count/android/sdk/ModuleFeedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand All @@ -269,6 +266,7 @@ public void run() {
try {

ModuleRatings.RatingDialogWebView webView = new ModuleRatings.RatingDialogWebView(context);

webView.getSettings().setJavaScriptEnabled(true);
webView.clearCache(true);
webView.clearHistory();
Expand All @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit d6a4d71

Please sign in to comment.