diff --git a/build.gradle b/build.gradle index d306b3e..61034a8 100644 --- a/build.gradle +++ b/build.gradle @@ -6,10 +6,10 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' + classpath 'com.android.tools.build:gradle:2.2.0' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/example/src/main/java/it/snipsnap/slyce_messaging_example/MainActivity.java b/example/src/main/java/it/snipsnap/slyce_messaging_example/MainActivity.java index b656d26..9cf0c2f 100644 --- a/example/src/main/java/it/snipsnap/slyce_messaging_example/MainActivity.java +++ b/example/src/main/java/it/snipsnap/slyce_messaging_example/MainActivity.java @@ -62,6 +62,7 @@ private static Message getRandomMessage() { message.setAvatarUrl("https://lh3.googleusercontent.com/-Y86IN-vEObo/AAAAAAAAAAI/AAAAAAAKyAM/6bec6LqLXXA/s0-c-k-no-ns/photo.jpg"); message.setUserId("LP"); message.setSource(MessageSource.EXTERNAL_USER); + message.setDisplayName("FD100F"); } else { message.setAvatarUrl("https://scontent-lga3-1.xx.fbcdn.net/v/t1.0-9/10989174_799389040149643_722795835011402620_n.jpg?oh=bff552835c414974cc446043ac3c70ca&oe=580717A5"); message.setUserId("MP"); diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c08f858..28d9764 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon May 16 10:54:06 EDT 2016 +#Wed Oct 05 12:16:18 PDT 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/local.properties b/local.properties deleted file mode 100644 index 7b0edc2..0000000 --- a/local.properties +++ /dev/null @@ -1,11 +0,0 @@ -## This file is automatically generated by Android Studio. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -#Thu Aug 04 11:57:49 EDT 2016 -ndk.dir=sdk.dir=/usr/local/android-sdk-linux diff --git a/slyce-messaging/.DS_Store b/slyce-messaging/.DS_Store index f93ad88..aec608a 100644 Binary files a/slyce-messaging/.DS_Store and b/slyce-messaging/.DS_Store differ diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/SlyceMessagingFragment.java b/slyce-messaging/src/main/java/it/slyce/messaging/SlyceMessagingFragment.java index 33de2b6..823cbba 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/SlyceMessagingFragment.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/SlyceMessagingFragment.java @@ -1,9 +1,7 @@ package it.slyce.messaging; -import android.Manifest; import android.app.Fragment; import android.content.Intent; -import android.content.pm.PackageManager; import android.content.res.TypedArray; import android.graphics.Color; import android.net.Uri; @@ -12,11 +10,10 @@ import android.os.Bundle; import android.os.Environment; import android.provider.MediaStore; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.text.TextUtils; +import android.text.Editable; +import android.text.TextWatcher; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -55,6 +52,8 @@ import it.slyce.messaging.utils.asyncTasks.ReplaceMessagesTask; import it.slyce.messaging.view.ViewUtils; + + /** * Created by John C. Hunchar on 1/12/16. */ @@ -62,7 +61,7 @@ public class SlyceMessagingFragment extends Fragment implements OnClickListener private static final int START_RELOADING_DATA_AT_SCROLL_VALUE = 5000; // TODO: maybe change this? make it customizable? - private EditText mEntryField; + public EditText mEntryField; private LinearLayoutManager mLinearLayoutManager; private List mMessages; private List mMessageItems; @@ -227,12 +226,6 @@ public boolean onTouch(View v, MotionEvent event) { loadMoreMessagesIfNecessary(); startLoadMoreMessagesListener(); - if (ContextCompat.checkSelfPermission(getActivity().getApplicationContext(), - Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED || - ContextCompat.checkSelfPermission(getActivity().getApplicationContext(), - Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) - ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 232); - return rootView; } @@ -434,7 +427,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { private void sendUserTextMessage() { String text = ViewUtils.getStringFromEditText(mEntryField); - if (TextUtils.isEmpty(text)) + if (text == null || text.replace(" ","").length() <= 0) return; mEntryField.setText(""); diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/MessageViewHolder.java b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/MessageViewHolder.java index 63d6c72..e9ff73a 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/MessageViewHolder.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/MessageViewHolder.java @@ -17,6 +17,7 @@ public class MessageViewHolder extends RecyclerView.ViewHolder { public TextView timestamp; public ViewGroup avatarContainer; public CustomSettings customSettings; + public TextView username; public MessageViewHolder(View itemView, CustomSettings customSettings) { super(itemView); diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/externalUser/text/MessageExternalUserTextViewHolder.java b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/externalUser/text/MessageExternalUserTextViewHolder.java index 143342f..0de427c 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/externalUser/text/MessageExternalUserTextViewHolder.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/externalUser/text/MessageExternalUserTextViewHolder.java @@ -22,18 +22,17 @@ public MessageExternalUserTextViewHolder(View itemView, final CustomSettings cus super(itemView, customSettings); avatar = (ImageView) itemView.findViewById(R.id.message_scout_text_image_view_avatar); - carrot = (ImageView) itemView.findViewById(R.id.message_scout_text_image_view_carrot); text = (TextView) itemView.findViewById(R.id.message_scout_text_text_view_text); timestamp = (TextView) itemView.findViewById(R.id.message_scout_text_text_view_timestamp); avatarContainer = (ViewGroup) itemView.findViewById(R.id.message_scout_text_image_view_avatar_group); initials = (TextView) itemView.findViewById(R.id.message_scout_text_text_view_initials); bubble = (FrameLayout) itemView.findViewById(R.id.message_scout_text_view_group_bubble); + username = (TextView) itemView.findViewById(R.id.username); Drawable drawable = ContextCompat.getDrawable(itemView.getContext(), R.drawable.shape_rounded_rectangle_white); // Drawable drawable = itemView.getContext().getDrawable(); drawable.setColorFilter(customSettings.externalBubbleBackgroundColor, PorterDuff.Mode.SRC_ATOP); bubble.setBackground(drawable); - carrot.setColorFilter(customSettings.externalBubbleBackgroundColor); text.setTextColor(customSettings.externalBubbleTextColor); timestamp.setTextColor(customSettings.timestampColor); } diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/internalUser/media/MessageInternalUserViewHolder.java b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/internalUser/media/MessageInternalUserViewHolder.java index 0a4bad0..b76add3 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/internalUser/media/MessageInternalUserViewHolder.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/internalUser/media/MessageInternalUserViewHolder.java @@ -23,5 +23,6 @@ public MessageInternalUserViewHolder(View itemView, CustomSettings customSetting initials = (TextView) itemView.findViewById(R.id.message_user_media_text_view_initials); timestamp = (TextView) itemView.findViewById(R.id.message_user_media_text_view_timestamp); avatarContainer = (ViewGroup) itemView.findViewById(R.id.message_user_media_view_group_avatar); + username = (TextView) itemView.findViewById(R.id.username); } } diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/internalUser/text/MessageInternalUserTextViewHolder.java b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/internalUser/text/MessageInternalUserTextViewHolder.java index 9a88a66..4594d34 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/internalUser/text/MessageInternalUserTextViewHolder.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/internalUser/text/MessageInternalUserTextViewHolder.java @@ -22,18 +22,17 @@ public MessageInternalUserTextViewHolder(View itemView, CustomSettings customSet super(itemView, customSettings); avatar = (ImageView) itemView.findViewById(R.id.message_user_text_image_view_avatar); - carrot = (ImageView) itemView.findViewById(R.id.message_user_text_image_view_carrot); initials = (TextView) itemView.findViewById(R.id.message_user_text_text_view_initials); text = (TextView) itemView.findViewById(R.id.message_user_text_text_view_text); timestamp = (TextView) itemView.findViewById(R.id.message_user_text_text_view_timestamp); avatarContainer = (ViewGroup) itemView.findViewById(R.id.message_user_text_view_group_avatar); bubble = (FrameLayout) itemView.findViewById(R.id.message_user_text_view_group_bubble); + username = (TextView) itemView.findViewById(R.id.username); Drawable drawable = ContextCompat.getDrawable(itemView.getContext(), R.drawable.shape_rounded_rectangle_white); // Drawable drawable = itemView.getContext().getDrawable(); drawable.setColorFilter(customSettings.localBubbleBackgroundColor, PorterDuff.Mode.SRC_ATOP); bubble.setBackground(drawable); - carrot.setColorFilter(customSettings.localBubbleBackgroundColor); text.setTextColor(customSettings.localBubbleTextColor); timestamp.setTextColor(customSettings.timestampColor); } diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/media/MessageMediaItem.java b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/media/MessageMediaItem.java index 411c7fc..f445de6 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/media/MessageMediaItem.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/media/MessageMediaItem.java @@ -44,6 +44,7 @@ public void buildMessageItem( // Populate views with content messageMediaViewHolder.timestamp.setText(date != null ? date : ""); messageMediaViewHolder.initials.setText(initials != null ? initials : ""); + messageMediaViewHolder.username.setText(message.getDisplayName() != null ? message.getDisplayName() : ""); messageMediaViewHolder.media.setWidthToHeightRatio(widthToHeightRatio); messageMediaViewHolder.media.setImageUrlToLoadOnLayout(mediaUrl); @@ -73,6 +74,7 @@ public void onClick(View view) { messageMediaViewHolder.avatar.setVisibility(isFirstConsecutiveMessageFromSource && !TextUtils.isEmpty(avatarUrl) ? View.VISIBLE : View.INVISIBLE); messageMediaViewHolder.avatarContainer.setVisibility(isFirstConsecutiveMessageFromSource ? View.VISIBLE : View.INVISIBLE); messageMediaViewHolder.initials.setVisibility(isFirstConsecutiveMessageFromSource && TextUtils.isEmpty(avatarUrl) ? View.VISIBLE : View.GONE); + messageMediaViewHolder.username.setVisibility(isFirstConsecutiveMessageFromSource ? View.VISIBLE : View.GONE); messageMediaViewHolder.media.setVisibility(!TextUtils.isEmpty(mediaUrl) ? View.VISIBLE : View.INVISIBLE); messageMediaViewHolder.timestamp.setVisibility(isLastConsecutiveMessageFromSource ? View.VISIBLE : View.GONE); } diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/text/MessageTextItem.java b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/text/MessageTextItem.java index 7764443..398ac76 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/text/MessageTextItem.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/text/MessageTextItem.java @@ -46,6 +46,8 @@ public void buildMessageItem( messageTextViewHolder.initials.setText(initials != null ? initials : ""); messageTextViewHolder.text.setText(text != null ? text : ""); messageTextViewHolder.timestamp.setText(date != null ? date : ""); + messageTextViewHolder.username.setText(message.getDisplayName() != null ? message.getDisplayName() : ""); + messageTextViewHolder.bubble.setOnLongClickListener(new View.OnLongClickListener() { @Override @@ -75,8 +77,8 @@ public void onClick(View view) { messageTextViewHolder.avatar.setVisibility(isFirstConsecutiveMessageFromSource && !TextUtils.isEmpty(avatarUrl) ? View.VISIBLE : View.INVISIBLE); messageTextViewHolder.avatarContainer.setVisibility(isFirstConsecutiveMessageFromSource ? View.VISIBLE : View.INVISIBLE); - messageTextViewHolder.carrot.setVisibility(isFirstConsecutiveMessageFromSource ? View.VISIBLE : View.INVISIBLE); messageTextViewHolder.initials.setVisibility(isFirstConsecutiveMessageFromSource && TextUtils.isEmpty(avatarUrl) ? View.VISIBLE : View.GONE); + messageTextViewHolder.username.setVisibility(isFirstConsecutiveMessageFromSource ? View.VISIBLE : View.GONE); messageTextViewHolder.timestamp.setVisibility(isLastConsecutiveMessageFromSource ? View.VISIBLE : View.GONE); } } diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/text/MessageTextViewHolder.java b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/text/MessageTextViewHolder.java index 5ae5c00..d811d69 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/text/MessageTextViewHolder.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/message/messageItem/master/text/MessageTextViewHolder.java @@ -12,7 +12,6 @@ * Created by matthewpage on 6/27/16. */ public abstract class MessageTextViewHolder extends MessageViewHolder { - public ImageView carrot; public TextView text; public FrameLayout bubble; diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/utils/MessageUtils.java b/slyce-messaging/src/main/java/it/slyce/messaging/utils/MessageUtils.java index 6af433c..99e4928 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/utils/MessageUtils.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/utils/MessageUtils.java @@ -30,17 +30,7 @@ public static void markMessageItemAtIndexIfFirstOrLastFromSource(int i, List messageItems) { - return i == 0 || - previousMessageIsSpinner(i, messageItems) || - previousMessageIsFromAnotherSender(i, messageItems); - } - - private static boolean previousMessageIsFromAnotherSender(int i, List messageItems) { - return messageItems.get(i - 1).getMessageSource() != messageItems.get(i).getMessageSource(); - } - - private static boolean previousMessageIsSpinner(int i, List messageItems) { - return isSpinnerMessage(i - 1, messageItems); + return true; } private static boolean isTheLastConsecutiveMessageFromSource(int i, List messageItems) { diff --git a/slyce-messaging/src/main/java/it/slyce/messaging/view/text/FontTextView.java b/slyce-messaging/src/main/java/it/slyce/messaging/view/text/FontTextView.java index 1266964..6b320cc 100644 --- a/slyce-messaging/src/main/java/it/slyce/messaging/view/text/FontTextView.java +++ b/slyce-messaging/src/main/java/it/slyce/messaging/view/text/FontTextView.java @@ -5,8 +5,14 @@ import android.content.res.TypedArray; import android.graphics.Typeface; import android.os.Build; +import android.text.Layout; +import android.text.Selection; +import android.text.Spannable; +import android.text.Spanned; import android.text.TextUtils; +import android.text.style.ClickableSpan; import android.util.AttributeSet; +import android.view.MotionEvent; import android.widget.TextView; import it.slyce.messaging.R; @@ -69,4 +75,48 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def } } } + + @Override + public boolean onTouchEvent(MotionEvent event) { + TextView widget = (TextView) this; + Object text = widget.getText(); + if (text instanceof Spanned) { + Spannable buffer = (Spannable) text; + + int action = event.getAction(); + + if (action == MotionEvent.ACTION_UP + || action == MotionEvent.ACTION_DOWN) { + int x = (int) event.getX(); + int y = (int) event.getY(); + + x -= widget.getTotalPaddingLeft(); + y -= widget.getTotalPaddingTop(); + + x += widget.getScrollX(); + y += widget.getScrollY(); + + Layout layout = widget.getLayout(); + int line = layout.getLineForVertical(y); + int off = layout.getOffsetForHorizontal(line, x); + + ClickableSpan[] link = buffer.getSpans(off, off, + ClickableSpan.class); + + if (link.length != 0) { + if (action == MotionEvent.ACTION_UP) { + link[0].onClick(widget); + } else if (action == MotionEvent.ACTION_DOWN) { + Selection.setSelection(buffer, + buffer.getSpanStart(link[0]), + buffer.getSpanEnd(link[0])); + } + return true; + } + } + + } + + return false; + } } diff --git a/slyce-messaging/src/main/res/drawable/shape_rounded_rectangle_gray.xml b/slyce-messaging/src/main/res/drawable/shape_rounded_rectangle_gray.xml index aa97584..bf856df 100644 --- a/slyce-messaging/src/main/res/drawable/shape_rounded_rectangle_gray.xml +++ b/slyce-messaging/src/main/res/drawable/shape_rounded_rectangle_gray.xml @@ -2,8 +2,6 @@ + android:radius="6dp" /> - diff --git a/slyce-messaging/src/main/res/drawable/shape_rounded_rectangle_white.xml b/slyce-messaging/src/main/res/drawable/shape_rounded_rectangle_white.xml index c55843c..74ca991 100644 --- a/slyce-messaging/src/main/res/drawable/shape_rounded_rectangle_white.xml +++ b/slyce-messaging/src/main/res/drawable/shape_rounded_rectangle_white.xml @@ -1,9 +1,8 @@ - + + + - diff --git a/slyce-messaging/src/main/res/layout/item_message_external_text.xml b/slyce-messaging/src/main/res/layout/item_message_external_text.xml index f557264..e46ba7f 100644 --- a/slyce-messaging/src/main/res/layout/item_message_external_text.xml +++ b/slyce-messaging/src/main/res/layout/item_message_external_text.xml @@ -31,23 +31,28 @@ app:font="museo_sans_500.otf" tools:text="JF"/> + + - + + - + + + \ No newline at end of file