Modified comment-view creation. Modified activities link colour.

This commit is contained in:
RyanBateman 2012-09-21 11:43:13 -04:00
parent 7be202ac1e
commit f85e517b2a
12 changed files with 222 additions and 189 deletions

View file

@ -78,6 +78,7 @@
<string name="profile_started_following">Started following </string> <string name="profile_started_following">Started following </string>
<string name="profile_replied_to">Replied to</string> <string name="profile_replied_to">Replied to</string>
<string name="profile_with_comment">with the comment</string> <string name="profile_with_comment">with the comment</string>
<string name="profile_liked_comment">Liked the comment</string>
<string name="profile_shared_story">Shared the story</string> <string name="profile_shared_story">Shared the story</string>
<string name="profile_button_follow">Follow</string> <string name="profile_button_follow">Follow</string>
<string name="profile_button_unfollow">Following</string> <string name="profile_button_unfollow">Following</string>

View file

@ -15,7 +15,7 @@ import com.newsblur.fragment.ProfileDetailsFragment;
import com.newsblur.network.APIManager; import com.newsblur.network.APIManager;
import com.newsblur.network.domain.ActivitiesResponse; import com.newsblur.network.domain.ActivitiesResponse;
import com.newsblur.network.domain.ProfileResponse; import com.newsblur.network.domain.ProfileResponse;
import com.newsblur.util.PrefsUtil; import com.newsblur.util.PrefsUtils;
public class Profile extends SherlockFragmentActivity { public class Profile extends SherlockFragmentActivity {
@ -78,7 +78,7 @@ public class Profile extends SherlockFragmentActivity {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
if (TextUtils.isEmpty(userId)) { if (TextUtils.isEmpty(userId)) {
detailsFragment.setUser(PrefsUtil.getUserDetails(Profile.this), true); detailsFragment.setUser(PrefsUtils.getUserDetails(Profile.this), true);
} }
} }
@ -90,7 +90,7 @@ public class Profile extends SherlockFragmentActivity {
activities = profileResponse.activities; activities = profileResponse.activities;
} else { } else {
apiManager.updateUserProfile(); apiManager.updateUserProfile();
user = PrefsUtil.getUserDetails(Profile.this); user = PrefsUtils.getUserDetails(Profile.this);
profileResponse = apiManager.getUser(user.id); profileResponse = apiManager.getUser(user.id);
if (profileResponse != null) { if (profileResponse != null) {
activities = profileResponse.activities; activities = profileResponse.activities;

View file

@ -35,7 +35,7 @@ import com.newsblur.fragment.ShareDialogFragment;
import com.newsblur.fragment.SyncUpdateFragment; import com.newsblur.fragment.SyncUpdateFragment;
import com.newsblur.fragment.TextSizeDialogFragment; import com.newsblur.fragment.TextSizeDialogFragment;
import com.newsblur.util.PrefConstants; import com.newsblur.util.PrefConstants;
import com.newsblur.util.PrefsUtil; import com.newsblur.util.PrefsUtils;
import com.newsblur.util.UIUtils; import com.newsblur.util.UIUtils;
public abstract class Reading extends SherlockFragmentActivity implements OnPageChangeListener, SyncUpdateFragment.SyncUpdateFragmentInterface, OnSeekBarChangeListener { public abstract class Reading extends SherlockFragmentActivity implements OnPageChangeListener, SyncUpdateFragment.SyncUpdateFragmentInterface, OnSeekBarChangeListener {
@ -106,7 +106,7 @@ public abstract class Reading extends SherlockFragmentActivity implements OnPage
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int currentItem = pager.getCurrentItem(); int currentItem = pager.getCurrentItem();
Story story = readingAdapter.getStory(currentItem); Story story = readingAdapter.getStory(currentItem);
UserProfile user = PrefsUtil.getUserDetails(this); UserProfile user = PrefsUtils.getUserDetails(this);
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:

View file

@ -7,7 +7,7 @@ import com.newsblur.network.domain.LoginResponse;
import com.newsblur.service.DetachableResultReceiver; import com.newsblur.service.DetachableResultReceiver;
import com.newsblur.service.SyncService; import com.newsblur.service.SyncService;
import com.newsblur.service.DetachableResultReceiver.Receiver; import com.newsblur.service.DetachableResultReceiver.Receiver;
import com.newsblur.util.PrefsUtil; import com.newsblur.util.PrefsUtils;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -116,7 +116,7 @@ public class LoginProgressFragment extends Fragment implements Receiver {
updateStatus.setText(R.string.login_logged_in); updateStatus.setText(R.string.login_logged_in);
updateStatus.startAnimation(a); updateStatus.startAnimation(a);
loginProfilePicture.setImageBitmap(PrefsUtil.getUserImage(getActivity())); loginProfilePicture.setImageBitmap(PrefsUtils.getUserImage(getActivity()));
feedProgress.setVisibility(View.VISIBLE); feedProgress.setVisibility(View.VISIBLE);
Log.d(TAG, "Authenticated. Starting receiver."); Log.d(TAG, "Authenticated. Starting receiver.");

View file

@ -19,7 +19,7 @@ import com.newsblur.activity.NewsBlurApplication;
import com.newsblur.domain.UserProfile; import com.newsblur.domain.UserProfile;
import com.newsblur.network.APIManager; import com.newsblur.network.APIManager;
import com.newsblur.util.ImageLoader; import com.newsblur.util.ImageLoader;
import com.newsblur.util.PrefsUtil; import com.newsblur.util.PrefsUtils;
import com.newsblur.util.UIUtils; import com.newsblur.util.UIUtils;
public class ProfileDetailsFragment extends Fragment implements OnClickListener { public class ProfileDetailsFragment extends Fragment implements OnClickListener {
@ -111,7 +111,7 @@ public class ProfileDetailsFragment extends Fragment implements OnClickListener
} }
} else { } else {
followButton.setVisibility(View.GONE); followButton.setVisibility(View.GONE);
Bitmap userPicture = PrefsUtil.getUserImage(getActivity()); Bitmap userPicture = PrefsUtils.getUserImage(getActivity());
userPicture = UIUtils.roundCorners(userPicture, 5); userPicture = UIUtils.roundCorners(userPicture, 5);
imageView.setImageBitmap(userPicture); imageView.setImageBitmap(userPicture);
} }

View file

@ -13,6 +13,7 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayout;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -33,8 +34,9 @@ import com.newsblur.network.APIManager;
import com.newsblur.network.SetupCommentSectionTask; import com.newsblur.network.SetupCommentSectionTask;
import com.newsblur.util.ImageLoader; import com.newsblur.util.ImageLoader;
import com.newsblur.util.PrefConstants; import com.newsblur.util.PrefConstants;
import com.newsblur.util.PrefsUtil; import com.newsblur.util.PrefsUtils;
import com.newsblur.util.UIUtils; import com.newsblur.util.UIUtils;
import com.newsblur.util.ViewUtils;
import com.newsblur.view.NewsblurWebview; import com.newsblur.view.NewsblurWebview;
import com.newsblur.view.TagAdapter; import com.newsblur.view.TagAdapter;
@ -87,7 +89,7 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
inflater = getActivity().getLayoutInflater(); inflater = getActivity().getLayoutInflater();
user = PrefsUtil.getUserDetails(getActivity()); user = PrefsUtils.getUserDetails(getActivity());
feedTitle = getArguments().getString("feedTitle"); feedTitle = getArguments().getString("feedTitle");
feedColor = getArguments().getString("feedColor"); feedColor = getArguments().getString("feedColor");
@ -283,11 +285,13 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
@Override @Override
public void sharedCallback(String sharedText, boolean hasBeenShared) { public void sharedCallback(String sharedText, boolean hasAlreadyBeenShared) {
view.findViewById(R.id.reading_share_bar).setVisibility(View.VISIBLE);
view.findViewById(R.id.share_bar_underline).setVisibility(View.VISIBLE);
if (!hasBeenShared) { if (!hasAlreadyBeenShared) {
LayoutInflater inflater = getActivity().getLayoutInflater();
if (!TextUtils.isEmpty(sharedText)) {
View commentView = inflater.inflate(R.layout.include_comment, null); View commentView = inflater.inflate(R.layout.include_comment, null);
commentView.setTag(SetupCommentSectionTask.COMMENT_VIEW_BY + user.id); commentView.setTag(SetupCommentSectionTask.COMMENT_VIEW_BY + user.id);
@ -296,7 +300,7 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
commentText.setText(sharedText); commentText.setText(sharedText);
ImageView commentImage = (ImageView) commentView.findViewById(R.id.comment_user_image); ImageView commentImage = (ImageView) commentView.findViewById(R.id.comment_user_image);
commentImage.setImageBitmap(UIUtils.roundCorners(PrefsUtil.getUserImage(getActivity()), 10f)); commentImage.setImageBitmap(UIUtils.roundCorners(PrefsUtils.getUserImage(getActivity()), 10f));
TextView commentSharedDate = (TextView) commentView.findViewById(R.id.comment_shareddate); TextView commentSharedDate = (TextView) commentView.findViewById(R.id.comment_shareddate);
commentSharedDate.setText(R.string.now); commentSharedDate.setText(R.string.now);
@ -317,6 +321,16 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
} }
}, 1000); }, 1000);
ViewUtils.setupCommentCount(getActivity(), view, story.commentCount + 1);
final ImageView image = ViewUtils.createSharebarImage(getActivity(), imageLoader, user);
((GridLayout) view.findViewById(R.id.reading_social_commentimages)).addView(image);
} else {
ViewUtils.setupShareCount(getActivity(), view, story.sharedUserIds.length + 1);
final ImageView image = ViewUtils.createSharebarImage(getActivity(), imageLoader, user);
((GridLayout) view.findViewById(R.id.reading_social_shareimages)).addView(image);
}
} else { } else {
View commentViewForUser = view.findViewWithTag(SetupCommentSectionTask.COMMENT_VIEW_BY + user.id); View commentViewForUser = view.findViewWithTag(SetupCommentSectionTask.COMMENT_VIEW_BY + user.id);
commentViewForUser.setBackgroundResource(R.drawable.transition_edit_background); commentViewForUser.setBackgroundResource(R.drawable.transition_edit_background);
@ -335,7 +349,6 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
TextView commentDateText = (TextView) view.findViewWithTag(SetupCommentSectionTask.COMMENT_DATE_BY + user.id); TextView commentDateText = (TextView) view.findViewWithTag(SetupCommentSectionTask.COMMENT_DATE_BY + user.id);
commentDateText.setText(R.string.now); commentDateText.setText(R.string.now);
} }
} }

View file

@ -26,7 +26,7 @@ import com.newsblur.domain.Comment;
import com.newsblur.domain.Story; import com.newsblur.domain.Story;
import com.newsblur.domain.UserProfile; import com.newsblur.domain.UserProfile;
import com.newsblur.network.APIManager; import com.newsblur.network.APIManager;
import com.newsblur.util.PrefsUtil; import com.newsblur.util.PrefsUtils;
public class ShareDialogFragment extends DialogFragment { public class ShareDialogFragment extends DialogFragment {
@ -61,7 +61,7 @@ public class ShareDialogFragment extends DialogFragment {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
story = (Story) getArguments().getSerializable(STORY); story = (Story) getArguments().getSerializable(STORY);
callback = (SharedCallbackDialog) getArguments().getSerializable(CALLBACK); callback = (SharedCallbackDialog) getArguments().getSerializable(CALLBACK);
user = PrefsUtil.getUserDetails(getActivity()); user = PrefsUtils.getUserDetails(getActivity());
previouslySavedShareText = getArguments().getString(PREVIOUSLY_SAVED_SHARE_TEXT); previouslySavedShareText = getArguments().getString(PREVIOUSLY_SAVED_SHARE_TEXT);
apiManager = new APIManager(getActivity()); apiManager = new APIManager(getActivity());

View file

@ -38,7 +38,7 @@ import com.newsblur.network.domain.ProfileResponse;
import com.newsblur.network.domain.SocialFeedResponse; import com.newsblur.network.domain.SocialFeedResponse;
import com.newsblur.network.domain.StoriesResponse; import com.newsblur.network.domain.StoriesResponse;
import com.newsblur.serialization.DateStringTypeAdapter; import com.newsblur.serialization.DateStringTypeAdapter;
import com.newsblur.util.PrefsUtil; import com.newsblur.util.PrefsUtils;
public class APIManager { public class APIManager {
@ -63,7 +63,7 @@ public class APIManager {
final APIResponse response = client.post(APIConstants.URL_LOGIN, values); final APIResponse response = client.post(APIConstants.URL_LOGIN, values);
if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) {
LoginResponse loginResponse = gson.fromJson(response.responseString, LoginResponse.class); LoginResponse loginResponse = gson.fromJson(response.responseString, LoginResponse.class);
PrefsUtil.saveCookie(context, response.cookie); PrefsUtils.saveCookie(context, response.cookie);
return loginResponse; return loginResponse;
} else { } else {
return new LoginResponse(); return new LoginResponse();
@ -148,7 +148,7 @@ public class APIManager {
final APIResponse response = client.post(APIConstants.URL_SIGNUP, values); final APIResponse response = client.post(APIConstants.URL_SIGNUP, values);
if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) {
LoginResponse loginResponse = gson.fromJson(response.responseString, LoginResponse.class); LoginResponse loginResponse = gson.fromJson(response.responseString, LoginResponse.class);
PrefsUtil.saveCookie(context, response.cookie); PrefsUtils.saveCookie(context, response.cookie);
CookieSyncManager.createInstance(context.getApplicationContext()); CookieSyncManager.createInstance(context.getApplicationContext());
CookieManager cookieManager = CookieManager.getInstance(); CookieManager cookieManager = CookieManager.getInstance();
@ -167,7 +167,7 @@ public class APIManager {
final APIResponse response = client.get(APIConstants.URL_MY_PROFILE); final APIResponse response = client.get(APIConstants.URL_MY_PROFILE);
if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) {
ProfileResponse profileResponse = gson.fromJson(response.responseString, ProfileResponse.class); ProfileResponse profileResponse = gson.fromJson(response.responseString, ProfileResponse.class);
PrefsUtil.saveUserDetails(context, profileResponse.user); PrefsUtils.saveUserDetails(context, profileResponse.user);
return profileResponse; return profileResponse;
} else { } else {
return null; return null;

View file

@ -14,7 +14,6 @@ import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v7.widget.GridLayout; import android.support.v7.widget.GridLayout;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -33,8 +32,8 @@ import com.newsblur.domain.UserProfile;
import com.newsblur.fragment.ReplyDialogFragment; import com.newsblur.fragment.ReplyDialogFragment;
import com.newsblur.network.domain.ProfileResponse; import com.newsblur.network.domain.ProfileResponse;
import com.newsblur.util.ImageLoader; import com.newsblur.util.ImageLoader;
import com.newsblur.util.PrefsUtil; import com.newsblur.util.PrefsUtils;
import com.newsblur.util.UIUtils; import com.newsblur.util.ViewUtils;
public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> { public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
public static final String COMMENT_BY = "commentBy"; public static final String COMMENT_BY = "commentBy";
@ -56,8 +55,6 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
private UserProfile user; private UserProfile user;
private final FragmentManager manager; private final FragmentManager manager;
private Cursor commentCursor; private Cursor commentCursor;
private String comment;
private String sharedBy;
public SetupCommentSectionTask(final Context context, final View view, final FragmentManager manager, LayoutInflater inflater, final ContentResolver resolver, final APIManager apiManager, final Story story, final ImageLoader imageLoader) { public SetupCommentSectionTask(final Context context, final View view, final FragmentManager manager, LayoutInflater inflater, final ContentResolver resolver, final APIManager apiManager, final Story story, final ImageLoader imageLoader) {
this.context = context; this.context = context;
@ -68,9 +65,7 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
this.story = story; this.story = story;
this.imageLoader = imageLoader; this.imageLoader = imageLoader;
viewHolder = new WeakReference<View>(view); viewHolder = new WeakReference<View>(view);
comment = context.getResources().getString(R.string.reading_comment_count); user = PrefsUtils.getUserDetails(context);
sharedBy = context.getResources().getString(R.string.reading_shared_count);
user = PrefsUtil.getUserDetails(context);
} }
@Override @Override
@ -248,48 +243,11 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
GridLayout sharedGrid = (GridLayout) viewHolder.get().findViewById(R.id.reading_social_shareimages); GridLayout sharedGrid = (GridLayout) viewHolder.get().findViewById(R.id.reading_social_shareimages);
GridLayout commentGrid = (GridLayout) viewHolder.get().findViewById(R.id.reading_social_commentimages); GridLayout commentGrid = (GridLayout) viewHolder.get().findViewById(R.id.reading_social_commentimages);
TextView commentText = (TextView) viewHolder.get().findViewById(R.id.comment_by); ViewUtils.setupCommentCount(context, viewHolder.get(), commentCursor.getCount());
if (commentCursor.getCount() > 0) { ViewUtils.setupShareCount(context, viewHolder.get(), story.sharedUserIds.length);
comment = String.format(comment, commentCursor.getCount());
commentText.setText(commentCursor.getCount() > 1 ? comment : comment.substring(0, comment.length() - 1));
} else {
commentText.setVisibility(View.INVISIBLE);
}
TextView sharesText = (TextView) viewHolder.get().findViewById(R.id.shared_by);
if (story.sharedUserIds.length > 0) {
sharedBy = String.format(sharedBy, story.sharedUserIds.length);
sharesText.setText(story.sharedUserIds.length > 1 ? sharedBy : sharedBy.substring(0, sharedBy.length() - 1));
} else {
sharesText.setVisibility(View.INVISIBLE);
}
for (final String userId : story.publicUserIds) { for (final String userId : story.publicUserIds) {
ImageView image = new ImageView(context); ImageView image = ViewUtils.createSharebarImage(context, imageLoader, publicUserMap.get(userId));
int imageLength = UIUtils.convertDPsToPixels(context, 25);
image.setMaxHeight(imageLength);
image.setMaxWidth(imageLength);
GridLayout.LayoutParams imageParameters = new GridLayout.LayoutParams();
imageParameters.height = imageLength;
imageParameters.setGravity(Gravity.RIGHT);
imageParameters.width = imageLength;
imageParameters.leftMargin = UIUtils.convertDPsToPixels(context, 3);
imageParameters.rightMargin = UIUtils.convertDPsToPixels(context, 3);
imageParameters.topMargin = UIUtils.convertDPsToPixels(context, 3);
imageParameters.bottomMargin = UIUtils.convertDPsToPixels(context, 3);
image.setLayoutParams(imageParameters);
imageLoader.displayImageByUid(publicUserMap.get(userId).photoUrl, image);
image.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(context, Profile.class);
i.putExtra(Profile.USER_ID, userId);
context.startActivity(i);
}
});
sharedGrid.addView(image); sharedGrid.addView(image);
} }
@ -297,30 +255,11 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
for (int i = 0; i < commentCursor.getCount(); i++) { for (int i = 0; i < commentCursor.getCount(); i++) {
final Comment comment = Comment.fromCursor(commentCursor); final Comment comment = Comment.fromCursor(commentCursor);
ImageView image = new ImageView(context); UserProfile user;
int imageLength = UIUtils.convertDPsToPixels(context, 25); if ((user = publicUserMap.get(comment.userId)) == null) {
image.setMaxHeight(imageLength); user = friendUserMap.get(comment.userId);
image.setMaxWidth(imageLength);
GridLayout.LayoutParams imageParameters = new GridLayout.LayoutParams();
imageParameters.height = imageLength;
imageParameters.width = imageLength;
imageParameters.leftMargin = UIUtils.convertDPsToPixels(context, 3);
imageParameters.rightMargin = UIUtils.convertDPsToPixels(context, 3);
imageParameters.topMargin = UIUtils.convertDPsToPixels(context, 3);
imageParameters.bottomMargin = UIUtils.convertDPsToPixels(context, 3);
image.setLayoutParams(imageParameters);
imageLoader.displayImageByUid(publicUserMap.get(comment.userId).photoUrl, image);
image.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(context, Profile.class);
i.putExtra(Profile.USER_ID, comment.userId);
context.startActivity(i);
} }
}); ImageView image = ViewUtils.createSharebarImage(context, imageLoader, user);
commentGrid.addView(image); commentGrid.addView(image);
commentCursor.moveToNext(); commentCursor.moveToNext();
} }

View file

@ -16,7 +16,7 @@ import android.graphics.BitmapFactory;
import com.newsblur.domain.UserProfile; import com.newsblur.domain.UserProfile;
public class PrefsUtil { public class PrefsUtils {
public static void saveCookie(final Context context, final String cookie) { public static void saveCookie(final Context context, final String cookie) {
final SharedPreferences preferences = context.getSharedPreferences(PrefConstants.PREFERENCES, 0); final SharedPreferences preferences = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);

View file

@ -0,0 +1,68 @@
package com.newsblur.util;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.GridLayout;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.newsblur.R;
import com.newsblur.activity.Profile;
import com.newsblur.domain.UserProfile;
public class ViewUtils {
public static void setupShareCount(Context context, View storyView, int sharedUserCount) {
String sharedBy = context.getResources().getString(R.string.reading_shared_count);
TextView sharesText = (TextView) storyView.findViewById(R.id.shared_by);
if (sharedUserCount > 0) {
sharedBy = String.format(sharedBy, sharedUserCount);
sharesText.setText(sharedUserCount > 1 ? sharedBy : sharedBy.substring(0, sharedBy.length() - 1));
} else {
sharesText.setVisibility(View.INVISIBLE);
}
}
public static void setupCommentCount(Context context, View storyView, int sharedCommentCount) {
String commentsBy = context.getResources().getString(R.string.reading_comment_count);
TextView sharesText = (TextView) storyView.findViewById(R.id.comment_by);
if (sharedCommentCount > 0) {
commentsBy = String.format(commentsBy, sharedCommentCount);
sharesText.setText(sharedCommentCount > 1 ? commentsBy : commentsBy.substring(0, commentsBy.length() - 1));
} else {
sharesText.setVisibility(View.INVISIBLE);
}
}
public static ImageView createSharebarImage(final Context context, final ImageLoader imageLoader, final UserProfile user) {
ImageView image = new ImageView(context);
int imageLength = UIUtils.convertDPsToPixels(context, 25);
image.setMaxHeight(imageLength);
image.setMaxWidth(imageLength);
GridLayout.LayoutParams imageParameters = new GridLayout.LayoutParams();
imageParameters.height = imageLength;
imageParameters.setGravity(Gravity.RIGHT);
imageParameters.width = imageLength;
imageParameters.leftMargin = UIUtils.convertDPsToPixels(context, 3);
imageParameters.rightMargin = UIUtils.convertDPsToPixels(context, 3);
imageParameters.topMargin = UIUtils.convertDPsToPixels(context, 3);
imageParameters.bottomMargin = UIUtils.convertDPsToPixels(context, 3);
image.setLayoutParams(imageParameters);
imageLoader.displayImageByUid(user.photoUrl, image);
image.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(context, Profile.class);
i.putExtra(Profile.USER_ID, user.userId);
context.startActivity(i);
}
});
return image;
}
}

View file

@ -26,7 +26,7 @@ public class ActivitiesAdapter extends ArrayAdapter<ActivitiesResponse> {
private LayoutInflater inflater; private LayoutInflater inflater;
private ImageLoader imageLoader; private ImageLoader imageLoader;
private final String startedFollowing, ago, repliedTo, sharedStory, withComment; private final String startedFollowing, ago, repliedTo, sharedStory, withComment, likedComment;
private ForegroundColorSpan midgray, highlight, darkgray; private ForegroundColorSpan midgray, highlight, darkgray;
private String TAG = "ActivitiesAdapter"; private String TAG = "ActivitiesAdapter";
private Context context; private Context context;
@ -44,11 +44,12 @@ public class ActivitiesAdapter extends ArrayAdapter<ActivitiesResponse> {
Resources resources = context.getResources(); Resources resources = context.getResources();
startedFollowing = resources.getString(R.string.profile_started_following); startedFollowing = resources.getString(R.string.profile_started_following);
repliedTo = resources.getString(R.string.profile_replied_to); repliedTo = resources.getString(R.string.profile_replied_to);
likedComment = resources.getString(R.string.profile_liked_comment);
sharedStory = resources.getString(R.string.profile_shared_story); sharedStory = resources.getString(R.string.profile_shared_story);
withComment = resources.getString(R.string.profile_with_comment); withComment = resources.getString(R.string.profile_with_comment);
ago = resources.getString(R.string.profile_ago); ago = resources.getString(R.string.profile_ago);
highlight = new ForegroundColorSpan(resources.getColor(R.color.lightorange)); highlight = new ForegroundColorSpan(resources.getColor(R.color.linkblue));
midgray = new ForegroundColorSpan(resources.getColor(R.color.midgray)); midgray = new ForegroundColorSpan(resources.getColor(R.color.midgray));
darkgray = new ForegroundColorSpan(resources.getColor(R.color.darkgray)); darkgray = new ForegroundColorSpan(resources.getColor(R.color.darkgray));
} }
@ -80,6 +81,17 @@ public class ActivitiesAdapter extends ArrayAdapter<ActivitiesResponse> {
stringBuilder.setSpan(darkgray, 0, startedFollowing.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); stringBuilder.setSpan(darkgray, 0, startedFollowing.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilder.setSpan(usernameClick, startedFollowing.length() + 1, startedFollowing.length() + 1 + activity.user.username.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); stringBuilder.setSpan(usernameClick, startedFollowing.length() + 1, startedFollowing.length() + 1 + activity.user.username.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilder.setSpan(highlight, startedFollowing.length() + 1, startedFollowing.length() + 1 + activity.user.username.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); stringBuilder.setSpan(highlight, startedFollowing.length() + 1, startedFollowing.length() + 1 + activity.user.username.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (TextUtils.equals(activity.category, "comment_like")) {
stringBuilder.append(likedComment);
stringBuilder.append(" \"");
stringBuilder.append(activity.content);
stringBuilder.append("\" ");
stringBuilder.append("by ");
stringBuilder.append(activity.user.username);
stringBuilder.setSpan(darkgray, 0, likedComment.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilder.setSpan(highlight, likedComment.length() + 1, likedComment.length() + 3 + activity.content.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilder.setSpan(midgray, stringBuilder.length() - activity.user.username.length() - 4, stringBuilder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilder.setSpan(usernameClick, likedComment.length() + 3 + activity.content.length() + 4, stringBuilder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (TextUtils.equals(activity.category, "comment_reply")) { } else if (TextUtils.equals(activity.category, "comment_reply")) {
stringBuilder.append(repliedTo); stringBuilder.append(repliedTo);
stringBuilder.append(" "); stringBuilder.append(" ");