1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-06-26 13:34:52 +02:00

Merge PR #98 from Diaspora-for-Android/94_Rework_tags_fragment

Rework tags & aspects fragment
 ThemedFragment for Aspects & tagst, fixes #94 #81
This commit is contained in:
Gregor Santner 2016-10-26 14:33:31 +02:00 committed by GitHub
commit e239f519e4
15 changed files with 381 additions and 116 deletions

View file

@ -11,6 +11,8 @@ android {
targetSdkVersion 24 targetSdkVersion 24
versionCode 8 versionCode 8
versionName "0.1.6-next" versionName "0.1.6-next"
vectorDrawables.useSupportLibrary=true
} }
buildTypes { buildTypes {
release { release {

View file

@ -62,6 +62,7 @@ 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.DiasporaPodList; import com.github.dfa.diaspora_android.data.DiasporaPodList;
import com.github.dfa.diaspora_android.data.PodUserProfile; import com.github.dfa.diaspora_android.data.PodUserProfile;
import com.github.dfa.diaspora_android.fragment.AspectListFragment;
import com.github.dfa.diaspora_android.fragment.BrowserFragment; import com.github.dfa.diaspora_android.fragment.BrowserFragment;
import com.github.dfa.diaspora_android.fragment.CustomFragment; import com.github.dfa.diaspora_android.fragment.CustomFragment;
import com.github.dfa.diaspora_android.fragment.DiasporaStreamFragment; import com.github.dfa.diaspora_android.fragment.DiasporaStreamFragment;
@ -286,6 +287,10 @@ public class MainActivity extends ThemedActivity
HashtagListFragment hlf = new HashtagListFragment(); HashtagListFragment hlf = new HashtagListFragment();
fm.beginTransaction().add(hlf, fragmentTag).commit(); fm.beginTransaction().add(hlf, fragmentTag).commit();
return hlf; return hlf;
case AspectListFragment.TAG:
AspectListFragment alf = new AspectListFragment();
fm.beginTransaction().add(alf, fragmentTag).commit();
return alf;
case PodSelectionFragment.TAG: case PodSelectionFragment.TAG:
PodSelectionFragment psf = new PodSelectionFragment(); PodSelectionFragment psf = new PodSelectionFragment();
fm.beginTransaction().add(psf, fragmentTag).commit(); fm.beginTransaction().add(psf, fragmentTag).commit();
@ -987,14 +992,7 @@ public class MainActivity extends ThemedActivity
//TODO: Replace with fragment //TODO: Replace with fragment
case R.id.nav_aspects: { case R.id.nav_aspects: {
DiasporaStreamFragment stream = (DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG); showFragment(getFragment(AspectListFragment.TAG));
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(DiasporaUrlHelper.URL_BLANK);
WebHelper.showAspectList(stream.getWebView(), app);
setTitle(R.string.aspects);
} else {
snackbarNoInternet.show();
}
} }
break; break;

View file

@ -26,6 +26,8 @@ import com.github.dfa.diaspora_android.util.ProxyHandler;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.List;
/** /**
* Settings * Settings
* Created by gsantner (https://gsantner.github.io/) on 20.03.16. Part of Diaspora for Android. * Created by gsantner (https://gsantner.github.io/) on 20.03.16. Part of Diaspora for Android.
@ -197,7 +199,7 @@ public class AppSettings {
setStringArray(prefPod, R.string.pref_key__podprofile_aspects, aspects); setStringArray(prefPod, R.string.pref_key__podprofile_aspects, aspects);
} }
public PodAspect[] getPodAspects() { public PodAspect[] getAspects() {
String[] s = getStringArray(prefPod, R.string.pref_key__podprofile_aspects); String[] s = getStringArray(prefPod, R.string.pref_key__podprofile_aspects);
PodAspect[] aspects = new PodAspect[s.length]; PodAspect[] aspects = new PodAspect[s.length];
for (int i = 0; i < aspects.length; i++) { for (int i = 0; i < aspects.length; i++) {
@ -210,8 +212,24 @@ public class AppSettings {
return getStringArray(prefPod, R.string.pref_key__podprofile_followed_tags); return getStringArray(prefPod, R.string.pref_key__podprofile_followed_tags);
} }
public void setFollowedTags(String[] tags) { public void setFollowedTags(String[] values) {
setStringArray(prefPod, R.string.pref_key__podprofile_followed_tags, tags); setStringArray(prefPod, R.string.pref_key__podprofile_followed_tags, values);
}
public String[] getFollowedTagsFavs() {
return getStringArray(prefPod, R.string.pref_key__podprofile_followed_tags_favs);
}
public void setFollowedTagsFavs(List<String> values) {
setStringArray(prefPod, R.string.pref_key__podprofile_followed_tags_favs, values.toArray(new String[values.size()]));
}
public String[] getAspectFavs() {
return getStringArray(prefPod, R.string.pref_key__podprofile_aspects_favs);
}
public void setAspectFavs(List<String> values) {
setStringArray(prefPod, R.string.pref_key__podprofile_aspects_favs, values.toArray(new String[values.size()]));
} }
public int getUnreadMessageCount() { public int getUnreadMessageCount() {

View file

@ -59,7 +59,7 @@ public class PodUserProfile {
avatarUrl = appSettings.getAvatarUrl(); avatarUrl = appSettings.getAvatarUrl();
guid = appSettings.getProfileId(); guid = appSettings.getProfileId();
name = appSettings.getName(); name = appSettings.getName();
podAspects = appSettings.getPodAspects(); podAspects = appSettings.getAspects();
followedTags = appSettings.getFollowedTags(); followedTags = appSettings.getFollowedTags();
notificationCount = appSettings.getNotificationCount(); notificationCount = appSettings.getNotificationCount();
unreadMessagesCount = appSettings.getUnreadMessageCount(); unreadMessagesCount = appSettings.getUnreadMessageCount();

View file

@ -0,0 +1,197 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
package com.github.dfa.diaspora_android.fragment;
import android.content.Context;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.activity.MainActivity;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.data.PodAspect;
import com.github.dfa.diaspora_android.listener.OnSomethingClickListener;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import com.github.dfa.diaspora_android.util.Helpers;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Fragment that shows a list of the Aspects
*/
public class AspectListFragment extends ThemedFragment implements OnSomethingClickListener<Object> {
public static final String TAG = "com.github.dfa.diaspora_android.AspectListFragment";
protected RecyclerView aspectsRecyclerView;
protected App app;
protected DiasporaUrlHelper urls;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
AppLog.d(this, "onCreateView()");
return inflater.inflate(R.layout.recycler_list__fragment, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
aspectsRecyclerView = (RecyclerView) view.findViewById(R.id.fragment_list__recycler_view);
app = (App) getActivity().getApplication();
AppSettings appSettings = app.getSettings();
urls = new DiasporaUrlHelper(appSettings);
aspectsRecyclerView.setHasFixedSize(true);
aspectsRecyclerView.setNestedScrollingEnabled(false);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
aspectsRecyclerView.setLayoutManager(layoutManager);
final AspectAdapter adapter = new AspectAdapter(appSettings, this);
aspectsRecyclerView.setAdapter(adapter);
//Set window title
getActivity().setTitle(R.string.nav_aspects);
}
@Override
public String getFragmentTag() {
return TAG;
}
@Override
public void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater) {
/* Nothing to do */
}
@Override
public boolean onBackPressed() {
return false;
}
@Override
public void onSomethingClicked(Object null1, Integer null2, String aspectId) {
((MainActivity) getActivity()).openDiasporaUrl(urls.getAspectUrl(aspectId));
}
@Override
protected void applyColorToViews() {
aspectsRecyclerView.invalidate();
}
public static class AspectAdapter extends RecyclerView.Adapter<AspectAdapter.ViewHolder> {
private AppSettings appSettings;
private PodAspect[] aspectList;
private List<String> aspectFavsList;
private OnSomethingClickListener<Object> aspectClickedListener;
static class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.recycler_view__list_item__text)
public TextView title;
@BindView(R.id.recycler_view__list_item__favourite)
AppCompatImageView favouriteImage;
@BindView(R.id.recycler_view__list_item__root)
RelativeLayout root;
ViewHolder(View v) {
super(v);
ButterKnife.bind(this, v);
}
}
AspectAdapter(AppSettings appSettings, OnSomethingClickListener<Object> aspectClickedListener) {
this.appSettings = appSettings;
this.aspectList = appSettings.getAspects();
this.aspectFavsList = new ArrayList<>(Arrays.asList(appSettings.getAspectFavs()));
this.aspectClickedListener = aspectClickedListener;
}
@Override
public int getItemCount() {
return aspectList.length;
}
@Override
public AspectAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.recycler_view__list_item, parent, false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
// Alternating colors
final Context c = holder.root.getContext();
final PodAspect aspect = aspectList[position];
holder.title.setText(aspect.name);
if (position % 2 == 1) {
holder.root.setBackgroundColor(Helpers.getColorFromRessource(c, R.color.md_grey_300));
}
// Favourite (Star) Image
applyFavouriteImage(holder.favouriteImage, isAspectFaved(aspect.name));
// Click on fav button
holder.favouriteImage.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (isAspectFaved(aspect.name)) {
aspectFavsList.remove(aspectFavsList.indexOf(aspect.name));
} else {
aspectFavsList.add(aspect.name);
}
appSettings.setAspectFavs(aspectFavsList);
applyFavouriteImage(holder.favouriteImage, isAspectFaved(aspect.name));
}
});
holder.root.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
aspectClickedListener.onSomethingClicked(null, null, aspect.id + "");
}
});
}
private boolean isAspectFaved(String tag) {
return aspectFavsList.contains(tag);
}
private void applyFavouriteImage(AppCompatImageView imageView, boolean isFaved) {
imageView.setImageResource(isFaved ? R.drawable.ic_star_filled_48px : R.drawable.ic_star_border_black_48px);
imageView.setColorFilter(isFaved ? appSettings.getAccentColor() : 0, PorterDuff.Mode.SRC_ATOP);
}
}
}

View file

@ -329,12 +329,12 @@ public class DiasporaStreamFragment extends BrowserFragment {
@JavascriptInterface @JavascriptInterface
public void setUserProfile(final String webMessage) throws JSONException { public void setUserProfile(final String webMessage) throws JSONException {
PodUserProfile pup = ((App) getActivity().getApplication()).getPodUserProfile(); PodUserProfile pup = ((App) getActivity().getApplication()).getPodUserProfile();
AppLog.v(this, "StreamFragment.JavaScriptInterface.setUserProfile()"); AppLog.spam(this, "StreamFragment.JavaScriptInterface.setUserProfile()");
if (pup.isRefreshNeeded()) { if (pup.isRefreshNeeded()) {
AppLog.v(this, "PodUserProfile needs refresh; Try to parse JSON"); AppLog.v(this, "PodUserProfile needs refresh; Try to parse JSON");
pup.parseJson(webMessage); pup.parseJson(webMessage);
} else { } else {
AppLog.v(this, "No PodUserProfile refresh needed"); AppLog.spam(this, "No PodUserProfile refresh needed");
} }
} }

View file

@ -18,7 +18,10 @@
*/ */
package com.github.dfa.diaspora_android.fragment; package com.github.dfa.diaspora_android.fragment;
import android.content.Context;
import android.graphics.PorterDuff;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -26,49 +29,57 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.github.dfa.diaspora_android.App; import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.activity.MainActivity; import com.github.dfa.diaspora_android.activity.MainActivity;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.listener.OnSomethingClickListener;
import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper; import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import com.github.dfa.diaspora_android.util.Helpers;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/** /**
* Fragment that shows a list of the Hashtags the user follows * Fragment that shows a list of the HashTags the user follows
* Created by vanitas on 29.09.16.
*/ */
public class HashtagListFragment extends ThemedFragment implements OnSomethingClickListener<Object> {
public class HashtagListFragment extends CustomFragment {
public static final String TAG = "com.github.dfa.diaspora_android.HashtagListFragment"; public static final String TAG = "com.github.dfa.diaspora_android.HashtagListFragment";
protected RecyclerView followedTagsRecyclerView; protected RecyclerView followedTagsRecyclerView;
protected String[] followedTags;
protected App app; protected App app;
protected DiasporaUrlHelper urls; protected DiasporaUrlHelper urls;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
AppLog.d(this, "onCreateView()"); AppLog.d(this, "onCreateView()");
return inflater.inflate(R.layout.hashtag_list__fragment, container, false); return inflater.inflate(R.layout.recycler_list__fragment, container, false);
} }
@Override @Override
public void onViewCreated(View view, Bundle savedInstanceState) { public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
this.followedTagsRecyclerView = (RecyclerView) view.findViewById(R.id.fragment_followed_tags__recycler_view); followedTagsRecyclerView = (RecyclerView) view.findViewById(R.id.fragment_list__recycler_view);
this.app = (App) getActivity().getApplication(); app = (App) getActivity().getApplication();
this.urls = new DiasporaUrlHelper(app.getSettings()); AppSettings appSettings = app.getSettings();
urls = new DiasporaUrlHelper(appSettings);
followedTags = app.getPodUserProfile().getFollowedTags();
followedTagsRecyclerView.setHasFixedSize(true); followedTagsRecyclerView.setHasFixedSize(true);
followedTagsRecyclerView.setNestedScrollingEnabled(false); followedTagsRecyclerView.setNestedScrollingEnabled(false);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this.getContext()); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
followedTagsRecyclerView.setLayoutManager(layoutManager); followedTagsRecyclerView.setLayoutManager(layoutManager);
final FollowedTagsAdapter adapter = new FollowedTagsAdapter(followedTags, onHashtagClickListener); final FollowedTagsAdapter adapter = new FollowedTagsAdapter(appSettings, this);
followedTagsRecyclerView.setAdapter(adapter); followedTagsRecyclerView.setAdapter(adapter);
//Set window title //Set window title
@ -90,57 +101,96 @@ public class HashtagListFragment extends CustomFragment {
return false; return false;
} }
protected View.OnClickListener onHashtagClickListener = new View.OnClickListener() { @Override
@Override public void onSomethingClicked(Object null1, Integer null2, String tag) {
public void onClick(View view) { ((MainActivity) getActivity()).openDiasporaUrl(urls.getSearchTagsUrl(tag));
int itemPosition = followedTagsRecyclerView.getChildLayoutPosition(view); }
if (itemPosition > -1 && itemPosition < followedTags.length) {
String tag = followedTags[itemPosition]; @Override
((MainActivity) getActivity()).openDiasporaUrl(urls.getSearchTagsUrl(tag)); protected void applyColorToViews() {
} followedTagsRecyclerView.invalidate();
} }
};
public static class FollowedTagsAdapter extends RecyclerView.Adapter<FollowedTagsAdapter.ViewHolder> { public static class FollowedTagsAdapter extends RecyclerView.Adapter<FollowedTagsAdapter.ViewHolder> {
private AppSettings appSettings;
private String[] followedTagsList; private String[] followedTagsList;
private View.OnClickListener itemClickListener; private List<String> followedTagsFavsList;
private OnSomethingClickListener<Object> tagClickedListener;
public static class ViewHolder extends RecyclerView.ViewHolder { static class ViewHolder extends RecyclerView.ViewHolder {
// each data item is just a string in this case @BindView(R.id.recycler_view__list_item__text)
public TextView title; public TextView title;
@BindView(R.id.recycler_view__list_item__favourite)
AppCompatImageView favouriteImage;
@BindView(R.id.recycler_view__list_item__root)
RelativeLayout root;
public ViewHolder(View v) { ViewHolder(View v) {
super(v); super(v);
title = (TextView) v.findViewById(R.id.recycler_view__list_item__text); ButterKnife.bind(this, v);
} }
} }
// Provide a suitable constructor (depends on the kind of dataset)
public FollowedTagsAdapter(String[] tags, View.OnClickListener itemClickListener) { FollowedTagsAdapter(AppSettings appSettings, OnSomethingClickListener<Object> tagClickedListener) {
this.followedTagsList = tags; this.appSettings = appSettings;
this.itemClickListener = itemClickListener; this.followedTagsList = appSettings.getFollowedTags();
this.followedTagsFavsList = new ArrayList<>(Arrays.asList(appSettings.getFollowedTagsFavs()));
this.tagClickedListener = tagClickedListener;
}
@Override
public int getItemCount() {
return followedTagsList.length;
} }
@Override @Override
public FollowedTagsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public FollowedTagsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()) View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.recycler_view__list_item, parent, false); .inflate(R.layout.recycler_view__list_item, parent, false);
v.setOnClickListener(itemClickListener);
return new ViewHolder(v); return new ViewHolder(v);
} }
// Replace the contents of a view (invoked by the layout manager)
@Override @Override
public void onBindViewHolder(ViewHolder holder, int position) { public void onBindViewHolder(final ViewHolder holder, final int position) {
// Alternating colors
final Context c = holder.root.getContext();
final String tag = followedTagsList[position];
holder.title.setText(tag);
if (position % 2 == 1) {
holder.root.setBackgroundColor(Helpers.getColorFromRessource(c, R.color.md_grey_300));
}
holder.title.setText(followedTagsList[position]); // Favourite (Star) Image
applyFavouriteImage(holder.favouriteImage, isFollowedTagFaved(tag));
// Click on fav button
holder.favouriteImage.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (isFollowedTagFaved(tag)) {
followedTagsFavsList.remove(followedTagsFavsList.indexOf(tag));
} else {
followedTagsFavsList.add(tag);
}
appSettings.setFollowedTagsFavs(followedTagsFavsList);
applyFavouriteImage(holder.favouriteImage, isFollowedTagFaved(tag));
}
});
holder.root.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
tagClickedListener.onSomethingClicked(null, null, tag);
}
});
} }
// Return the size of your dataset (invoked by the layout manager) private boolean isFollowedTagFaved(String tag) {
@Override return followedTagsFavsList.contains(tag);
public int getItemCount() { }
return followedTagsList.length;
private void applyFavouriteImage(AppCompatImageView imageView, boolean isFaved) {
imageView.setImageResource(isFaved ? R.drawable.ic_star_filled_48px : R.drawable.ic_star_border_black_48px);
imageView.setColorFilter(isFaved ? appSettings.getAccentColor() : 0, PorterDuff.Mode.SRC_ATOP);
} }
} }
} }

View file

@ -0,0 +1,15 @@
package com.github.dfa.diaspora_android.listener;
/**
* Listener for different types of click events
*/
public interface OnSomethingClickListener<T> {
/**
* Triggered when something was clicked
*
* @param o Some object, or null
* @param i Some index, int value or null
* @param s Some String, or null
*/
void onSomethingClicked(T o, Integer i, String s);
}

View file

@ -43,6 +43,7 @@ public class DiasporaUrlHelper {
public static final String SUBURL_COMMENTED = "/commented"; public static final String SUBURL_COMMENTED = "/commented";
public static final String SUBURL_MENTIONS = "/mentions"; public static final String SUBURL_MENTIONS = "/mentions";
public static final String SUBURL_PUBLIC = "/public"; public static final String SUBURL_PUBLIC = "/public";
public static final String SUBURL_ASPECT = "/aspects?a_ids[]=";
public static final String SUBURL_TOGGLE_MOBILE = "/mobile/toggle"; public static final String SUBURL_TOGGLE_MOBILE = "/mobile/toggle";
public static final String SUBURL_SEARCH_TAGS = "/tags/"; public static final String SUBURL_SEARCH_TAGS = "/tags/";
public static final String SUBURL_SEARCH_PEOPLE = "/people.mobile?q="; public static final String SUBURL_SEARCH_PEOPLE = "/people.mobile?q=";
@ -144,6 +145,16 @@ public class DiasporaUrlHelper {
return getPodUrl() + SUBURL_PEOPLE + profileId; return getPodUrl() + SUBURL_PEOPLE + profileId;
} }
/**
* Return a url that queries posts from the given aspect
*
* @param aspectId ID of the aspect
* @return https://(pod-domain.tld)//aspects?a_ids[]=aspectId
*/
public String getAspectUrl(String aspectId) {
return getPodUrl() + SUBURL_ASPECT + aspectId;
}
/** /**
* Return a url that points to the activities feed of the currently registered diaspora account * Return a url that points to the activities feed of the currently registered diaspora account
* *
@ -263,7 +274,6 @@ public class DiasporaUrlHelper {
return getPodUrl() + SUBURL_MANAGE_CONTACTS; return getPodUrl() + SUBURL_MANAGE_CONTACTS;
} }
public String getSuburlNotificationsAlsoCommentedUrl() { public String getSuburlNotificationsAlsoCommentedUrl() {
return getPodUrl() + SUBURL_NOTIFICATIONS_ALSO_COMMENTED; return getPodUrl() + SUBURL_NOTIFICATIONS_ALSO_COMMENTED;
} }

View file

@ -26,14 +26,6 @@ import android.text.Html;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import android.webkit.WebView; import android.webkit.WebView;
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;
import com.github.dfa.diaspora_android.data.PodUserProfile;
import java.util.Locale;
/** /**
* Created by Gregor Santner on 07.08.16. * Created by Gregor Santner on 07.08.16.
* https://gsantner.github.io * https://gsantner.github.io
@ -110,52 +102,4 @@ public class WebHelper {
" }" + " }" +
"})();"); "})();");
} }
public static void showAspectList(final WebView wv, final App app) {
wv.stopLoading();
PodUserProfile profile = app.getPodUserProfile();
StringBuilder sb = new StringBuilder();
sb.append("<html><body style='margin-top: 25px; margin-left:auto;margin-right:auto; font-size: 400%;'>");
// Content
for (PodAspect aspect : profile.getAspects()) {
sb.append("<span style='margin-left: 30px; '></span>&raquo; &nbsp;");
sb.append(aspect.toHtmlLink(app));
sb.append("<hr style='height:5px;' />");
}
// End
sb.append("</body></html>");
wv.loadDataWithBaseURL(null, sb.toString(), "text/html", "UTF-16", null);
}
public static void showFollowedTagsList(final WebView wv, final App app) {
wv.stopLoading();
PodUserProfile profile = app.getPodUserProfile();
StringBuilder sb = new StringBuilder();
sb.append("<html><body style='margin-top: 25px; margin-left:auto;margin-right:auto; font-size: 400%;'>");
// Content
AppSettings appSettings = app.getSettings();
String pod0BaseUrl = appSettings.getPod().getPodUrl().getBaseUrl();
sb.append("<span style='margin-left: 30px; '></span>&raquo; &nbsp;");
sb.append(String.format(Locale.getDefault(),
"<a href='%s/followed_tags' style='color: #000000; text-decoration: none;'><b>%s</b></a>",
pod0BaseUrl, app.getString(R.string.all_tags)));
sb.append("<hr style='height:5px;' />");
for (String tag : profile.getFollowedTags()) {
sb.append("<span style='margin-left: 30px; '></span>&raquo; &nbsp;");
sb.append(String.format(Locale.getDefault(),
"<a href='%s/tags/%s' style='color: #000000; text-decoration: none;'>#%s</a>",
pod0BaseUrl, tag, tag));
sb.append("<hr style='height:5px;' />");
}
// End
sb.append("</body></html>");
wv.loadDataWithBaseURL(null, sb.toString(), "text/html", "UTF-16", null);
}
} }

View file

@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#000000" android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z"/>
</vector>

View file

@ -0,0 +1,6 @@
<vector android:height="24dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffff00"
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"
android:strokeColor="#000000" android:strokeWidth="1"/>
</vector>

View file

@ -14,7 +14,7 @@
android:orientation="vertical"> android:orientation="vertical">
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/fragment_followed_tags__recycler_view" android:id="@+id/fragment_list__recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scrollbars="vertical" android:scrollbars="vertical"

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/recycler_view__list_item__root" android:id="@+id/recycler_view__list_item__root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -10,18 +11,36 @@
android:id="@+id/recycler_view__list_item__divider" android:id="@+id/recycler_view__list_item__divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_alignParentTop="true"
android:background="@color/divider" /> android:background="@color/divider" />
<TextView <TextView
android:id="@+id/recycler_view__list_item__text" android:id="@+id/recycler_view__list_item__text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginBottom="12dp" android:layout_alignParentBottom="true"
android:layout_marginEnd="@dimen/activity_horizontal_margin" android:layout_alignParentStart="true"
android:layout_below="@id/recycler_view__list_item__divider"
android:layout_marginStart="@dimen/activity_horizontal_margin" android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_toStartOf="@+id/recycler_view__list_item__favourite"
android:gravity="center_vertical"
android:paddingBottom="12dp"
android:textAppearance="@style/TextAppearance.AppCompat.Large" android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@color/primary_text" android:textColor="@color/primary_text"
tools:text="Very much text" /> tools:text="Very much text" />
</LinearLayout> <android.support.v7.widget.AppCompatImageView
android:id="@+id/recycler_view__list_item__favourite"
android:layout_width="32dp"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_below="@id/recycler_view__list_item__divider"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginTop="12dp"
android:paddingBottom="12dp"
android:scaleType="center"
app:srcCompat="@drawable/ic_star_border_black_48px" />
</RelativeLayout>

View file

@ -51,7 +51,9 @@
<string name="pref_key__podprofile_name" translatable="false">podUserProfile_name</string> <string name="pref_key__podprofile_name" translatable="false">podUserProfile_name</string>
<string name="pref_key__podprofile_id" translatable="false">podUserProfile_guid</string> <string name="pref_key__podprofile_id" translatable="false">podUserProfile_guid</string>
<string name="pref_key__podprofile_aspects" translatable="false">podUserProfile_aspects</string> <string name="pref_key__podprofile_aspects" translatable="false">podUserProfile_aspects</string>
<string name="pref_key__podprofile_aspects_favs" translatable="false">podUserProfile_aspects_favs</string>
<string name="pref_key__podprofile_followed_tags" translatable="false">podUserProfile_followedTags</string> <string name="pref_key__podprofile_followed_tags" translatable="false">podUserProfile_followedTags</string>
<string name="pref_key__podprofile_followed_tags_favs" translatable="false">podUserProfile_followedTags_favs</string>
<string name="pref_key__podprofile_unread_message_count" translatable="false">podUserProfile_unreadMessageCount</string> <string name="pref_key__podprofile_unread_message_count" translatable="false">podUserProfile_unreadMessageCount</string>
<string name="pref_key__podprofile_notification_count" translatable="false">podUserProfile_NotificationCount</string> <string name="pref_key__podprofile_notification_count" translatable="false">podUserProfile_NotificationCount</string>