diff --git a/mastodon/build.gradle b/mastodon/build.gradle index 5d7eaa3f..6df80ffa 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.joinmastodon.android" minSdk 23 targetSdk 33 - versionCode 65 - versionName "2.0.4" + versionCode 66 + versionName "2.1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" resConfigs "ar-rSA", "be-rBY", "bn-rBD", "bs-rBA", "ca-rES", "cs-rCZ", "da-rDK", "de-rDE", "el-rGR", "es-rES", "eu-rES", "fa-rIR", "fi-rFI", "fil-rPH", "fr-rFR", "ga-rIE", "gd-rGB", "gl-rES", "hi-rIN", "hr-rHR", "hu-rHU", "hy-rAM", "ig-rNG", "in-rID", "is-rIS", "it-rIT", "iw-rIL", "ja-rJP", "kab", "ko-rKR", "my-rMM", "nl-rNL", "no-rNO", "oc-rFR", "pl-rPL", "pt-rBR", "pt-rPT", "ro-rRO", "ru-rRU", "si-rLK", "sl-rSI", "sv-rSE", "th-rTH", "tr-rTR", "uk-rUA", "ur-rIN", "vi-rVN", "zh-rCN", "zh-rTW" } diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/UpdateAccountCredentialsPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/UpdateAccountCredentialsPreferences.java index 686b64e3..eecebf50 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/UpdateAccountCredentialsPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/UpdateAccountCredentialsPreferences.java @@ -6,18 +6,19 @@ import org.joinmastodon.android.model.Preferences; import org.joinmastodon.android.model.StatusPrivacy; public class UpdateAccountCredentialsPreferences extends MastodonAPIRequest{ - public UpdateAccountCredentialsPreferences(Preferences preferences, Boolean locked, Boolean discoverable){ + public UpdateAccountCredentialsPreferences(Preferences preferences, Boolean locked, Boolean discoverable, Boolean indexable){ super(HttpMethod.PATCH, "/accounts/update_credentials", Account.class); - setRequestBody(new Request(locked, discoverable, new RequestSource(preferences.postingDefaultVisibility, preferences.postingDefaultLanguage))); + setRequestBody(new Request(locked, discoverable, indexable, new RequestSource(preferences.postingDefaultVisibility, preferences.postingDefaultLanguage))); } private static class Request{ - public Boolean locked, discoverable; + public Boolean locked, discoverable, indexable; public RequestSource source; - public Request(Boolean locked, Boolean discoverable, RequestSource source){ + public Request(Boolean locked, Boolean discoverable, Boolean indexable, RequestSource source){ this.locked=locked; this.discoverable=discoverable; + this.indexable=indexable; this.source=source; } } 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 a20c6ce1..576ecc59 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, null) + new UpdateAccountCredentialsPreferences(preferences, null, self.discoverable, !self.noindex) .setCallback(new Callback<>(){ @Override public void onSuccess(Account result){ @@ -261,4 +261,8 @@ public class AccountSession{ return false; }); } + + public void updateAccountInfo(){ + AccountSessionManager.getInstance().updateSessionLocalInfo(this); + } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java index ca26f57f..bff464b4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java @@ -279,7 +279,7 @@ public class AccountSessionManager{ } } - private void updateSessionLocalInfo(AccountSession session){ + /*package*/ void updateSessionLocalInfo(AccountSession session){ new GetOwnAccount() .setCallback(new Callback<>(){ @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsMainFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsMainFragment.java index 53504602..93ae3b82 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsMainFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsMainFragment.java @@ -52,6 +52,7 @@ public class SettingsMainFragment extends BaseSettingsFragment{ onDataLoaded(List.of( new ListItem<>(R.string.settings_behavior, 0, R.drawable.ic_settings_24px, this::onBehaviorClick), new ListItem<>(R.string.settings_display, 0, R.drawable.ic_style_24px, this::onDisplayClick), + new ListItem<>(R.string.settings_privacy, 0, R.drawable.ic_privacy_tip_24px, this::onPrivacyClick), new ListItem<>(R.string.settings_filters, 0, R.drawable.ic_filter_alt_24px, this::onFiltersClick), new ListItem<>(R.string.settings_notifications, 0, R.drawable.ic_notifications_24px, this::onNotificationsClick), new ListItem<>(AccountSessionManager.get(accountID).domain, getString(R.string.settings_server_explanation), R.drawable.ic_dns_24px, this::onServerClick), @@ -63,7 +64,9 @@ public class SettingsMainFragment extends BaseSettingsFragment{ data.add(0, new ListItem<>("Debug settings", null, R.drawable.ic_settings_24px, ()->Nav.go(getActivity(), SettingsDebugFragment.class, makeFragmentArgs()), null, 0, true)); } - AccountSessionManager.get(accountID).reloadPreferences(null); + AccountSession session=AccountSessionManager.get(accountID); + session.reloadPreferences(null); + session.updateAccountInfo(); E.register(this); } @@ -127,6 +130,10 @@ public class SettingsMainFragment extends BaseSettingsFragment{ Nav.go(getActivity(), SettingsDisplayFragment.class, makeFragmentArgs()); } + private void onPrivacyClick(){ + Nav.go(getActivity(), SettingsPrivacyFragment.class, makeFragmentArgs()); + } + private void onFiltersClick(){ Nav.go(getActivity(), SettingsFiltersFragment.class, makeFragmentArgs()); } 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 new file mode 100644 index 00000000..8bc98da8 --- /dev/null +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsPrivacyFragment.java @@ -0,0 +1,39 @@ +package org.joinmastodon.android.fragments.settings; + +import android.os.Bundle; + +import org.joinmastodon.android.R; +import org.joinmastodon.android.api.session.AccountSessionManager; +import org.joinmastodon.android.model.Account; +import org.joinmastodon.android.model.viewmodel.CheckableListItem; + +import java.util.List; + +public class SettingsPrivacyFragment extends BaseSettingsFragment{ + private CheckableListItem discoverableItem, indexableItem; + + @Override + public void onCreate(Bundle savedInstanceState){ + super.onCreate(savedInstanceState); + setTitle(R.string.settings_privacy); + 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)) + )); + } + + @Override + protected void doLoadData(int offset, int count){} + + @Override + public void onPause(){ + super.onPause(); + Account self=AccountSessionManager.get(accountID).self; + if(self.discoverable!=discoverableItem.checked || self.indexable!=indexableItem.checked){ + self.discoverable=discoverableItem.checked; + self.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 47d99bc3..54ad17de 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/Account.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/Account.java @@ -132,6 +132,9 @@ public class Account extends BaseModel{ * When a timed mute will expire, if applicable. */ public Instant muteExpiresAt; + public boolean noindex; + public boolean indexable; + public boolean hideCollections; @Override @@ -191,6 +194,9 @@ public class Account extends BaseModel{ ", source="+source+ ", suspended="+suspended+ ", muteExpiresAt="+muteExpiresAt+ + ", noindex="+noindex+ + ", indexable="+indexable+ + ", hideCollections="+hideCollections+ '}'; } } diff --git a/mastodon/src/main/res/drawable/ic_privacy_tip_24px.xml b/mastodon/src/main/res/drawable/ic_privacy_tip_24px.xml new file mode 100644 index 00000000..47e3c09e --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_privacy_tip_24px.xml @@ -0,0 +1,9 @@ + + + diff --git a/mastodon/src/main/res/drawable/ic_thumbs_up_down_24px.xml b/mastodon/src/main/res/drawable/ic_thumbs_up_down_24px.xml new file mode 100644 index 00000000..16056960 --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_thumbs_up_down_24px.xml @@ -0,0 +1,9 @@ + + + diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index 20b8593b..af28ff40 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -596,6 +596,9 @@ Translated from %1$s using %2$s Show original Translation failed. Maybe the administrator has not enabled translations on this server or this server is running an older version of Mastodon where translations are not yet supported. + Privacy and reach + Feature profile and posts in discovery algorithms + Include public posts in search results %,d participant