mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 03:19:24 +01:00
Small improvements
This commit is contained in:
@@ -44,6 +44,7 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
@@ -131,22 +132,23 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
|
||||
DB.getInstance(this).account().liveAccounts().observe(this, new Observer<List<EntityAccount>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityAccount> accounts) {
|
||||
if (accounts == null)
|
||||
accounts = new ArrayList<>();
|
||||
|
||||
ArrayAdapterDrawer drawerArray = new ArrayAdapterDrawer(ActivityView.this, R.layout.item_drawer);
|
||||
|
||||
if (accounts != null) {
|
||||
final Collator collator = Collator.getInstance(Locale.getDefault());
|
||||
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
|
||||
final Collator collator = Collator.getInstance(Locale.getDefault());
|
||||
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
|
||||
|
||||
Collections.sort(accounts, new Comparator<EntityAccount>() {
|
||||
@Override
|
||||
public int compare(EntityAccount a1, EntityAccount a2) {
|
||||
return collator.compare(a1.name, a2.name);
|
||||
}
|
||||
});
|
||||
Collections.sort(accounts, new Comparator<EntityAccount>() {
|
||||
@Override
|
||||
public int compare(EntityAccount a1, EntityAccount a2) {
|
||||
return collator.compare(a1.name, a2.name);
|
||||
}
|
||||
});
|
||||
|
||||
for (EntityAccount account : accounts)
|
||||
drawerArray.add(new DrawerItem(-1, R.drawable.baseline_folder_24, account.name, account.id));
|
||||
}
|
||||
for (EntityAccount account : accounts)
|
||||
drawerArray.add(new DrawerItem(-1, R.drawable.baseline_folder_24, account.name, account.id));
|
||||
|
||||
drawerArray.add(new DrawerItem(ActivityView.this, R.drawable.baseline_settings_applications_24, R.string.menu_setup));
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.widget.ProgressBar;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -93,8 +94,10 @@ public class FragmentAccounts extends FragmentEx {
|
||||
DB.getInstance(getContext()).account().liveAccounts().observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityAccount> accounts) {
|
||||
if (accounts != null)
|
||||
adapter.set(accounts);
|
||||
if (accounts == null)
|
||||
accounts = new ArrayList<>();
|
||||
|
||||
adapter.set(accounts);
|
||||
|
||||
pbWait.setVisibility(View.GONE);
|
||||
grpReady.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -703,8 +703,11 @@ public class FragmentCompose extends FragmentEx {
|
||||
new Observer<List<EntityAttachment>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityAttachment> attachments) {
|
||||
adapter.set(attachments == null ? new ArrayList<EntityAttachment>() : attachments);
|
||||
grpAttachments.setVisibility(attachments != null && attachments.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
if (attachments == null)
|
||||
attachments = new ArrayList<>();
|
||||
|
||||
adapter.set(attachments);
|
||||
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.widget.ProgressBar;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -93,8 +94,7 @@ public class FragmentIdentities extends FragmentEx {
|
||||
DB.getInstance(getContext()).identity().liveIdentities().observe(getViewLifecycleOwner(), new Observer<List<TupleIdentityEx>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<TupleIdentityEx> identities) {
|
||||
if (identities != null)
|
||||
adapter.set(identities);
|
||||
adapter.set(identities == null ? new ArrayList<TupleIdentityEx>() : identities);
|
||||
|
||||
pbWait.setVisibility(View.GONE);
|
||||
grpReady.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -41,6 +41,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -389,7 +390,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||
@Override
|
||||
public void onChanged(List<EntityAccount> accounts) {
|
||||
if (accounts == null)
|
||||
return;
|
||||
accounts = new ArrayList<>();
|
||||
|
||||
EntityAccount unselected = new EntityAccount();
|
||||
unselected.id = -1L;
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import java.text.Collator;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
@@ -291,7 +292,10 @@ public class FragmentMessage extends FragmentEx {
|
||||
db.folder().liveFolders(message.account).removeObservers(getViewLifecycleOwner());
|
||||
db.folder().liveFolders(message.account).observe(getViewLifecycleOwner(), new Observer<List<TupleFolderEx>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable final List<TupleFolderEx> folders) {
|
||||
public void onChanged(@Nullable List<TupleFolderEx> folders) {
|
||||
if (folders == null)
|
||||
folders = new ArrayList<>();
|
||||
|
||||
boolean inInbox = EntityFolder.INBOX.equals(message.folderType);
|
||||
boolean inOutbox = EntityFolder.OUTBOX.equals(message.folderType);
|
||||
boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType);
|
||||
@@ -345,9 +349,11 @@ public class FragmentMessage extends FragmentEx {
|
||||
new Observer<List<EntityAttachment>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityAttachment> attachments) {
|
||||
if (attachments != null)
|
||||
adapter.set(attachments);
|
||||
grpAttachments.setVisibility(attachments != null && attachments.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
if (attachments == null)
|
||||
attachments = new ArrayList<>();
|
||||
|
||||
adapter.set(attachments);
|
||||
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -75,8 +76,10 @@ public class FragmentOperations extends FragmentEx {
|
||||
DB.getInstance(getContext()).operation().liveOperations().observe(getViewLifecycleOwner(), new Observer<List<EntityOperation>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityOperation> operations) {
|
||||
if (operations != null)
|
||||
adapter.set(operations);
|
||||
if (operations == null)
|
||||
operations = new ArrayList<>();
|
||||
|
||||
adapter.set(operations);
|
||||
|
||||
pbWait.setVisibility(View.GONE);
|
||||
grpReady.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -141,9 +141,6 @@ public class ServiceSynchronize extends LifecycleService {
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nullable TupleAccountStats stats) {
|
||||
if (stats == null)
|
||||
return;
|
||||
|
||||
NotificationManager nm = getSystemService(NotificationManager.class);
|
||||
nm.notify(NOTIFICATION_SYNCHRONIZE,
|
||||
getNotificationService(stats.accounts, stats.operations, stats.unsent).build());
|
||||
@@ -189,7 +186,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onLoad(Context context, Bundle args) throws Throwable {
|
||||
protected Void onLoad(Context context, Bundle args) {
|
||||
long time = args.getLong("time");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
@@ -352,6 +349,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||
@Override
|
||||
public void notification(StoreEvent e) {
|
||||
Log.i(Helper.TAG, account.name + " event: " + e.getMessage());
|
||||
db.account().setAccountError(account.id, e.getMessage());
|
||||
}
|
||||
});
|
||||
istore.addFolderListener(new FolderAdapter() {
|
||||
@@ -410,7 +408,12 @@ public class ServiceSynchronize extends LifecycleService {
|
||||
|
||||
monitorFolder(account, folder, fstore, ifolder, state);
|
||||
|
||||
} catch (FolderClosedException ex) {
|
||||
// Happens when no connectivity
|
||||
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
||||
|
||||
} catch (IllegalStateException ex) {
|
||||
// Happens when syncing message
|
||||
// This operation is not allowed on a closed folder
|
||||
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user