summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java107
1 files changed, 53 insertions, 54 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 70478c035..f21a729a4 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,7 +34,6 @@ 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;
@@ -52,6 +51,7 @@ import android.widget.Toast;
import com.bumptech.glide.Glide;
+import com.vanniktech.emoji.EmojiTextView;
import java.io.File;
import java.io.FileOutputStream;
@@ -102,6 +102,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
private int behaviorWithAttachments;
private boolean isOnWifi;
private NotificationsListAdapter.ViewHolder holder;
+ private int style;
public NotificationsListAdapter(Context context, boolean isOnWifi, int behaviorWithAttachments, List<Notification> notifications){
this.context = context;
@@ -131,16 +132,29 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
int textSizePercent = sharedpreferences.getInt(Helper.SET_TEXT_SIZE, 110);
+
final float scale = context.getResources().getDisplayMetrics().density;
String type = notification.getType();
String typeString = "";
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
boolean expand_cw = sharedpreferences.getBoolean(Helper.SET_EXPAND_CW, false);
- if (theme == THEME_DARK || theme == THEME_BLACK){
- holder.main_container_trans.setAlpha(.3f);
+ if (theme == THEME_DARK ){
+ holder.main_container_trans.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1));
+ holder.main_container_trans.setAlpha(.5f);
+ }else if( theme == THEME_BLACK){
+ holder.main_container_trans.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_1));
+ holder.main_container_trans.setAlpha(.5f);
+ }else{
+ holder.main_container_trans.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_1));
+ holder.main_container_trans.setAlpha(.5f);
+ }
+ if (theme == Helper.THEME_DARK) {
+ style = R.style.DialogDark;
+ } else if (theme == Helper.THEME_BLACK){
+ style = R.style.DialogBlack;
}else {
- holder.main_container_trans.setAlpha(.1f);
+ style = R.style.Dialog;
}
Drawable imgH = null;
switch (type){
@@ -151,11 +165,20 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
else
typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_mention));
if( theme == Helper.THEME_DARK){
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1));
+ if( notification.getStatus().getVisibility().equals("direct"))
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_private));
+ else
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1));
}else if( theme == Helper.THEME_BLACK){
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_1));
+ if( notification.getStatus().getVisibility().equals("direct"))
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_private));
+ else
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_1));
}else {
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_1));
+ if( notification.getStatus().getVisibility().equals("direct"))
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_private));
+ else
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_1));
}
imgH = ContextCompat.getDrawable(context, R.drawable.ic_chat_bubble_outline);
holder.main_container_trans.setVisibility(View.GONE);
@@ -168,11 +191,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
else
typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_reblog));
if( theme == Helper.THEME_DARK){
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_2));
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1));
}else if( theme == Helper.THEME_BLACK){
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_2));
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_1));
}else {
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_2));
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_1));
}
imgH = ContextCompat.getDrawable(context, R.drawable.ic_repeat_head);
holder.main_container_trans.setVisibility(View.VISIBLE);
@@ -185,11 +208,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
else
typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_favourite));
if( theme == Helper.THEME_DARK){
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_3));
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1));
}else if( theme == Helper.THEME_BLACK){
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_3));
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_1));
}else {
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_3));
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_1));
}
imgH = ContextCompat.getDrawable(context, R.drawable.ic_star_border_header);
holder.main_container_trans.setVisibility(View.VISIBLE);
@@ -202,11 +225,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
else
typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_follow));
if( theme == Helper.THEME_DARK){
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_4));
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1));
}else if( theme == Helper.THEME_BLACK){
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_4));
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_1));
}else {
- holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_4));
+ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_1));
}
imgH = ContextCompat.getDrawable(context, R.drawable.ic_follow_notif_header);
holder.main_container_trans.setVisibility(View.GONE);
@@ -258,7 +281,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
changeDrawableColor(context, R.drawable.ic_star_border,R.color.dark_icon);
changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.dark_text);
- changeDrawableColor(context, R.drawable.ic_delete,R.color.dark_text);
+ changeDrawableColor(context, holder.notification_delete,R.color.dark_text);
}else {
changeDrawableColor(context, R.drawable.ic_reply,R.color.black);
changeDrawableColor(context, holder.status_more, R.color.black);
@@ -267,7 +290,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
changeDrawableColor(context, R.drawable.ic_star_border,R.color.black);
changeDrawableColor(context, R.drawable.ic_photo,R.color.black);
changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.black);
- changeDrawableColor(context, R.drawable.ic_delete,R.color.black);
+ changeDrawableColor(context, holder.notification_delete,R.color.black);
}
final Status status = notification.getStatus();
@@ -408,6 +431,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
}
if( type.equals("favourite") || type.equals("reblog")){
holder.status_document_container.setVisibility(View.GONE);
+ holder.status_show_more.setVisibility(View.GONE);
}else {
if (status.getReblog() == null) {
if (status.getMedia_attachments().size() < 1) {
@@ -416,7 +440,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
} else {
//If medias are loaded without any conditions or if device is on wifi
if (!status.isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
- loadAttachments(status, holder);
+ loadAttachments(notification, holder);
holder.status_show_more.setVisibility(View.GONE);
status.setAttachmentShown(true);
} else {
@@ -427,29 +451,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
holder.status_show_more.setVisibility(View.VISIBLE);
holder.status_document_container.setVisibility(View.GONE);
} else {
- loadAttachments(status, holder);
- }
- }
- }
- } else { //Attachments for reblogs
- if (status.getReblog().getMedia_attachments().size() < 1) {
- holder.status_document_container.setVisibility(View.GONE);
- holder.status_show_more.setVisibility(View.GONE);
- } else {
- //If medias are loaded without any conditions or if device is on wifi
- if (!status.getReblog().isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
- loadAttachments(status.getReblog(), holder);
- holder.status_show_more.setVisibility(View.GONE);
- status.getReblog().setAttachmentShown(true);
- } else {
- //Text depending if toots is sensitive or not
- String textShowMore = (status.getReblog().isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.load_attachment);
- holder.status_show_more.setText(textShowMore);
- if (!status.isAttachmentShown()) {
- holder.status_show_more.setVisibility(View.VISIBLE);
- holder.status_document_container.setVisibility(View.GONE);
- } else {
- loadAttachments(status.getReblog(), holder);
+ loadAttachments(notification, holder);
}
}
}
@@ -498,8 +500,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
holder.status_show_more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- loadAttachments(status, holder);
- holder.status_show_more.setVisibility(View.GONE);
+ loadAttachments(notification, holder);
notification.getStatus().setAttachmentShown(true);
notifyNotificationChanged(notification);
/*
@@ -520,8 +521,6 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
public void onFinish() {
notification.getStatus().setAttachmentShown(false);
- holder.status_show_more.setVisibility(View.VISIBLE);
-
notifyNotificationChanged(notification);
}
}.start();
@@ -639,7 +638,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
final API.StatusAction doAction;
switch (item.getItemId()) {
case R.id.action_remove:
- builderInner = new AlertDialog.Builder(context);
+ builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
doAction = API.StatusAction.UNSTATUS;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
@@ -649,7 +648,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
builderInner.setMessage(Html.fromHtml(status.getContent()));
break;
case R.id.action_mute:
- builderInner = new AlertDialog.Builder(context);
+ builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
doAction = API.StatusAction.MUTE;
break;
@@ -657,12 +656,12 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
Helper.openBrowser(context, status.getUrl());
return true;
case R.id.action_block:
- builderInner = new AlertDialog.Builder(context);
+ builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[1]);
doAction = API.StatusAction.BLOCK;
break;
case R.id.action_report:
- builderInner = new AlertDialog.Builder(context);
+ builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[2]);
doAction = API.StatusAction.REPORT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
@@ -823,7 +822,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
private void displayConfirmationNotificationDialog(final Notification notification){
final ArrayList seletedItems = new ArrayList();
- AlertDialog dialog = new AlertDialog.Builder(context)
+ AlertDialog dialog = new AlertDialog.Builder(context, style)
.setTitle(R.string.delete_notification_ask)
.setMultiChoiceItems(new String[]{context.getString(R.string.delete_notification_ask_all)}, null, new DialogInterface.OnMultiChoiceClickListener() {
@Override
@@ -945,8 +944,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
}
- private void loadAttachments(final Status status, ViewHolder holder){
- List<Attachment> attachments = status.getMedia_attachments();
+ private void loadAttachments(final Notification notification, ViewHolder holder){
+ List<Attachment> attachments = notification.getStatus().getMedia_attachments();
if( attachments != null && attachments.size() > 0){
int i = 0;
holder.status_document_container.setVisibility(View.VISIBLE);
@@ -1014,7 +1013,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
public void onClick(View v) {
Intent intent = new Intent(context, MediaActivity.class);
Bundle b = new Bundle();
- intent.putParcelableArrayListExtra("mediaArray", status.getMedia_attachments());
+ intent.putParcelableArrayListExtra("mediaArray", notification.getStatus().getMedia_attachments());
b.putInt("position", finalPosition);
intent.putExtras(b);
context.startActivity(intent);