Added swipe to seen

pull/159/head
M66B 6 years ago
parent 87b9dbd834
commit f0922e9152

@ -200,8 +200,6 @@ public class EntityFolder extends EntityOrder implements Serializable {
}
static int getIcon(String type) {
if (type == null)
return R.drawable.baseline_list_24;
if (EntityFolder.INBOX.equals(type))
return R.drawable.baseline_inbox_24;
if (EntityFolder.DRAFTS.equals(type))

@ -147,6 +147,9 @@ public class FragmentAccount extends FragmentBase {
private static final int REQUEST_SAVE = 2;
private static final int REQUEST_DELETE = 3;
static final Long SWIPE_ACTION_ASK = -1L;
static final Long SWIPE_ACTION_SEEN = -2L;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -1401,10 +1404,15 @@ public class FragmentAccount extends FragmentBase {
}
EntityFolder ask = new EntityFolder();
ask.id = -1L;
ask.id = SWIPE_ACTION_ASK;
ask.name = getString(R.string.title_ask_what);
folders.add(1, ask);
EntityFolder seen = new EntityFolder();
seen.id = SWIPE_ACTION_SEEN;
seen.name = getString(R.string.title_seen);
folders.add(1, seen);
adapterSwipe.clear();
adapterSwipe.addAll(folders);

@ -1254,10 +1254,21 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
int margin = Helper.dp2pixels(getContext(), 12);
int size = Helper.dp2pixels(getContext(), 24);
int icon;
long action = (dX > 0 ? swipes.swipe_right : swipes.swipe_left);
if (FragmentAccount.SWIPE_ACTION_ASK.equals(action))
icon = R.drawable.baseline_list_24;
else if (FragmentAccount.SWIPE_ACTION_SEEN.equals(action))
if (message.ui_seen)
icon = R.drawable.baseline_visibility_off_24;
else
icon = R.drawable.baseline_visibility_24;
else
icon = EntityFolder.getIcon(dX > 0 ? swipes.right_type : swipes.left_type);
Drawable d = getResources().getDrawable(icon, getContext().getTheme()).mutate();
if (dX > 0) {
// Right swipe
Drawable d = getResources().getDrawable(
EntityFolder.getIcon(swipes.right_type), getContext().getTheme()).mutate();
d.setAlpha(Math.round(255 * Math.min(dX / (2 * margin + size), 1.0f)));
int padding = (rect.height() - size);
d.setBounds(
@ -1268,8 +1279,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
d.draw(canvas);
} else if (dX < 0) {
// Left swipe
Drawable d = getResources().getDrawable(
EntityFolder.getIcon(swipes.left_type), getContext().getTheme()).mutate();
d.setAlpha(Math.round(255 * Math.min(-dX / (2 * margin + size), 1.0f)));
int padding = (rect.height() - size);
d.setBounds(
@ -1304,7 +1313,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Log.i("Swiped dir=" + direction + " message=" + message.id);
if (direction == ItemTouchHelper.LEFT ? swipes.swipe_left < 0 : swipes.swipe_right < 0) {
Long action = (direction == ItemTouchHelper.LEFT ? swipes.swipe_left : swipes.swipe_right);
if (FragmentAccount.SWIPE_ACTION_SEEN.equals(action))
onActionSeenSelection(!message.ui_seen, message.id);
else if (FragmentAccount.SWIPE_ACTION_ASK.equals(action)) {
adapter.notifyItemChanged(viewHolder.getAdapterPosition());
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), viewHolder.itemView);
@ -1391,7 +1403,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putBoolean("thread", viewType != AdapterMessage.ViewType.THREAD);
args.putLong("target", direction == ItemTouchHelper.LEFT ? swipes.swipe_left : swipes.swipe_right);
args.putLong("target", action);
new SimpleTask<ArrayList<MessageTarget>>() {
@Override

Loading…
Cancel
Save