mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 16:33:39 +00:00
parent
368f5c8dba
commit
c6e2b5f6c5
@ -5,6 +5,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:adjustViewBounds="true"
|
||||
android:clickable="false"
|
||||
android:longClickable="false"
|
||||
android:scaleType="fitCenter"
|
||||
android:contentDescription="@string/conversation_item__mms_image_description" />
|
||||
|
||||
|
@ -17,9 +17,10 @@
|
||||
android:layout_height="@dimen/transfer_controls_contracted_width"
|
||||
android:padding="15dp"
|
||||
android:gravity="center"
|
||||
android:longClickable="false"
|
||||
android:textColor="?conversation_item_received_text_primary_color"
|
||||
android:drawableLeft="@drawable/ic_file_download_white_36dp"
|
||||
android:textSize="16dp"
|
||||
android:visibility="gone"
|
||||
android:textStyle="bold" />
|
||||
</merge>
|
||||
</merge>
|
||||
|
@ -161,6 +161,7 @@ public class ConversationItem extends LinearLayout
|
||||
mediaThumbnail.setThumbnailClickListener(new ThumbnailClickListener());
|
||||
mediaThumbnail.setDownloadClickListener(new ThumbnailDownloadClickListener());
|
||||
mediaThumbnail.setOnLongClickListener(passthroughClickListener);
|
||||
mediaThumbnail.setOnClickListener(passthroughClickListener);
|
||||
bodyText.setOnLongClickListener(passthroughClickListener);
|
||||
bodyText.setOnClickListener(passthroughClickListener);
|
||||
}
|
||||
@ -228,7 +229,8 @@ public class ConversationItem extends LinearLayout
|
||||
|
||||
private void setInteractionState(MessageRecord messageRecord) {
|
||||
setSelected(batchSelected.contains(messageRecord));
|
||||
mediaThumbnail.setClickable(!shouldInterceptClicks(messageRecord));
|
||||
mediaThumbnail.setFocusable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
|
||||
mediaThumbnail.setClickable(!shouldInterceptClicks(messageRecord) && batchSelected.isEmpty());
|
||||
mediaThumbnail.setLongClickable(batchSelected.isEmpty());
|
||||
bodyText.setAutoLinkMask(batchSelected.isEmpty() ? Linkify.ALL : 0);
|
||||
}
|
||||
@ -420,9 +422,10 @@ public class ConversationItem extends LinearLayout
|
||||
}
|
||||
|
||||
public void onClick(final View v, final Slide slide) {
|
||||
if (batchSelected.isEmpty() &&
|
||||
MediaPreviewActivity.isContentTypeSupported(slide.getContentType()) &&
|
||||
slide.getThumbnailUri() != null)
|
||||
if (shouldInterceptClicks(messageRecord) || !batchSelected.isEmpty()) {
|
||||
performClick();
|
||||
} else if (MediaPreviewActivity.isContentTypeSupported(slide.getContentType()) &&
|
||||
slide.getThumbnailUri() != null)
|
||||
{
|
||||
Intent intent = new Intent(context, MediaPreviewActivity.class);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
@ -474,12 +477,14 @@ public class ConversationItem extends LinearLayout
|
||||
|
||||
private class PassthroughClickListener implements View.OnLongClickListener, View.OnClickListener {
|
||||
|
||||
@Override public boolean onLongClick(View v) {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
performLongClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public void onClick(View v) {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
performClick();
|
||||
}
|
||||
}
|
||||
|
@ -34,19 +34,21 @@ import org.thoughtcrime.securesms.util.FutureTaskListener;
|
||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||
|
||||
import ws.com.google.android.mms.pdu.PduPart;
|
||||
|
||||
public class ThumbnailView extends FrameLayout {
|
||||
private static final String TAG = ThumbnailView.class.getSimpleName();
|
||||
|
||||
private boolean hideControls;
|
||||
private ImageView image;
|
||||
private ImageView removeButton;
|
||||
private TransferControlView transferControls;
|
||||
private int backgroundColorHint;
|
||||
private int radius;
|
||||
private boolean hideControls;
|
||||
private ImageView image;
|
||||
private ImageView removeButton;
|
||||
private int backgroundColorHint;
|
||||
private int radius;
|
||||
private OnClickListener parentClickListener;
|
||||
|
||||
private Optional<TransferControlView> transferControls = Optional.absent();
|
||||
private ListenableFutureTask<SlideDeck> slideDeckFuture = null;
|
||||
private SlideDeckListener slideDeckListener = null;
|
||||
private ThumbnailClickListener thumbnailClickListener = null;
|
||||
@ -67,7 +69,7 @@ public class ThumbnailView extends FrameLayout {
|
||||
inflate(context, R.layout.thumbnail_view, this);
|
||||
radius = getResources().getDimensionPixelSize(R.dimen.message_bubble_corner_radius);
|
||||
image = (ImageView) findViewById(R.id.thumbnail_image);
|
||||
setOnClickListener(new ThumbnailClickDispatcher());
|
||||
super.setOnClickListener(new ThumbnailClickDispatcher());
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ThumbnailView, 0, 0);
|
||||
@ -76,10 +78,18 @@ public class ThumbnailView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void setOnClickListener(OnClickListener l) {
|
||||
parentClickListener = l;
|
||||
}
|
||||
|
||||
@Override public void setFocusable(boolean focusable) {
|
||||
super.setFocusable(focusable);
|
||||
if (transferControls.isPresent()) transferControls.get().setFocusable(focusable);
|
||||
}
|
||||
|
||||
@Override public void setClickable(boolean clickable) {
|
||||
super.setClickable(clickable);
|
||||
image.setClickable(clickable);
|
||||
transferControls.setClickable(clickable);
|
||||
if (transferControls.isPresent()) transferControls.get().setClickable(clickable);
|
||||
}
|
||||
|
||||
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
@ -97,8 +107,10 @@ public class ThumbnailView extends FrameLayout {
|
||||
}
|
||||
|
||||
private TransferControlView getTransferControls() {
|
||||
if (transferControls == null) transferControls = ViewUtil.inflateStub(this, R.id.transfer_controls_stub);
|
||||
return transferControls;
|
||||
if (!transferControls.isPresent()) {
|
||||
transferControls = Optional.of((TransferControlView)ViewUtil.inflateStub(this, R.id.transfer_controls_stub));
|
||||
}
|
||||
return transferControls.get();
|
||||
}
|
||||
|
||||
public void setBackgroundColorHint(int color) {
|
||||
@ -117,7 +129,7 @@ public class ThumbnailView extends FrameLayout {
|
||||
String slideId = id + "::" + timestamp;
|
||||
|
||||
if (!slideId.equals(this.slideId)) {
|
||||
if (transferControls != null) transferControls.clear();
|
||||
if (transferControls.isPresent()) getTransferControls().clear();
|
||||
image.setImageDrawable(null);
|
||||
this.slide = null;
|
||||
this.slideId = slideId;
|
||||
@ -166,9 +178,9 @@ public class ThumbnailView extends FrameLayout {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (isContextValid()) Glide.clear(image);
|
||||
if (slideDeckFuture != null) slideDeckFuture.removeListener(slideDeckListener);
|
||||
if (transferControls != null) transferControls.clear();
|
||||
if (isContextValid()) Glide.clear(image);
|
||||
if (slideDeckFuture != null) slideDeckFuture.removeListener(slideDeckListener);
|
||||
if (transferControls.isPresent()) getTransferControls().clear();
|
||||
slide = null;
|
||||
slideId = null;
|
||||
slideDeckFuture = null;
|
||||
@ -177,7 +189,7 @@ public class ThumbnailView extends FrameLayout {
|
||||
|
||||
public void hideControls(boolean hideControls) {
|
||||
this.hideControls = hideControls;
|
||||
if (hideControls && transferControls != null) transferControls.setVisibility(View.GONE);
|
||||
if (hideControls && transferControls.isPresent()) getTransferControls().setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void showProgressSpinner() {
|
||||
@ -296,6 +308,8 @@ public class ThumbnailView extends FrameLayout {
|
||||
slide.getTransferProgress() == PartDatabase.TRANSFER_PROGRESS_DONE)
|
||||
{
|
||||
thumbnailClickListener.onClick(view, slide);
|
||||
} else if (parentClickListener != null) {
|
||||
parentClickListener.onClick(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ public class TransferControlView extends FrameLayout {
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
background.setColorFilter(0x66ffffff, Mode.MULTIPLY);
|
||||
}
|
||||
setLongClickable(false);
|
||||
ViewUtil.setBackground(this, background);
|
||||
setVisibility(GONE);
|
||||
|
||||
@ -65,12 +66,26 @@ public class TransferControlView extends FrameLayout {
|
||||
this.expandedWidth = getResources().getDimensionPixelSize(R.dimen.transfer_controls_expanded_width);
|
||||
}
|
||||
|
||||
@Override protected void onAttachedToWindow() {
|
||||
@Override
|
||||
public void setFocusable(boolean focusable) {
|
||||
super.setFocusable(focusable);
|
||||
downloadDetails.setFocusable(focusable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickable(boolean clickable) {
|
||||
super.setClickable(clickable);
|
||||
downloadDetails.setClickable(clickable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().registerSticky(this);
|
||||
}
|
||||
|
||||
@Override protected void onDetachedFromWindow() {
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
@ -134,7 +149,8 @@ public class TransferControlView extends FrameLayout {
|
||||
private Animator getWidthAnimator(final int from, final int to) {
|
||||
final ValueAnimator anim = ValueAnimator.ofInt(from, to);
|
||||
anim.addUpdateListener(new AnimatorUpdateListener() {
|
||||
@Override public void onAnimationUpdate(ValueAnimator animation) {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
final int val = (Integer)animation.getAnimatedValue();
|
||||
final ViewGroup.LayoutParams layoutParams = getLayoutParams();
|
||||
layoutParams.width = val;
|
||||
@ -150,7 +166,8 @@ public class TransferControlView extends FrameLayout {
|
||||
public void onEventAsync(final PartProgressEvent event) {
|
||||
if (this.slide != null && event.partId.equals(this.slide.getPart().getPartId())) {
|
||||
Util.runOnMain(new Runnable() {
|
||||
@Override public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressWheel.setInstantProgress(((float)event.progress) / event.total);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user