From cc04e08e7432920da712742804bde5f67b3391f7 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Mon, 13 Jul 2020 11:02:15 +0200 Subject: [PATCH] Added new icon poll --- .../de/test/antennapod/EspressoTestUtils.java | 7 ++++ .../antennapod/activity/MainActivity.java | 2 ++ .../antennapod/dialog/IconPollDialog.java | 35 +++++++++++++++++++ core/src/main/res/values/strings.xml | 6 ++++ 4 files changed, 50 insertions(+) create mode 100644 app/src/main/java/de/danoeh/antennapod/dialog/IconPollDialog.java diff --git a/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java b/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java index 41c8365fb..7b11e5b55 100644 --- a/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java +++ b/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java @@ -21,6 +21,7 @@ import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.storage.PodDBAdapter; +import de.danoeh.antennapod.dialog.IconPollDialog; import de.danoeh.antennapod.dialog.RatingDialog; import de.danoeh.antennapod.fragment.NavDrawerFragment; import org.awaitility.Awaitility; @@ -134,6 +135,12 @@ public class EspressoTestUtils { .putString(UserPreferences.PREF_UPDATE_INTERVAL, "0") .commit(); + InstrumentationRegistry.getInstrumentation().getTargetContext() + .getSharedPreferences(IconPollDialog.PREFS_NAME, Context.MODE_PRIVATE) + .edit() + .putBoolean(IconPollDialog.KEY_DIALOG_ALLOWED, false) + .commit(); + RatingDialog.init(InstrumentationRegistry.getTargetContext()); RatingDialog.saveRated(); } 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(); + } +} diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 93a21ef13..5082d7b10 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -828,4 +828,10 @@ Setting updated successfully. Looks like you stream a lot. Do you want episode lists to show stream buttons? Looks like you download a lot. Do you want episode lists to show download buttons? + + + New icon + Thank you for being a beta tester!\n\nTo celebrate the public release of version 2.0.0, we set up a vote for a new app icon. Vote now to help shape the future of AntennaPod! + Vote + Accept other user\'s vote