|
|
|
@ -389,8 +389,6 @@ public class FragmentMessages extends FragmentBase
|
|
|
|
|
private boolean scrolling = false;
|
|
|
|
|
private boolean navigating = false;
|
|
|
|
|
|
|
|
|
|
private GestureDetector gestureDetector;
|
|
|
|
|
|
|
|
|
|
private AdapterMessage adapter;
|
|
|
|
|
|
|
|
|
|
private AdapterMessage.ViewType viewType;
|
|
|
|
@ -1198,65 +1196,67 @@ public class FragmentMessages extends FragmentBase
|
|
|
|
|
};
|
|
|
|
|
rvMessage.addItemDecoration(dateDecorator);
|
|
|
|
|
|
|
|
|
|
gestureDetector =
|
|
|
|
|
new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onLongPress(@NonNull MotionEvent e) {
|
|
|
|
|
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
|
|
|
|
return;
|
|
|
|
|
rvMessage.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
|
|
|
|
|
private final GestureDetector gestureDetector =
|
|
|
|
|
new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onLongPress(@NonNull MotionEvent e) {
|
|
|
|
|
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
|
|
|
|
return;
|
|
|
|
|
if (swiping)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int x = Math.round(e.getX());
|
|
|
|
|
int y = Math.round(e.getY());
|
|
|
|
|
int x = Math.round(e.getX());
|
|
|
|
|
int y = Math.round(e.getY());
|
|
|
|
|
|
|
|
|
|
Rect rect = new Rect();
|
|
|
|
|
for (int i = 0; i < rvMessage.getChildCount(); i++) {
|
|
|
|
|
View child = rvMessage.getChildAt(i);
|
|
|
|
|
if (child == null)
|
|
|
|
|
continue;
|
|
|
|
|
Rect rect = new Rect();
|
|
|
|
|
for (int i = 0; i < rvMessage.getChildCount(); i++) {
|
|
|
|
|
View child = rvMessage.getChildAt(i);
|
|
|
|
|
if (child == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
dateDecorator.getItemOffsets(rect, child, rvMessage, null);
|
|
|
|
|
if (rect.height() == 0)
|
|
|
|
|
continue;
|
|
|
|
|
dateDecorator.getItemOffsets(rect, child, rvMessage, null);
|
|
|
|
|
if (rect.height() == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
rect.set(child.getLeft(), child.getTop() - rect.top, child.getRight(), child.getTop());
|
|
|
|
|
if (!rect.contains(x, y))
|
|
|
|
|
continue;
|
|
|
|
|
rect.set(child.getLeft(), child.getTop() - rect.top, child.getRight(), child.getTop());
|
|
|
|
|
if (!rect.contains(x, y))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
int pos = rvMessage.getChildAdapterPosition(child);
|
|
|
|
|
if (pos == NO_POSITION)
|
|
|
|
|
continue;
|
|
|
|
|
int pos = rvMessage.getChildAdapterPosition(child);
|
|
|
|
|
if (pos == NO_POSITION)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
TupleMessageEx message = adapter.getItemAtPosition(pos);
|
|
|
|
|
if (message == null)
|
|
|
|
|
continue;
|
|
|
|
|
TupleMessageEx message = adapter.getItemAtPosition(pos);
|
|
|
|
|
if (message == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.setTimeInMillis(message.received);
|
|
|
|
|
cal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
cal.set(Calendar.MINUTE, 0);
|
|
|
|
|
cal.set(Calendar.SECOND, 0);
|
|
|
|
|
cal.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
|
|
|
|
|
if (date_week) {
|
|
|
|
|
cal.setMinimalDaysInFirstWeek(4); // ISO 8601
|
|
|
|
|
cal.setFirstDayOfWeek(Calendar.MONDAY);
|
|
|
|
|
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
|
|
|
|
|
cal.add(Calendar.DATE, 7);
|
|
|
|
|
} else
|
|
|
|
|
cal.add(Calendar.DATE, 1);
|
|
|
|
|
long to = cal.getTimeInMillis();
|
|
|
|
|
|
|
|
|
|
cal.add(Calendar.DATE, date_week ? -7 : -1);
|
|
|
|
|
long from = cal.getTimeInMillis();
|
|
|
|
|
|
|
|
|
|
onMenuSelect(from, to, true);
|
|
|
|
|
Helper.performHapticFeedback(view, HapticFeedbackConstants.CONFIRM);
|
|
|
|
|
return;
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.setTimeInMillis(message.received);
|
|
|
|
|
cal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
cal.set(Calendar.MINUTE, 0);
|
|
|
|
|
cal.set(Calendar.SECOND, 0);
|
|
|
|
|
cal.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
|
|
|
|
|
if (date_week) {
|
|
|
|
|
cal.setMinimalDaysInFirstWeek(4); // ISO 8601
|
|
|
|
|
cal.setFirstDayOfWeek(Calendar.MONDAY);
|
|
|
|
|
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
|
|
|
|
|
cal.add(Calendar.DATE, 7);
|
|
|
|
|
} else
|
|
|
|
|
cal.add(Calendar.DATE, 1);
|
|
|
|
|
long to = cal.getTimeInMillis();
|
|
|
|
|
|
|
|
|
|
cal.add(Calendar.DATE, date_week ? -7 : -1);
|
|
|
|
|
long from = cal.getTimeInMillis();
|
|
|
|
|
|
|
|
|
|
onMenuSelect(from, to, true);
|
|
|
|
|
Helper.performHapticFeedback(view, HapticFeedbackConstants.CONFIRM);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rvMessage.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
|
|
|
|
|
gestureDetector.onTouchEvent(e);
|
|
|
|
@ -3282,7 +3282,6 @@ public class FragmentMessages extends FragmentBase
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
swiping = false;
|
|
|
|
|
gestureDetector.setIsLongpressEnabled(true);
|
|
|
|
|
Log.i("Swiping ended");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -3293,7 +3292,6 @@ public class FragmentMessages extends FragmentBase
|
|
|
|
|
getMainHandler().removeCallbacks(disableSwiping);
|
|
|
|
|
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
|
|
|
|
|
swiping = true;
|
|
|
|
|
gestureDetector.setIsLongpressEnabled(false);
|
|
|
|
|
Log.i("Swiping started");
|
|
|
|
|
} else
|
|
|
|
|
getMainHandler().postDelayed(disableSwiping, ViewConfiguration.getLongPressTimeout() + 100);
|
|
|
|
|