diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index 39fb4ca8..1b13a2f8 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -1025,7 +1025,6 @@ public class MainActivity extends AppCompatActivity break; } - case R.id.nav_exit: { moveTaskToBack(true); finish(); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java index 56249843..990c77d7 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java @@ -1,10 +1,30 @@ +/* + This file is part of the Diaspora for Android. + + Diaspora for Android is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Diaspora for Android is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the Diaspora for Android. + + If not, see . + */ package com.github.dfa.diaspora_android.util; import com.github.dfa.diaspora_android.data.AppSettings; /** - * Created by vanitas on 10.08.16. + * Helper class that provides easy access to specific urls related to diaspora + * Created by vanitasvitae on 10.08.16. */ +@SuppressWarnings("unused") public class DiasporaUrlHelper { private AppSettings settings; @@ -31,66 +51,142 @@ public class DiasporaUrlHelper { this.settings = settings; } + /** + * Return a https url of the pod set in AppSettings. + * Eg. https://pod.geraspora.de + * @return https://(pod-domain.tld) + */ public String getPodUrl() { return HTTPS+settings.getPodDomain(); } + /** + * Return a https url that points to the stream of the configured diaspora account + * @return https://(pod-domain.tld)/stream + */ public String getStreamUrl() { return getPodUrl()+SUBURL_STREAM; } + /** + * Return a https url that points to the notifications feed of the configured diaspora account + * @return https://(pod-domain.tld)/notifications + */ public String getNotificationsUrl() { return getPodUrl()+SUBURL_NOTIFICATIONS; } - public String getPostsUrl() { - return getPodUrl()+SUBURL_POSTS; + /** + * Returns a https url that points to the post with the id postId + * @return https://(pod-domain.tld)/posts/(postId) + */ + public String getPostsUrl(long postId) { + return getPodUrl()+SUBURL_POSTS+postId; } + /** + * Return a https url that points to the conversations overview of the registered diaspora account + * @return https://(pod-domain.tld)/conversations + */ public String getConversationsUrl() { return getPodUrl()+SUBURL_CONVERSATIONS; } + /** + * Return a https url that points to the new-post form that lets the user create a new post + * @return https://(pod-domain.tld)/status_messages/new + */ public String getNewPostUrl() { return getPodUrl()+SUBURL_NEW_POST; } + /** + * Return a https url that shows the profile of the currently registered diaspora account + * @return https://(pod-domain.tld)/people/(profileId) + */ public String getProfileUrl() { return getPodUrl()+SUBURL_PEOPLE+settings.getProfileId(); } + /** + * Return a https url that shows the profile of the user with user id profileId + * @param profileId Id of the profile to be shown + * @return https://(pod-domain.tld)/people/(profileId) + */ + public String getProfileUrl(long profileId) { + return getPodUrl()+SUBURL_PEOPLE+profileId; + } + + /** + * Return a https url that points to the activities feed of the currently registered diaspora account + * @return https://(pod-domain.tld)/activity + */ public String getActivityUrl() { return getPodUrl()+SUBURL_ACTIVITY; } + /** + * Return a https url that points to the feed of posts that were liked by the currently registered diaspora account + * @return https://(pod-domain.tld)/liked + */ public String getLikedPostsUrl() { return getPodUrl()+SUBURL_LIKED; } + /** + * Return a https url that points to the stream of posts that were commented by the currently registered diaspora account + * @return https://(pod-domain.tld)/commented + */ public String getCommentedUrl() { return getPodUrl()+SUBURL_COMMENTED; } + /** + * Return a https url that points to the stream of posts in which the currently registered diaspora account has been mentioned in + * @return https://(pod-domain.tld)/mentions + */ public String getMentionsUrl() { return getPodUrl()+SUBURL_MENTIONS; } + /** + * Return a https url that points to the stream of public posts + * @return https://(pod-domain.tld)/public + */ public String getPublicUrl() { return getPodUrl()+SUBURL_PUBLIC; } + /** + * Return a https url that toggles between mobile and desktop view when opened + * @return https://(pod-domain.tld)/mobile/toggle + */ public String getToggleMobileUrl() { return getPodUrl()+SUBURL_TOGGLE_MOBILE; } + /** + * Return a https url that queries posts for the given hashtag query + * @param query hashtag to be searched + * @return https://(pod-domain.tld)/tags/query + */ public String getSearchTagsUrl(String query) { return getPodUrl()+SUBURL_SEARCH_TAGS+query; } + /** + * Return a https url that queries user accounts for query + * @param query search term + * @return https://(pod-domain.tld)/people.mobile?q=(query) + */ public String getSearchPeopleUrl(String query) { return getPodUrl()+SUBURL_SEARCH_PEOPLE+query; } + /** + * Returns the url of the blank WebView + * @return about:blank + */ public String getBlankUrl() { return URL_BLANK; }