Merge pull request #2273 from deltachat/adb/improve-docs-tab

improve display of webxdc items in Docs tab
This commit is contained in:
Asiel Díaz Benítez
2022-04-11 14:13:33 -04:00
committed by GitHub
6 changed files with 100 additions and 3 deletions
+12 -1
View File
@@ -27,6 +27,17 @@
android:layout_weight="1"
android:visibility="gone"/>
<org.thoughtcrime.securesms.components.WebxdcView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/webxdc_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:visibility="gone"
app:compact="true"/>
<TextView android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -38,4 +49,4 @@
android:paddingTop="20dp"
tools:text="Jun 1"/>
</LinearLayout>
</LinearLayout>
+54
View File
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.thoughtcrime.securesms.components.WebxdcView">
<LinearLayout android:id="@+id/webxdc_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/webxdc_icon"
android:padding="4dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:scaleType="centerCrop"/>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:orientation="vertical"
android:focusable="false"
android:clickable="false">
<TextView android:id="@+id/webxdc_app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Signal.Text.Body"
android:singleLine="true"
android:maxLines="1"
android:ellipsize="end"
android:clickable="false"
android:textColor="?conversation_item_incoming_text_primary_color"
tools:text="Great App"/>
<TextView android:id="@+id/webxdc_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Signal.Text.Caption"
android:singleLine="true"
android:maxLines="1"
android:ellipsize="end"
android:clickable="false"
android:textColor="?conversation_item_incoming_text_primary_color"
tools:text="Webxdc"/>
</LinearLayout>
</LinearLayout>
</merge>
+4
View File
@@ -253,4 +253,8 @@
<attr name="aat_max_shown" format="integer" />
</declare-styleable>
<declare-styleable name="WebxdcView">
<attr name="compact" format="boolean" />
</declare-styleable>
</resources>
@@ -12,6 +12,7 @@ import com.codewaves.stickyheadergrid.StickyHeaderGridAdapter;
import org.thoughtcrime.securesms.components.AudioView;
import org.thoughtcrime.securesms.components.DocumentView;
import org.thoughtcrime.securesms.components.WebxdcView;
import org.thoughtcrime.securesms.database.loaders.BucketedThreadMediaLoader.BucketedThreadMedia;
import org.thoughtcrime.securesms.mms.AudioSlide;
import org.thoughtcrime.securesms.mms.DocumentSlide;
@@ -39,12 +40,14 @@ class ProfileDocumentsAdapter extends StickyHeaderGridAdapter {
private static class ViewHolder extends StickyHeaderGridAdapter.ItemViewHolder {
private final DocumentView documentView;
private final AudioView audioView;
private final WebxdcView webxdcView;
private final TextView date;
public ViewHolder(View v) {
super(v);
documentView = v.findViewById(R.id.document_view);
audioView = v.findViewById(R.id.audio_view);
webxdcView = v.findViewById(R.id.webxdc_view);
date = v.findViewById(R.id.date);
}
}
@@ -97,6 +100,7 @@ class ProfileDocumentsAdapter extends StickyHeaderGridAdapter {
if (slide != null && slide.hasAudio()) {
viewHolder.documentView.setVisibility(View.GONE);
viewHolder.webxdcView.setVisibility(View.GONE);
viewHolder.audioView.setVisibility(View.VISIBLE);
viewHolder.audioView.setAudio((AudioSlide)slide, dcMsg.getDuration());
@@ -107,8 +111,19 @@ class ProfileDocumentsAdapter extends StickyHeaderGridAdapter {
viewHolder.audioView.setLongClickable(selected.isEmpty());
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onMediaClicked(dcMsg));
}
else if (slide != null && slide.isWebxdcDocument()) {
viewHolder.audioView.setVisibility(View.GONE);
viewHolder.documentView.setVisibility(View.GONE);
viewHolder.webxdcView.setVisibility(View.VISIBLE);
viewHolder.webxdcView.setWebxdc(dcMsg, "Webxdc");
viewHolder.webxdcView.setOnClickListener(view -> itemClickListener.onMediaClicked(dcMsg));
viewHolder.webxdcView.setOnLongClickListener(view -> { itemClickListener.onMediaLongClicked(dcMsg); return true; });
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onMediaClicked(dcMsg));
}
else if (slide != null && slide.hasDocument()) {
viewHolder.audioView.setVisibility(View.GONE);
viewHolder.webxdcView.setVisibility(View.GONE);
viewHolder.documentView.setVisibility(View.VISIBLE);
viewHolder.documentView.setDocument((DocumentSlide)slide);
@@ -119,6 +134,7 @@ class ProfileDocumentsAdapter extends StickyHeaderGridAdapter {
else {
viewHolder.documentView.setVisibility(View.GONE);
viewHolder.audioView.setVisibility(View.GONE);
viewHolder.webxdcView.setVisibility(View.GONE);
}
viewHolder.itemView.setOnLongClickListener(view -> { itemClickListener.onMediaLongClicked(dcMsg); return true; });
@@ -153,7 +153,11 @@ public class ProfileDocumentsFragment
return;
}
DcHelper.openForViewOrShare(getActivity(), dcMsg.getId(), Intent.ACTION_VIEW);
if (dcMsg.getType() == DcMsg.DC_MSG_WEBXDC) {
WebxdcActivity.openWebxdcActivity(context, dcMsg);
} else {
DcHelper.openForViewOrShare(getActivity(), dcMsg.getId(), Intent.ACTION_VIEW);
}
}
@Override
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.components;
import android.content.Context;
import android.content.res.TypedArray;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
@@ -44,7 +45,14 @@ public class WebxdcView extends FrameLayout {
public WebxdcView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
inflate(context, R.layout.webxdc_view, this);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.WebxdcView, 0, 0);
boolean compact = a.getBoolean(R.styleable.WebxdcView_compact, false);
if (compact) {
inflate(context, R.layout.webxdc_compact_view, this);
} else {
inflate(context, R.layout.webxdc_view, this);
}
this.icon = findViewById(R.id.webxdc_icon);
this.appName = findViewById(R.id.webxdc_app_name);