better messages highlighting
This commit is contained in:
parent
1d7bd8f8da
commit
356d1e146e
|
@ -75,6 +75,7 @@ import androidx.appcompat.content.res.AppCompatResources;
|
|||
import androidx.core.view.inputmethod.InputConnectionCompat;
|
||||
import androidx.core.view.inputmethod.InputContentInfoCompat;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
|
||||
|
@ -143,6 +144,7 @@ import eu.siacs.conversations.ui.util.SendButtonTool;
|
|||
import eu.siacs.conversations.ui.util.ShareUtil;
|
||||
import eu.siacs.conversations.ui.util.ViewUtil;
|
||||
import eu.siacs.conversations.ui.widget.EditMessage;
|
||||
import eu.siacs.conversations.ui.widget.HighlighterView;
|
||||
import eu.siacs.conversations.ui.widget.TabLayout;
|
||||
import eu.siacs.conversations.utils.AccountUtils;
|
||||
import eu.siacs.conversations.utils.Compatibility;
|
||||
|
@ -1581,16 +1583,11 @@ public class ConversationFragment extends XmppFragment
|
|||
}
|
||||
|
||||
View view = ListViewUtils.getViewByPosition(actualIndex, binding.messagesView);
|
||||
View messageBox = view.findViewById(R.id.message_box);
|
||||
if (messageBox != null) {
|
||||
messageBox.animate()
|
||||
.scaleX(1.03f)
|
||||
.scaleY(1.03f)
|
||||
.setInterpolator(new CycleInterpolator(0.5f))
|
||||
.setDuration(300L)
|
||||
.start();
|
||||
HighlighterView highlighter = view.findViewById(R.id.highlighter);
|
||||
if (highlighter != null) {
|
||||
highlighter.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}, 300L);
|
||||
}, 200L);
|
||||
}
|
||||
|
||||
private void updateSelection(String uuid, Integer offsetFormTop, Runnable selectionUpdatedRunnable, boolean populateFromMam, boolean recursiveFetch) {
|
||||
|
|
|
@ -787,6 +787,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
}
|
||||
}
|
||||
|
||||
View highlighter = view.findViewById(R.id.highlighter);
|
||||
if (highlighter != null) {
|
||||
highlighter.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
boolean darkBackground = type == RECEIVED && (!isInValidSession || mUseGreenBackground) || activity.isDarkTheme();
|
||||
|
||||
if (type == DATE_SEPARATOR) {
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package eu.siacs.conversations.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
|
||||
public class HighlighterView extends View {
|
||||
|
||||
private Runnable hideHighlight = () -> {
|
||||
if (getVisibility() == View.INVISIBLE) return;
|
||||
|
||||
animate()
|
||||
.alpha(0.0f)
|
||||
.setInterpolator(new FastOutSlowInInterpolator())
|
||||
.setDuration(300L)
|
||||
.withEndAction(() -> setVisibility(View.INVISIBLE))
|
||||
.start();
|
||||
};
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
public HighlighterView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public HighlighterView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public HighlighterView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public HighlighterView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibility(int visibility) {
|
||||
super.setVisibility(visibility);
|
||||
|
||||
if (visibility != View.VISIBLE) {
|
||||
handler.removeCallbacks(hideHighlight);
|
||||
animate().cancel();
|
||||
setAlpha(0);
|
||||
} else {
|
||||
animate()
|
||||
.alpha(0.5f)
|
||||
.setInterpolator(new FastOutSlowInInterpolator())
|
||||
.setDuration(300L)
|
||||
.start();
|
||||
|
||||
handler.removeCallbacks(hideHighlight);
|
||||
handler.postDelayed(hideHighlight, 2000);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,11 +4,24 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingTop="4dp">
|
||||
|
||||
<eu.siacs.conversations.ui.widget.HighlighterView
|
||||
android:id="@+id/highlighter"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignBottom="@id/message_box"
|
||||
android:background="?color_message_selection"
|
||||
android:layout_marginLeft="-8dp"
|
||||
android:layout_marginRight="-8dp"
|
||||
android:alpha="0"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<com.makeramen.roundedimageview.RoundedImageView
|
||||
android:id="@+id/message_photo"
|
||||
android:layout_width="48dp"
|
||||
|
|
|
@ -4,11 +4,24 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:clipToPadding="false"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingBottom="4dp">
|
||||
|
||||
<eu.siacs.conversations.ui.widget.HighlighterView
|
||||
android:id="@+id/highlighter"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignBottom="@id/message_box"
|
||||
android:background="?color_message_selection"
|
||||
android:layout_marginLeft="-8dp"
|
||||
android:layout_marginRight="-8dp"
|
||||
android:alpha="0"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<com.makeramen.roundedimageview.RoundedImageView
|
||||
android:id="@+id/message_photo"
|
||||
android:layout_width="48dp"
|
||||
|
@ -93,7 +106,6 @@
|
|||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<View
|
||||
android:id="@+id/clicks_interceptor"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -101,4 +113,5 @@
|
|||
android:layout_alignParentTop="true"
|
||||
android:layout_alignBottom="@id/message_box"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in a new issue