|
|
|
@ -16,12 +16,10 @@ |
|
|
|
|
package com.keylesspalace.tusky.adapter; |
|
|
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
|
import android.content.SharedPreferences; |
|
|
|
|
import android.graphics.Color; |
|
|
|
|
import android.graphics.PorterDuff; |
|
|
|
|
import android.graphics.Typeface; |
|
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
|
import android.preference.PreferenceManager; |
|
|
|
|
import android.support.annotation.NonNull; |
|
|
|
|
import android.support.annotation.Nullable; |
|
|
|
|
import android.support.v4.content.ContextCompat; |
|
|
|
@ -70,6 +68,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
private NotificationActionListener notificationActionListener; |
|
|
|
|
private FooterViewHolder.State footerState; |
|
|
|
|
private boolean mediaPreviewEnabled; |
|
|
|
|
private boolean useAbsoluteTime; |
|
|
|
|
private BidiFormatter bidiFormatter; |
|
|
|
|
|
|
|
|
|
public NotificationsAdapter(StatusActionListener statusListener, |
|
|
|
@ -80,6 +79,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
this.notificationActionListener = notificationActionListener; |
|
|
|
|
footerState = FooterViewHolder.State.END; |
|
|
|
|
mediaPreviewEnabled = true; |
|
|
|
|
useAbsoluteTime = false; |
|
|
|
|
bidiFormatter = BidiFormatter.getInstance(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -91,7 +91,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
case VIEW_TYPE_MENTION: { |
|
|
|
|
View view = LayoutInflater.from(parent.getContext()) |
|
|
|
|
.inflate(R.layout.item_status, parent, false); |
|
|
|
|
return new StatusViewHolder(view); |
|
|
|
|
return new StatusViewHolder(view, useAbsoluteTime); |
|
|
|
|
} |
|
|
|
|
case VIEW_TYPE_FOOTER: { |
|
|
|
|
View view = LayoutInflater.from(parent.getContext()) |
|
|
|
@ -101,7 +101,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
case VIEW_TYPE_STATUS_NOTIFICATION: { |
|
|
|
|
View view = LayoutInflater.from(parent.getContext()) |
|
|
|
|
.inflate(R.layout.item_status_notification, parent, false); |
|
|
|
|
return new StatusNotificationViewHolder(view); |
|
|
|
|
return new StatusNotificationViewHolder(view, useAbsoluteTime); |
|
|
|
|
} |
|
|
|
|
case VIEW_TYPE_FOLLOW: { |
|
|
|
|
View view = LayoutInflater.from(parent.getContext()) |
|
|
|
@ -142,7 +142,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
StatusNotificationViewHolder holder = (StatusNotificationViewHolder) viewHolder; |
|
|
|
|
StatusViewData.Concrete statusViewData = concreteNotificaton.getStatusViewData(); |
|
|
|
|
|
|
|
|
|
if(statusViewData == null) { |
|
|
|
|
if (statusViewData == null) { |
|
|
|
|
holder.showNotificationContent(false); |
|
|
|
|
} else { |
|
|
|
|
holder.showNotificationContent(true); |
|
|
|
@ -245,6 +245,10 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
mediaPreviewEnabled = enabled; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setUseAbsoluteTime(boolean useAbsoluteTime) { |
|
|
|
|
this.useAbsoluteTime = useAbsoluteTime; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public interface NotificationActionListener { |
|
|
|
|
void onViewAccount(String id); |
|
|
|
|
|
|
|
|
@ -323,7 +327,9 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
private NotificationActionListener notificationActionListener; |
|
|
|
|
private StatusViewData.Concrete statusViewData; |
|
|
|
|
|
|
|
|
|
StatusNotificationViewHolder(View itemView) { |
|
|
|
|
private boolean useAbsoluteTime; |
|
|
|
|
|
|
|
|
|
StatusNotificationViewHolder(View itemView, boolean useAbsoluteTime) { |
|
|
|
|
super(itemView); |
|
|
|
|
message = itemView.findViewById(R.id.notification_top_text); |
|
|
|
|
statusNameBar = itemView.findViewById(R.id.status_name_bar); |
|
|
|
@ -345,6 +351,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
message.setOnClickListener(this); |
|
|
|
|
statusContent.setOnClickListener(this); |
|
|
|
|
contentWarningButton.setOnCheckedChangeListener(this); |
|
|
|
|
|
|
|
|
|
this.useAbsoluteTime = useAbsoluteTime; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void showNotificationContent(boolean show) { |
|
|
|
@ -370,8 +378,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void setCreatedAt(@Nullable Date createdAt) { |
|
|
|
|
SharedPreferences defPrefs = PreferenceManager.getDefaultSharedPreferences(timestampInfo.getContext()); |
|
|
|
|
if (defPrefs.getBoolean("absoluteTimeView", true)) { |
|
|
|
|
if (useAbsoluteTime) { |
|
|
|
|
String time = "ERROR!"; |
|
|
|
|
if (createdAt != null) { |
|
|
|
|
SimpleDateFormat sdf; |
|
|
|
@ -429,7 +436,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
} |
|
|
|
|
case REBLOG: { |
|
|
|
|
icon = ContextCompat.getDrawable(context, R.drawable.ic_repeat_24dp); |
|
|
|
|
if(icon != null) { |
|
|
|
|
if (icon != null) { |
|
|
|
|
icon.setColorFilter(ContextCompat.getColor(context, |
|
|
|
|
R.color.color_accent_dark), PorterDuff.Mode.SRC_ATOP); |
|
|
|
|
} |
|
|
|
@ -490,10 +497,12 @@ public class NotificationsAdapter extends RecyclerView.Adapter { |
|
|
|
|
switch (v.getId()) { |
|
|
|
|
case R.id.notification_container: |
|
|
|
|
case R.id.notification_content: |
|
|
|
|
if (notificationActionListener != null) notificationActionListener.onViewStatusForNotificationId(notificationId); |
|
|
|
|
if (notificationActionListener != null) |
|
|
|
|
notificationActionListener.onViewStatusForNotificationId(notificationId); |
|
|
|
|
break; |
|
|
|
|
case R.id.notification_top_text: |
|
|
|
|
if (notificationActionListener != null) notificationActionListener.onViewAccount(accountId); |
|
|
|
|
if (notificationActionListener != null) |
|
|
|
|
notificationActionListener.onViewAccount(accountId); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|