From 9478cd4ea15d4fab6fa15d26f737f83fb6ca9e8f Mon Sep 17 00:00:00 2001 From: Vavassor Date: Mon, 20 Mar 2017 16:34:23 -0400 Subject: [PATCH] You can navigate to who favourited/reblogged you from clicking the notification now. Closes #11 --- .../tusky/NotificationsAdapter.java | 25 ++++++++++++++----- .../tusky/NotificationsFragment.java | 2 +- .../tusky/ViewMediaFragment.java | 4 +-- .../res/layout/item_status_notification.xml | 7 +++--- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/NotificationsAdapter.java b/app/src/main/java/com/keylesspalace/tusky/NotificationsAdapter.java index 53ef8ca9..f760e9e2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/NotificationsAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/NotificationsAdapter.java @@ -43,13 +43,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe private List notifications; private StatusActionListener statusListener; - private FollowListener followListener; + private NotificationActionListener notificationActionListener; - NotificationsAdapter(StatusActionListener statusListener, FollowListener followListener) { + NotificationsAdapter(StatusActionListener statusListener, + NotificationActionListener notificationActionListener) { super(); notifications = new ArrayList<>(); this.statusListener = statusListener; - this.followListener = followListener; + this.notificationActionListener = notificationActionListener; } @Override @@ -96,13 +97,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe StatusNotificationViewHolder holder = (StatusNotificationViewHolder) viewHolder; holder.setMessage(type, notification.account.getDisplayName(), notification.status); + holder.setupButtons(notificationActionListener, notification.account.id); break; } case FOLLOW: { FollowViewHolder holder = (FollowViewHolder) viewHolder; holder.setMessage(notification.account.getDisplayName(), notification.account.username, notification.account.avatar); - holder.setupButtons(followListener, notification.account.id); + holder.setupButtons(notificationActionListener, notification.account.id); break; } } @@ -175,7 +177,7 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe notifyItemChanged(position); } - interface FollowListener { + interface NotificationActionListener { void onViewAccount(String id); } @@ -213,7 +215,7 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe .into(avatar); } - void setupButtons(final FollowListener listener, final String accountId) { + void setupButtons(final NotificationActionListener listener, final String accountId) { avatar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -227,12 +229,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe private TextView message; private ImageView icon; private TextView statusContent; + private ViewGroup container; StatusNotificationViewHolder(View itemView) { super(itemView); message = (TextView) itemView.findViewById(R.id.notification_text); icon = (ImageView) itemView.findViewById(R.id.notification_icon); statusContent = (TextView) itemView.findViewById(R.id.notification_content); + container = (ViewGroup) itemView.findViewById(R.id.notification_container); } void setMessage(Notification.Type type, String displayName, Status status) { @@ -262,5 +266,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe message.setText(str); statusContent.setText(status.content); } + + void setupButtons(final NotificationActionListener listener, final String accountId) { + container.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + listener.onViewAccount(accountId); + } + }); + } } } diff --git a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java index 7ab62b63..7d6c0c2d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java @@ -40,7 +40,7 @@ import retrofit2.Response; public class NotificationsFragment extends SFragment implements SwipeRefreshLayout.OnRefreshListener, StatusActionListener, - NotificationsAdapter.FollowListener { + NotificationsAdapter.NotificationActionListener { private static final String TAG = "Notifications"; // logging tag private SwipeRefreshLayout swipeRefreshLayout; diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewMediaFragment.java b/app/src/main/java/com/keylesspalace/tusky/ViewMediaFragment.java index 980cb587..df950037 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewMediaFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/ViewMediaFragment.java @@ -85,13 +85,13 @@ public class ViewMediaFragment extends DialogFragment { } }); - /* An upward swipe motion also closes the viewer. This is especially useful when the photo + /* A vertical swipe motion also closes the viewer. This is especially useful when the photo * mostly fills the screen so clicking outside is difficult. */ attacher.setOnSingleFlingListener(new PhotoViewAttacher.OnSingleFlingListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if (velocityY < 0.0 && Math.abs(velocityY) > Math.abs(velocityX)) { + if (Math.abs(velocityY) > Math.abs(velocityX)) { dismiss(); return true; } diff --git a/app/src/main/res/layout/item_status_notification.xml b/app/src/main/res/layout/item_status_notification.xml index b658ed42..472d5d23 100644 --- a/app/src/main/res/layout/item_status_notification.xml +++ b/app/src/main/res/layout/item_status_notification.xml @@ -2,11 +2,12 @@ + android:paddingRight="16dp">