From e0b12ab0e2344b99b1852c90e4e6e47c068a6ce0 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 25 Jan 2023 15:14:42 +0100 Subject: [PATCH] Change alert dialogs --- .../android/activities/BasePeertubeActivity.java | 3 ++- .../android/activities/PeertubeBaseMainActivity.java | 4 ++-- .../peertube/activities/AllPlaylistsActivity.java | 3 ++- .../peertube/activities/InstancePickerActivity.java | 6 ++++-- .../android/peertube/activities/PeertubeActivity.java | 11 ++++++----- .../activities/PeertubeEditUploadActivity.java | 3 ++- .../peertube/activities/PeertubeMainActivity.java | 7 ++++--- .../peertube/activities/PeertubeRegisterActivity.java | 4 +++- .../peertube/activities/ShowAccountActivity.java | 3 ++- .../peertube/activities/ShowChannelActivity.java | 5 +++-- .../peertube/activities/VideosTimelineActivity.java | 5 +++-- .../android/peertube/drawer/AboutInstanceAdapter.java | 6 ++++-- .../android/peertube/drawer/ChannelListAdapter.java | 6 ++++-- .../android/peertube/drawer/CommentListAdapter.java | 10 ++++++---- .../android/peertube/drawer/PeertubeAdapter.java | 8 +++++--- .../android/peertube/drawer/PlaylistAdapter.java | 7 +++++-- .../peertube/fragment/DisplayChannelsFragment.java | 4 +++- .../peertube/fragment/DisplayPlaylistsFragment.java | 4 +++- .../app/fedilab/android/peertube/helper/Helper.java | 5 +++-- .../android/peertube/helper/SwitchAccountHelper.java | 4 +++- 20 files changed, 69 insertions(+), 39 deletions(-) diff --git a/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java b/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java index 956e7f89..a5c29d7a 100644 --- a/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java +++ b/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java @@ -30,6 +30,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.google.android.exoplayer2.ExoPlayer; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.jetbrains.annotations.NotNull; @@ -96,7 +97,7 @@ public class BasePeertubeActivity extends BaseBarActivity { if (item.getItemId() == R.id.action_cast) { if (PeertubeBaseMainActivity.chromeCasts != null && PeertubeBaseMainActivity.chromeCasts.size() > 0) { String[] chromecast_choice = new String[PeertubeBaseMainActivity.chromeCasts.size()]; - AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); + AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); alt_bld.setTitle(R.string.chromecast_choice); int i = 0; for (ChromeCast cc : PeertubeBaseMainActivity.chromeCasts) { diff --git a/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java b/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java index aef21de7..77ca77bd 100644 --- a/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java +++ b/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java @@ -23,7 +23,6 @@ import android.os.Handler; import android.os.Looper; import android.view.View; -import androidx.appcompat.app.AppCompatActivity; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import java.io.IOException; @@ -36,6 +35,7 @@ import java.util.List; import app.fedilab.android.R; import app.fedilab.android.databinding.ActivityMainPeertubeBinding; +import app.fedilab.android.mastodon.activities.BaseActivity; import app.fedilab.android.peertube.client.data.VideoData; import app.fedilab.android.peertube.helper.Helper; import su.litvak.chromecast.api.v2.ChromeCast; @@ -43,7 +43,7 @@ import su.litvak.chromecast.api.v2.ChromeCasts; import su.litvak.chromecast.api.v2.ChromeCastsListener; import su.litvak.chromecast.api.v2.MediaStatus; -public abstract class PeertubeBaseMainActivity extends AppCompatActivity implements ChromeCastsListener { +public abstract class PeertubeBaseMainActivity extends BaseActivity implements ChromeCastsListener { public static List chromeCasts; public static ChromeCast chromeCast; diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/AllPlaylistsActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/AllPlaylistsActivity.java index 684800b6..90573175 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/AllPlaylistsActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/AllPlaylistsActivity.java @@ -47,6 +47,7 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.load.resource.bitmap.CenterCrop; import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.request.RequestOptions; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import java.util.ArrayList; import java.util.HashMap; @@ -160,7 +161,7 @@ public class AllPlaylistsActivity extends BaseBarActivity implements PlaylistAda public void manageAlert(Playlist playlistParam) { playlistToEdit = playlistParam; - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(AllPlaylistsActivity.this); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(AllPlaylistsActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); bindingDialog = AddPlaylistPeertubeBinding.inflate(LayoutInflater.from(AllPlaylistsActivity.this), null, false); dialogBuilder.setView(bindingDialog.getRoot()); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/InstancePickerActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/InstancePickerActivity.java index cab8aef6..0505ebf4 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/InstancePickerActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/InstancePickerActivity.java @@ -32,6 +32,8 @@ import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; @@ -106,7 +108,7 @@ public class InstancePickerActivity extends BaseBarActivity { itemsKeyLanguage = new String[languages.size()]; binding.pickupLanguages.setOnClickListener(v -> { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(InstancePickerActivity.this); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(InstancePickerActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); int i = 0; if (languages.size() > 0) { @@ -173,7 +175,7 @@ public class InstancePickerActivity extends BaseBarActivity { binding.pickupCategories.setOnClickListener(v -> { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(InstancePickerActivity.this); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(InstancePickerActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); int i = 0; if (categories.size() > 0) { Iterator> it = categories.entrySet().iterator(); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java index a6360188..a6bfa899 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java @@ -108,6 +108,7 @@ import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.VideoSize; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; import org.jetbrains.annotations.NotNull; @@ -674,7 +675,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis } private void reportAlert(RetrofitPeertubeAPI.ActionType type, AlertDialog alertDialog) { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(PeertubeActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); LayoutInflater inflater1 = getLayoutInflater(); View dialogView = inflater1.inflate(R.layout.popup_report_peertube, new LinearLayout(PeertubeActivity.this), false); dialogBuilder.setView(dialogView); @@ -874,7 +875,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis }); binding.videoInformation.setOnClickListener(v -> { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(PeertubeActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.popup_video_info_peertube, new LinearLayout(PeertubeActivity.this), false); TextView info_privacy = dialogView.findViewById(R.id.info_privacy); @@ -1111,7 +1112,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis } else if (itemId == R.id.action_report) { AlertDialog alertDialog; AlertDialog.Builder dialogBuilder; - dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this); + dialogBuilder = new MaterialAlertDialogBuilder(PeertubeActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); LayoutInflater inflater1 = getLayoutInflater(); View dialogView = inflater1.inflate(R.layout.popup_report_choice, new LinearLayout(PeertubeActivity.this), false); dialogBuilder.setView(dialogView); @@ -1243,7 +1244,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (promptNSFW && peertube != null && peertube.isNsfw() && (nsfwAction.compareTo(Helper.BLUR) == 0 || nsfwAction.compareTo(Helper.DO_NOT_LIST) == 0)) { AlertDialog alertDialog; AlertDialog.Builder dialogBuilder; - dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this); + dialogBuilder = new MaterialAlertDialogBuilder(PeertubeActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); dialogBuilder.setTitle(R.string.nsfw_title_warning); dialogBuilder.setCancelable(false); dialogBuilder.setMessage(R.string.nsfw_message_warning); @@ -2035,7 +2036,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis return; } if (apiResponse.getPlaylists() != null && apiResponse.getPlaylists().size() > 0) { - AlertDialog.Builder builder = new AlertDialog.Builder(PeertubeActivity.this); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(PeertubeActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); builder.setTitle(R.string.modify_playlists); List ownerPlaylists = apiResponse.getPlaylists(); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeEditUploadActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeEditUploadActivity.java index d7140026..87fb1aa4 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeEditUploadActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeEditUploadActivity.java @@ -43,6 +43,7 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.load.resource.bitmap.CenterCrop; import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.request.RequestOptions; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import java.util.Iterator; import java.util.LinkedHashMap; @@ -108,7 +109,7 @@ public class PeertubeEditUploadActivity extends BaseBarActivity { binding.setUploadDelete.setOnClickListener(v -> { AlertDialog.Builder builderInner; - builderInner = new AlertDialog.Builder(PeertubeEditUploadActivity.this); + builderInner = new MaterialAlertDialogBuilder(PeertubeEditUploadActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); builderInner.setMessage(getString(R.string.delete_video_confirmation)); builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); builderInner.setPositiveButton(R.string.yes, (dialog, which) -> { diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java index 1b8ca1b6..0c30d991 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java @@ -60,6 +60,7 @@ import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; import com.google.android.material.bottomnavigation.BottomNavigationView; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.kobakei.ratethisapp.RateThisApp; import org.jetbrains.annotations.NotNull; @@ -141,7 +142,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity { @SuppressLint("ApplySharedPref") public static void showRadioButtonDialogFullInstances(Activity activity, boolean storeInDb) { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity); - AlertDialog.Builder alt_bld = new AlertDialog.Builder(activity); + AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(activity, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); alt_bld.setTitle(R.string.instance_choice); String instance = HelperInstance.getLiveInstance(activity); final EditText input = new EditText(activity); @@ -577,7 +578,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity { instanceConfig = new RetrofitPeertubeAPI(PeertubeMainActivity.this).getConfigInstance(); } catch (Error error) { runOnUiThread(() -> { - AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); + AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); alt_bld.setTitle(R.string.refresh_token_failed); alt_bld.setMessage(R.string.refresh_token_failed_message); alt_bld.setNegativeButton(R.string.action_logout, (dialog, id) -> { @@ -710,7 +711,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity { @SuppressLint("ApplySharedPref") private void showRadioButtonDialog() { - AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); + AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); alt_bld.setTitle(R.string.instance_choice); final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this); String acad = HelperInstance.getLiveInstance(PeertubeMainActivity.this); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeRegisterActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeRegisterActivity.java index e8d3936f..021791f5 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeRegisterActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeRegisterActivity.java @@ -31,6 +31,8 @@ import android.widget.TextView; import androidx.appcompat.app.AlertDialog; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -184,7 +186,7 @@ public class PeertubeRegisterActivity extends BaseBarActivity { return; } - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PeertubeRegisterActivity.this); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(PeertubeRegisterActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); dialogBuilder.setCancelable(false); dialogBuilder.setPositiveButton(R.string.validate, (dialog, which) -> { dialog.dismiss(); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/ShowAccountActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/ShowAccountActivity.java index e4888812..97093aa1 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/ShowAccountActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/ShowAccountActivity.java @@ -42,6 +42,7 @@ import androidx.lifecycle.ViewModelProvider; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.tabs.TabLayout; import org.jetbrains.annotations.NotNull; @@ -120,7 +121,7 @@ public class ShowAccountActivity extends BaseBarActivity { PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class); viewModel.post(MUTE, accountAcct == null ? account.getUsername() + "@" + account.getHost() : accountAcct, null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(MUTE, apiResponse)); } else if (item.getItemId() == R.id.action_report) { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ShowAccountActivity.this); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(ShowAccountActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); LayoutInflater inflater1 = getLayoutInflater(); View dialogView = inflater1.inflate(R.layout.popup_report_peertube, new LinearLayout(ShowAccountActivity.this), false); dialogBuilder.setView(dialogView); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/ShowChannelActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/ShowChannelActivity.java index 04be2a31..fb451d85 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/ShowChannelActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/ShowChannelActivity.java @@ -50,6 +50,7 @@ import androidx.preference.PreferenceManager; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.tabs.TabLayout; import org.jetbrains.annotations.NotNull; @@ -133,7 +134,7 @@ public class ShowChannelActivity extends BaseBarActivity { PostActionsVM viewModel = new ViewModelProvider(ShowChannelActivity.this).get(PostActionsVM.class); viewModel.post(MUTE, channel.getOwnerAccount().getAcct(), null).observe(ShowChannelActivity.this, apiResponse -> manageVIewPostActions(MUTE, apiResponse)); } else if (item.getItemId() == R.id.action_report) { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ShowChannelActivity.this); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(ShowChannelActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); LayoutInflater inflater1 = getLayoutInflater(); View dialogView = inflater1.inflate(R.layout.popup_report_peertube, new LinearLayout(ShowChannelActivity.this), false); dialogBuilder.setView(dialogView); @@ -264,7 +265,7 @@ public class ShowChannelActivity extends BaseBarActivity { } else if (doAction == action.UNFOLLOW) { boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true); if (confirm_unfollow) { - AlertDialog.Builder unfollowConfirm = new AlertDialog.Builder(ShowChannelActivity.this); + AlertDialog.Builder unfollowConfirm = new MaterialAlertDialogBuilder(ShowChannelActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); unfollowConfirm.setTitle(getString(R.string.unfollow_confirm)); unfollowConfirm.setMessage(channel.getAcct()); unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/VideosTimelineActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/VideosTimelineActivity.java index 49dacfd1..dcff6809 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/VideosTimelineActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/VideosTimelineActivity.java @@ -16,7 +16,6 @@ package app.fedilab.android.peertube.activities; import static app.fedilab.android.peertube.viewmodel.TimelineVM.TimelineType.HISTORY; -import android.app.AlertDialog; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -25,6 +24,8 @@ import android.view.View; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import org.jetbrains.annotations.NotNull; import java.text.SimpleDateFormat; @@ -144,7 +145,7 @@ public class VideosTimelineActivity extends BaseBarActivity { finish(); return true; } else if (item.getItemId() == R.id.action_delete) { - AlertDialog.Builder builder = new AlertDialog.Builder(VideosTimelineActivity.this); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(VideosTimelineActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); builder.setTitle(R.string.delete_history); builder.setMessage(R.string.delete_history_confirm); builder.setIcon(android.R.drawable.ic_dialog_alert) diff --git a/app/src/main/java/app/fedilab/android/peertube/drawer/AboutInstanceAdapter.java b/app/src/main/java/app/fedilab/android/peertube/drawer/AboutInstanceAdapter.java index c9fc4199..ba2ea933 100644 --- a/app/src/main/java/app/fedilab/android/peertube/drawer/AboutInstanceAdapter.java +++ b/app/src/main/java/app/fedilab/android/peertube/drawer/AboutInstanceAdapter.java @@ -17,10 +17,10 @@ package app.fedilab.android.peertube.drawer; import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE; +import static app.fedilab.android.mastodon.helper.Helper.dialogStyle; import android.annotation.SuppressLint; import android.app.Activity; -import android.app.AlertDialog; import android.content.Context; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; @@ -40,6 +40,8 @@ import androidx.appcompat.widget.PopupMenu; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import java.util.List; import app.fedilab.android.R; @@ -141,7 +143,7 @@ public class AboutInstanceAdapter extends RecyclerView.Adapter { int itemId = item.getItemId(); if (itemId == R.id.action_delete) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context, dialogStyle()); builder.setTitle(R.string.delete_instance); builder.setMessage(R.string.delete_instance_confirm); builder.setIcon(android.R.drawable.ic_dialog_alert) diff --git a/app/src/main/java/app/fedilab/android/peertube/drawer/ChannelListAdapter.java b/app/src/main/java/app/fedilab/android/peertube/drawer/ChannelListAdapter.java index 0a28a668..3d5a1082 100644 --- a/app/src/main/java/app/fedilab/android/peertube/drawer/ChannelListAdapter.java +++ b/app/src/main/java/app/fedilab/android/peertube/drawer/ChannelListAdapter.java @@ -16,8 +16,8 @@ package app.fedilab.android.peertube.drawer; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE; +import static app.fedilab.android.mastodon.helper.Helper.dialogStyle; -import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -37,6 +37,8 @@ import androidx.appcompat.widget.PopupMenu; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import java.util.List; import app.fedilab.android.R; @@ -93,7 +95,7 @@ public class ChannelListAdapter extends RecyclerView.Adapter { int itemId = item.getItemId(); if (itemId == R.id.action_delete) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context, dialogStyle()); builder.setTitle(context.getString(R.string.delete_channel) + ": " + channel.getName()); builder.setMessage(context.getString(R.string.action_channel_confirm_delete)); builder.setIcon(android.R.drawable.ic_dialog_alert) diff --git a/app/src/main/java/app/fedilab/android/peertube/drawer/CommentListAdapter.java b/app/src/main/java/app/fedilab/android/peertube/drawer/CommentListAdapter.java index fc449543..02155247 100644 --- a/app/src/main/java/app/fedilab/android/peertube/drawer/CommentListAdapter.java +++ b/app/src/main/java/app/fedilab/android/peertube/drawer/CommentListAdapter.java @@ -14,12 +14,12 @@ package app.fedilab.android.peertube.drawer; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ +import static app.fedilab.android.mastodon.helper.Helper.dialogStyle; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.MUTE; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPLY; import android.annotation.SuppressLint; import android.app.Activity; -import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.os.Build; @@ -49,6 +49,8 @@ import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelStoreOwner; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -159,8 +161,9 @@ public class CommentListAdapter extends RecyclerView.Adapter { int itemId = item.getItemId(); + MaterialAlertDialogBuilder builder; if (itemId == R.id.action_delete) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder = new MaterialAlertDialogBuilder(context, dialogStyle()); builder.setTitle(R.string.delete_comment); builder.setMessage(R.string.delete_comment_confirm); builder.setIcon(android.R.drawable.ic_dialog_alert) @@ -193,8 +196,7 @@ public class CommentListAdapter extends RecyclerView.Adapter. */ +import static app.fedilab.android.mastodon.helper.Helper.dialogStyle; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.FOLLOW; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.UNFOLLOW; import static app.fedilab.android.peertube.viewmodel.TimelineVM.TimelineType.MY_VIDEOS; @@ -50,6 +51,7 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.transition.Transition; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import java.util.ArrayList; import java.util.List; @@ -227,7 +229,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter dialog.dismiss()); @@ -257,7 +259,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter 0) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(context, dialogStyle()); builder.setTitle(R.string.modify_playlists); List ownerPlaylists = apiResponse.getPlaylists(); diff --git a/app/src/main/java/app/fedilab/android/peertube/drawer/PlaylistAdapter.java b/app/src/main/java/app/fedilab/android/peertube/drawer/PlaylistAdapter.java index be5187f4..fa000a0a 100644 --- a/app/src/main/java/app/fedilab/android/peertube/drawer/PlaylistAdapter.java +++ b/app/src/main/java/app/fedilab/android/peertube/drawer/PlaylistAdapter.java @@ -15,8 +15,9 @@ package app.fedilab.android.peertube.drawer; * see . */ +import static app.fedilab.android.mastodon.helper.Helper.dialogStyle; + import android.annotation.SuppressLint; -import android.app.AlertDialog; import android.content.Context; import android.view.LayoutInflater; import android.view.View; @@ -29,6 +30,8 @@ import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelStoreOwner; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import java.util.List; import app.fedilab.android.R; @@ -102,7 +105,7 @@ public class PlaylistAdapter extends RecyclerView.Adapter { int itemId = item.getItemId(); if (itemId == R.id.action_delete) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context, dialogStyle()); builder.setTitle(context.getString(R.string.action_lists_delete) + ": " + playlist.getDisplayName()); builder.setMessage(context.getString(R.string.action_lists_confirm_delete)); builder.setIcon(android.R.drawable.ic_dialog_alert) diff --git a/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayChannelsFragment.java b/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayChannelsFragment.java index e1eafd7b..d70976c4 100644 --- a/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayChannelsFragment.java +++ b/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayChannelsFragment.java @@ -14,6 +14,7 @@ package app.fedilab.android.peertube.fragment; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ +import static app.fedilab.android.mastodon.helper.Helper.dialogStyle; import static app.fedilab.android.peertube.activities.PeertubeUploadActivity.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE; import android.Manifest; @@ -46,6 +47,7 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.load.resource.bitmap.CenterCrop; import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.request.RequestOptions; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.floatingactionbutton.FloatingActionButton; import java.util.ArrayList; @@ -234,7 +236,7 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap public void manageAlert(ChannelParams oldChannelValues) { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(context, dialogStyle()); bindingDialog = AddChannelPeertubeBinding.inflate(LayoutInflater.from(context), null, false); dialogBuilder.setView(bindingDialog.getRoot()); diff --git a/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayPlaylistsFragment.java b/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayPlaylistsFragment.java index 9ad50ae2..ed101621 100644 --- a/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayPlaylistsFragment.java +++ b/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayPlaylistsFragment.java @@ -14,6 +14,7 @@ package app.fedilab.android.peertube.fragment; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ +import static app.fedilab.android.mastodon.helper.Helper.dialogStyle; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.DataType.MY_CHANNELS; import static app.fedilab.android.peertube.helper.Helper.peertubeInformation; @@ -43,6 +44,7 @@ import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.floatingactionbutton.FloatingActionButton; import org.jetbrains.annotations.NotNull; @@ -120,7 +122,7 @@ public class DisplayPlaylistsFragment extends Fragment { if (add_new != null) { add_new.setOnClickListener(view -> { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(context, dialogStyle()); LayoutInflater inflater1 = ((Activity) context).getLayoutInflater(); View dialogView = inflater1.inflate(R.layout.add_playlist_peertube, new LinearLayout(context), false); dialogBuilder.setView(dialogView); diff --git a/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java b/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java index 93df21f9..ee4dcda2 100644 --- a/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java @@ -18,6 +18,7 @@ import static android.content.Context.DOWNLOAD_SERVICE; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN; +import static app.fedilab.android.mastodon.helper.Helper.dialogStyle; import static app.fedilab.android.peertube.activities.PeertubeMainActivity.typeOfConnection; import android.annotation.SuppressLint; @@ -500,7 +501,7 @@ public class Helper { * @param url String download url */ public static void manageDownloads(final Context context, final String url) { - final AlertDialog.Builder builder = new AlertDialog.Builder(context); + final AlertDialog.Builder builder = new MaterialAlertDialogBuilder(context, dialogStyle()); final DownloadManager.Request request; try { request = new DownloadManager.Request(Uri.parse(url.trim())); @@ -535,7 +536,7 @@ public class Helper { * @param currentAccount BaseAccount */ public static void logoutCurrentUser(Activity activity, BaseAccount currentAccount) { - AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(activity, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); + AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(activity, dialogStyle()); alt_bld.setTitle(R.string.action_logout); if (currentAccount.mastodon_account != null && currentAccount.mastodon_account.username != null && currentAccount.instance != null) { alt_bld.setMessage(activity.getString(R.string.logout_account_confirmation, currentAccount.mastodon_account.username, currentAccount.instance)); diff --git a/app/src/main/java/app/fedilab/android/peertube/helper/SwitchAccountHelper.java b/app/src/main/java/app/fedilab/android/peertube/helper/SwitchAccountHelper.java index 297656a2..7122ce35 100644 --- a/app/src/main/java/app/fedilab/android/peertube/helper/SwitchAccountHelper.java +++ b/app/src/main/java/app/fedilab/android/peertube/helper/SwitchAccountHelper.java @@ -26,6 +26,8 @@ import android.content.SharedPreferences; import androidx.appcompat.app.AlertDialog; import androidx.preference.PreferenceManager; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import java.util.List; import app.fedilab.android.R; @@ -47,7 +49,7 @@ public class SwitchAccountHelper { e.printStackTrace(); } - AlertDialog.Builder builderSingle = new AlertDialog.Builder(activity); + AlertDialog.Builder builderSingle = new MaterialAlertDialogBuilder(activity, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); builderSingle.setTitle(activity.getString(R.string.list_of_accounts)); if (accounts != null) { final OwnAccountsAdapter accountsListAdapter = new OwnAccountsAdapter(activity, accounts);