From cc04e08e7432920da712742804bde5f67b3391f7 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Mon, 13 Jul 2020 11:02:15 +0200 Subject: Added new icon poll --- .../danoeh/antennapod/activity/MainActivity.java | 2 ++ .../danoeh/antennapod/dialog/IconPollDialog.java | 35 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 app/src/main/java/de/danoeh/antennapod/dialog/IconPollDialog.java (limited to 'app/src/main') diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index eaa423708..8c8ce9522 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -32,6 +32,7 @@ import de.danoeh.antennapod.core.event.MessageEvent; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.core.util.download.AutoUpdateManager; +import de.danoeh.antennapod.dialog.IconPollDialog; import de.danoeh.antennapod.dialog.RatingDialog; import de.danoeh.antennapod.fragment.AddFeedFragment; import de.danoeh.antennapod.fragment.AudioPlayerFragment; @@ -315,6 +316,7 @@ public class MainActivity extends CastEnabledActivity { super.onStart(); EventBus.getDefault().register(this); RatingDialog.init(this); + IconPollDialog.showIfNeeded(this); if (lastTheme != UserPreferences.getNoTitleTheme()) { finish(); diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/IconPollDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/IconPollDialog.java new file mode 100644 index 000000000..70cf6dc78 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/dialog/IconPollDialog.java @@ -0,0 +1,35 @@ +package de.danoeh.antennapod.dialog; + +import android.content.Context; +import android.content.SharedPreferences; +import androidx.appcompat.app.AlertDialog; +import de.danoeh.antennapod.R; +import de.danoeh.antennapod.core.util.IntentUtils; + +public class IconPollDialog { + + private IconPollDialog() { + + } + + public static final String PREFS_NAME = "IconPollDialog"; + public static final String KEY_DIALOG_ALLOWED = "dialog_allowed"; + + public static void showIfNeeded(Context context) { + SharedPreferences preferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); + + if (!preferences.getBoolean(KEY_DIALOG_ALLOWED, true)) { + return; + } + + new AlertDialog.Builder(context) + .setTitle(R.string.icon_poll_title) + .setMessage(R.string.icon_poll_message) + .setCancelable(false) + .setPositiveButton(R.string.icon_poll_vote, (dialog, which) -> + IntentUtils.openInBrowser(context, "https://www.surveymonkey.com/r/96WSBLC")) + .setNegativeButton(R.string.icon_poll_dont_vote, null) + .setOnDismissListener(dialog -> preferences.edit().putBoolean(KEY_DIALOG_ALLOWED, false).apply()) + .show(); + } +} -- cgit v1.2.3