mirror of https://github.com/M66B/FairEmail.git
Added error FABs
This commit is contained in:
parent
611d32bb2d
commit
3b1cfbb743
|
@ -66,6 +66,7 @@ public class FragmentFolders extends FragmentBase {
|
|||
private Group grpHintSync;
|
||||
private Group grpReady;
|
||||
private FloatingActionButton fab;
|
||||
private FloatingActionButton fabError;
|
||||
|
||||
private long account;
|
||||
private boolean show_hidden = false;
|
||||
|
@ -100,6 +101,7 @@ public class FragmentFolders extends FragmentBase {
|
|||
grpHintSync = view.findViewById(R.id.grpHintSync);
|
||||
grpReady = view.findViewById(R.id.grpReady);
|
||||
fab = view.findViewById(R.id.fab);
|
||||
fabError = view.findViewById(R.id.fabError);
|
||||
|
||||
// Wire controls
|
||||
|
||||
|
@ -181,6 +183,15 @@ public class FragmentFolders extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
fabError.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.content_frame, new FragmentAccounts()).addToBackStack("accounts");
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
});
|
||||
|
||||
if (account < 0)
|
||||
fab.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
|
@ -214,6 +225,7 @@ public class FragmentFolders extends FragmentBase {
|
|||
grpReady.setVisibility(View.GONE);
|
||||
pbWait.setVisibility(View.VISIBLE);
|
||||
fab.hide();
|
||||
fabError.hide();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -276,6 +288,12 @@ public class FragmentFolders extends FragmentBase {
|
|||
@Override
|
||||
public void onChanged(@Nullable EntityAccount account) {
|
||||
setSubtitle(account == null ? null : account.name);
|
||||
|
||||
if (account != null && account.error != null)
|
||||
fabError.show();
|
||||
else
|
||||
fabError.hide();
|
||||
|
||||
if (account == null)
|
||||
fab.hide();
|
||||
else
|
||||
|
|
|
@ -124,6 +124,7 @@ public class FragmentMessages extends FragmentBase {
|
|||
private Group grpReady;
|
||||
private FloatingActionButton fab;
|
||||
private FloatingActionButton fabMore;
|
||||
private FloatingActionButton fabError;
|
||||
|
||||
private long account;
|
||||
private long folder;
|
||||
|
@ -271,6 +272,7 @@ public class FragmentMessages extends FragmentBase {
|
|||
grpReady = view.findViewById(R.id.grpReady);
|
||||
fab = view.findViewById(R.id.fab);
|
||||
fabMore = view.findViewById(R.id.fabMore);
|
||||
fabError = view.findViewById(R.id.fabError);
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
|
@ -516,6 +518,13 @@ public class FragmentMessages extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
fabError.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onMenuFolders(account);
|
||||
}
|
||||
});
|
||||
|
||||
addBackPressedListener(onBackPressedListener);
|
||||
|
||||
// Initialize
|
||||
|
@ -531,6 +540,7 @@ public class FragmentMessages extends FragmentBase {
|
|||
|
||||
fab.hide();
|
||||
fabMore.hide();
|
||||
fabError.hide();
|
||||
|
||||
if (viewType == AdapterMessage.ViewType.THREAD) {
|
||||
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
|
||||
|
@ -2195,6 +2205,11 @@ public class FragmentMessages extends FragmentBase {
|
|||
else
|
||||
setSubtitle(getString(R.string.title_name_count, name, nf.format(unseen)));
|
||||
|
||||
if (errors)
|
||||
fabError.show();
|
||||
else
|
||||
fabError.hide();
|
||||
|
||||
// Auto scroll
|
||||
if (lastUnseen == null || lastUnseen != unseen) {
|
||||
if ((!refreshing && manual) ||
|
||||
|
@ -2204,13 +2219,6 @@ public class FragmentMessages extends FragmentBase {
|
|||
lastUnseen = unseen;
|
||||
}
|
||||
|
||||
// Show errors
|
||||
if (errors && !refreshing && swipeRefresh.isRefreshing())
|
||||
if (folders.size() == 1)
|
||||
Snackbar.make(view, folders.get(0).error, Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
Snackbar.make(view, R.string.title_sync_errors, Snackbar.LENGTH_LONG).show();
|
||||
|
||||
refresh = sync;
|
||||
swipeRefresh.setEnabled(pull && refresh);
|
||||
swipeRefresh.setRefreshing(refreshing);
|
||||
|
|
|
@ -137,4 +137,15 @@
|
|||
android:tint="@color/colorActionForeground"
|
||||
android:tooltipText="@string/title_add"
|
||||
app:backgroundTint="?attr/colorAccent" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fabError"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/fab_padding"
|
||||
android:src="@drawable/baseline_warning_24"
|
||||
android:tint="@color/colorActionForeground"
|
||||
android:tooltipText="@string/title_compose"
|
||||
app:backgroundTint="@color/lightColorWarning" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
@ -238,4 +238,15 @@
|
|||
android:tint="@color/colorActionForeground"
|
||||
android:tooltipText="@string/title_compose"
|
||||
app:backgroundTint="?attr/colorAccent" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fabError"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/fab_padding"
|
||||
android:src="@drawable/baseline_warning_24"
|
||||
android:tint="@color/colorActionForeground"
|
||||
android:tooltipText="@string/title_compose"
|
||||
app:backgroundTint="@color/lightColorWarning" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
@ -294,7 +294,6 @@
|
|||
<string name="title_no_idle">This provider does not support push messages. This will delay reception of new messages and increase battery usage.</string>
|
||||
<string name="title_no_utf8">This provider does not support UTF-8</string>
|
||||
<string name="title_no_sync">Synchronization errors since %1$s</string>
|
||||
<string name="title_sync_errors">Synchronizing some folders failed</string>
|
||||
<string name="title_identity_required">An identity is required to send messages</string>
|
||||
<string name="title_drafts_required">A drafts folder is required to send messages</string>
|
||||
<string name="title_account_delete">Delete this account permanently?</string>
|
||||
|
|
Loading…
Reference in New Issue