Show selected count

This commit is contained in:
M66B 2020-05-31 12:37:48 +02:00
parent 916a499c0f
commit c2d6b8576c
3 changed files with 42 additions and 9 deletions

View File

@ -240,6 +240,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private FloatingActionButton fabReply;
private FloatingActionButton fabCompose;
private FloatingActionButton fabMore;
private TextView tvSelectedCount;
private FloatingActionButton fabSearch;
private FloatingActionButton fabError;
@ -444,6 +445,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
fabReply = view.findViewById(R.id.fabReply);
fabCompose = view.findViewById(R.id.fabCompose);
fabMore = view.findViewById(R.id.fabMore);
tvSelectedCount = view.findViewById(R.id.tvSelectedCount);
fabSearch = view.findViewById(R.id.fabSearch);
fabError = view.findViewById(R.id.fabError);
@ -975,6 +977,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
});
tvSelectedCount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onMore();
}
});
fabSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -1117,6 +1126,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
fabSearch.hide();
fabMore.hide();
tvSelectedCount.setVisibility(View.GONE);
fabError.hide();
if (viewType == AdapterMessage.ViewType.THREAD) {
@ -1226,10 +1236,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (activity != null)
activity.invalidateOptionsMenu();
if (selectionTracker != null && selectionTracker.hasSelection())
fabMore.show();
else
fabMore.hide();
updateMore();
}
@Override
@ -3090,11 +3097,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
loadMessages(false);
updateExpanded();
if (selectionTracker != null && selectionTracker.hasSelection())
fabMore.show();
else
fabMore.hide();
updateMore();
// Folder
switch (viewType) {
@ -3878,6 +3881,17 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
swipeRefresh.setRefreshing(refreshing);
}
private void updateMore() {
if (selectionTracker != null && selectionTracker.hasSelection()) {
fabMore.show();
tvSelectedCount.setText(NF.format(selectionTracker.getSelection().size()));
tvSelectedCount.setVisibility(View.VISIBLE);
} else {
fabMore.hide();
tvSelectedCount.setVisibility(View.GONE);
}
}
private void loadMessages(final boolean top) {
if (viewType == AdapterMessage.ViewType.THREAD && onclose != null) {
ViewModelMessages model = new ViewModelProvider(getActivity()).get(ViewModelMessages.class);

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?attr/colorPrimary" />
<corners android:radius="6dp" />
</shape>

View File

@ -340,6 +340,20 @@
app:backgroundTint="?attr/colorFabBackground"
app:srcCompat="@drawable/baseline_more_vert_24" />
<TextView
android:id="@+id/tvSelectedCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selected_count_background"
android:elevation="7dp"
android:paddingHorizontal="6dp"
android:paddingVertical="3dp"
android:text="3"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/action_foreground"
app:layout_anchor="@id/fabMore"
app:layout_anchorGravity="center_horizontal|bottom" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabSearch"
android:layout_width="wrap_content"