Skip to content

Commit cbb3010

Browse files
authored
Merge pull request #1646 from Automattic/update/add-was-sustainer-preference
Add check for was_sustainer property to verify sustainer status
2 parents 3d41b68 + ba17ed1 commit cbb3010

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Simplenote/src/main/java/com/automattic/simplenote/PreferencesFragment.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,8 @@ public boolean onPreferenceClick(Preference preference) {
243243

244244
final SwitchPreferenceCompat sustainerIconPreference = findPreference("pref_key_sustainer_icon");
245245
try {
246-
if (
247-
mPreferencesBucket.get(PREFERENCES_OBJECT_KEY).getCurrentSubscriptionPlatform() != null &&
248-
Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
249-
) {
246+
boolean wasSustainer = mPreferencesBucket.get(PREFERENCES_OBJECT_KEY).getWasSustainer();
247+
if (wasSustainer && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
250248
sustainerIconPreference.setVisible(true);
251249
sustainerIconPreference.setOnPreferenceChangeListener((preference, newValue) -> {
252250
toggleSustainerAppIcon((boolean) newValue);

Simplenote/src/main/java/com/automattic/simplenote/models/Preferences.java

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class Preferences extends BucketObject {
1919
private static final String SUBSCRIPTION_LEVEL_KEY = "subscription_level";
2020
private static final String SUBSCRIPTION_PLATFORM_KEY = "subscription_platform";
2121
private static final String SUBSCRIPTION_DATE_KEY = "subscription_date";
22+
private static final String WAS_SUSTAINER_KEY = "was_sustainer";
2223

2324
private Preferences(String key, JSONObject properties) {
2425
super(key, properties);
@@ -115,6 +116,15 @@ public void setSubscriptionLevel(SubscriptionLevel subscriptionLevel) {
115116
setProperty(SUBSCRIPTION_LEVEL_KEY, subscriptionLevel.getName());
116117
}
117118

119+
public boolean getWasSustainer() {
120+
Object wasSustainer = getProperty(WAS_SUSTAINER_KEY);
121+
if (wasSustainer == null) {
122+
return false;
123+
}
124+
125+
return (Boolean)getProperty(WAS_SUSTAINER_KEY);
126+
}
127+
118128
public static class Schema extends BucketSchema<Preferences> {
119129

120130
public Schema() {

0 commit comments

Comments
 (0)