diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java index a59df7ad..1a0bf119 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java @@ -6,6 +6,7 @@ import android.content.res.Resources; import android.database.Cursor; import android.graphics.PorterDuff; import android.graphics.Typeface; +import android.net.Uri; import android.os.Handler; import android.provider.ContactsContract; import android.provider.Telephony; @@ -26,13 +27,16 @@ import com.android.mms.transaction.TransactionService; import com.android.mms.util.DownloadManager; import com.google.android.mms.ContentType; import com.google.android.mms.pdu_alt.PduHeaders; +import com.koushikdutta.ion.Ion; import com.moez.QKSMS.QKSMSApp; import com.moez.QKSMS.R; +import com.moez.QKSMS.common.LiveViewManager; import com.moez.QKSMS.common.emoji.EmojiRegistry; import com.moez.QKSMS.common.utils.CursorUtils; import com.moez.QKSMS.common.utils.LinkifyUtils; import com.moez.QKSMS.common.utils.MessageUtils; import com.moez.QKSMS.data.Contact; +import com.moez.QKSMS.enums.QKPreference; import com.moez.QKSMS.transaction.SmsHelper; import com.moez.QKSMS.ui.ThemeManager; import com.moez.QKSMS.ui.base.QKActivity; @@ -50,13 +54,15 @@ import java.util.regex.Pattern; public class MessageListAdapter extends RecyclerCursorAdapter { private final String TAG = "MessageListAdapter"; - public static final int INCOMING_ITEM_TYPE_SMS = 0; - public static final int OUTGOING_ITEM_TYPE_SMS = 1; - public static final int INCOMING_ITEM_TYPE_MMS = 2; - public static final int OUTGOING_ITEM_TYPE_MMS = 3; + public static final int INCOMING_ITEM = 0; + public static final int OUTGOING_ITEM = 1; private ArrayList mSelectedConversations = new ArrayList<>(); + private static final Pattern urlPattern = Pattern.compile( + "\\b(https?:\\/\\/\\S+(?:png|jpe?g|gif)\\S*)\\b", + Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); + private MessageItemCache mMessageItemCache; private MessageColumns.ColumnsMap mColumnsMap; @@ -114,7 +120,7 @@ public class MessageListAdapter extends RecyclerCursorAdapter { + holder.mMmsView.getForeground().setColorFilter(ThemeManager.getBackgroundColor(), PorterDuff.Mode.SRC_ATOP); + }); + return holder; } @@ -183,13 +193,13 @@ public class MessageListAdapter extends RecyclerCursorAdapter { + try { + holder.setImage("url_img" + holder.getItemId(), result); + holder.mImageView.setOnClickListener(v -> { + Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(imageUrl)); + mContext.startActivity(i); + }); + } catch (NullPointerException imageException) { + imageException.printStackTrace(); + } + }); + } LinkifyUtils.addLinks(holder.mBodyTextView); } holder.mBodyTextView.setVisibility(TextUtils.isEmpty(buf) ? View.GONE : View.VISIBLE); @@ -552,15 +579,15 @@ public class MessageListAdapter extends RecyclerCursorAdapter impleme protected AvatarView mAvatarView; protected LinearLayout mMessageBlock; protected View mSpace; - // MMS only views. These are nested within ViewStubs, so we don't need to obtain a reference - // to them right away. We'll inflate the stub only when needed - protected View mMmsView; + protected FrameLayout mMmsView; protected ImageView mImageView; protected ImageButton mSlideShowButton; protected Button mDownloadButton; @@ -59,30 +58,14 @@ public class MessageListViewHolder extends ClickyViewHolder impleme mAvatarView = (AvatarView) view.findViewById(R.id.avatar); mMessageBlock = (LinearLayout) view.findViewById(R.id.message_block); mSpace = view.findViewById(R.id.space); + mMmsView = (FrameLayout) view.findViewById(R.id.mms_view); + mImageView = (ImageView) view.findViewById(R.id.image_view); + mSlideShowButton = (ImageButton) view.findViewById(R.id.play_slideshow_button); } protected void showMmsView(boolean visible) { - if (mMmsView == null) { - mMmsView = mRoot.findViewById(R.id.mms_view); - // if mMmsView is still null here, that mean the mms section hasn't been inflated - - if (visible && mMmsView == null) { - // inflate the mms view_stub - View mmsStub = mRoot.findViewById(R.id.mms_layout_view_stub); - mmsStub.setVisibility(View.VISIBLE); - mMmsView = mRoot.findViewById(R.id.mms_view); - } - } - if (mMmsView != null) { - if (mImageView == null) { - mImageView = (ImageView) mRoot.findViewById(R.id.image_view); - } - if (mSlideShowButton == null) { - mSlideShowButton = (ImageButton) mRoot.findViewById(R.id.play_slideshow_button); - } - mMmsView.setVisibility(visible ? View.VISIBLE : View.GONE); - mImageView.setVisibility(visible ? View.VISIBLE : View.GONE); - } + mMmsView.setVisibility(visible ? View.VISIBLE : View.GONE); + mImageView.setVisibility(visible ? View.VISIBLE : View.GONE); } protected void inflateDownloadControls() { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/MmsImageView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/MmsImageView.java deleted file mode 100644 index 50176134..00000000 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/MmsImageView.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.moez.QKSMS.ui.view; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.widget.ImageView; -import com.moez.QKSMS.common.utils.ImageUtils; - -public class MmsImageView extends ImageView { - private final String TAG = "MmsImageView"; - - public MmsImageView(Context context) { - super(context); - } - - public MmsImageView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - public void setImageDrawable(Drawable drawable) { - if (drawable != null) { - int width = getWidth(); - Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); - - if (bitmap != null) { - float ratio = (float) width / (float) bitmap.getWidth(); - int height = (int) (bitmap.getHeight() * ratio); - - if (width > 0 && height > 0) { - super.setImageDrawable(ImageUtils.getRoundedDrawable(getContext(), Bitmap.createScaledBitmap(bitmap, width, height, true), 4)); - } - } - } else { - super.setImageDrawable(drawable); - } - } -} diff --git a/QKSMS/src/main/res/drawable-xxhdpi/card_mask.9.png b/QKSMS/src/main/res/drawable-xxhdpi/card_mask.9.png new file mode 100644 index 00000000..b3568be5 Binary files /dev/null and b/QKSMS/src/main/res/drawable-xxhdpi/card_mask.9.png differ diff --git a/QKSMS/src/main/res/layout/list_item_message_in.xml b/QKSMS/src/main/res/layout/list_item_message_in.xml index 10241df8..8ff6f43b 100644 --- a/QKSMS/src/main/res/layout/list_item_message_in.xml +++ b/QKSMS/src/main/res/layout/list_item_message_in.xml @@ -45,24 +45,45 @@ android:gravity="left" android:orientation="vertical"> - - + + + + + + + + - - + + + + + + + + - - - - - - - - -