/*
- * Copyright 2016-2017 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
import android.widget.EditText;
import com.stoutner.privacybrowser.R;
+import com.stoutner.privacybrowser.activities.MainWebViewActivity;
// `android.support.v7.app.AlertDialog` uses more of the horizontal screen real estate versus `android.app.AlertDialog's` smaller width.
// We have to use `AppCompatDialogFragment` instead of `DialogFragment` or an error is produced on API <=22.
// 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.save_image_as);
- // The parent view is `null` because it will be assigned by `AlertDialog`.
+
+ // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`.
dialogBuilder.setView(layoutInflater.inflate(R.layout.download_image_dialog, null));
// Set an `onClick()` listener on the negative button.
// Set the text for `downloadImageNameTextView`.
EditText downloadImageNameTextView = (EditText) alertDialog.findViewById(R.id.download_image_name);
- assert downloadImageNameTextView != null; // Remove the warning on the following line that `downloadImageNameTextView` might be `null`.
downloadImageNameTextView.setText(imageFileName);
// Allow the `enter` key on the keyboard to save the file from `downloadImageNameTextView`.