Revert "Left/right experiment"

This reverts commit 790c09af9f.

Refs #116
This commit is contained in:
M66B 2018-09-14 16:16:06 +00:00
parent 790c09af9f
commit 1ab82368fe
4 changed files with 4 additions and 145 deletions

View File

@ -1,92 +0,0 @@
package eu.faircode.email;
import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import androidx.constraintlayout.widget.ConstraintLayout;
public class ConstraintLayoutTouch extends ConstraintLayout {
private IGestureListener listener = null;
enum Direction {Left, Right, Up, Down}
private static final long VELOCITY_THRESHOLD = 3000;
public ConstraintLayoutTouch(Context context) {
super(context);
}
public ConstraintLayoutTouch(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ConstraintLayoutTouch(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (listener != null)
gestureDetector.onTouchEvent(ev);
return super.onInterceptTouchEvent(ev);
}
void setGestureListener(IGestureListener listener) {
this.listener = listener;
}
private GestureDetector gestureDetector = new GestureDetector(getContext(), new GestureDetector.OnGestureListener() {
@Override
public boolean onDown(final MotionEvent e) {
return false;
}
@Override
public void onShowPress(final MotionEvent e) {
}
@Override
public boolean onSingleTapUp(final MotionEvent e) {
return false;
}
@Override
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX,
final float distanceY) {
return false;
}
@Override
public void onLongPress(final MotionEvent e) {
}
@Override
public boolean onFling(final MotionEvent e1, final MotionEvent e2,
final float velocityX,
final float velocityY) {
if (Math.abs(velocityX) < VELOCITY_THRESHOLD && Math.abs(velocityY) < VELOCITY_THRESHOLD)
return false;
if (Math.abs(velocityX) > Math.abs(velocityY)) {
if (velocityX >= 0)
listener.onSwipe(Direction.Right);
else
listener.onSwipe(Direction.Left);
} else {
if (velocityY >= 0)
listener.onSwipe(Direction.Down);
else
listener.onSwipe(Direction.Up);
}
return true;
}
});
interface IGestureListener {
void onSwipe(Direction direction);
}
}

View File

@ -160,23 +160,6 @@ public interface DaoMessage {
" ORDER BY message.received")
LiveData<List<EntityMessage>> liveUnseenUnified();
@Query("SELECT message.*" +
", account.name AS accountName, account.color AS accountColor" +
", folder.name as folderName, folder.type as folderType" +
", (SELECT COUNT(m1.id) FROM message m1 WHERE m1.account = message.account AND m1.thread = message.thread AND NOT m1.ui_hide) AS count" +
", (SELECT COUNT(m2.id) FROM message m2 WHERE m2.account = message.account AND m2.thread = message.thread AND NOT m2.ui_hide AND NOT m2.ui_seen) AS unseen" +
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
" FROM message related" +
" JOIN message ON message.folder = related.folder" +
" JOIN account ON account.id = message.account" +
" JOIN folder ON folder.id = message.folder" +
" WHERE related.id = :id" +
" ORDER BY" +
" CASE WHEN :next OR message.sent IS NULL THEN message.sent ELSE -message.sent END, " +
" CASE WHEN :next OR message.received IS NULL THEN message.received ELSE -message.received END" +
" LIMIT 1")
TupleMessageEx getMessage(long id, boolean next);
@Query("SELECT uid FROM message" +
" WHERE folder = :folder" +
" AND received >= :received" +

View File

@ -100,7 +100,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class FragmentMessage extends FragmentEx {
private ConstraintLayoutTouch view;
private ViewGroup view;
private View vwAnswerAnchor;
private ImageView ivFlagged;
private ImageView ivAvatar;
@ -157,7 +157,7 @@ public class FragmentMessage extends FragmentEx {
@Override
@Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = (ConstraintLayoutTouch) inflater.inflate(R.layout.fragment_message, container, false);
view = (ViewGroup) inflater.inflate(R.layout.fragment_message, container, false);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
debug = prefs.getBoolean("debug", false);
@ -405,38 +405,6 @@ public class FragmentMessage extends FragmentEx {
}
});
view.setGestureListener(new ConstraintLayoutTouch.IGestureListener() {
@Override
public void onSwipe(ConstraintLayoutTouch.Direction direction) {
if (message == null)
return;
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putBoolean("next",
direction == ConstraintLayoutTouch.Direction.Down ||
direction == ConstraintLayoutTouch.Direction.Right);
new SimpleTask<TupleMessageEx>() {
@Override
protected TupleMessageEx onLoad(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
boolean next = args.getBoolean("next");
return DB.getInstance(context).message().getMessage(id, next);
}
@Override
protected void onLoaded(Bundle args, TupleMessageEx message) {
if (message != null) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGE)
.putExtra("message", message));
}
}
}.load(FragmentMessage.this, args);
}
});
// Initialize
grpHeader.setVisibility(View.GONE);
grpAddresses.setVisibility(View.GONE);

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<eu.faircode.email.ConstraintLayoutTouch xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -438,4 +438,4 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="scroll" />
</eu.faircode.email.ConstraintLayoutTouch>
</androidx.constraintlayout.widget.ConstraintLayout>