Added reply fab

pull/161/head
M66B 5 years ago
parent 5432a9ff8c
commit 9cc05ea6ee

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

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

Loading…
Cancel
Save