+++ /dev/null
-/*
- * Copyright © 2018-2020 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
- *
- * Privacy Browser is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Privacy Browser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.stoutner.privacybrowser.dialogs;
-
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.content.res.Configuration;
-import android.os.Build;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.view.WindowManager;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AlertDialog;
-import androidx.fragment.app.DialogFragment;
-
-import com.stoutner.privacybrowser.R;
-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.
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog);
-
- // Get the current theme status.
- int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
- // Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
- dialogBuilder.setIcon(R.drawable.block_ads_enabled_night);
- } else {
- dialogBuilder.setIcon(R.drawable.block_ads_enabled_day);
- }
-
- // 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()` when the minimum API >= 23.
- AdConsentDatabaseHelper adConsentDatabaseHelper = new AdConsentDatabaseHelper(getActivity().getApplicationContext(), null, null, 0);
-
- // Set the title.
- dialogBuilder.setTitle(R.string.ad_consent);
-
- // Set the text.
- dialogBuilder.setMessage(R.string.ad_consent_text);
-
- // Configure the close button.
- dialogBuilder.setNegativeButton(R.string.close_browser, (DialogInterface dialog, int which) -> {
- // Update the ad consent database.
- adConsentDatabaseHelper.updateAdConsent(false);
-
- // Close the browser. `finishAndRemoveTask` also removes Privacy Browser from the recent app list.
- if (Build.VERSION.SDK_INT >= 21) {
- getActivity().finishAndRemoveTask();
- } else {
- getActivity().finish();
- }
-
- // Remove the terminated program from RAM. The status code is `0`.
- System.exit(0);
- });
-
- // Configure the accept button.
- dialogBuilder.setPositiveButton(R.string.accept_ads, (DialogInterface dialog, int which) -> {
- // Update the ad consent database.
- adConsentDatabaseHelper.updateAdConsent(true);
-
- // Load an ad. `getContext()` can be used instead of `getActivity.getApplicationContext()` once the minimum API >= 23.
- AdHelper.loadAd(getActivity().findViewById(R.id.adview), getActivity().getApplicationContext(), getActivity(), getString(R.string.ad_unit_id));
- });
-
- // Create an alert dialog from the alert dialog builder.
- AlertDialog alertDialog = dialogBuilder.create();
-
- // Get a handle for the shared preferences.
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
- // Get the screenshot preference.
- boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
-
- // Disable screenshots if not allowed.
- if (!allowScreenshots) {
- // Remove the warning below that `getWindow()` might be null.
- assert alertDialog.getWindow() != null;
-
- // Disable screenshots.
- alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
- }
-
- // Return the alert dialog.
- return alertDialog;
- }
-
- // Close Privacy Browser Free if the dialog is cancelled without selecting a button (by tapping on the background).
- @Override
- public void onCancel(@NonNull 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()` when the minimum API >= 23.
- AdConsentDatabaseHelper adConsentDatabaseHelper = new AdConsentDatabaseHelper(getActivity().getApplicationContext(), null, null, 0);
-
- // Update the ad consent database.
- adConsentDatabaseHelper.updateAdConsent(false);
-
- // Close the browser. `finishAndRemoveTask()` also removes Privacy Browser from the recent app list.
- if (Build.VERSION.SDK_INT >= 21) {
- getActivity().finishAndRemoveTask();
- } else {
- getActivity().finish();
- }
-
- // Remove the terminated program from RAM. The status code is `0`.
- System.exit(0);
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2018-2021 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.dialogs
+
+import android.app.Dialog
+import android.content.DialogInterface
+import android.os.Build
+import android.os.Bundle
+import android.view.WindowManager
+
+import androidx.appcompat.app.AlertDialog
+import androidx.fragment.app.DialogFragment
+import androidx.preference.PreferenceManager
+
+import com.stoutner.privacybrowser.R
+import com.stoutner.privacybrowser.helpers.AdConsentDatabaseHelper
+import com.stoutner.privacybrowser.helpers.AdHelper
+import kotlin.system.exitProcess
+
+class AdConsentDialog : DialogFragment() {
+ // Declare the class variables.
+ private lateinit var adConsentDatabaseHelper: AdConsentDatabaseHelper
+
+ override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
+ // Use a builder to create the alert dialog.
+ val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog)
+
+ // Set the icon according to the theme.
+ dialogBuilder.setIconAttribute(R.attr.blockAdsBlueIcon)
+
+ // Initialize the bookmarks database helper.
+ adConsentDatabaseHelper = AdConsentDatabaseHelper(requireContext())
+
+ // Set the title.
+ dialogBuilder.setTitle(R.string.ad_consent)
+
+ // Set the text.
+ dialogBuilder.setMessage(R.string.ad_consent_text)
+
+ // Set the close browser button.
+ dialogBuilder.setNegativeButton(R.string.close_browser) { _: DialogInterface?, _: Int ->
+ // Update the ad consent database.
+ adConsentDatabaseHelper.updateAdConsent(false)
+
+ // Close the browser. `finishAndRemoveTask` also removes Privacy Browser from the recent app list.
+ if (Build.VERSION.SDK_INT >= 21) {
+ requireActivity().finishAndRemoveTask()
+ } else {
+ requireActivity().finish()
+ }
+
+ // Remove the terminated program from RAM. The status code is `0`.
+ exitProcess(0)
+ }
+
+ // Set the accept ads button.
+ dialogBuilder.setPositiveButton(R.string.accept_ads) { _: DialogInterface?, _: Int ->
+ // Update the ad consent database.
+ adConsentDatabaseHelper.updateAdConsent(true)
+
+ // Load an ad.
+ AdHelper.loadAd(requireActivity().findViewById(R.id.adview), requireContext(), requireActivity(), getString(R.string.ad_unit_id))
+ }
+
+ // Create an alert dialog from the alert dialog builder.
+ val alertDialog = dialogBuilder.create()
+
+ // Get a handle for the shared preferences.
+ val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+ // Get the screenshot preference.
+ val allowScreenshots = sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false)
+
+ // Disable screenshots if not allowed.
+ if (!allowScreenshots) {
+ // Disable screenshots.
+ alertDialog.window!!.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
+ }
+
+ // Return the alert dialog.
+ return alertDialog
+ }
+
+ // Close Privacy Browser Free if the dialog is cancelled without selecting a button (by tapping on the background).
+ override fun onCancel(dialogInterface: DialogInterface) {
+ // Update the ad consent database.
+ adConsentDatabaseHelper.updateAdConsent(false)
+
+ // Close the browser. `finishAndRemoveTask()` also removes Privacy Browser from the recent app list.
+ if (Build.VERSION.SDK_INT >= 21) {
+ requireActivity().finishAndRemoveTask()
+ } else {
+ requireActivity().finish()
+ }
+
+ // Remove the terminated program from RAM. The status code is `0`.
+ exitProcess(0)
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright © 2018 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
- *
- * Privacy Browser is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Privacy Browser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.stoutner.privacybrowser.helpers;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-public class AdConsentDatabaseHelper extends SQLiteOpenHelper {
- private static final int SCHEMA_VERSION = 1;
- private static final String AD_CONSENT_DATABASE = "ad_consent.db";
- private static final String AD_CONSENT_TABLE = "ad_consent";
-
- private static final String _ID = "_id";
- private static final String AD_CONSENT = "ad_consent";
-
- private static final String CREATE_AD_CONSENT_TABLE = "CREATE TABLE " + AD_CONSENT_TABLE + " (" +
- _ID + " INTEGER PRIMARY KEY, " +
- AD_CONSENT + " BOOLEAN)";
-
- // Initialize the database. The lint warnings for the unused parameters are suppressed.
- public AdConsentDatabaseHelper(Context context, @SuppressWarnings("UnusedParameters") String name, SQLiteDatabase.CursorFactory cursorFactory, @SuppressWarnings("UnusedParameters") int version) {
- super(context, AD_CONSENT_DATABASE, cursorFactory, SCHEMA_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase adConsentDatabase) {
- // Create the ad consent database.
- adConsentDatabase.execSQL(CREATE_AD_CONSENT_TABLE);
-
- // Create an ad consent ContentValues.
- ContentValues adConsentContentValues = new ContentValues();
-
- // Populate the ad consent content values.
- adConsentContentValues.put(AD_CONSENT, false);
-
- // Insert a new row. The second argument is `null`, which makes it so that a completely null row cannot be created.
- adConsentDatabase.insert(AD_CONSENT_TABLE, null, adConsentContentValues);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase adConsentDatabase, int oldVersion, int newVersion) {
- // Code for upgrading the database will be added here if the schema version ever increases above 1.
- }
-
- // Check to see if ad consent has been granted.
- public boolean isGranted() {
- // Get a readable database handle.
- SQLiteDatabase adConsentDatabase = this.getReadableDatabase();
-
- // Get the ad consent cursor.
- Cursor adConsentCursor = adConsentDatabase.rawQuery("SELECT * FROM " + AD_CONSENT_TABLE, null);
-
- // Move to the first entry.
- adConsentCursor.moveToFirst();
-
- // Get the ad consent boolean.
- boolean adConsent = (adConsentCursor.getInt(adConsentCursor.getColumnIndex(AD_CONSENT)) == 1);
-
- // Close the cursor.
- adConsentCursor.close();
-
- // Close the database.
- adConsentDatabase.close();
-
- // Return the ad consent boolean.
- return adConsent;
- }
-
- // Update the ad consent.
- public void updateAdConsent(boolean adConsent) {
- // Get a writable database handle.
- SQLiteDatabase adConsentDatabase = this.getWritableDatabase();
-
- // Create an ad consent integer.
- int adConsentInt;
-
- // Set the ad consent integer according to the boolean.
- if (adConsent) {
- adConsentInt = 1;
- } else {
- adConsentInt = 0;
- }
-
- // Update the ad consent in the database.
- adConsentDatabase.execSQL("UPDATE " + AD_CONSENT_TABLE + " SET " + AD_CONSENT + " = " + adConsentInt);
-
- // Close the database.
- adConsentDatabase.close();
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2018,2021 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.helpers
+
+import android.content.ContentValues
+import android.content.Context
+import android.database.sqlite.SQLiteDatabase
+import android.database.sqlite.SQLiteOpenHelper
+
+// Define the class constants.
+private const val SCHEMA_VERSION = 1
+private const val AD_CONSENT_DATABASE = "ad_consent.db"
+private const val AD_CONSENT_TABLE = "ad_consent"
+private const val ID = "_id"
+private const val AD_CONSENT = "ad_consent"
+private const val CREATE_AD_CONSENT_TABLE = "CREATE TABLE $AD_CONSENT_TABLE ($ID INTEGER PRIMARY KEY, $AD_CONSENT BOOLEAN)"
+
+class AdConsentDatabaseHelper (context: Context) : SQLiteOpenHelper(context, AD_CONSENT_DATABASE, null, SCHEMA_VERSION) {
+ override fun onCreate(adConsentDatabase: SQLiteDatabase) {
+ // Create the ad consent table.
+ adConsentDatabase.execSQL(CREATE_AD_CONSENT_TABLE)
+
+ // Create an ad consent content values.
+ val adConsentContentValues = ContentValues()
+
+ // Populate the ad consent content values with the default data.
+ adConsentContentValues.put(AD_CONSENT, false)
+
+ // Insert a new row. The second argument is `null`, which makes it so that a completely null row cannot be created.
+ adConsentDatabase.insert(AD_CONSENT_TABLE, null, adConsentContentValues)
+ }
+
+ override fun onUpgrade(adConsentDatabase: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
+ // Code for upgrading the database will be added here if the schema version ever increases above 1.
+ }
+
+ // Check to see if ad consent has been granted.
+ val isGranted: Boolean get() {
+ // Get a readable database handle.
+ val adConsentDatabase = this.readableDatabase
+
+ // Get the ad consent cursor.
+ val adConsentCursor = adConsentDatabase.rawQuery("SELECT * FROM $AD_CONSENT_TABLE", null)
+
+ // Move the cursor to the first entry.
+ adConsentCursor.moveToFirst()
+
+ // Get the ad consent boolean.
+ val adConsent = adConsentCursor.getInt(adConsentCursor.getColumnIndex(AD_CONSENT)) == 1
+
+ // Close the cursor.
+ adConsentCursor.close()
+
+ // Close the database.
+ adConsentDatabase.close()
+
+ // Return the ad consent boolean.
+ return adConsent
+ }
+
+ // Update the ad consent.
+ fun updateAdConsent(adConsent: Boolean) {
+ // Get a writable database handle.
+ val adConsentDatabase = this.writableDatabase
+
+ // Set the ad consent integer according to the boolean.
+ val adConsentInt = if (adConsent) 1 else 0
+
+ // Update the ad consent in the database.
+ adConsentDatabase.execSQL("UPDATE $AD_CONSENT_TABLE SET $AD_CONSENT = $adConsentInt")
+
+ // Close the database.
+ adConsentDatabase.close()
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
- *
- * Privacy Browser is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Privacy Browser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.stoutner.privacybrowser.helpers;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.util.DisplayMetrics;
-import android.view.Display;
-import android.view.View;
-import android.widget.RelativeLayout;
-
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.FragmentManager;
-
-import com.google.ads.mediation.admob.AdMobAdapter;
-import com.google.android.gms.ads.AdRequest;
-import com.google.android.gms.ads.AdSize;
-import com.google.android.gms.ads.AdView;
-import com.google.android.gms.ads.MobileAds;
-
-import com.stoutner.privacybrowser.R;
-import com.stoutner.privacybrowser.dialogs.AdConsentDialog;
-
-public class AdHelper {
- private static boolean initialized;
-
- public static void initializeAds(View view, Context applicationContext, Activity activity, FragmentManager fragmentManager, String adUnitId) {
- if (!initialized) { // This is the first run.
- // Initialize mobile ads.
- MobileAds.initialize(applicationContext);
-
- // Initialize the bookmarks database helper. The `0` specifies a database version, but that is ignored and set instead using a constant in `AdConsentDatabaseHelper`.
- AdConsentDatabaseHelper adConsentDatabaseHelper = new AdConsentDatabaseHelper(applicationContext, null, null, 0);
-
- // Check to see if consent has been granted.
- boolean adConsentGranted = adConsentDatabaseHelper.isGranted();
-
- // Display the ad consent dialog if needed.
- if (!adConsentGranted) { // Ad consent has not been granted.
- // Instantiate the ad consent dialog.
- DialogFragment adConsentDialogFragment = new AdConsentDialog();
-
- // Display the ad consent dialog.
- adConsentDialogFragment.show(fragmentManager, "Ad Consent");
- } else { // Ad consent has been granted.
- // Load an ad.
- loadAd(view, applicationContext, activity, adUnitId);
- }
-
- // Set the initialized variable to true so this section doesn't run again.
- initialized = true;
- } else { // Ads have previously been initialized.
- // Load an ad.
- loadAd(view, applicationContext, activity, adUnitId);
- }
- }
-
- public static void loadAd(View view, Context applicationContext, Activity activity, String adUnitId) {
- // Cast the generic view to an AdView.
- AdView adView = (AdView) view;
-
- // Save the layout parameters. They are used when programatically recreating the ad below.
- RelativeLayout.LayoutParams adViewLayoutParameters = (RelativeLayout.LayoutParams) adView.getLayoutParams();
-
- // Get a handle for the ad view parent.
- RelativeLayout adViewParentLayout = (RelativeLayout) adView.getParent();
-
- // Remove the AdView.
- adViewParentLayout.removeView(adView);
-
- // Create a new AdView. This is necessary because the size can change when the device is rotated.
- adView = new AdView(applicationContext);
-
- // Set the ad unit ID.
- adView.setAdUnitId(adUnitId);
-
- // Set the view ID.
- adView.setId(R.id.adview);
-
- // Set the layout parameters.
- adView.setLayoutParams(adViewLayoutParameters);
-
- // Add the new ad view to the parent layout.
- adViewParentLayout.addView(adView);
-
- // Get a handle for the display.
- Display display = activity.getWindowManager().getDefaultDisplay();
-
- // Initialize a display metrics.
- DisplayMetrics displayMetrics = new DisplayMetrics();
-
- // Get the display metrics from the display.
- display.getMetrics(displayMetrics);
-
- // Get the width pixels and the density.
- float widthPixels = displayMetrics.widthPixels;
- float density = displayMetrics.density;
-
- // Calculate the ad width.
- int adWidth = (int) (widthPixels / density);
-
- // Get the ad size. This line should be enabled once Firebase Ads is updated to 20.0.0.
- AdSize adSize = AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(applicationContext, adWidth);
-
- // Set the ad size on the adView.
- adView.setAdSize(adSize);
-
- // Create an ad settings bundle.
- Bundle adSettingsBundle = new Bundle();
-
- // Only request non-personalized ads. https://developers.google.com/ad-manager/mobile-ads-sdk/android/eu-consent#forward_consent_to_the_google_mobile_ads_sdk
- adSettingsBundle.putString("npa", "1");
-
- // Build the ad request.
- AdRequest adRequest = new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class, adSettingsBundle).build();
-
- // Make it so.
- adView.loadAd(adRequest);
- }
-
- // This method exists here for the sake of consistency with the following two methods.
- public static void hideAd(View view) {
- // Cast the generic view to an AdView.
- AdView adView = (AdView) view;
-
- // Hide the ad.
- adView.setVisibility(View.GONE);
- }
-
- // This method exists here so that the main WebView activity doesn't need to import `com.google.android.gms.ads.AdView`.
- public static void pauseAd(View view) {
- // Cast The generic view to an AdView.
- AdView adView = (AdView) view;
-
- // Pause the AdView.
- adView.pause();
- }
-
- // This method exists here so that the main WebView activity doesn't need to import `com.google.android.gms.ads.AdView`.
- public static void resumeAd(View view) {
- // Cast the generic view to an AdView.
- AdView adView = (AdView) view;
-
- // Resume the AdView.
- adView.resume();
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2016-2021 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.helpers
+
+import android.app.Activity
+import android.content.Context
+import android.os.Bundle
+import android.util.DisplayMetrics
+import android.view.View
+import android.widget.RelativeLayout
+
+import androidx.fragment.app.FragmentManager
+
+import com.google.ads.mediation.admob.AdMobAdapter
+import com.google.android.gms.ads.AdRequest
+import com.google.android.gms.ads.AdSize
+import com.google.android.gms.ads.AdView
+import com.google.android.gms.ads.MobileAds
+
+import com.stoutner.privacybrowser.R
+import com.stoutner.privacybrowser.dialogs.AdConsentDialog
+
+object AdHelper {
+ // Define the class variables.
+ private var initialized = false
+
+ // The `@JvmStatic` notation can be removed once all the code has migrated to Kotlin.
+ @JvmStatic
+ fun initializeAds(view: View, context: Context, activity: Activity, fragmentManager: FragmentManager, adUnitId: String) {
+ // Check to see if the ads have been initialized.
+ if (!initialized) { // This is the first run; the ads have not yet been initialized.
+ // Initialize mobile ads.
+ MobileAds.initialize(context)
+
+ // Initialize the bookmarks database helper.
+ val adConsentDatabaseHelper = AdConsentDatabaseHelper(context)
+
+ // Check to see if consent has been granted.
+ val adConsentGranted = adConsentDatabaseHelper.isGranted
+
+ // Display the ad consent dialog if needed.
+ if (!adConsentGranted) { // Ad consent has not been granted.
+ // Instantiate the ad consent dialog.
+ val adConsentDialogFragment = AdConsentDialog()
+
+ // Display the ad consent dialog.
+ adConsentDialogFragment.show(fragmentManager,"Ad Consent")
+ } else { // Ad consent has already been granted.
+ // Load an ad.
+ loadAd(view, context, activity, adUnitId)
+ }
+
+ // Set the initialized variable to true so this section doesn't run again.
+ initialized = true
+ } else { // Ads have previously been initialized.
+ // Load an ad.
+ loadAd(view, context, activity, adUnitId)
+ }
+ }
+
+ // The `@JvmStatic` notation can be removed once all the code has migrated to Kotlin.
+ @JvmStatic
+ fun loadAd(view: View, context: Context, activity: Activity, adUnitId: String) {
+ // Cast the generic view to an AdView.
+ var adView = view as AdView
+
+ // Save the layout parameters. They are used when programatically recreating the ad below.
+ val adViewLayoutParameters = adView.layoutParams as RelativeLayout.LayoutParams
+
+ // Get a handle for the ad view parent.
+ val adViewParentLayout = adView.parent as RelativeLayout
+
+ // Remove the AdView.
+ adViewParentLayout.removeView(adView)
+
+ // Create a new AdView. This is necessary because the size can change when the device is rotated.
+ adView = AdView(context)
+
+ // Set the ad unit ID.
+ adView.adUnitId = adUnitId
+
+ // Set the view ID.
+ adView.id = R.id.adview
+
+ // Set the layout parameters.
+ adView.layoutParams = adViewLayoutParameters
+
+ // Add the new ad view to the parent layout.
+ adViewParentLayout.addView(adView)
+
+ // Get a handle for the display. Once the minimum API >= 30, this should be changed to `context.getDisplay()`.
+ @Suppress("DEPRECATION") val display = activity.windowManager.defaultDisplay
+
+ // Initialize a display metrics.
+ val displayMetrics = DisplayMetrics()
+
+ // Get the display metrics from the display. Once the minimum APO >= 30, this should be replaced with `WindowMetrics.getBounds()` and `Configuration.densityDpi`.
+ @Suppress("DEPRECATION")
+ display.getMetrics(displayMetrics)
+
+ // Get the width pixels and the density.
+ val widthPixels = displayMetrics.widthPixels.toFloat()
+ val density = displayMetrics.density
+
+ // Calculate the ad width.
+ val adWidth = (widthPixels / density).toInt()
+
+ // Get the ad size.
+ val adSize = AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(context, adWidth)
+
+ // Set the ad size on the adView.
+ adView.adSize = adSize
+
+ // Create an ad settings bundle.
+ val adSettingsBundle = Bundle()
+
+ // Only request non-personalized ads. <https://developers.google.com/ad-manager/mobile-ads-sdk/android/eu-consent#forward_consent_to_the_google_mobile_ads_sdk>
+ adSettingsBundle.putString("npa", "1")
+
+ // Build the ad request.
+ val adRequest = AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter::class.java, adSettingsBundle).build()
+
+ // Make it so.
+ adView.loadAd(adRequest)
+ }
+
+ // The `@JvmStatic` notation can be removed once all the code has migrated to Kotlin.
+ // This method exists here for the sake of consistency with the following two methods.
+ @JvmStatic
+ fun hideAd(view: View) {
+ // Cast the generic view to an AdView.
+ val adView = view as AdView
+
+ // Hide the ad.
+ adView.visibility = View.GONE
+ }
+
+ // The `@JvmStatic` notation can be removed once all the code has migrated to Kotlin.
+ // This method exists here so that the main WebView activity doesn't need to import `com.google.android.gms.ads.AdView`.
+ @JvmStatic
+ fun pauseAd(view: View) {
+ // Cast The generic view to an AdView.
+ val adView = view as AdView
+
+ // Pause the AdView.
+ adView.pause()
+ }
+
+ // The `@JvmStatic` notation can be removed once all the code has migrated to Kotlin.
+ // This method exists here so that the main WebView activity doesn't need to import `com.google.android.gms.ads.AdView`.
+ @JvmStatic
+ fun resumeAd(view: View) {
+ // Cast the generic view to an AdView.
+ val adView = view as AdView
+
+ // Resume the AdView.
+ adView.resume()
+ }
+}
\ No newline at end of file
<body>
<h3><a href="https://www.stoutner.com/privacy-browser-3-8/">3.8</a> (version code 55)</h3>
- <p>24. Mai 2021 - Mindest-API 19, Ziel-API 30</p>
+ <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=1650cd6eff9ef807a84263328cb73e755250e3af">24. Mai 2021</a> - Mindest-API 19, Ziel-API 30</p>
<ul>
<li>Option hinzugefügt, um die <a href="https://redmine.stoutner.com/issues/143">App-Leiste unten anzuzeigen</a>.</li>
<li>Option zum <a href="https://redmine.stoutner.com/issues/677">Speichern von Web-Archiven</a> wieder integriert.</li>
<body>
<h3><a href="https://www.stoutner.com/privacy-browser-3-8/">3.8</a> (version code 55)</h3>
- <p>24 May 2021 - minimum API 19, target API 30</p>
+ <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=1650cd6eff9ef807a84263328cb73e755250e3af">24 May 2021</a> - minimum API 19, target API 30</p>
<ul>
<li>Add an option to <a href="https://redmine.stoutner.com/issues/143">move the app bar to the bottom</a>.</li>
<li>Reimplement the <a href="https://redmine.stoutner.com/issues/677">saving of web archives</a>.</li>
<body>
<h3><a href="https://www.stoutner.com/privacy-browser-3-8/">3.8</a> (código de versión 55)</h3>
- <p>24 de mayo de 2021 - API mínimo 19, API dirigido 30</p>
+ <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=1650cd6eff9ef807a84263328cb73e755250e3af">24 de mayo de 2021</a> - API mínimo 19, API dirigido 30</p>
<ul>
<li>Añadir una opción para <a href="https://redmine.stoutner.com/issues/143">mover la barra de aplicaciones a la parte inferior</a>.</li>
<li>Reimplementar el <a href="https://redmine.stoutner.com/issues/677">guardar archivos web</a>.</li>
<body>
<h3><a href="https://www.stoutner.com/privacy-browser-3-8/">3.8</a> (version du code 55)</h3>
- <p>24 Mai 2021 - API minimale : 19, API optimale : 30</p>
+ <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=1650cd6eff9ef807a84263328cb73e755250e3af">24 Mai 2021</a> - API minimale : 19, API optimale : 30</p>
<ul>
<li>Add an option to <a href="https://redmine.stoutner.com/issues/143">move the app bar to the bottom</a>.</li>
<li>Reimplement the <a href="https://redmine.stoutner.com/issues/677">saving of web archives</a>.</li>
<body>
<h3><a href="https://www.stoutner.com/privacy-browser-3-8/">3.8</a> (versione codice 55)</h3>
- <p>24 Maggio 2021 - minima API 19, target API 30</p>
+ <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=1650cd6eff9ef807a84263328cb73e755250e3af">24 Maggio 2021</a> - minima API 19, target API 30</p>
<ul>
<li>Aggiunta l'opzione per <a href="https://redmine.stoutner.com/issues/143">spostare in basso la barra dell'app</a>.</li>
<li>Nuova implementazione del <a href="https://redmine.stoutner.com/issues/677">salvataggio degli archivi web</a>.</li>
<body>
<h3><a href="https://www.stoutner.com/privacy-browser-3-8/">3.8</a> (código da versão 55)</h3>
- <p>24 May 2021 - minimum API 19, target API 30</p>
+ <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=1650cd6eff9ef807a84263328cb73e755250e3af">24 May 2021</a> - minimum API 19, target API 30</p>
<ul>
<li>Adicionado uma opção para <a href="https://redmine.stoutner.com/issues/143">mover a barra de aplicativos para a parte inferior</a>.</li>
<li>Reimplementado o <a href="https://redmine.stoutner.com/issues/677">salvamento de arquivos da web</a>.</li>
<!--
Copyright © 2016-2021 Soren Stoutner <soren@stoutner.com>.
+ Translation 2021 Thiago Nazareno Conceição Silva de Jesus <mochileiro2006-trilhas@yahoo.com.br>. Copyright assigned to Soren Stoutner <soren@stoutner.com>.
+
This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
Privacy Browser is free software: you can redistribute it and/or modify
<!--
Copyright © 2016-2021 Soren Stoutner <soren@stoutner.com>.
+ Translation 2021 Thiago Nazareno Conceição Silva de Jesus <mochileiro2006-trilhas@yahoo.com.br>. Copyright assigned to Soren Stoutner <soren@stoutner.com>.
+
This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
Privacy Browser is free software: you can redistribute it and/or modify
<!--
Copyright © 2016-2018,2020-2021 Soren Stoutner <soren@stoutner.com>.
+ Translation 2021 Thiago Nazareno Conceição Silva de Jesus <mochileiro2006-trilhas@yahoo.com.br>. Copyright assigned to Soren Stoutner <soren@stoutner.com>.
+
This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
Privacy Browser is free software: you can redistribute it and/or modify
<!--
Copyright © 2016-2018,2020-2021 Soren Stoutner <soren@stoutner.com>.
+ Translation 2021 Thiago Nazareno Conceição Silva de Jesus <mochileiro2006-trilhas@yahoo.com.br>. Copyright assigned to Soren Stoutner <soren@stoutner.com>.
+
This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
Privacy Browser is free software: you can redistribute it and/or modify
<!--
Copyright © 2016-2018,2020 Soren Stoutner <soren@stoutner.com>.
+ Translation 2021 Thiago Nazareno Conceição Silva de Jesus <mochileiro2006-trilhas@yahoo.com.br>. Copyright assigned to Soren Stoutner <soren@stoutner.com>.
+
This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
Privacy Browser is free software: you can redistribute it and/or modify
<body>
<h3><a href="https://www.stoutner.com/privacy-browser-3-8/">3.8</a> (код версии 55)</h3>
- <p>24 мая 2021 года - минимальный API 19, целевой API 30</p>
+ <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=1650cd6eff9ef807a84263328cb73e755250e3af">24 мая 2021 года</a> - минимальный API 19, целевой API 30</p>
<ul>
<li>Добавлена возможность перемещения <a href="https://redmine.stoutner.com/issues/143">панели приложения в нижнюю часть</a>.</li>
<li>Реализовано <a href="https://redmine.stoutner.com/issues/677">сохранение веб-архивов</a>.</li>
<body>
<h3><a href="https://www.stoutner.com/privacy-browser-3-8/">3.8</a> (version code 55)</h3>
- <p>24 Mayıs 2021 - minimum API 19, target API 30</p>
+ <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=1650cd6eff9ef807a84263328cb73e755250e3af">24 Mayıs 2021</a> - minimum API 19, target API 30</p>
<ul>
<li>Add an option to <a href="https://redmine.stoutner.com/issues/143">move the app bar to the bottom</a>.</li>
<li>Reimplement the <a href="https://redmine.stoutner.com/issues/677">saving of web archives</a>.</li>
val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.move_to_folder_blue_day)
- } else {
- dialogBuilder.setIcon(R.drawable.move_to_folder_blue_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.moveToFolderBlueIcon)
// Set the title.
dialogBuilder.setTitle(R.string.move_to_folder)
val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.proxy_enabled_day)
- } else {
- dialogBuilder.setIcon(R.drawable.proxy_enabled_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.proxyBlueIcon)
// Set the title.
dialogBuilder.setTitle(R.string.open)
val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_day)
- } else {
- dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.sslCertificateBlueIcon)
} else { // There is a favorite icon.
// Create a drawable version of the favorite icon.
val favoriteIconDrawable: Drawable = BitmapDrawable(resources, favoriteIconBitmap)
val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.proxy_enabled_day)
- } else {
- dialogBuilder.setIcon(R.drawable.proxy_enabled_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.proxyBlueIcon)
// Set the title and the message according to the proxy mode.
when (proxyMode) {
dialogBuilder.setTitle(R.string.save_logcat)
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.save_dialog_day)
- } else {
- dialogBuilder.setIcon(R.drawable.save_dialog_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.saveBlueIcon)
}
SAVE_ABOUT_VERSION_TEXT -> {
dialogBuilder.setTitle(R.string.save_text)
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.save_text_blue_day)
- } else {
- dialogBuilder.setIcon(R.drawable.save_text_blue_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.saveTextBlueIcon)
}
SAVE_ABOUT_VERSION_IMAGE -> {
dialogBuilder.setTitle(R.string.save_image)
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.images_enabled_day)
- } else {
- dialogBuilder.setIcon(R.drawable.images_enabled_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.imagesBlueIcon)
}
}
dialogBuilder.setTitle(R.string.save_url)
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.copy_enabled_day)
- } else {
- dialogBuilder.setIcon(R.drawable.copy_enabled_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.copyBlueIcon)
}
SAVE_ARCHIVE -> {
dialogBuilder.setTitle(R.string.save_archive)
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.dom_storage_cleared_day)
- } else {
- dialogBuilder.setIcon(R.drawable.dom_storage_cleared_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.domStorageBlueIcon)
// Convert the URL to a URI.
val uri = Uri.parse(originalUrlString)
dialogBuilder.setTitle(R.string.save_image)
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.images_enabled_day)
- } else {
- dialogBuilder.setIcon(R.drawable.images_enabled_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.imagesBlueIcon)
// Convert the URL to a URI.
val uri = Uri.parse(originalUrlString)
val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
// Set the icon according to the theme.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
- dialogBuilder.setIcon(R.drawable.block_ads_enabled_day)
- } else {
- dialogBuilder.setIcon(R.drawable.block_ads_enabled_night)
- }
+ dialogBuilder.setIconAttribute(R.attr.blockAdsBlueIcon)
// Set the title.
dialogBuilder.setTitle(resources.getString(R.string.request_details) + " - " + id)
<item name="selectAllIcon">@drawable/select_all_night</item>
<item name="shareIcon">@drawable/share_night</item>
<item name="sortIcon">@drawable/sort_night</item>
-
- <!-- Dialog Icons. -->
- <item name="aboutBlueIcon">@drawable/about_blue_night</item>
- <item name="domainsBlueIcon">@drawable/domains_night</item>
- <item name="fontSizeBlueIcon">@drawable/font_size_night</item>
- <item name="lockBlueIcon">@drawable/lock_night</item>
- <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_night</item>
</style>
<style name="PrivacyBrowserAppBar" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" >
</style>
<style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
+ <!-- Colors. -->
<item name="colorAccent">@color/violet_500</item>
+
+ <!-- Dialog Icons. -->
+ <item name="aboutBlueIcon">@drawable/about_blue_night</item>
+ <item name="blockAdsBlueIcon">@drawable/block_ads_enabled_night</item>
+ <item name="copyBlueIcon">@drawable/copy_enabled_night</item>
+ <item name="domainsBlueIcon">@drawable/domains_night</item>
+ <item name="domStorageBlueIcon">@drawable/dom_storage_cleared_night</item>
+ <item name="fontSizeBlueIcon">@drawable/font_size_night</item>
+ <item name="imagesBlueIcon">@drawable/images_enabled_night</item>
+ <item name="lockBlueIcon">@drawable/lock_night</item>
+ <item name="moveToFolderBlueIcon">@drawable/move_to_folder_blue_night</item>
+ <item name="proxyBlueIcon">@drawable/proxy_enabled_night</item>
+ <item name="saveBlueIcon">@drawable/save_dialog_night</item>
+ <item name="saveTextBlueIcon">@drawable/save_text_blue_night</item>
+ <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_night</item>
</style>
</resources>
\ No newline at end of file
<item name="selectAllIcon">@drawable/select_all_night</item>
<item name="shareIcon">@drawable/share_night</item>
<item name="sortIcon">@drawable/sort_night</item>
-
- <!-- Dialog Icons. -->
- <item name="aboutBlueIcon">@drawable/about_blue_night</item>
- <item name="domainsBlueIcon">@drawable/domains_night</item>
- <item name="fontSizeBlueIcon">@drawable/font_size_night</item>
- <item name="lockBlueIcon">@drawable/lock_night</item>
- <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_night</item>
</style>
<style name="PrivacyBrowserAppBar" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" >
</style>
<style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
+ <!-- Colors. -->
<item name="colorAccent">@color/violet_500</item>
+
+ <!-- Dialog Icons. -->
+ <item name="aboutBlueIcon">@drawable/about_blue_night</item>
+ <item name="blockAdsBlueIcon">@drawable/block_ads_enabled_night</item>
+ <item name="copyBlueIcon">@drawable/copy_enabled_night</item>
+ <item name="domainsBlueIcon">@drawable/domains_night</item>
+ <item name="domStorageBlueIcon">@drawable/dom_storage_cleared_night</item>
+ <item name="fontSizeBlueIcon">@drawable/font_size_night</item>
+ <item name="imagesBlueIcon">@drawable/images_enabled_night</item>
+ <item name="lockBlueIcon">@drawable/lock_night</item>
+ <item name="moveToFolderBlueIcon">@drawable/move_to_folder_blue_night</item>
+ <item name="proxyBlueIcon">@drawable/proxy_enabled_night</item>
+ <item name="saveBlueIcon">@drawable/save_dialog_night</item>
+ <item name="saveTextBlueIcon">@drawable/save_text_blue_night</item>
+ <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_night</item>
</style>
</resources>
\ No newline at end of file
<item name="selectAllIcon">@drawable/select_all_night</item>
<item name="shareIcon">@drawable/share_night</item>
<item name="sortIcon">@drawable/sort_night</item>
-
- <!-- Dialog Icons. -->
- <item name="aboutBlueIcon">@drawable/about_blue_night</item>
- <item name="domainsBlueIcon">@drawable/domains_night</item>
- <item name="fontSizeBlueIcon">@drawable/font_size_night</item>
- <item name="lockBlueIcon">@drawable/lock_night</item>
- <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_night</item>
</style>
<style name="PrivacyBrowserAppBar" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" >
</style>
<style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
+ <!-- Colors. -->
<item name="colorAccent">@color/violet_500</item>
+
+ <!-- Dialog Icons. -->
+ <item name="aboutBlueIcon">@drawable/about_blue_night</item>
+ <item name="blockAdsBlueIcon">@drawable/block_ads_enabled_night</item>
+ <item name="copyBlueIcon">@drawable/copy_enabled_night</item>
+ <item name="domainsBlueIcon">@drawable/domains_night</item>
+ <item name="domStorageBlueIcon">@drawable/dom_storage_cleared_night</item>
+ <item name="fontSizeBlueIcon">@drawable/font_size_night</item>
+ <item name="imagesBlueIcon">@drawable/images_enabled_night</item>
+ <item name="lockBlueIcon">@drawable/lock_night</item>
+ <item name="moveToFolderBlueIcon">@drawable/move_to_folder_blue_night</item>
+ <item name="proxyBlueIcon">@drawable/proxy_enabled_night</item>
+ <item name="saveBlueIcon">@drawable/save_dialog_night</item>
+ <item name="saveTextBlueIcon">@drawable/save_text_blue_night</item>
+ <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_night</item>
</style>
</resources>
\ No newline at end of file
<item name="selectAllIcon">@drawable/select_all_day</item>
<item name="shareIcon">@drawable/share_day</item>
<item name="sortIcon">@drawable/sort_day</item>
-
- <!-- Dialog Icons. -->
- <item name="aboutBlueIcon">@drawable/about_blue_day</item>
- <item name="domainsBlueIcon">@drawable/domains_day</item>
- <item name="fontSizeBlueIcon">@drawable/font_size_day</item>
- <item name="lockBlueIcon">@drawable/lock_day</item>
- <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_day</item>
</style>
<style name="PrivacyBrowserAppBar" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" >
</style>
<style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
+ <!-- Colors. -->
<item name="colorAccent">@color/blue_700</item>
+
+ <!-- Dialog Icons. -->
+ <item name="aboutBlueIcon">@drawable/about_blue_day</item>
+ <item name="blockAdsBlueIcon">@drawable/block_ads_enabled_day</item>
+ <item name="copyBlueIcon">@drawable/copy_enabled_day</item>
+ <item name="domainsBlueIcon">@drawable/domains_day</item>
+ <item name="domStorageBlueIcon">@drawable/dom_storage_cleared_day</item>
+ <item name="fontSizeBlueIcon">@drawable/font_size_day</item>
+ <item name="imagesBlueIcon">@drawable/images_enabled_day</item>
+ <item name="lockBlueIcon">@drawable/lock_day</item>
+ <item name="moveToFolderBlueIcon">@drawable/move_to_folder_blue_day</item>
+ <item name="proxyBlueIcon">@drawable/proxy_enabled_day</item>
+ <item name="saveBlueIcon">@drawable/save_dialog_day</item>
+ <item name="saveTextBlueIcon">@drawable/save_text_blue_day</item>
+ <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_day</item>
</style>
</resources>
\ No newline at end of file
<item name="selectAllIcon">@drawable/select_all_day</item>
<item name="shareIcon">@drawable/share_day</item>
<item name="sortIcon">@drawable/sort_day</item>
-
- <!-- Dialog Icons. -->
- <item name="aboutBlueIcon">@drawable/about_blue_day</item>
- <item name="domainsBlueIcon">@drawable/domains_day</item>
- <item name="fontSizeBlueIcon">@drawable/font_size_day</item>
- <item name="lockBlueIcon">@drawable/lock_day</item>
- <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_day</item>
</style>
<style name="PrivacyBrowserAppBar" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" >
</style>
<style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
+ <!-- Colors. -->
<item name="colorAccent">@color/blue_700</item>
+
+ <!-- Dialog Icons. -->
+ <item name="aboutBlueIcon">@drawable/about_blue_day</item>
+ <item name="blockAdsBlueIcon">@drawable/block_ads_enabled_day</item>
+ <item name="copyBlueIcon">@drawable/copy_enabled_day</item>
+ <item name="domainsBlueIcon">@drawable/domains_day</item>
+ <item name="domStorageBlueIcon">@drawable/dom_storage_cleared_day</item>
+ <item name="fontSizeBlueIcon">@drawable/font_size_day</item>
+ <item name="imagesBlueIcon">@drawable/images_enabled_day</item>
+ <item name="lockBlueIcon">@drawable/lock_day</item>
+ <item name="moveToFolderBlueIcon">@drawable/move_to_folder_blue_day</item>
+ <item name="proxyBlueIcon">@drawable/proxy_enabled_day</item>
+ <item name="saveBlueIcon">@drawable/save_dialog_day</item>
+ <item name="saveTextBlueIcon">@drawable/save_text_blue_day</item>
+ <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_day</item>
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright © 2017-2020 Soren Stoutner <soren@stoutner.com>.
+ Copyright © 2017-2021 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
<!-- Dialog Icons. -->
<attr name="aboutBlueIcon" format="reference" />
+ <attr name="blockAdsBlueIcon" format="reference" />
+ <attr name="copyBlueIcon" format="reference" />
<attr name="domainsBlueIcon" format="reference" />
+ <attr name="domStorageBlueIcon" format="reference" />
<attr name="fontSizeBlueIcon" format="reference" />
+ <attr name="imagesBlueIcon" format="reference" />
<attr name="lockBlueIcon" format="reference" />
+ <attr name="moveToFolderBlueIcon" format="reference" />
+ <attr name="proxyBlueIcon" format="reference" />
+ <attr name="saveBlueIcon" format="reference" />
+ <attr name="saveTextBlueIcon" format="reference" />
<attr name="sslCertificateBlueIcon" format="reference" />
</resources>
\ No newline at end of file
<item name="selectAllIcon">@drawable/select_all_day</item>
<item name="shareIcon">@drawable/share_day</item>
<item name="sortIcon">@drawable/sort_day</item>
-
- <!-- Dialog Icons. -->
- <item name="aboutBlueIcon">@drawable/about_blue_day</item>
- <item name="domainsBlueIcon">@drawable/domains_day</item>
- <item name="fontSizeBlueIcon">@drawable/font_size_day</item>
- <item name="lockBlueIcon">@drawable/lock_day</item>
- <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_day</item>
</style>
<style name="PrivacyBrowserAppBar" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" >
</style>
<style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
+ <!-- Colors. -->
<item name="colorAccent">@color/blue_700</item>
+
+ <!-- Dialog Icons. -->
+ <item name="aboutBlueIcon">@drawable/about_blue_day</item>
+ <item name="blockAdsBlueIcon">@drawable/block_ads_enabled_day</item>
+ <item name="copyBlueIcon">@drawable/copy_enabled_day</item>
+ <item name="domainsBlueIcon">@drawable/domains_day</item>
+ <item name="domStorageBlueIcon">@drawable/dom_storage_cleared_day</item>
+ <item name="fontSizeBlueIcon">@drawable/font_size_day</item>
+ <item name="imagesBlueIcon">@drawable/images_enabled_day</item>
+ <item name="lockBlueIcon">@drawable/lock_day</item>
+ <item name="moveToFolderBlueIcon">@drawable/move_to_folder_blue_day</item>
+ <item name="proxyBlueIcon">@drawable/proxy_enabled_day</item>
+ <item name="saveBlueIcon">@drawable/save_dialog_day</item>
+ <item name="saveTextBlueIcon">@drawable/save_text_blue_day</item>
+ <item name="sslCertificateBlueIcon">@drawable/ssl_certificate_enabled_day</item>
</style>
</resources>
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright © 2018-2019 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
- *
- * Privacy Browser is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Privacy Browser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.stoutner.privacybrowser.dialogs;
-
-// The AndroidX dialog fragment must be used or an error is produced on API <=22.
-import androidx.fragment.app.DialogFragment;
-
-public class AdConsentDialog extends DialogFragment {
- // Do nothing because this is the standard flavor.
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2018-2019,2021 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.dialogs
+
+import androidx.fragment.app.DialogFragment
+
+class AdConsentDialog : DialogFragment() {
+ // Do nothing because this is the standard flavor.
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright © 2016-2018,2020 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
- *
- * Privacy Browser is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Privacy Browser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.stoutner.privacybrowser.helpers;
-import android.app.Activity;
-import android.content.Context;
-import android.view.View;
-
-import androidx.fragment.app.FragmentManager;
-
-@SuppressWarnings("unused")
-public class AdHelper {
- public static void initializeAds(View view, Context applicationContext, Activity activity, FragmentManager fragmentManager, String adUnitId) {
- // Do nothing because this is the standard flavor.
- }
-
- public static void loadAd(View view, Context applicationContext, Activity activity, String adUnitId) {
- // Do nothing because this is the standard flavor.
- }
-
- public static void hideAd(View view) {
- // Do nothing because this is the standard flavor.
- }
-
- public static void pauseAd(View view) {
- // Do nothing because this is the standard flavor.
- }
-
- public static void resumeAd(View view) {
- // Do nothing because this is the standard flavor.
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2016-2018,2020-2021 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.helpers
+
+import android.app.Activity
+import android.content.Context
+import android.view.View
+
+import androidx.fragment.app.FragmentManager
+
+// The `@JvmStatic` notation can be removed once all the code has migrated to Kotlin.
+@Suppress("UNUSED_PARAMETER")
+object AdHelper {
+ @JvmStatic
+ fun initializeAds(view: View, context: Context, activity: Activity, fragmentManager: FragmentManager, adUnitId: String) {
+ // Do nothing because this is the standard flavor.
+ }
+
+ @JvmStatic
+ fun loadAd(view: View, context: Context, activity: Activity, adUnitId: String) {
+ // Do nothing because this is the standard flavor.
+ }
+
+ @JvmStatic
+ fun hideAd(view: View) {
+ // Do nothing because this is the standard flavor.
+ }
+
+ @JvmStatic
+ fun pauseAd(view: View) {
+ // Do nothing because this is the standard flavor.
+ }
+
+ @JvmStatic
+ fun resumeAd(view: View) {
+ // Do nothing because this is the standard flavor.
+ }
+}
\ No newline at end of file