X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FUrlHistoryDialog.java;h=0fe8afaa94e2e5d4078b1fae54e79d4896903204;hp=9b9d9f610ca82346a56e05b25b86c06369e6283a;hb=ba40295dffd761ccdc95d3b46ca7acbad1f00d5e;hpb=012e5595c82d6e8d0b8a46f1ef18a02a56341182 diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java index 9b9d9f61..0fe8afaa 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2018 Soren Stoutner . + * Copyright © 2016-2019 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -29,11 +29,6 @@ import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.content.ContextCompat; -// `AppCompatDialogFragment` must be used instead of `DialogFragment` or an error is produced on API <= 22. -// `android.support.v7.app.AlertDialog` also uses more of the horizontal screen real estate versus `android.app.AlertDialog's` smaller width. -import android.support.v7.app.AppCompatDialogFragment; import android.util.Base64; import android.view.LayoutInflater; import android.view.View; @@ -42,6 +37,10 @@ import android.webkit.WebBackForwardList; import android.widget.AdapterView; import android.widget.ListView; +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.DialogFragment; // The AndroidX dialog fragment must be used or an error is produced on API <=22. + import com.stoutner.privacybrowser.R; import com.stoutner.privacybrowser.activities.MainWebViewActivity; import com.stoutner.privacybrowser.adapters.HistoryArrayAdapter; @@ -50,44 +49,44 @@ import com.stoutner.privacybrowser.definitions.History; import java.io.ByteArrayOutputStream; import java.util.ArrayList; -public class UrlHistoryDialog extends AppCompatDialogFragment{ +public class UrlHistoryDialog extends DialogFragment{ // `historyArrayList` and `currentPageId` pass information from `onCreate()` to `onCreateDialog()`. private final ArrayList historyArrayList = new ArrayList<>(); private int currentPageId; public static UrlHistoryDialog loadBackForwardList(Context context, WebBackForwardList webBackForwardList) { - // Create `argumentsBundle`. + // Create an arguments bundle. Bundle argumentsBundle = new Bundle(); - // Store `currentPageIndex`. + // Store the current page index. int currentPageIndex = webBackForwardList.getCurrentIndex(); - // Setup `urlArrayList` and `iconArrayList`. + // Setup the URL array list and the icon array list. ArrayList urlArrayList = new ArrayList<>(); ArrayList iconBase64StringArrayList = new ArrayList<>(); - // Get the default favorite icon `Drawable`. + // Get the default favorite icon drawable. `ContextCompat` must be used until the minimum API >= 21. Drawable defaultFavoriteIconDrawable = ContextCompat.getDrawable(context, R.drawable.world); - // Convert `defaultFavoriteIconDrawable` to a `BitmapDrawable`. + // Convert the default favorite icon drawable to a `BitmapDrawable`. BitmapDrawable defaultFavoriteIconBitmapDrawable = (BitmapDrawable) defaultFavoriteIconDrawable; // Remove the incorrect lint error that `getBitmap()` might be null. assert defaultFavoriteIconBitmapDrawable != null; - // Extract a `Bitmap` from `defaultFavoriteIconBitmapDrawable`. + // Extract a `Bitmap` from the default favorite icon `BitmapDrawable`. Bitmap defaultFavoriteIcon = defaultFavoriteIconBitmapDrawable.getBitmap(); - // Populate `urlArrayList` and `iconArrayList` from `webBackForwardList`. + // Populate the URL array list and the icon array list from `webBackForwardList`. for (int i=0; i < webBackForwardList.getSize(); i++) { // Store the URL. urlArrayList.add(webBackForwardList.getItemAtIndex(i).getUrl()); - // Create a variable to store the icon `Bitmap`. + // Create a variable to store the icon bitmap. Bitmap iconBitmap; - // Store the icon `Bitmap`. + // Store the icon bitmap. if (webBackForwardList.getItemAtIndex(i).getFavicon() == null) { // If `webBackForwardList` does not have a favorite icon, use Privacy Browser's default world icon. iconBitmap = defaultFavoriteIcon; @@ -119,7 +118,7 @@ public class UrlHistoryDialog extends AppCompatDialogFragment{ argumentsBundle.putStringArrayList("URL_History", urlArrayList); argumentsBundle.putStringArrayList("Favorite_Icons", iconBase64StringArrayList); - // Add `argumentsBundle` to this instance of `UrlHistoryDialog`. + // Add the arguments bundle to this instance of `UrlHistoryDialog`. UrlHistoryDialog thisUrlHistoryDialog = new UrlHistoryDialog(); thisUrlHistoryDialog.setArguments(argumentsBundle); return thisUrlHistoryDialog;