Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated libs #360

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.novoda:bintray-release:0.8.0'
classpath 'com.android.tools.build:gradle:4.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
19 changes: 4 additions & 15 deletions chatkit/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'


android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 30

defaultConfig {
minSdkVersion 14
Expand All @@ -18,16 +17,6 @@ android {
}
}

publish {
groupId = 'com.github.stfalcon'
artifactId = 'chatkit'
publishVersion = '0.3.3'
desc = 'ChatKit - is a library designed to simplify the development of UI for such a trivial task as chat. It have flexible possibilities for styling, customizing and data management'
licences = ['Apache-2.0']
uploadName = 'ChatKit'
website = 'https://github.com/stfalcon-studio/ChatKit.git'
}

ext {
supportVersion = '27.1.1'
flexboxVersion = '1.0.0'
Expand All @@ -36,7 +25,7 @@ ext {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:design:$supportVersion"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.0.0'
implementation "com.google.android:flexbox:$flexboxVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.stfalcon.chatkit.commons;

import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.widget.ImageView;

/**
Expand Down
10 changes: 5 additions & 5 deletions chatkit/src/main/java/com/stfalcon/chatkit/commons/Style.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.annotation.AttrRes;
import android.support.annotation.ColorRes;
import android.support.annotation.DimenRes;
import android.support.annotation.DrawableRes;
import android.support.v4.content.ContextCompat;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorRes;
import androidx.annotation.DimenRes;
import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat;
import android.util.AttributeSet;
import android.util.TypedValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.stfalcon.chatkit.commons;

import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ public interface IMessage {
* @return the message creation date
*/
Date getCreatedAt();

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.stfalcon.chatkit.commons.models;

import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.stfalcon.chatkit.messages.MessageHolders;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package com.stfalcon.chatkit.dialogs;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SimpleItemAnimator;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
import android.util.AttributeSet;

import com.stfalcon.chatkit.commons.models.IDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import android.graphics.Typeface;
import android.graphics.drawable.GradientDrawable;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.stfalcon.chatkit.messages;

import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;

import android.text.Spannable;
import android.text.method.LinkMovementMethod;
import android.util.SparseArray;
Expand Down Expand Up @@ -564,6 +565,7 @@ protected ViewHolder getHolder(ViewGroup parent, int viewType, MessagesListStyle

@SuppressWarnings("unchecked")
protected void bind(final ViewHolder holder, final Object item, boolean isSelected,
boolean isContinuous, boolean isLastItemInGroup,
final ImageLoader imageLoader,
final View.OnClickListener onMessageClickListener,
final View.OnLongClickListener onMessageLongClickListener,
Expand All @@ -573,6 +575,8 @@ protected void bind(final ViewHolder holder, final Object item, boolean isSelect
if (item instanceof IMessage) {
((MessageHolders.BaseMessageViewHolder) holder).isSelected = isSelected;
((MessageHolders.BaseMessageViewHolder) holder).imageLoader = imageLoader;
((BaseMessageViewHolder) holder).isFirstItemInGroup = isContinuous;
((BaseMessageViewHolder) holder).isLastItemInGroup = isLastItemInGroup;
holder.itemView.setOnLongClickListener(onMessageLongClickListener);
holder.itemView.setOnClickListener(onMessageClickListener);

Expand Down Expand Up @@ -676,6 +680,9 @@ public static abstract class BaseMessageViewHolder<MESSAGE extends IMessage> ext

boolean isSelected;

boolean isFirstItemInGroup;

boolean isLastItemInGroup;
/**
* For setting custom data to ViewHolder
*/
Expand Down Expand Up @@ -705,6 +712,31 @@ public boolean isSelected() {
return isSelected;
}

/**
* Returns whether item belongs to the same user
*
* @return weather item belongs to the same user.
*/
public boolean isFirstItemInGroup() {
return isFirstItemInGroup;
}

/**
* Returns whether the current item and the next belongs to the same user
*/
public boolean isLastItemInGroup() {
return isLastItemInGroup;
}

public List<View> getVisibleViewsForFirstItemInGroup() {
return new ArrayList<>();
}

public List<View> getVisibleViewsForLastItemInGroup() {
return new ArrayList<>();
}


/**
* Returns weather is selection mode enabled
*
Expand Down Expand Up @@ -769,6 +801,26 @@ public void onBind(MESSAGE message) {
if (text != null) {
text.setText(message.getText());
}

if (isLastItemInGroup()) {
for (View continousView : getVisibleViewsForLastItemInGroup()) {
continousView.setVisibility(View.VISIBLE);
}
} else {
for (View continousView : getVisibleViewsForLastItemInGroup()) {
continousView.setVisibility(View.GONE);
}
}

if (isFirstItemInGroup()) {
for (View continousView : getVisibleViewsForFirstItemInGroup()) {
continousView.setVisibility(View.VISIBLE);
}
} else {
for (View continousView : getVisibleViewsForFirstItemInGroup()) {
continousView.setVisibility(View.INVISIBLE);
}
}
}

@Override
Expand Down Expand Up @@ -828,6 +880,26 @@ public void onBind(MESSAGE message) {
if (text != null) {
text.setText(message.getText());
}

if (isLastItemInGroup()) {
for (View continousView : getVisibleViewsForLastItemInGroup()) {
continousView.setVisibility(View.VISIBLE);
}
} else {
for (View continousView : getVisibleViewsForLastItemInGroup()) {
continousView.setVisibility(View.GONE);
}
}

if (isFirstItemInGroup()) {
for (View continousView : getVisibleViewsForFirstItemInGroup()) {
continousView.setVisibility(View.VISIBLE);
}
} else {
for (View continousView : getVisibleViewsForFirstItemInGroup()) {
continousView.setVisibility(View.INVISIBLE);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.Space;
import androidx.core.view.ViewCompat;
import androidx.legacy.widget.Space;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.v4.graphics.drawable.DrawableCompat;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.core.graphics.drawable.DrawableCompat;
import android.util.AttributeSet;

import com.stfalcon.chatkit.R;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
package com.stfalcon.chatkit.messages;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SimpleItemAnimator;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;

import android.util.AttributeSet;

import com.stfalcon.chatkit.commons.models.IMessage;
Expand Down Expand Up @@ -75,13 +77,8 @@ void setAdapter(MessagesListAdapter<MESSAGE> adapter) {
*/
public <MESSAGE extends IMessage>
void setAdapter(MessagesListAdapter<MESSAGE> adapter, boolean reverseLayout) {
SimpleItemAnimator itemAnimator = new DefaultItemAnimator();
itemAnimator.setSupportsChangeAnimations(false);

LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),
LinearLayoutManager.VERTICAL, reverseLayout);

setItemAnimator(itemAnimator);
setLayoutManager(layoutManager);
adapter.setLayoutManager(layoutManager);
adapter.setStyle(messagesListStyle);
Expand Down
Loading