X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FUrlHistoryDialog.java;h=8a703929b6d12226b817dbe5319b7edebb6aca31;hb=d420aa6be32a78b27905074edc3881a6e71d2263;hp=4811ea2dae1853bee544ae24b55b56dc8b30b896;hpb=61a76e491469916f2f30aebb47b98cda7cceb557;p=PrivacyBrowserAndroid.git 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 4811ea2d..8a703929 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-2017 Soren Stoutner . + * Copyright © 2016-2017 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -41,6 +41,7 @@ import android.widget.AdapterView; import android.widget.ListView; import com.stoutner.privacybrowser.R; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; import com.stoutner.privacybrowser.adapters.HistoryArrayAdapter; import com.stoutner.privacybrowser.definitions.History; @@ -50,7 +51,7 @@ import java.util.ArrayList; public class UrlHistoryDialog extends AppCompatDialogFragment{ // `historyArrayList` and `currentPageId` pass information from `onCreate()` to `onCreateDialog()`. - private ArrayList historyArrayList = new ArrayList<>(); + private final ArrayList historyArrayList = new ArrayList<>(); private int currentPageId; public static UrlHistoryDialog loadBackForwardList(Context context, WebBackForwardList webBackForwardList) { @@ -182,8 +183,15 @@ public class UrlHistoryDialog extends AppCompatDialogFragment{ // Get the activity's layout inflater. LayoutInflater layoutInflater = getActivity().getLayoutInflater(); - // Use `AlertDialog.Builder` to create the `AlertDialog`. `R.style.lightAlertDialog` formats the color of the button text. - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog); + // Use `AlertDialog.Builder` to create the `AlertDialog`. + AlertDialog.Builder dialogBuilder; + + // Set the style according to the theme. + if (MainWebViewActivity.darkTheme) { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark); + } else { + dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight); + } // Set the title. dialogBuilder.setTitle(R.string.history); @@ -220,9 +228,6 @@ public class UrlHistoryDialog extends AppCompatDialogFragment{ // Get a handle for `listView`. ListView listView = (ListView) alertDialog.findViewById(R.id.history_listview); - // Remove the warning below that `listView` might be `null`. - assert listView != null; - // Set the adapter on `listView`. listView.setAdapter(historyArrayAdapter); @@ -233,15 +238,9 @@ public class UrlHistoryDialog extends AppCompatDialogFragment{ // Convert the `long` `id` to an `int`. int itemId = (int) id; - // Only enable the click if it is not on the `currentPageId`. + // Only consume the click if it is not on the `currentPageId`. if (itemId != currentPageId) { - // Get the history entry for this `itemId`. - History historyEntry = historyArrayAdapter.getItem(itemId); - - // Remove the lint warning below that `historyEntry` might be `null`. - assert historyEntry != null; - - // Send the history entry URL to be loaded in `mainWebView`. + // Go forward or back to `itemId`. urlHistoryListener.onUrlHistoryEntrySelected(currentPageId - itemId); // Dismiss the `Dialog`.