Added reply fab

This commit is contained in:
M66B 2019-08-16 15:25:06 +02:00
parent 5432a9ff8c
commit 9cc05ea6ee
2 changed files with 78 additions and 30 deletions

View File

@ -173,7 +173,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private Group grpHintSwipe;
private Group grpHintSelect;
private Group grpReady;
private FloatingActionButton fab;
private FloatingActionButton fabReply;
private FloatingActionButton fabCompose;
private FloatingActionButton fabMore;
private FloatingActionButton fabSearch;
private FloatingActionButton fabError;
@ -353,9 +354,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
grpHintSwipe = view.findViewById(R.id.grpHintSwipe);
grpHintSelect = view.findViewById(R.id.grpHintSelect);
grpReady = view.findViewById(R.id.grpReady);
fab = view.findViewById(R.id.fab);
fabSearch = view.findViewById(R.id.fabSearch);
fabReply = view.findViewById(R.id.fabReply);
fabCompose = view.findViewById(R.id.fabCompose);
fabMore = view.findViewById(R.id.fabMore);
fabSearch = view.findViewById(R.id.fabSearch);
fabError = view.findViewById(R.id.fabError);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
@ -693,7 +696,20 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
});
fab.setOnClickListener(new View.OnClickListener() {
fabReply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (values.containsKey("expanded") && values.get("expanded").size() > 0) {
long id = values.get("expanded").get(0);
Intent reply = new Intent(getContext(), ActivityCompose.class)
.putExtra("action", "reply")
.putExtra("reference", id);
startActivity(reply);
}
}
});
fabCompose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getContext(), ActivityCompose.class)
@ -703,7 +719,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
});
fab.setOnLongClickListener(new View.OnLongClickListener() {
fabCompose.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Bundle args = new Bundle();
@ -740,6 +756,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
});
fabMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onMore();
}
});
fabSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -801,13 +824,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
});
fabMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onMore();
}
});
fabError.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -828,11 +844,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ibUp.setVisibility(View.GONE);
bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(false);
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(false);
bottom_navigation.setVisibility(View.GONE);
bottom_navigation.setVisibility(actionbar ? View.INVISIBLE : View.GONE);
grpReady.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
fab.hide();
fabReply.hide();
fabCompose.hide();
if (viewType == AdapterMessage.ViewType.SEARCH && !server)
fabSearch.show();
else
@ -2213,9 +2230,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override
public void onChanged(List<TupleIdentityEx> identities) {
if (identities == null || identities.size() == 0)
fab.hide();
fabCompose.hide();
else
fab.show();
fabCompose.show();
}
});
}
@ -2782,6 +2799,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Log.i("Submit messages=" + messages.size());
adapter.submitList(messages);
updateExpanded();
// This is to workaround not drawing when the search is expanded
new Handler().post(new Runnable() {
@Override
@ -2984,9 +3003,21 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void updateExpanded() {
boolean expanded = (values.containsKey("expanded") && values.get("expanded").size() > 0);
ibDown.setVisibility(expanded ? View.VISIBLE : View.GONE);
ibUp.setVisibility(expanded ? View.VISIBLE : View.GONE);
int expanded = (values.containsKey("expanded") ? values.get("expanded").size() : 0);
if (expanded == 1) {
long id = values.get("expanded").get(0);
int pos = adapter.getPositionForKey(id);
TupleMessageEx message = adapter.getItemAtPosition(pos);
if (message != null && message.content && !EntityFolder.OUTBOX.equals(message.folderType))
fabReply.show();
else
fabReply.hide();
} else
fabReply.hide();
ibDown.setVisibility(expanded > 0 ? View.VISIBLE : View.GONE);
ibUp.setVisibility(expanded > 0 ? View.VISIBLE : View.GONE);
}
private void handleExpand(long id) {

View File

@ -179,13 +179,16 @@
app:layout_constraintStart_toStartOf="@id/rvMessage"
app:layout_constraintTop_toTopOf="@id/rvMessage" />
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabReply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_padding"
android:src="@drawable/baseline_reply_24"
android:tint="@color/colorActionForeground"
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent" />
<ImageButton
android:id="@+id/ibDown"
@ -194,8 +197,11 @@
android:background="?attr/selectableItemBackground"
android:padding="12dp"
android:src="@drawable/baseline_vertical_align_bottom_24"
app:layout_constraintBottom_toTopOf="@id/seekBar"
app:layout_constraintEnd_toStartOf="@id/ibUp" />
android:tint="?attr/colorSeparator"
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toStartOf="@+id/ibUp"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent" />
<ImageButton
android:id="@+id/ibUp"
@ -204,8 +210,19 @@
android:background="?attr/selectableItemBackground"
android:padding="12dp"
android:src="@drawable/baseline_vertical_align_top_24"
app:layout_constraintBottom_toTopOf="@id/seekBar"
app:layout_constraintEnd_toEndOf="parent" />
android:tint="?attr/colorSeparator"
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/ibDown" />
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
@ -276,7 +293,7 @@
app:backgroundTint="?attr/colorAccent" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:id="@+id/fabCompose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"