1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-25 22:02:08 +01:00

Aspect name as title (fixes#44 , fixes #47)

This commit is contained in:
Gregor Santner 2016-08-13 15:31:27 +02:00
parent 05819d6cf2
commit 4f148191f7
5 changed files with 105 additions and 54 deletions

View file

@ -11,6 +11,7 @@
- Click on profile picture now opens users profile - Click on profile picture now opens users profile
- Disabled backup functionality to prevent attackers to steal login cookies - Disabled backup functionality to prevent attackers to steal login cookies
- Allow slider customization - Allow slider customization
- Show aspect name after selection
# v0.1.4 (2016-07-31) # v0.1.4 (2016-07-31)
- by @vanitasvitae, @gsantner, @di72nn - by @vanitasvitae, @gsantner, @di72nn

View file

@ -220,7 +220,7 @@ public class MainActivity extends AppCompatActivity
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getNotificationsUrl()); webView.loadUrlNew(urls.getNotificationsUrl());
} else { } else {
Snackbar.make(contentLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show(); Snackbar.make(contentLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show();
} }
@ -238,7 +238,7 @@ public class MainActivity extends AppCompatActivity
if (savedInstanceState == null) { if (savedInstanceState == null) {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadData("", "text/html", null); webView.loadData("", "text/html", null);
webView.loadUrl(url); webView.loadUrlNew(url);
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
} }
@ -383,7 +383,7 @@ public class MainActivity extends AppCompatActivity
public void onClick(View view) { public void onClick(View view) {
navDrawer.closeDrawer(GravityCompat.START); navDrawer.closeDrawer(GravityCompat.START);
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getProfileUrl()); webView.loadUrlNew(urls.getProfileUrl());
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
} }
@ -488,7 +488,7 @@ public class MainActivity extends AppCompatActivity
if (loadUrl != null) { if (loadUrl != null) {
webView.stopLoading(); webView.stopLoading();
navDrawer.closeDrawers(); navDrawer.closeDrawers();
webView.loadUrl(loadUrl); webView.loadUrlNew(loadUrl);
} }
} }
@ -579,6 +579,8 @@ public class MainActivity extends AppCompatActivity
setTitle(R.string.nav_mentions); setTitle(R.string.nav_mentions);
} else if (subUrl.startsWith(DiasporaUrlHelper.SUBURL_PUBLIC)) { } else if (subUrl.startsWith(DiasporaUrlHelper.SUBURL_PUBLIC)) {
setTitle(R.string.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()) { switch (item.getItemId()) {
case R.id.action_notifications: { case R.id.action_notifications: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getNotificationsUrl()); webView.loadUrlNew(urls.getNotificationsUrl());
return true; return true;
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
@ -631,7 +633,7 @@ public class MainActivity extends AppCompatActivity
case R.id.action_conversations: { case R.id.action_conversations: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getConversationsUrl()); webView.loadUrlNew(urls.getConversationsUrl());
return true; return true;
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
@ -656,13 +658,13 @@ public class MainActivity extends AppCompatActivity
} }
case R.id.action_toggle_desktop_page: { case R.id.action_toggle_desktop_page: {
webView.loadUrl(urls.getToggleMobileUrl()); webView.loadUrlNew(urls.getToggleMobileUrl());
return true; return true;
} }
case R.id.action_compose: { case R.id.action_compose: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getNewPostUrl()); webView.loadUrlNew(urls.getNewPostUrl());
} else { } else {
snackbarNoInternet.show(); 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(); Snackbar.make(contentLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show();
} else { // User have added a search tag } else { // User have added a search tag
if (wasClickedOnSearchForPeople) { if (wasClickedOnSearchForPeople) {
webView.loadUrl(urls.getSearchPeopleUrl(cleanTag)); webView.loadUrlNew(urls.getSearchPeopleUrl(cleanTag));
} else { } else {
webView.loadUrl(urls.getSearchTagsUrl(cleanTag)); webView.loadUrlNew(urls.getSearchTagsUrl(cleanTag));
} }
} }
@ -866,9 +868,8 @@ public class MainActivity extends AppCompatActivity
textToBeShared = sharedText; textToBeShared = sharedText;
} }
webView.stopLoading(); webView.loadUrlNew(urls.getBlankUrl());
webView.loadUrl(urls.getBlankUrl()); webView.loadUrlNew(urls.getNewPostUrl());
webView.loadUrl(urls.getNewPostUrl());
} }
/** /**
@ -877,7 +878,7 @@ public class MainActivity extends AppCompatActivity
* @param intent * @param intent
*/ */
void handleSendSubject(Intent intent) { void handleSendSubject(Intent intent) {
webView.loadUrl(urls.getNewPostUrl()); webView.loadUrlNew(urls.getNewPostUrl());
String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT)); String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT));
String subject = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_SUBJECT)); String subject = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_SUBJECT));
@ -890,9 +891,8 @@ public class MainActivity extends AppCompatActivity
final String sharedContent = WebHelper.escapeHtmlText(content); final String sharedContent = WebHelper.escapeHtmlText(content);
textToBeShared = "**" + sharedSubject + "** " + sharedContent; textToBeShared = "**" + sharedSubject + "** " + sharedContent;
webView.stopLoading(); webView.loadUrlNew(urls.getBlankUrl());
webView.loadUrl(urls.getBlankUrl()); webView.loadUrlNew(urls.getNewPostUrl());
webView.loadUrl(urls.getNewPostUrl());
} }
//TODO: Implement? //TODO: Implement?
@ -954,7 +954,7 @@ public class MainActivity extends AppCompatActivity
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.nav_stream: { case R.id.nav_stream: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getStreamUrl()); webView.loadUrlNew(urls.getStreamUrl());
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
} }
@ -963,7 +963,7 @@ public class MainActivity extends AppCompatActivity
case R.id.nav_profile: { case R.id.nav_profile: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getProfileUrl()); webView.loadUrlNew(urls.getProfileUrl());
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
} }
@ -982,6 +982,7 @@ public class MainActivity extends AppCompatActivity
case R.id.nav_aspects: { case R.id.nav_aspects: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrlNew(DiasporaUrlHelper.URL_BLANK);
WebHelper.showAspectList(webView, app); WebHelper.showAspectList(webView, app);
setTitle(R.string.aspects); setTitle(R.string.aspects);
} else { } else {
@ -992,7 +993,7 @@ public class MainActivity extends AppCompatActivity
case R.id.nav_activities: { case R.id.nav_activities: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getActivityUrl()); webView.loadUrlNew(urls.getActivityUrl());
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
} }
@ -1001,7 +1002,7 @@ public class MainActivity extends AppCompatActivity
case R.id.nav_liked: { case R.id.nav_liked: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getLikedPostsUrl()); webView.loadUrlNew(urls.getLikedPostsUrl());
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
} }
@ -1010,7 +1011,7 @@ public class MainActivity extends AppCompatActivity
case R.id.nav_commented: { case R.id.nav_commented: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getCommentedUrl()); webView.loadUrlNew(urls.getCommentedUrl());
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
} }
@ -1019,7 +1020,7 @@ public class MainActivity extends AppCompatActivity
case R.id.nav_mentions: { case R.id.nav_mentions: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getMentionsUrl()); webView.loadUrlNew(urls.getMentionsUrl());
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
} }
@ -1028,7 +1029,7 @@ public class MainActivity extends AppCompatActivity
case R.id.nav_public: { case R.id.nav_public: {
if (WebHelper.isOnline(MainActivity.this)) { if (WebHelper.isOnline(MainActivity.this)) {
webView.loadUrl(urls.getPublicUrl()); webView.loadUrlNew(urls.getPublicUrl());
} else { } else {
snackbarNoInternet.show(); snackbarNoInternet.show();
} }

View file

@ -260,7 +260,7 @@ public class AppSettings {
} }
public boolean isVisibleInNavHelp_license() { 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() { public boolean isVisibleInNavPublic_activities() {
@ -268,27 +268,27 @@ public class AppSettings {
} }
public boolean isVisibleInNavMentions() { 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() { 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() { 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() { 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() { 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() { 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() { public boolean isVisibleInNavProfile() {

View file

@ -58,6 +58,7 @@ public class ContextMenuWebView extends NestedWebView {
private Context context; private Context context;
private Activity parentActivity; private Activity parentActivity;
private String lasLoadUrl = "";
public ContextMenuWebView(Context context, AttributeSet attrs, int defStyle) { public ContextMenuWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); super(context, attrs, defStyle);
@ -189,13 +190,23 @@ public class ContextMenuWebView extends NestedWebView {
} }
} }
public void loadUrlNew(String url){
stopLoading();
loadUrl(url);
}
@Override @Override
public void loadUrl(String url) { public void loadUrl(String url) {
super.loadUrl(url); super.loadUrl(url);
// Don't spam intents ;)
if (!lasLoadUrl.equals(url)) {
Intent updateActivityTitleIntent = new Intent(MainActivity.ACTION_UPDATE_TITLE_FROM_URL); Intent updateActivityTitleIntent = new Intent(MainActivity.ACTION_UPDATE_TITLE_FROM_URL);
updateActivityTitleIntent.putExtra(MainActivity.EXTRA_URL, getUrl()); updateActivityTitleIntent.putExtra(MainActivity.EXTRA_URL, getUrl());
LocalBroadcastManager.getInstance(context).sendBroadcast(updateActivityTitleIntent); LocalBroadcastManager.getInstance(context).sendBroadcast(updateActivityTitleIntent);
} }
lasLoadUrl = url;
}
public void setParentActivity(Activity activity) { public void setParentActivity(Activity activity) {
this.parentActivity = activity; this.parentActivity = activity;

View file

@ -18,7 +18,10 @@
*/ */
package com.github.dfa.diaspora_android.util; 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.AppSettings;
import com.github.dfa.diaspora_android.data.PodAspect;
/** /**
* Helper class that provides easy access to specific urls related to diaspora * 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. * Return a https url of the pod set in AppSettings.
* Eg. https://pod.geraspora.de * Eg. https://pod.geraspora.de
*
* @return https://(pod-domain.tld) * @return https://(pod-domain.tld)
*/ */
public String getPodUrl() { 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 a https url that points to the stream of the configured diaspora account
*
* @return https://(pod-domain.tld)/stream * @return https://(pod-domain.tld)/stream
*/ */
public String getStreamUrl() { 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 a https url that points to the notifications feed of the configured diaspora account
*
* @return https://(pod-domain.tld)/notifications * @return https://(pod-domain.tld)/notifications
*/ */
public String getNotificationsUrl() { public String getNotificationsUrl() {
@ -78,6 +84,7 @@ public class DiasporaUrlHelper {
/** /**
* Returns a https url that points to the post with the id postId * Returns a https url that points to the post with the id postId
*
* @return https://(pod-domain.tld)/posts/(postId) * @return https://(pod-domain.tld)/posts/(postId)
*/ */
public String getPostsUrl(long 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 a https url that points to the conversations overview of the registered diaspora account
*
* @return https://(pod-domain.tld)/conversations * @return https://(pod-domain.tld)/conversations
*/ */
public String getConversationsUrl() { 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 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 * @return https://(pod-domain.tld)/status_messages/new
*/ */
public String getNewPostUrl() { 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 a https url that shows the profile of the currently registered diaspora account
*
* @return https://(pod-domain.tld)/people/(profileId) * @return https://(pod-domain.tld)/people/(profileId)
*/ */
public String getProfileUrl() { 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 * Return a https url that shows the profile of the user with user id profileId
*
* @param profileId Id of the profile to be shown * @param profileId Id of the profile to be shown
* @return https://(pod-domain.tld)/people/(profileId) * @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 a https url that points to the activities feed of the currently registered diaspora account
*
* @return https://(pod-domain.tld)/activity * @return https://(pod-domain.tld)/activity
*/ */
public String getActivityUrl() { 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 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 * @return https://(pod-domain.tld)/liked
*/ */
public String getLikedPostsUrl() { 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 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 * @return https://(pod-domain.tld)/commented
*/ */
public String getCommentedUrl() { 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 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 * @return https://(pod-domain.tld)/mentions
*/ */
public String getMentionsUrl() { public String getMentionsUrl() {
@ -151,6 +166,7 @@ public class DiasporaUrlHelper {
/** /**
* Return a https url that points to the stream of public posts * Return a https url that points to the stream of public posts
*
* @return https://(pod-domain.tld)/public * @return https://(pod-domain.tld)/public
*/ */
public String getPublicUrl() { public String getPublicUrl() {
@ -159,6 +175,7 @@ public class DiasporaUrlHelper {
/** /**
* Return a https url that toggles between mobile and desktop view when opened * Return a https url that toggles between mobile and desktop view when opened
*
* @return https://(pod-domain.tld)/mobile/toggle * @return https://(pod-domain.tld)/mobile/toggle
*/ */
public String getToggleMobileUrl() { public String getToggleMobileUrl() {
@ -167,6 +184,7 @@ public class DiasporaUrlHelper {
/** /**
* Return a https url that queries posts for the given hashtag query * Return a https url that queries posts for the given hashtag query
*
* @param query hashtag to be searched * @param query hashtag to be searched
* @return https://(pod-domain.tld)/tags/query * @return https://(pod-domain.tld)/tags/query
*/ */
@ -176,6 +194,7 @@ public class DiasporaUrlHelper {
/** /**
* Return a https url that queries user accounts for query * Return a https url that queries user accounts for query
*
* @param query search term * @param query search term
* @return https://(pod-domain.tld)/people.mobile?q=(query) * @return https://(pod-domain.tld)/people.mobile?q=(query)
*/ */
@ -185,9 +204,28 @@ public class DiasporaUrlHelper {
/** /**
* Returns the url of the blank WebView * Returns the url of the blank WebView
*
* @return about:blank * @return about:blank
*/ */
public String getBlankUrl() { public String getBlankUrl() {
return URL_BLANK; 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);
}
} }