mirror of
https://github.com/oxen-io/session-android.git
synced 2025-05-01 01:10:48 +00:00
Remove unused ConversationItemFooter
This commit is contained in:
parent
2228a05b2e
commit
617dbc8799
@ -1,149 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.components;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.session.libsession.snode.SnodeAPI;
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
|
||||||
import org.thoughtcrime.securesms.conversation.v2.components.ExpirationTimerView;
|
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent;
|
|
||||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
|
||||||
import org.thoughtcrime.securesms.util.DateUtils;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
public class ConversationItemFooter extends LinearLayout {
|
|
||||||
|
|
||||||
private TextView dateView;
|
|
||||||
private ExpirationTimerView timerView;
|
|
||||||
private ImageView insecureIndicatorView;
|
|
||||||
private DeliveryStatusView deliveryStatusView;
|
|
||||||
|
|
||||||
public ConversationItemFooter(Context context) {
|
|
||||||
super(context);
|
|
||||||
init(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConversationItemFooter(Context context, @Nullable AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
init(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConversationItemFooter(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
init(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(@Nullable AttributeSet attrs) {
|
|
||||||
inflate(getContext(), R.layout.conversation_item_footer, this);
|
|
||||||
|
|
||||||
dateView = findViewById(R.id.footer_date);
|
|
||||||
timerView = findViewById(R.id.footer_expiration_timer);
|
|
||||||
insecureIndicatorView = findViewById(R.id.footer_insecure_indicator);
|
|
||||||
deliveryStatusView = findViewById(R.id.footer_delivery_status);
|
|
||||||
|
|
||||||
if (attrs != null) {
|
|
||||||
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ConversationItemFooter, 0, 0);
|
|
||||||
setTextColor(typedArray.getInt(R.styleable.ConversationItemFooter_footer_text_color, getResources().getColor(R.color.core_white)));
|
|
||||||
setIconColor(typedArray.getInt(R.styleable.ConversationItemFooter_footer_icon_color, getResources().getColor(R.color.core_white)));
|
|
||||||
typedArray.recycle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDetachedFromWindow() {
|
|
||||||
super.onDetachedFromWindow();
|
|
||||||
timerView.stopAnimation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessageRecord(@NonNull MessageRecord messageRecord, @NonNull Locale locale) {
|
|
||||||
presentDate(messageRecord, locale);
|
|
||||||
presentTimer(messageRecord);
|
|
||||||
presentInsecureIndicator(messageRecord);
|
|
||||||
presentDeliveryStatus(messageRecord);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTextColor(int color) {
|
|
||||||
dateView.setTextColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIconColor(int color) {
|
|
||||||
timerView.setColorFilter(color);
|
|
||||||
insecureIndicatorView.setColorFilter(color);
|
|
||||||
deliveryStatusView.setTint(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void presentDate(@NonNull MessageRecord messageRecord, @NonNull Locale locale) {
|
|
||||||
dateView.forceLayout();
|
|
||||||
|
|
||||||
if (messageRecord.isFailed()) {
|
|
||||||
dateView.setText(R.string.ConversationItem_error_not_delivered);
|
|
||||||
} else {
|
|
||||||
dateView.setText(DateUtils.getExtendedRelativeTimeSpanString(getContext(), locale, messageRecord.getTimestamp()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
|
||||||
private void presentTimer(@NonNull final MessageRecord messageRecord) {
|
|
||||||
if (messageRecord.getExpiresIn() > 0 && !messageRecord.isPending()) {
|
|
||||||
this.timerView.setVisibility(View.VISIBLE);
|
|
||||||
this.timerView.setPercentComplete(0);
|
|
||||||
|
|
||||||
if (messageRecord.getExpireStarted() > 0) {
|
|
||||||
this.timerView.setExpirationTime(messageRecord.getExpireStarted(),
|
|
||||||
messageRecord.getExpiresIn());
|
|
||||||
this.timerView.startAnimation();
|
|
||||||
|
|
||||||
if (messageRecord.getExpireStarted() + messageRecord.getExpiresIn() <= SnodeAPI.getNowWithOffset()) {
|
|
||||||
ApplicationContext.getInstance(getContext()).getExpiringMessageManager().checkSchedule();
|
|
||||||
}
|
|
||||||
} else if (!messageRecord.isOutgoing() && !messageRecord.isMediaPending()) {
|
|
||||||
new AsyncTask<Void, Void, Void>() {
|
|
||||||
@Override
|
|
||||||
protected Void doInBackground(Void... params) {
|
|
||||||
ExpiringMessageManager expirationManager = ApplicationContext.getInstance(getContext()).getExpiringMessageManager();
|
|
||||||
long id = messageRecord.getId();
|
|
||||||
boolean mms = messageRecord.isMms();
|
|
||||||
|
|
||||||
if (mms) DatabaseComponent.get(getContext()).mmsDatabase().markExpireStarted(id);
|
|
||||||
else DatabaseComponent.get(getContext()).smsDatabase().markExpireStarted(id);
|
|
||||||
|
|
||||||
expirationManager.scheduleDeletion(id, mms, messageRecord.getExpiresIn());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.timerView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void presentInsecureIndicator(@NonNull MessageRecord messageRecord) {
|
|
||||||
insecureIndicatorView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void presentDeliveryStatus(@NonNull MessageRecord messageRecord) {
|
|
||||||
if (!messageRecord.isFailed()) {
|
|
||||||
if (!messageRecord.isOutgoing()) deliveryStatusView.setNone();
|
|
||||||
else if (messageRecord.isPending()) deliveryStatusView.setPending();
|
|
||||||
else if (messageRecord.isRead()) deliveryStatusView.setRead();
|
|
||||||
else if (messageRecord.isDelivered()) deliveryStatusView.setDelivered();
|
|
||||||
else deliveryStatusView.setSent();
|
|
||||||
} else {
|
|
||||||
deliveryStatusView.setNone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
tools:parentTag="org.thoughtcrime.securesms.components.ConversationItemFooter">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginEnd="6dp"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="left|start|center_vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/footer_date"
|
|
||||||
android:autoLink="none"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="@dimen/very_small_font_size"
|
|
||||||
android:linksClickable="false"
|
|
||||||
style="@style/Signal.Text.Caption.MessageSent"
|
|
||||||
android:textColor="?conversation_item_sent_text_secondary_color"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
tools:text="30 mins"/>
|
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.conversation.v2.components.ExpirationTimerView
|
|
||||||
android:id="@+id/footer_expiration_timer"
|
|
||||||
android:layout_gravity="center_vertical|end"
|
|
||||||
android:layout_marginStart="6dp"
|
|
||||||
android:layout_width="12dp"
|
|
||||||
android:layout_height="12dp"
|
|
||||||
android:contentDescription="@string/AccessibilityId_timer_icon"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/footer_insecure_indicator"
|
|
||||||
android:layout_width="12dp"
|
|
||||||
android:layout_height="11dp"
|
|
||||||
android:src="@drawable/ic_unlocked_white_18dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_gravity="center_vertical|end"
|
|
||||||
android:contentDescription="@string/conversation_item__secure_message_description"
|
|
||||||
tools:visibility="visible"/>
|
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.DeliveryStatusView
|
|
||||||
android:id="@+id/footer_delivery_status"
|
|
||||||
android:layout_width="20dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical" />
|
|
||||||
|
|
||||||
</merge>
|
|
@ -319,11 +319,6 @@
|
|||||||
<attr name="doc_downloadButtonTint" format="color" />
|
<attr name="doc_downloadButtonTint" format="color" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="ConversationItemFooter">
|
|
||||||
<attr name="footer_text_color" format="color" />
|
|
||||||
<attr name="footer_icon_color" format="color" />
|
|
||||||
</declare-styleable>
|
|
||||||
|
|
||||||
<declare-styleable name="ConversationItemThumbnail">
|
<declare-styleable name="ConversationItemThumbnail">
|
||||||
<attr name="conversationThumbnail_minWidth" format="dimension" />
|
<attr name="conversationThumbnail_minWidth" format="dimension" />
|
||||||
<attr name="conversationThumbnail_maxWidth" format="dimension" />
|
<attr name="conversationThumbnail_maxWidth" format="dimension" />
|
||||||
|
@ -252,11 +252,6 @@
|
|||||||
<attr name="doc_downloadButtonTint" format="color" />
|
<attr name="doc_downloadButtonTint" format="color" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="ConversationItemFooter">
|
|
||||||
<attr name="footer_text_color" format="color" />
|
|
||||||
<attr name="footer_icon_color" format="color" />
|
|
||||||
</declare-styleable>
|
|
||||||
|
|
||||||
<declare-styleable name="ConversationItemThumbnail">
|
<declare-styleable name="ConversationItemThumbnail">
|
||||||
<attr name="conversationThumbnail_minWidth" format="dimension" />
|
<attr name="conversationThumbnail_minWidth" format="dimension" />
|
||||||
<attr name="conversationThumbnail_maxWidth" format="dimension" />
|
<attr name="conversationThumbnail_maxWidth" format="dimension" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user