mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
show document info in profile
This commit is contained in:
@@ -63,7 +63,7 @@
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?conversation_item_outgoing_text_secondary_color"
|
||||
android:textColor="@color/audio_icon"
|
||||
android:textSize="@dimen/conversation_item_date_text_size"
|
||||
style="@style/Signal.Text.Preview"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
|
||||
@@ -45,8 +45,6 @@
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:padding="8dp"
|
||||
app:foregroundTintColor="@color/audio_icon"
|
||||
app:backgroundTintColor="?conversation_item_incoming_bubble_color"
|
||||
android:background="@drawable/message_bubble_background_sent_alone"/>
|
||||
|
||||
<org.thoughtcrime.securesms.components.DocumentView
|
||||
|
||||
@@ -6,6 +6,4 @@
|
||||
android:layout_width="210dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:foregroundTintColor="@color/white"
|
||||
app:backgroundTintColor="@color/blue_500"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
@@ -4,6 +4,4 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="210dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:foregroundTintColor="@color/grey_500"
|
||||
app:backgroundTintColor="@color/white"
|
||||
android:visibility="gone"/>
|
||||
|
||||
@@ -4,40 +4,37 @@
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp">
|
||||
android:padding="10dp">
|
||||
|
||||
<org.thoughtcrime.securesms.components.DocumentView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/document_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible"/>
|
||||
android:visibility="gone"/>
|
||||
|
||||
<org.thoughtcrime.securesms.components.AudioView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/audio_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView android:id="@+id/date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingStart="8dp"
|
||||
android:textSize="12sp"
|
||||
android:textColor="?attr/profile_document_foreground"
|
||||
android:paddingTop="20dp"
|
||||
tools:text="Jun 1"/>
|
||||
<FrameLayout
|
||||
android:id="@+id/selected_indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/MediaOverview_Media_selected_overlay"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/check"
|
||||
android:layout_gravity="center"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -170,12 +170,6 @@
|
||||
<attr name="thumbnail_radius" format="dimension" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="AudioView">
|
||||
<attr name="widgetBackground" format="color"/>
|
||||
<attr name="foregroundTintColor" format="color" />
|
||||
<attr name="backgroundTintColor" format="color" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="CircleColorImageView">
|
||||
<attr name="circleColor" format="color"/>
|
||||
</declare-styleable>
|
||||
|
||||
@@ -272,18 +272,6 @@ public class ConversationItem extends LinearLayout
|
||||
} else {
|
||||
bodyBubble.getBackground().setColorFilter(incomingBubbleColor, PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
|
||||
if (audioViewStub.resolved()) {
|
||||
setAudioViewTint(messageRecord);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAudioViewTint(DcMsg messageRecord) {
|
||||
if (messageRecord.isOutgoing()) {
|
||||
audioViewStub.get().setTint(getContext().getResources().getColor(R.color.audio_icon), outgoingBubbleColor);
|
||||
} else {
|
||||
audioViewStub.get().setTint(getContext().getResources().getColor(R.color.audio_icon), incomingBubbleColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void setInteractionState(DcMsg messageRecord, boolean pulseHighlight) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -10,9 +11,14 @@ import android.widget.TextView;
|
||||
import com.b44t.messenger.DcMsg;
|
||||
import com.codewaves.stickyheadergrid.StickyHeaderGridAdapter;
|
||||
|
||||
import org.thoughtcrime.securesms.components.AudioView;
|
||||
import org.thoughtcrime.securesms.components.DocumentView;
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.database.loaders.BucketedThreadMediaLoader.BucketedThreadMedia;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.mms.DocumentSlide;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
import org.thoughtcrime.securesms.util.DateUtils;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -26,19 +32,22 @@ class ProfileDocumentsAdapter extends StickyHeaderGridAdapter {
|
||||
private static final String TAG = ProfileDocumentsAdapter.class.getSimpleName();
|
||||
|
||||
private final Context context;
|
||||
private final GlideRequests glideRequests;
|
||||
private final Locale locale;
|
||||
private final ItemClickListener itemClickListener;
|
||||
private final Set<DcMsg> selected;
|
||||
private final Set<DcMsg> selected;
|
||||
|
||||
private BucketedThreadMedia media;
|
||||
|
||||
private static class ViewHolder extends StickyHeaderGridAdapter.ItemViewHolder {
|
||||
View selectedIndicator;
|
||||
private final DocumentView documentView;
|
||||
private final AudioView audioView;
|
||||
private final TextView date;
|
||||
|
||||
ViewHolder(View v) {
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
selectedIndicator = v.findViewById(R.id.selected_indicator);
|
||||
documentView = v.findViewById(R.id.document_view);
|
||||
audioView = v.findViewById(R.id.audio_view);
|
||||
date = v.findViewById(R.id.date);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +61,11 @@ class ProfileDocumentsAdapter extends StickyHeaderGridAdapter {
|
||||
}
|
||||
|
||||
ProfileDocumentsAdapter(@NonNull Context context,
|
||||
@NonNull GlideRequests glideRequests,
|
||||
BucketedThreadMedia media,
|
||||
Locale locale,
|
||||
ItemClickListener clickListener)
|
||||
{
|
||||
this.context = context;
|
||||
this.glideRequests = glideRequests;
|
||||
this.locale = locale;
|
||||
this.media = media;
|
||||
this.itemClickListener = clickListener;
|
||||
@@ -85,13 +92,33 @@ class ProfileDocumentsAdapter extends StickyHeaderGridAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindItemViewHolder(ItemViewHolder viewHolder, int section, int offset) {
|
||||
DcMsg mediaRecord = media.get(section, offset);
|
||||
View selectedIndicator = ((ViewHolder)viewHolder).selectedIndicator;
|
||||
Slide slide = MediaUtil.getSlideForMsg(context, mediaRecord);
|
||||
public void onBindItemViewHolder(ItemViewHolder itemViewHolder, int section, int offset) {
|
||||
ViewHolder viewHolder = ((ViewHolder)itemViewHolder);
|
||||
DcMsg dcMsg = media.get(section, offset);
|
||||
Slide slide = MediaUtil.getSlideForMsg(context, dcMsg);
|
||||
|
||||
if (slide != null && slide.hasAudio()) {
|
||||
viewHolder.documentView.setVisibility(View.GONE);
|
||||
|
||||
selectedIndicator.setVisibility(selected.contains(mediaRecord) ? View.VISIBLE : View.GONE);
|
||||
viewHolder.audioView.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
else if (slide != null && slide.hasDocument()) {
|
||||
viewHolder.documentView.setVisibility(View.VISIBLE);
|
||||
viewHolder.documentView.setDocument((DocumentSlide)slide);
|
||||
viewHolder.documentView.setOnClickListener(view -> {
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(context);
|
||||
dcContext.openForViewOrShare(dcMsg.getId(), Intent.ACTION_VIEW);
|
||||
});
|
||||
|
||||
viewHolder.audioView.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
viewHolder.documentView.setVisibility(View.GONE);
|
||||
viewHolder.audioView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
viewHolder.date.setText(DateUtils.getBriefRelativeTimeSpanString(context, locale, dcMsg.getTimestamp()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,7 +73,6 @@ public class ProfileDocumentsFragment
|
||||
this.gridManager = new StickyHeaderGridLayoutManager(1);
|
||||
|
||||
this.recyclerView.setAdapter(new ProfileDocumentsAdapter(getContext(),
|
||||
GlideApp.with(this),
|
||||
new BucketedThreadMediaLoader.BucketedThreadMedia(getContext()),
|
||||
locale,
|
||||
this));
|
||||
|
||||
@@ -74,13 +74,7 @@ public class AudioView extends FrameLayout implements AudioSlidePlayer.Listener
|
||||
this.pauseButton.setBackground(context.getDrawable(R.drawable.ic_circle_fill_white_48dp));
|
||||
}
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AudioView, 0, 0);
|
||||
setTint(typedArray.getColor(R.styleable.AudioView_foregroundTintColor, Color.WHITE),
|
||||
typedArray.getColor(R.styleable.AudioView_backgroundTintColor, Color.WHITE));
|
||||
container.setBackgroundColor(typedArray.getColor(R.styleable.AudioView_widgetBackground, Color.TRANSPARENT));
|
||||
typedArray.recycle();
|
||||
}
|
||||
setTint(getContext().getResources().getColor(R.color.audio_icon));
|
||||
}
|
||||
|
||||
public void setAudio(final @NonNull AudioSlide audio, int duration)
|
||||
@@ -166,18 +160,15 @@ public class AudioView extends FrameLayout implements AudioSlidePlayer.Listener
|
||||
}
|
||||
}
|
||||
|
||||
public void setTint(int foregroundTint, int backgroundTint) {
|
||||
public void setTint(int foregroundTint) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
this.playButton.setBackgroundTintList(ColorStateList.valueOf(foregroundTint));
|
||||
this.playButton.setImageTintList(ColorStateList.valueOf(backgroundTint));
|
||||
this.pauseButton.setBackgroundTintList(ColorStateList.valueOf(foregroundTint));
|
||||
this.pauseButton.setImageTintList(ColorStateList.valueOf(backgroundTint));
|
||||
} else {
|
||||
this.playButton.setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
|
||||
this.pauseButton.setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
this.timestamp.setTextColor(foregroundTint);
|
||||
this.seekBar.getProgressDrawable().setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
|
||||
@@ -53,7 +53,6 @@ public class DocumentView extends FrameLayout {
|
||||
|
||||
public void setDocument(final @NonNull DocumentSlide documentSlide)
|
||||
{
|
||||
|
||||
this.documentSlide = documentSlide;
|
||||
|
||||
this.fileName.setText(documentSlide.getFileName().or(getContext().getString(R.string.unknown)));
|
||||
|
||||
Reference in New Issue
Block a user