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