From 2304d5a963fd1fcd7b390526db175cad5943d037 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sat, 15 Sep 2018 17:45:33 +0200 Subject: [PATCH] Improve notifications tab --- .../drawers/NotificationsListAdapter.java | 11 +++ .../mastodon/drawers/StatusListAdapter.java | 86 +++++++++---------- .../res/layout/fragment_notifications.xml | 5 +- 3 files changed, 56 insertions(+), 46 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java index b21a247a6..70478c035 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java @@ -34,9 +34,11 @@ import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.text.method.LinkMovementMethod; +import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.Button; @@ -767,6 +769,15 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On } }); + holder.notification_status_content.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) { + try{view.requestFocus();}catch (Exception ignored){} + } + return false; + } + }); if( theme == Helper.THEME_LIGHT) { holder.status_show_more.setTextColor(ContextCompat.getColor(context, R.color.white)); } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index 5de4800f1..33a42f6b0 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -607,7 +607,48 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct if( !status.isEmojiFound()) status.makeEmojis(context, StatusListAdapter.this); - + holder.status_content.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) { + try{view.requestFocus();}catch (Exception ignored){} + } + return false; + } + }); + //Click on a conversation + if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && (getItemViewType(position) == DISPLAYED_STATUS || getItemViewType(position) == COMPACT_STATUS)) { + holder.status_content.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(context, ShowConversationActivity.class); + Bundle b = new Bundle(); + if (status.getReblog() == null) + b.putString("statusId", status.getId()); + else + b.putString("statusId", status.getReblog().getId()); + intent.putExtras(b); + if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) + ((Activity) context).finish(); + context.startActivity(intent); + } + }); + holder.main_container.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(context, ShowConversationActivity.class); + Bundle b = new Bundle(); + if (status.getReblog() == null) + b.putString("statusId", status.getId()); + else + b.putString("statusId", status.getReblog().getId()); + intent.putExtras(b); + if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) + ((Activity) context).finish(); + context.startActivity(intent); + } + }); + } holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE); @@ -998,48 +1039,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct } - holder.status_content.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View view, MotionEvent motionEvent) { - if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) { - try{view.requestFocus();}catch (Exception ignored){} - } - return false; - } - }); - //Click on a conversation - if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && (getItemViewType(position) == DISPLAYED_STATUS || getItemViewType(position) == COMPACT_STATUS)) { - holder.status_content.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(context, ShowConversationActivity.class); - Bundle b = new Bundle(); - if (status.getReblog() == null) - b.putString("statusId", status.getId()); - else - b.putString("statusId", status.getReblog().getId()); - intent.putExtras(b); - if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) - ((Activity) context).finish(); - context.startActivity(intent); - } - }); - holder.main_container.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(context, ShowConversationActivity.class); - Bundle b = new Bundle(); - if (status.getReblog() == null) - b.putString("statusId", status.getId()); - else - b.putString("statusId", status.getReblog().getId()); - intent.putExtras(b); - if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) - ((Activity) context).finish(); - context.startActivity(intent); - } - }); - } + if( theme == Helper.THEME_LIGHT){ holder.main_container.setBackgroundResource(R.color.mastodonC3__); }else if (theme == Helper.THEME_DARK){ diff --git a/app/src/main/res/layout/fragment_notifications.xml b/app/src/main/res/layout/fragment_notifications.xml index 5426586f7..ae4125791 100644 --- a/app/src/main/res/layout/fragment_notifications.xml +++ b/app/src/main/res/layout/fragment_notifications.xml @@ -31,9 +31,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none" - android:divider="@null" - > - + + />