X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Ffree%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FAdConsentDialog.java;h=c0cf972180468c0cc7ca43834a6dc0ee6aa672f3;hp=94f8a91e60019bf40c10be40bb7eef602a8d9d93;hb=ba40295dffd761ccdc95d3b46ca7acbad1f00d5e;hpb=33bd447a83bd3d763ee26bbb3a3f4adb074776ed diff --git a/app/src/free/java/com/stoutner/privacybrowser/dialogs/AdConsentDialog.java b/app/src/free/java/com/stoutner/privacybrowser/dialogs/AdConsentDialog.java index 94f8a91e..c0cf9721 100644 --- a/app/src/free/java/com/stoutner/privacybrowser/dialogs/AdConsentDialog.java +++ b/app/src/free/java/com/stoutner/privacybrowser/dialogs/AdConsentDialog.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018 Soren Stoutner . + * Copyright © 2018-2019 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -21,17 +21,20 @@ package com.stoutner.privacybrowser.dialogs; import android.app.AlertDialog; import android.app.Dialog; -import android.app.DialogFragment; import android.content.DialogInterface; import android.os.Build; import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; + import com.stoutner.privacybrowser.R; import com.stoutner.privacybrowser.activities.MainWebViewActivity; import com.stoutner.privacybrowser.helpers.AdConsentDatabaseHelper; import com.stoutner.privacybrowser.helpers.AdHelper; public class AdConsentDialog extends DialogFragment { + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use a builder to create the alert dialog. @@ -46,8 +49,11 @@ public class AdConsentDialog extends DialogFragment { dialogBuilder.setIcon(R.drawable.block_ads_enabled_light); } + // Remove the incorrect lint warning below that `getApplicationContext()` might be null. + assert getActivity() != null; + // Initialize the bookmarks database helper. The `0` specifies a database version, but that is ignored and set instead using a constant in `AdConsentDatabaseHelper`. - // `getContext()` can be used instead of `getActivity.getApplicationContext()` on the minimum API >= 23. + // `getContext()` can be used instead of `getActivity.getApplicationContext()` when the minimum API >= 23. AdConsentDatabaseHelper adConsentDatabaseHelper = new AdConsentDatabaseHelper(getActivity().getApplicationContext(), null, null, 0); // Set the title. @@ -88,8 +94,11 @@ public class AdConsentDialog extends DialogFragment { // Close Privacy Browser Free if the dialog is cancelled without selecting a button (by tapping on the background). @Override public void onCancel(DialogInterface dialogInterface) { + // Remove the incorrect lint warning below that `getApplicationContext()` might be null. + assert getActivity() != null; + // Initialize the bookmarks database helper. The `0` specifies a database version, but that is ignored and set instead using a constant in `AdConsentDatabaseHelper`. - // `getContext()` can be used instead of `getActivity.getApplicationContext()` on the minimum API >= 23. + // `getContext()` can be used instead of `getActivity.getApplicationContext()` when the minimum API >= 23. AdConsentDatabaseHelper adConsentDatabaseHelper = new AdConsentDatabaseHelper(getActivity().getApplicationContext(), null, null, 0); // Update the ad consent database.