forked from mastodon/mastodon-android
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
1,222 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...a/org/joinmastodon/android/api/requests/accounts/UpdateAccountCredentialsPreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.joinmastodon.android.api.requests.accounts; | ||
|
||
import org.joinmastodon.android.api.MastodonAPIRequest; | ||
import org.joinmastodon.android.model.Account; | ||
import org.joinmastodon.android.model.Preferences; | ||
import org.joinmastodon.android.model.StatusPrivacy; | ||
|
||
public class UpdateAccountCredentialsPreferences extends MastodonAPIRequest<Account>{ | ||
public UpdateAccountCredentialsPreferences(Preferences preferences, Boolean locked, Boolean discoverable){ | ||
super(HttpMethod.PATCH, "/accounts/update_credentials", Account.class); | ||
setRequestBody(new Request(locked, discoverable, new RequestSource(preferences.postingDefaultVisibility, preferences.postingDefaultLanguage))); | ||
} | ||
|
||
private static class Request{ | ||
public Boolean locked, discoverable; | ||
public RequestSource source; | ||
|
||
public Request(Boolean locked, Boolean discoverable, RequestSource source){ | ||
this.locked=locked; | ||
this.discoverable=discoverable; | ||
this.source=source; | ||
} | ||
} | ||
|
||
private static class RequestSource{ | ||
public StatusPrivacy privacy; | ||
public String language; | ||
|
||
public RequestSource(StatusPrivacy privacy, String language){ | ||
this.privacy=privacy; | ||
this.language=language; | ||
} | ||
} | ||
} |
17 changes: 6 additions & 11 deletions
17
mastodon/src/main/java/org/joinmastodon/android/api/requests/markers/GetMarkers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
package org.joinmastodon.android.api.requests.markers; | ||
|
||
import org.joinmastodon.android.api.ApiUtils; | ||
import org.joinmastodon.android.api.MastodonAPIRequest; | ||
import org.joinmastodon.android.model.Marker; | ||
import org.joinmastodon.android.model.Markers; | ||
import org.joinmastodon.android.model.TimelineMarkers; | ||
|
||
import java.util.EnumSet; | ||
|
||
public class GetMarkers extends MastodonAPIRequest<Markers> { | ||
public GetMarkers(EnumSet<Marker.Type> timelines) { | ||
super(HttpMethod.GET, "/markers", Markers.class); | ||
for (String type : ApiUtils.enumSetToStrings(timelines, Marker.Type.class)){ | ||
addQueryParameter("timeline[]", type); | ||
} | ||
public class GetMarkers extends MastodonAPIRequest<TimelineMarkers> { | ||
public GetMarkers(){ | ||
super(HttpMethod.GET, "/markers", TimelineMarkers.class); | ||
addQueryParameter("timeline[]", "home"); | ||
addQueryParameter("timeline[]", "notifications"); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
mastodon/src/main/java/org/joinmastodon/android/api/session/AccountLocalPreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.joinmastodon.android.api.session; | ||
|
||
import android.content.SharedPreferences; | ||
|
||
public class AccountLocalPreferences{ | ||
private final SharedPreferences prefs; | ||
|
||
public boolean showInteractionCounts; | ||
public boolean customEmojiInNames; | ||
public boolean showCWs; | ||
public boolean hideSensitiveMedia; | ||
public boolean serverSideFiltersSupported; | ||
|
||
public AccountLocalPreferences(SharedPreferences prefs){ | ||
this.prefs=prefs; | ||
showInteractionCounts=prefs.getBoolean("interactionCounts", true); | ||
customEmojiInNames=prefs.getBoolean("emojiInNames", true); | ||
showCWs=prefs.getBoolean("showCWs", true); | ||
hideSensitiveMedia=prefs.getBoolean("hideSensitive", true); | ||
serverSideFiltersSupported=prefs.getBoolean("serverSideFilters", false); | ||
} | ||
|
||
public long getNotificationsPauseEndTime(){ | ||
return prefs.getLong("notificationsPauseTime", 0L); | ||
} | ||
|
||
public void setNotificationsPauseEndTime(long time){ | ||
prefs.edit().putLong("notificationsPauseTime", time).apply(); | ||
} | ||
|
||
public void save(){ | ||
prefs.edit() | ||
.putBoolean("interactionCounts", showInteractionCounts) | ||
.putBoolean("emojiInNames", customEmojiInNames) | ||
.putBoolean("showCWs", showCWs) | ||
.putBoolean("hideSensitive", hideSensitiveMedia) | ||
.putBoolean("serverSideFilters", serverSideFiltersSupported) | ||
.apply(); | ||
} | ||
} |
Oops, something went wrong.