mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 04:12:08 +01:00
Aspect name as title (fixes#44 , fixes #47)
This commit is contained in:
parent
05819d6cf2
commit
4f148191f7
5 changed files with 105 additions and 54 deletions
|
@ -11,6 +11,7 @@
|
|||
- Click on profile picture now opens users profile
|
||||
- Disabled backup functionality to prevent attackers to steal login cookies
|
||||
- Allow slider customization
|
||||
- Show aspect name after selection
|
||||
|
||||
# v0.1.4 (2016-07-31)
|
||||
- by @vanitasvitae, @gsantner, @di72nn
|
||||
|
|
|
@ -220,7 +220,7 @@ public class MainActivity extends AppCompatActivity
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getNotificationsUrl());
|
||||
webView.loadUrlNew(urls.getNotificationsUrl());
|
||||
} else {
|
||||
Snackbar.make(contentLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ public class MainActivity extends AppCompatActivity
|
|||
if (savedInstanceState == null) {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadData("", "text/html", null);
|
||||
webView.loadUrl(url);
|
||||
webView.loadUrlNew(url);
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ public class MainActivity extends AppCompatActivity
|
|||
public void onClick(View view) {
|
||||
navDrawer.closeDrawer(GravityCompat.START);
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getProfileUrl());
|
||||
webView.loadUrlNew(urls.getProfileUrl());
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ public class MainActivity extends AppCompatActivity
|
|||
if (loadUrl != null) {
|
||||
webView.stopLoading();
|
||||
navDrawer.closeDrawers();
|
||||
webView.loadUrl(loadUrl);
|
||||
webView.loadUrlNew(loadUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -579,6 +579,8 @@ public class MainActivity extends AppCompatActivity
|
|||
setTitle(R.string.nav_mentions);
|
||||
} else if (subUrl.startsWith(DiasporaUrlHelper.SUBURL_PUBLIC)) {
|
||||
setTitle(R.string.public_);
|
||||
} else if (urls.isAspectUrl(url)){
|
||||
setTitle(urls.getAspectNameFromUrl(url, app));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -621,7 +623,7 @@ public class MainActivity extends AppCompatActivity
|
|||
switch (item.getItemId()) {
|
||||
case R.id.action_notifications: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getNotificationsUrl());
|
||||
webView.loadUrlNew(urls.getNotificationsUrl());
|
||||
return true;
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
|
@ -631,7 +633,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
case R.id.action_conversations: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getConversationsUrl());
|
||||
webView.loadUrlNew(urls.getConversationsUrl());
|
||||
return true;
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
|
@ -656,13 +658,13 @@ public class MainActivity extends AppCompatActivity
|
|||
}
|
||||
|
||||
case R.id.action_toggle_desktop_page: {
|
||||
webView.loadUrl(urls.getToggleMobileUrl());
|
||||
webView.loadUrlNew(urls.getToggleMobileUrl());
|
||||
return true;
|
||||
}
|
||||
|
||||
case R.id.action_compose: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getNewPostUrl());
|
||||
webView.loadUrlNew(urls.getNewPostUrl());
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
@ -719,9 +721,9 @@ public class MainActivity extends AppCompatActivity
|
|||
Snackbar.make(contentLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show();
|
||||
} else { // User have added a search tag
|
||||
if (wasClickedOnSearchForPeople) {
|
||||
webView.loadUrl(urls.getSearchPeopleUrl(cleanTag));
|
||||
webView.loadUrlNew(urls.getSearchPeopleUrl(cleanTag));
|
||||
} else {
|
||||
webView.loadUrl(urls.getSearchTagsUrl(cleanTag));
|
||||
webView.loadUrlNew(urls.getSearchTagsUrl(cleanTag));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -866,9 +868,8 @@ public class MainActivity extends AppCompatActivity
|
|||
textToBeShared = sharedText;
|
||||
}
|
||||
|
||||
webView.stopLoading();
|
||||
webView.loadUrl(urls.getBlankUrl());
|
||||
webView.loadUrl(urls.getNewPostUrl());
|
||||
webView.loadUrlNew(urls.getBlankUrl());
|
||||
webView.loadUrlNew(urls.getNewPostUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -877,7 +878,7 @@ public class MainActivity extends AppCompatActivity
|
|||
* @param intent
|
||||
*/
|
||||
void handleSendSubject(Intent intent) {
|
||||
webView.loadUrl(urls.getNewPostUrl());
|
||||
webView.loadUrlNew(urls.getNewPostUrl());
|
||||
String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT));
|
||||
String subject = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_SUBJECT));
|
||||
|
||||
|
@ -890,9 +891,8 @@ public class MainActivity extends AppCompatActivity
|
|||
final String sharedContent = WebHelper.escapeHtmlText(content);
|
||||
textToBeShared = "**" + sharedSubject + "** " + sharedContent;
|
||||
|
||||
webView.stopLoading();
|
||||
webView.loadUrl(urls.getBlankUrl());
|
||||
webView.loadUrl(urls.getNewPostUrl());
|
||||
webView.loadUrlNew(urls.getBlankUrl());
|
||||
webView.loadUrlNew(urls.getNewPostUrl());
|
||||
}
|
||||
|
||||
//TODO: Implement?
|
||||
|
@ -954,7 +954,7 @@ public class MainActivity extends AppCompatActivity
|
|||
switch (item.getItemId()) {
|
||||
case R.id.nav_stream: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getStreamUrl());
|
||||
webView.loadUrlNew(urls.getStreamUrl());
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
@ -963,7 +963,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
case R.id.nav_profile: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getProfileUrl());
|
||||
webView.loadUrlNew(urls.getProfileUrl());
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
@ -982,6 +982,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
case R.id.nav_aspects: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrlNew(DiasporaUrlHelper.URL_BLANK);
|
||||
WebHelper.showAspectList(webView, app);
|
||||
setTitle(R.string.aspects);
|
||||
} else {
|
||||
|
@ -992,7 +993,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
case R.id.nav_activities: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getActivityUrl());
|
||||
webView.loadUrlNew(urls.getActivityUrl());
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
@ -1001,7 +1002,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
case R.id.nav_liked: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getLikedPostsUrl());
|
||||
webView.loadUrlNew(urls.getLikedPostsUrl());
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
@ -1010,7 +1011,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
case R.id.nav_commented: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getCommentedUrl());
|
||||
webView.loadUrlNew(urls.getCommentedUrl());
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
@ -1019,7 +1020,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
case R.id.nav_mentions: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getMentionsUrl());
|
||||
webView.loadUrlNew(urls.getMentionsUrl());
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
@ -1028,7 +1029,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
case R.id.nav_public: {
|
||||
if (WebHelper.isOnline(MainActivity.this)) {
|
||||
webView.loadUrl(urls.getPublicUrl());
|
||||
webView.loadUrlNew(urls.getPublicUrl());
|
||||
} else {
|
||||
snackbarNoInternet.show();
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ public class AppSettings {
|
|||
}
|
||||
|
||||
public boolean isVisibleInNavHelp_license() {
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__help_license, false);
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__help_license, true);
|
||||
}
|
||||
|
||||
public boolean isVisibleInNavPublic_activities() {
|
||||
|
@ -268,27 +268,27 @@ public class AppSettings {
|
|||
}
|
||||
|
||||
public boolean isVisibleInNavMentions() {
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__mentions, false);
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__mentions, true);
|
||||
}
|
||||
|
||||
public boolean isVisibleInNavCommented() {
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__commented, false);
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__commented, true);
|
||||
}
|
||||
|
||||
public boolean isVisibleInNavLiked() {
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__liked, false);
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__liked, true);
|
||||
}
|
||||
|
||||
public boolean isVisibleInNavActivities() {
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__activities, false);
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__activities, true);
|
||||
}
|
||||
|
||||
public boolean isVisibleInNavAspects() {
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__aspects, false);
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__aspects, true);
|
||||
}
|
||||
|
||||
public boolean isVisibleInNavFollowed_tags() {
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__followed_tags, false);
|
||||
return getBoolean(prefApp, R.string.pref_key__visibility_nav__followed_tags, true);
|
||||
}
|
||||
|
||||
public boolean isVisibleInNavProfile() {
|
||||
|
|
|
@ -58,6 +58,7 @@ public class ContextMenuWebView extends NestedWebView {
|
|||
|
||||
private Context context;
|
||||
private Activity parentActivity;
|
||||
private String lasLoadUrl = "";
|
||||
|
||||
public ContextMenuWebView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
@ -189,13 +190,23 @@ public class ContextMenuWebView extends NestedWebView {
|
|||
}
|
||||
}
|
||||
|
||||
public void loadUrlNew(String url){
|
||||
stopLoading();
|
||||
loadUrl(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUrl(String url) {
|
||||
super.loadUrl(url);
|
||||
|
||||
// Don't spam intents ;)
|
||||
if (!lasLoadUrl.equals(url)) {
|
||||
Intent updateActivityTitleIntent = new Intent(MainActivity.ACTION_UPDATE_TITLE_FROM_URL);
|
||||
updateActivityTitleIntent.putExtra(MainActivity.EXTRA_URL, getUrl());
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(updateActivityTitleIntent);
|
||||
}
|
||||
lasLoadUrl = url;
|
||||
}
|
||||
|
||||
public void setParentActivity(Activity activity) {
|
||||
this.parentActivity = activity;
|
||||
|
|
|
@ -18,7 +18,10 @@
|
|||
*/
|
||||
package com.github.dfa.diaspora_android.util;
|
||||
|
||||
import com.github.dfa.diaspora_android.App;
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||
import com.github.dfa.diaspora_android.data.PodAspect;
|
||||
|
||||
/**
|
||||
* Helper class that provides easy access to specific urls related to diaspora
|
||||
|
@ -54,6 +57,7 @@ public class DiasporaUrlHelper {
|
|||
/**
|
||||
* Return a https url of the pod set in AppSettings.
|
||||
* Eg. https://pod.geraspora.de
|
||||
*
|
||||
* @return https://(pod-domain.tld)
|
||||
*/
|
||||
public String getPodUrl() {
|
||||
|
@ -62,6 +66,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a https url that points to the stream of the configured diaspora account
|
||||
*
|
||||
* @return https://(pod-domain.tld)/stream
|
||||
*/
|
||||
public String getStreamUrl() {
|
||||
|
@ -70,6 +75,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a https url that points to the notifications feed of the configured diaspora account
|
||||
*
|
||||
* @return https://(pod-domain.tld)/notifications
|
||||
*/
|
||||
public String getNotificationsUrl() {
|
||||
|
@ -78,6 +84,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* 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) {
|
||||
|
@ -86,6 +93,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a https url that points to the conversations overview of the registered diaspora account
|
||||
*
|
||||
* @return https://(pod-domain.tld)/conversations
|
||||
*/
|
||||
public String getConversationsUrl() {
|
||||
|
@ -94,6 +102,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* 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() {
|
||||
|
@ -102,6 +111,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a https url that shows the profile of the currently registered diaspora account
|
||||
*
|
||||
* @return https://(pod-domain.tld)/people/(profileId)
|
||||
*/
|
||||
public String getProfileUrl() {
|
||||
|
@ -110,6 +120,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
|
@ -119,6 +130,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* 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() {
|
||||
|
@ -127,6 +139,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* 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() {
|
||||
|
@ -135,6 +148,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* 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() {
|
||||
|
@ -143,6 +157,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* 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() {
|
||||
|
@ -151,6 +166,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a https url that points to the stream of public posts
|
||||
*
|
||||
* @return https://(pod-domain.tld)/public
|
||||
*/
|
||||
public String getPublicUrl() {
|
||||
|
@ -159,6 +175,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a https url that toggles between mobile and desktop view when opened
|
||||
*
|
||||
* @return https://(pod-domain.tld)/mobile/toggle
|
||||
*/
|
||||
public String getToggleMobileUrl() {
|
||||
|
@ -167,6 +184,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -176,6 +194,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a https url that queries user accounts for query
|
||||
*
|
||||
* @param query search term
|
||||
* @return https://(pod-domain.tld)/people.mobile?q=(query)
|
||||
*/
|
||||
|
@ -185,9 +204,28 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Returns the url of the blank WebView
|
||||
*
|
||||
* @return about:blank
|
||||
*/
|
||||
public String getBlankUrl() {
|
||||
return URL_BLANK;
|
||||
}
|
||||
|
||||
public boolean isAspectUrl(String url) {
|
||||
return url.startsWith(getPodUrl() + "/aspects?a_ids[]=");
|
||||
}
|
||||
|
||||
public String getAspectNameFromUrl(String url, App app) {
|
||||
url = url.replace(getPodUrl() + "/aspects?a_ids[]=", "").split(",")[0];
|
||||
try {
|
||||
int id = Integer.parseInt(url);
|
||||
for (PodAspect aspect : app.getPodUserProfile().getAspects()) {
|
||||
if (aspect.id == id) {
|
||||
return aspect.name;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return app.getString(R.string.aspects);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue