Browse Source

Preparations for multiple select

main
M66B 6 years ago
parent
commit
89ac44d312
3 changed files with 42 additions and 6 deletions
  1. +15
    -4
      app/src/main/java/eu/faircode/email/AdapterMessage.java
  2. +17
    -2
      app/src/main/res/layout/fragment_messages.xml
  3. +10
    -0
      app/src/main/res/menu/action_list_bottom.xml

+ 15
- 4
app/src/main/java/eu/faircode/email/AdapterMessage.java View File

@ -34,7 +34,9 @@ import android.widget.TextView;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleOwner;
@ -50,6 +52,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
private ViewType viewType; private ViewType viewType;
private boolean debug; private boolean debug;
private Map<Long, Boolean> selected = new HashMap<>();
private DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.LONG); private DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.LONG);
enum ViewType {FOLDER, THREAD} enum ViewType {FOLDER, THREAD}
@ -100,6 +103,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
private void bindTo(final TupleMessageEx message) { private void bindTo(final TupleMessageEx message) {
pbLoading.setVisibility(View.GONE); pbLoading.setVisibility(View.GONE);
itemView.setActivated(selected.containsKey(message.id) && selected.get(message.id));
if (EntityFolder.DRAFTS.equals(message.folderType) || if (EntityFolder.DRAFTS.equals(message.folderType) ||
EntityFolder.OUTBOX.equals(message.folderType) || EntityFolder.OUTBOX.equals(message.folderType) ||
EntityFolder.SENT.equals(message.folderType)) { EntityFolder.SENT.equals(message.folderType)) {
@ -186,10 +191,16 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
return false; return false;
TupleMessageEx message = getItem(pos); TupleMessageEx message = getItem(pos);
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGE)
.putExtra("id", message.id));
if (!selected.containsKey(message.id))
selected.put(message.id, false);
selected.put(message.id, !selected.get(message.id));
notifyItemChanged(pos);
//LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
//lbm.sendBroadcast(
// new Intent(ActivityView.ACTION_VIEW_MESSAGE)
// .putExtra("id", message.id));
return true; return true;
} }


+ 17
- 2
app/src/main/res/layout/fragment_messages.xml View File

@ -23,11 +23,26 @@
android:layout_height="0dp" android:layout_height="0dp"
android:scrollbarStyle="outsideOverlay" android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:background="@color/colorPrimary"
android:visibility="gone"
app:itemIconTint="@color/bottomnav_background"
app:itemTextColor="@color/bottomnav_background"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/action_list_bottom" />
<ProgressBar <ProgressBar
android:id="@+id/pbWait" android:id="@+id/pbWait"
style="@style/Base.Widget.AppCompat.ProgressBar" style="@style/Base.Widget.AppCompat.ProgressBar"
@ -54,6 +69,6 @@
android:src="@drawable/baseline_edit_24" android:src="@drawable/baseline_edit_24"
android:tint="@color/colorActionForeground" android:tint="@color/colorActionForeground"
app:backgroundTint="?attr/colorAccent" app:backgroundTint="?attr/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toBottomOf="@+id/rvFolder"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

+ 10
- 0
app/src/main/res/menu/action_list_bottom.xml View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_move"
android:icon="@drawable/baseline_folder_24"
android:title="@string/title_move"
app:showAsAction="ifRoom" />
</menu>

Loading…
Cancel
Save