/*
- * Copyright © 2015-2018 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2015-2019 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-// We have to use `AppCompatDialogFragment` instead of `DialogFragment` or an error is produced on API <=22.
-import android.support.v7.app.AppCompatDialogFragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.DialogFragment; // The AndroidX dialog fragment must be used or an error is produced on API <=22.
+
import com.stoutner.privacybrowser.activities.MainWebViewActivity;
import com.stoutner.privacybrowser.R;
-public class CreateHomeScreenShortcutDialog extends AppCompatDialogFragment {
+public class CreateHomeScreenShortcutDialog extends DialogFragment {
// The public interface is used to send information back to the parent activity.
public interface CreateHomeScreenShortcutListener {
- void onCreateHomeScreenShortcut(AppCompatDialogFragment dialogFragment);
+ void onCreateHomeScreenShortcut(DialogFragment dialogFragment);
}
//`createHomeScreenShortcutListener` is used in `onAttach()` and `onCreateDialog()`.
// Check to make sure that the parent activity implements the listener.
public void onAttach(Context context) {
+ // Run the default commands.
super.onAttach(context);
- try {
- createHomeScreenShortcutListener = (CreateHomeScreenShortcutListener) context;
- } catch(ClassCastException exception) {
- throw new ClassCastException(context.toString() + " must implement CreateHomeScreenShortcutListener.");
- }
+
+ // Get a handle for `CreateHomeScreenShortcutListener` from the launching context.
+ createHomeScreenShortcutListener = (CreateHomeScreenShortcutListener) context;
}
// `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the `AlertDialog`.