From fe1cfa1d7bb1a6f9fa861ed6c28180e45ddebf0c Mon Sep 17 00:00:00 2001 From: Grishka Date: Fri, 22 Sep 2023 21:33:21 +0300 Subject: [PATCH] Fix indexable setting --- .../joinmastodon/android/api/session/AccountSession.java | 2 +- .../fragments/settings/SettingsPrivacyFragment.java | 8 +++++--- .../main/java/org/joinmastodon/android/model/Account.java | 4 ---- .../main/java/org/joinmastodon/android/model/Source.java | 4 ++++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java index 576ecc59b..deb6ed433 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java @@ -195,7 +195,7 @@ public class AccountSession{ public void savePreferencesIfPending(){ if(preferencesNeedSaving){ - new UpdateAccountCredentialsPreferences(preferences, null, self.discoverable, !self.noindex) + new UpdateAccountCredentialsPreferences(preferences, null, self.discoverable, self.source.indexable) .setCallback(new Callback<>(){ @Override public void onSuccess(Account result){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsPrivacyFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsPrivacyFragment.java index 8bc98da82..743dd97ab 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsPrivacyFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsPrivacyFragment.java @@ -19,8 +19,10 @@ public class SettingsPrivacyFragment extends BaseSettingsFragment{ Account self=AccountSessionManager.get(accountID).self; onDataLoaded(List.of( discoverableItem=new CheckableListItem<>(R.string.settings_discoverable, 0, CheckableListItem.Style.SWITCH, self.discoverable, R.drawable.ic_thumbs_up_down_24px, ()->toggleCheckableItem(discoverableItem)), - indexableItem=new CheckableListItem<>(R.string.settings_indexable, 0, CheckableListItem.Style.SWITCH, self.indexable, R.drawable.ic_search_24px, ()->toggleCheckableItem(indexableItem)) + indexableItem=new CheckableListItem<>(R.string.settings_indexable, 0, CheckableListItem.Style.SWITCH, self.source.indexable!=null ? self.source.indexable : true, R.drawable.ic_search_24px, ()->toggleCheckableItem(indexableItem)) )); + if(self.source.indexable==null) + indexableItem.isEnabled=false; } @Override @@ -30,9 +32,9 @@ public class SettingsPrivacyFragment extends BaseSettingsFragment{ public void onPause(){ super.onPause(); Account self=AccountSessionManager.get(accountID).self; - if(self.discoverable!=discoverableItem.checked || self.indexable!=indexableItem.checked){ + if(self.discoverable!=discoverableItem.checked || (self.source.indexable!=null && self.source.indexable!=indexableItem.checked)){ self.discoverable=discoverableItem.checked; - self.indexable=indexableItem.checked; + self.source.indexable=indexableItem.checked; AccountSessionManager.get(accountID).savePreferencesLater(); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/Account.java b/mastodon/src/main/java/org/joinmastodon/android/model/Account.java index 54ad17de0..b12a1dae5 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/Account.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/Account.java @@ -133,8 +133,6 @@ public class Account extends BaseModel{ */ public Instant muteExpiresAt; public boolean noindex; - public boolean indexable; - public boolean hideCollections; @Override @@ -195,8 +193,6 @@ public class Account extends BaseModel{ ", suspended="+suspended+ ", muteExpiresAt="+muteExpiresAt+ ", noindex="+noindex+ - ", indexable="+indexable+ - ", hideCollections="+hideCollections+ '}'; } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/Source.java b/mastodon/src/main/java/org/joinmastodon/android/model/Source.java index 6307d0ccd..49095611b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/Source.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/Source.java @@ -37,6 +37,8 @@ public class Source extends BaseModel{ * The number of pending follow requests. */ public int followRequestCount; + public Boolean indexable; + public boolean hideCollections; @Override public void postprocess() throws ObjectValidationException{ @@ -54,6 +56,8 @@ public class Source extends BaseModel{ ", sensitive="+sensitive+ ", language='"+language+'\''+ ", followRequestCount="+followRequestCount+ + ", indexable="+indexable+ + ", hideCollections="+hideCollections+ '}'; } }