From e75d0de135425de40f47bd9299f496b615a14253 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 1 Apr 2021 15:46:29 -0400 Subject: [PATCH] Migrate rest of AlertDialogs to AppCompat --- .../main/java/org/schabi/newpipe/error/ErrorActivity.java | 2 +- .../java/org/schabi/newpipe/info_list/InfoItemDialog.java | 2 +- .../org/schabi/newpipe/local/bookmark/BookmarkFragment.java | 5 ++--- .../schabi/newpipe/local/dialog/PlaylistCreationDialog.java | 6 +++--- .../local/subscription/ImportConfirmationDialog.java | 2 +- .../newpipe/local/subscription/SubscriptionFragment.kt | 2 +- .../schabi/newpipe/settings/ContentSettingsFragment.java | 6 +++--- .../schabi/newpipe/settings/DownloadSettingsFragment.java | 2 +- .../java/org/schabi/newpipe/settings/tabs/AddTabDialog.java | 2 +- .../java/us/shandian/giga/ui/fragment/MissionsFragment.java | 2 +- 10 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java index 4efb7cf93..2fcba0e1a 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java @@ -1,7 +1,6 @@ package org.schabi.newpipe.error; import android.app.Activity; -import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -16,6 +15,7 @@ import android.view.View; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java index 8f00e50fd..c485337f0 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java @@ -1,13 +1,13 @@ package org.schabi.newpipe.info_list; import android.app.Activity; -import android.app.AlertDialog; import android.content.DialogInterface; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.stream.StreamInfoItem; diff --git a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java index e9032a1c6..a58bb4cd5 100644 --- a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java @@ -1,7 +1,5 @@ package org.schabi.newpipe.local.bookmark; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.os.Bundle; import android.os.Parcelable; import android.util.Log; @@ -12,6 +10,7 @@ import android.widget.EditText; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.FragmentManager; import org.reactivestreams.Subscriber; @@ -260,7 +259,7 @@ public final class BookmarkFragment extends BaseLocalListFragment changeLocalPlaylistName(selectedItem.uid, editText.getText().toString())) diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistCreationDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistCreationDialog.java index 4d19f0dd9..40ea27e8c 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistCreationDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistCreationDialog.java @@ -1,6 +1,5 @@ package org.schabi.newpipe.local.dialog; -import android.app.AlertDialog; import android.app.Dialog; import android.os.Bundle; import android.view.View; @@ -9,6 +8,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import org.schabi.newpipe.NewPipeDatabase; import org.schabi.newpipe.R; @@ -46,7 +46,7 @@ public final class PlaylistCreationDialog extends PlaylistDialog { final View dialogView = View.inflate(getContext(), R.layout.dialog_playlist_name, null); final EditText nameInput = dialogView.findViewById(R.id.playlist_name); - final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext()) + final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext()) .setTitle(R.string.create_playlist) .setView(dialogView) .setCancelable(true) @@ -54,7 +54,7 @@ public final class PlaylistCreationDialog extends PlaylistDialog { .setPositiveButton(R.string.create, (dialogInterface, i) -> { final String name = nameInput.getText().toString(); final LocalPlaylistManager playlistManager = - new LocalPlaylistManager(NewPipeDatabase.getInstance(getContext())); + new LocalPlaylistManager(NewPipeDatabase.getInstance(requireContext())); final Toast successToast = Toast.makeText(getActivity(), R.string.playlist_creation_success, Toast.LENGTH_SHORT); diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/ImportConfirmationDialog.java b/app/src/main/java/org/schabi/newpipe/local/subscription/ImportConfirmationDialog.java index 20b112cb4..30142157e 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/ImportConfirmationDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/ImportConfirmationDialog.java @@ -1,12 +1,12 @@ package org.schabi.newpipe.local.subscription; -import android.app.AlertDialog; import android.app.Dialog; import android.content.Intent; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt index 016e1e404..f8a6f0f4d 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt @@ -1,7 +1,6 @@ package org.schabi.newpipe.local.subscription import android.app.Activity -import android.app.AlertDialog import android.content.BroadcastReceiver import android.content.Context import android.content.DialogInterface @@ -17,6 +16,7 @@ import android.view.MenuInflater import android.view.View import android.view.ViewGroup import android.widget.Toast +import androidx.appcompat.app.AlertDialog import androidx.lifecycle.ViewModelProvider import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.preference.PreferenceManager diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index ad8400401..3fd44c4d5 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -1,7 +1,6 @@ package org.schabi.newpipe.settings; import android.app.Activity; -import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -10,6 +9,7 @@ import android.util.Log; import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; import androidx.preference.Preference; import androidx.preference.PreferenceManager; @@ -169,7 +169,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US); exportDatabase(path + "/NewPipeData-" + sdf.format(new Date()) + ".zip"); } else { - final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + final AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity()); builder.setMessage(R.string.override_current_data) .setPositiveButton(getString(R.string.finish), (d, id) -> importDatabase(path)) @@ -215,7 +215,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { //If settings file exist, ask if it should be imported. if (manager.extractSettings(filePath)) { - final AlertDialog.Builder alert = new AlertDialog.Builder(getContext()); + final AlertDialog.Builder alert = new AlertDialog.Builder(requireContext()); alert.setTitle(R.string.import_settings); alert.setNegativeButton(android.R.string.no, (dialog, which) -> { diff --git a/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java index abd543643..913512644 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/DownloadSettingsFragment.java @@ -1,7 +1,6 @@ package org.schabi.newpipe.settings; import android.app.Activity; -import android.app.AlertDialog; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; @@ -12,6 +11,7 @@ import android.util.Log; import android.widget.Toast; import androidx.annotation.StringRes; +import androidx.appcompat.app.AlertDialog; import androidx.preference.Preference; import com.nononsenseapps.filepicker.Utils; diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/AddTabDialog.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/AddTabDialog.java index 125b455f4..e2e833fee 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/AddTabDialog.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/AddTabDialog.java @@ -1,6 +1,5 @@ package org.schabi.newpipe.settings.tabs; -import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.view.LayoutInflater; @@ -11,6 +10,7 @@ import android.widget.TextView; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.AppCompatImageView; import org.schabi.newpipe.R; diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index b47bc97fd..c83eec819 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -1,7 +1,6 @@ package us.shandian.giga.ui.fragment; import android.app.Activity; -import android.app.AlertDialog; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -19,6 +18,7 @@ import android.view.ViewGroup; import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.GridLayoutManager;