diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/preferences/UsageStatistics.java | 21 | ||||
-rw-r--r-- | core/src/main/res/layout/popup_bubble_view.xml | 4 |
2 files changed, 11 insertions, 14 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UsageStatistics.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UsageStatistics.java index a5b00b08c..9835f9894 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UsageStatistics.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UsageStatistics.java @@ -4,8 +4,6 @@ import android.content.Context; import android.content.SharedPreferences; import androidx.annotation.NonNull; -import java.util.Calendar; - /** * Collects statistics about the app usage. The statistics are used to allow on-demand configuration: * "Looks like you stream a lot. Do you want to toggle the 'Prefer streaming' setting?". @@ -22,8 +20,7 @@ public class UsageStatistics { private static final String PREF_DB_NAME = "UsageStatistics"; private static final float MOVING_AVERAGE_WEIGHT = 0.8f; private static final float MOVING_AVERAGE_BIAS_THRESHOLD = 0.1f; - private static final long ASK_AGAIN_LATER_DELAY = 1000 * 3600 * 24 * 10; // 10 days - private static final String SUFFIX_HIDDEN_UNTIL = "_hiddenUntil"; + private static final String SUFFIX_HIDDEN = "_hidden"; private static SharedPreferences prefs; public static final StatsAction ACTION_STREAM = new StatsAction("downloadVsStream", 0); @@ -49,16 +46,16 @@ public class UsageStatistics { } public static boolean hasSignificantBiasTo(StatsAction action) { - final float movingAverage = prefs.getFloat(action.type, 0.5f); - final long askAfter = prefs.getLong(action.type + SUFFIX_HIDDEN_UNTIL, 0); - return Math.abs(action.value - movingAverage) < MOVING_AVERAGE_BIAS_THRESHOLD - && Calendar.getInstance().getTimeInMillis() > askAfter; + if (prefs.getBoolean(action.type + SUFFIX_HIDDEN, false)) { + return false; + } else { + final float movingAverage = prefs.getFloat(action.type, 0.5f); + return Math.abs(action.value - movingAverage) < MOVING_AVERAGE_BIAS_THRESHOLD; + } } - public static void askAgainLater(StatsAction action) { - prefs.edit().putLong(action.type + SUFFIX_HIDDEN_UNTIL, - Calendar.getInstance().getTimeInMillis() + ASK_AGAIN_LATER_DELAY) - .apply(); + public static void doNotAskAgain(StatsAction action) { + prefs.edit().putBoolean(action.type + SUFFIX_HIDDEN, true).apply(); } public static final class StatsAction { diff --git a/core/src/main/res/layout/popup_bubble_view.xml b/core/src/main/res/layout/popup_bubble_view.xml index cc93bec72..7dee08eb5 100644 --- a/core/src/main/res/layout/popup_bubble_view.xml +++ b/core/src/main/res/layout/popup_bubble_view.xml @@ -23,7 +23,7 @@ <Button android:id="@+id/balloon_button_negative" android:layout_width="wrap_content" - android:layout_height="36dp" + android:layout_height="wrap_content" android:textColor="?attr/colorOnSecondary" android:text="@string/no" style="@style/Widget.MaterialComponents.Button.TextButton" /> @@ -31,7 +31,7 @@ <Button android:id="@+id/balloon_button_positive" android:layout_width="wrap_content" - android:layout_height="36dp" + android:layout_height="wrap_content" android:textColor="?attr/colorOnSecondary" android:text="@string/yes" style="@style/Widget.MaterialComponents.Button.TextButton" /> |