don't ask for 24h if user cancels dialog (eg clicking outside)
This commit is contained in:
@@ -160,6 +160,7 @@ public final class Constants {
|
|||||||
|
|
||||||
public static final String KEY_ANALYTICS_ASKED_POLITELY = "analytics_asked";
|
public static final String KEY_ANALYTICS_ASKED_POLITELY = "analytics_asked";
|
||||||
public static final String KEY_ANALYTICS_CONSENT = "analytics_consent";
|
public static final String KEY_ANALYTICS_CONSENT = "analytics_consent";
|
||||||
|
public static final String KEY_ANALYTICS_LAST_ASKED = "analytics_last_asked";
|
||||||
|
|
||||||
public static final class Theme {
|
public static final class Theme {
|
||||||
public static final String LIGHT = "light";
|
public static final String LIGHT = "light";
|
||||||
|
|||||||
@@ -284,7 +284,8 @@ public class KeyListFragment extends RecyclerFragment<FlexibleAdapter<FlexibleKe
|
|||||||
}
|
}
|
||||||
|
|
||||||
Preferences preferences = Preferences.getPreferences(context);
|
Preferences preferences = Preferences.getPreferences(context);
|
||||||
if (!Constants.DEBUG && !preferences.isAnalyticsHasConsent() && preferences.isAnalyticsAskedPolitely()) {
|
boolean askedBeforeAndWasRejected = preferences.isAnalyticsAskedPolitely() && !preferences.isAnalyticsHasConsent();
|
||||||
|
if (!Constants.DEBUG && askedBeforeAndWasRejected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,6 +300,14 @@ public class KeyListFragment extends RecyclerFragment<FlexibleAdapter<FlexibleKe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long twentyFourHoursAgo = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1);
|
||||||
|
boolean askedLessThan24HoursAgo = preferences.getAnalyticsLastAsked() > twentyFourHoursAgo;
|
||||||
|
if (askedLessThan24HoursAgo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
preferences.setAnalyticsLastAskedNow();
|
||||||
|
|
||||||
TrackingManager trackingManager = ((KeychainApplication) requireActivity().getApplication()).getTrackingManager();
|
TrackingManager trackingManager = ((KeychainApplication) requireActivity().getApplication()).getTrackingManager();
|
||||||
AlertDialog show = new Builder(context)
|
AlertDialog show = new Builder(context)
|
||||||
.setMessage(R.string.dialog_analytics_text)
|
.setMessage(R.string.dialog_analytics_text)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.util;
|
|||||||
|
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
@@ -369,6 +370,14 @@ public class Preferences {
|
|||||||
mSharedPreferences.edit().putBoolean(Pref.KEY_ANALYTICS_CONSENT, hasUserConsent).apply();
|
mSharedPreferences.edit().putBoolean(Pref.KEY_ANALYTICS_CONSENT, hasUserConsent).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAnalyticsLastAskedNow() {
|
||||||
|
mSharedPreferences.edit().putLong(Pref.KEY_ANALYTICS_LAST_ASKED, System.currentTimeMillis()).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAnalyticsLastAsked() {
|
||||||
|
return mSharedPreferences.getLong(Pref.KEY_ANALYTICS_LAST_ASKED, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public static abstract class CloudSearchPrefs implements Parcelable {
|
public static abstract class CloudSearchPrefs implements Parcelable {
|
||||||
public abstract boolean isKeyserverEnabled();
|
public abstract boolean isKeyserverEnabled();
|
||||||
|
|||||||
Reference in New Issue
Block a user