From 2b0a5cd8764c0e02bd8c83891efcfa37a83a5751 Mon Sep 17 00:00:00 2001 From: Gregor Santner Date: Wed, 26 Oct 2016 14:33:05 +0200 Subject: [PATCH] ThemedFragment for Aspects & tagst, fixes #94 #81 --- app/build.gradle | 2 + .../activity/MainActivity.java | 14 +- .../diaspora_android/data/AppSettings.java | 24 ++- .../diaspora_android/data/PodUserProfile.java | 2 +- .../fragment/AspectListFragment.java | 197 ++++++++++++++++++ .../fragment/DiasporaStreamFragment.java | 4 +- .../fragment/HashtagListFragment.java | 128 ++++++++---- .../listener/OnSomethingClickListener.java | 15 ++ .../util/DiasporaUrlHelper.java | 12 +- .../dfa/diaspora_android/util/WebHelper.java | 56 ----- .../drawable/ic_star_border_black_48px.xml | 4 + .../main/res/drawable/ic_star_filled_48px.xml | 6 + ...agment.xml => recycler_list__fragment.xml} | 2 +- .../res/layout/recycler_view__list_item.xml | 29 ++- .../main/res/values/strings-preferences.xml | 2 + 15 files changed, 381 insertions(+), 116 deletions(-) create mode 100644 app/src/main/java/com/github/dfa/diaspora_android/fragment/AspectListFragment.java create mode 100644 app/src/main/java/com/github/dfa/diaspora_android/listener/OnSomethingClickListener.java create mode 100644 app/src/main/res/drawable/ic_star_border_black_48px.xml create mode 100644 app/src/main/res/drawable/ic_star_filled_48px.xml rename app/src/main/res/layout/{hashtag_list__fragment.xml => recycler_list__fragment.xml} (94%) diff --git a/app/build.gradle b/app/build.gradle index e580b2dc..fac00a3c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,6 +11,8 @@ android { targetSdkVersion 24 versionCode 8 versionName "0.1.6-next" + + vectorDrawables.useSupportLibrary=true } buildTypes { release { 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 852a84f6..9ede6ec8 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 @@ -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.DiasporaPodList; 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.CustomFragment; import com.github.dfa.diaspora_android.fragment.DiasporaStreamFragment; @@ -286,6 +287,10 @@ public class MainActivity extends ThemedActivity HashtagListFragment hlf = new HashtagListFragment(); fm.beginTransaction().add(hlf, fragmentTag).commit(); return hlf; + case AspectListFragment.TAG: + AspectListFragment alf = new AspectListFragment(); + fm.beginTransaction().add(alf, fragmentTag).commit(); + return alf; case PodSelectionFragment.TAG: PodSelectionFragment psf = new PodSelectionFragment(); fm.beginTransaction().add(psf, fragmentTag).commit(); @@ -987,14 +992,7 @@ public class MainActivity extends ThemedActivity //TODO: Replace with fragment case R.id.nav_aspects: { - DiasporaStreamFragment stream = (DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG); - if (WebHelper.isOnline(MainActivity.this)) { - openDiasporaUrl(DiasporaUrlHelper.URL_BLANK); - WebHelper.showAspectList(stream.getWebView(), app); - setTitle(R.string.aspects); - } else { - snackbarNoInternet.show(); - } + showFragment(getFragment(AspectListFragment.TAG)); } break; diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java index 95fd79fe..f8b83da0 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java @@ -26,6 +26,8 @@ import com.github.dfa.diaspora_android.util.ProxyHandler; import org.json.JSONException; import org.json.JSONObject; +import java.util.List; + /** * Settings * 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); } - public PodAspect[] getPodAspects() { + public PodAspect[] getAspects() { String[] s = getStringArray(prefPod, R.string.pref_key__podprofile_aspects); PodAspect[] aspects = new PodAspect[s.length]; 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); } - public void setFollowedTags(String[] tags) { - setStringArray(prefPod, R.string.pref_key__podprofile_followed_tags, tags); + public void setFollowedTags(String[] values) { + 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 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 values) { + setStringArray(prefPod, R.string.pref_key__podprofile_aspects_favs, values.toArray(new String[values.size()])); } public int getUnreadMessageCount() { diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/PodUserProfile.java b/app/src/main/java/com/github/dfa/diaspora_android/data/PodUserProfile.java index d6d3b2e2..dabd8b2d 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/PodUserProfile.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/PodUserProfile.java @@ -59,7 +59,7 @@ public class PodUserProfile { avatarUrl = appSettings.getAvatarUrl(); guid = appSettings.getProfileId(); name = appSettings.getName(); - podAspects = appSettings.getPodAspects(); + podAspects = appSettings.getAspects(); followedTags = appSettings.getFollowedTags(); notificationCount = appSettings.getNotificationCount(); unreadMessagesCount = appSettings.getUnreadMessageCount(); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/AspectListFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/AspectListFragment.java new file mode 100644 index 00000000..1952ecc3 --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/AspectListFragment.java @@ -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 . + */ +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 { + + 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 { + private AppSettings appSettings; + private PodAspect[] aspectList; + private List aspectFavsList; + private OnSomethingClickListener 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 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); + } + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/DiasporaStreamFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/DiasporaStreamFragment.java index 67523858..89e8de24 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/DiasporaStreamFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/DiasporaStreamFragment.java @@ -329,12 +329,12 @@ public class DiasporaStreamFragment extends BrowserFragment { @JavascriptInterface public void setUserProfile(final String webMessage) throws JSONException { PodUserProfile pup = ((App) getActivity().getApplication()).getPodUserProfile(); - AppLog.v(this, "StreamFragment.JavaScriptInterface.setUserProfile()"); + AppLog.spam(this, "StreamFragment.JavaScriptInterface.setUserProfile()"); if (pup.isRefreshNeeded()) { AppLog.v(this, "PodUserProfile needs refresh; Try to parse JSON"); pup.parseJson(webMessage); } else { - AppLog.v(this, "No PodUserProfile refresh needed"); + AppLog.spam(this, "No PodUserProfile refresh needed"); } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java index 6c32d6b9..143c089a 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java @@ -18,7 +18,10 @@ */ 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; @@ -26,49 +29,57 @@ 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.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 Hashtags the user follows - * Created by vanitas on 29.09.16. + * Fragment that shows a list of the HashTags the user follows */ - -public class HashtagListFragment extends CustomFragment { +public class HashtagListFragment extends ThemedFragment implements OnSomethingClickListener { public static final String TAG = "com.github.dfa.diaspora_android.HashtagListFragment"; protected RecyclerView followedTagsRecyclerView; - protected String[] followedTags; 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.hashtag_list__fragment, container, false); + return inflater.inflate(R.layout.recycler_list__fragment, container, false); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - this.followedTagsRecyclerView = (RecyclerView) view.findViewById(R.id.fragment_followed_tags__recycler_view); - this.app = (App) getActivity().getApplication(); - this.urls = new DiasporaUrlHelper(app.getSettings()); + followedTagsRecyclerView = (RecyclerView) view.findViewById(R.id.fragment_list__recycler_view); + app = (App) getActivity().getApplication(); + AppSettings appSettings = app.getSettings(); + urls = new DiasporaUrlHelper(appSettings); - followedTags = app.getPodUserProfile().getFollowedTags(); followedTagsRecyclerView.setHasFixedSize(true); followedTagsRecyclerView.setNestedScrollingEnabled(false); - RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this.getContext()); + RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext()); followedTagsRecyclerView.setLayoutManager(layoutManager); - final FollowedTagsAdapter adapter = new FollowedTagsAdapter(followedTags, onHashtagClickListener); + final FollowedTagsAdapter adapter = new FollowedTagsAdapter(appSettings, this); followedTagsRecyclerView.setAdapter(adapter); //Set window title @@ -90,57 +101,96 @@ public class HashtagListFragment extends CustomFragment { return false; } - protected View.OnClickListener onHashtagClickListener = new View.OnClickListener() { - @Override - public void onClick(View view) { - int itemPosition = followedTagsRecyclerView.getChildLayoutPosition(view); - if (itemPosition > -1 && itemPosition < followedTags.length) { - String tag = followedTags[itemPosition]; - ((MainActivity) getActivity()).openDiasporaUrl(urls.getSearchTagsUrl(tag)); - } - } - }; + @Override + public void onSomethingClicked(Object null1, Integer null2, String tag) { + ((MainActivity) getActivity()).openDiasporaUrl(urls.getSearchTagsUrl(tag)); + } + + @Override + protected void applyColorToViews() { + followedTagsRecyclerView.invalidate(); + } public static class FollowedTagsAdapter extends RecyclerView.Adapter { + private AppSettings appSettings; private String[] followedTagsList; - private View.OnClickListener itemClickListener; + private List followedTagsFavsList; + private OnSomethingClickListener tagClickedListener; - public static class ViewHolder extends RecyclerView.ViewHolder { - // each data item is just a string in this case + 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; - public ViewHolder(View v) { + ViewHolder(View 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) { - this.followedTagsList = tags; - this.itemClickListener = itemClickListener; + + FollowedTagsAdapter(AppSettings appSettings, OnSomethingClickListener tagClickedListener) { + this.appSettings = appSettings; + this.followedTagsList = appSettings.getFollowedTags(); + this.followedTagsFavsList = new ArrayList<>(Arrays.asList(appSettings.getFollowedTagsFavs())); + this.tagClickedListener = tagClickedListener; + } + + @Override + public int getItemCount() { + return followedTagsList.length; } @Override public FollowedTagsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()) .inflate(R.layout.recycler_view__list_item, parent, false); - v.setOnClickListener(itemClickListener); return new ViewHolder(v); } - // Replace the contents of a view (invoked by the layout manager) @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) - @Override - public int getItemCount() { - return followedTagsList.length; + private boolean isFollowedTagFaved(String tag) { + return followedTagsFavsList.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); } } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/listener/OnSomethingClickListener.java b/app/src/main/java/com/github/dfa/diaspora_android/listener/OnSomethingClickListener.java new file mode 100644 index 00000000..86ae6789 --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/listener/OnSomethingClickListener.java @@ -0,0 +1,15 @@ +package com.github.dfa.diaspora_android.listener; + +/** + * Listener for different types of click events + */ +public interface OnSomethingClickListener { + /** + * 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); +} 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 6b6b3820..1377b2a6 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 @@ -43,6 +43,7 @@ public class DiasporaUrlHelper { public static final String SUBURL_COMMENTED = "/commented"; public static final String SUBURL_MENTIONS = "/mentions"; 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_SEARCH_TAGS = "/tags/"; public static final String SUBURL_SEARCH_PEOPLE = "/people.mobile?q="; @@ -144,6 +145,16 @@ public class DiasporaUrlHelper { 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 * @@ -263,7 +274,6 @@ public class DiasporaUrlHelper { return getPodUrl() + SUBURL_MANAGE_CONTACTS; } - public String getSuburlNotificationsAlsoCommentedUrl() { return getPodUrl() + SUBURL_NOTIFICATIONS_ALSO_COMMENTED; } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/WebHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/util/WebHelper.java index 21861da6..8d9dd44f 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/WebHelper.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/WebHelper.java @@ -26,14 +26,6 @@ import android.text.Html; import android.webkit.URLUtil; 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. * 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(""); - - // Content - for (PodAspect aspect : profile.getAspects()) { - sb.append("»  "); - sb.append(aspect.toHtmlLink(app)); - sb.append("
"); - } - - // End - sb.append(""); - 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(""); - - // Content - AppSettings appSettings = app.getSettings(); - String pod0BaseUrl = appSettings.getPod().getPodUrl().getBaseUrl(); - sb.append("»  "); - sb.append(String.format(Locale.getDefault(), - "%s", - pod0BaseUrl, app.getString(R.string.all_tags))); - sb.append("
"); - for (String tag : profile.getFollowedTags()) { - sb.append("»  "); - sb.append(String.format(Locale.getDefault(), - "#%s", - pod0BaseUrl, tag, tag)); - sb.append("
"); - } - - // End - sb.append(""); - wv.loadDataWithBaseURL(null, sb.toString(), "text/html", "UTF-16", null); - } - } diff --git a/app/src/main/res/drawable/ic_star_border_black_48px.xml b/app/src/main/res/drawable/ic_star_border_black_48px.xml new file mode 100644 index 00000000..3da8c75b --- /dev/null +++ b/app/src/main/res/drawable/ic_star_border_black_48px.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_star_filled_48px.xml b/app/src/main/res/drawable/ic_star_filled_48px.xml new file mode 100644 index 00000000..2b1fe326 --- /dev/null +++ b/app/src/main/res/drawable/ic_star_filled_48px.xml @@ -0,0 +1,6 @@ + + + diff --git a/app/src/main/res/layout/hashtag_list__fragment.xml b/app/src/main/res/layout/recycler_list__fragment.xml similarity index 94% rename from app/src/main/res/layout/hashtag_list__fragment.xml rename to app/src/main/res/layout/recycler_list__fragment.xml index 7ca77b13..a61f9f4c 100644 --- a/app/src/main/res/layout/hashtag_list__fragment.xml +++ b/app/src/main/res/layout/recycler_list__fragment.xml @@ -14,7 +14,7 @@ android:orientation="vertical"> - - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings-preferences.xml b/app/src/main/res/values/strings-preferences.xml index d08d4de1..4406361d 100644 --- a/app/src/main/res/values/strings-preferences.xml +++ b/app/src/main/res/values/strings-preferences.xml @@ -51,7 +51,9 @@ podUserProfile_name podUserProfile_guid podUserProfile_aspects + podUserProfile_aspects_favs podUserProfile_followedTags + podUserProfile_followedTags_favs podUserProfile_unreadMessageCount podUserProfile_NotificationCount