2018-08-02 13:33:06 +00:00
|
|
|
package eu.faircode.email;
|
|
|
|
|
|
|
|
/*
|
2018-08-14 05:53:24 +00:00
|
|
|
This file is part of FairEmail.
|
2018-08-02 13:33:06 +00:00
|
|
|
|
2018-08-14 05:53:24 +00:00
|
|
|
FairEmail is free software: you can redistribute it and/or modify
|
2018-08-02 13:33:06 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
2018-10-29 10:46:49 +00:00
|
|
|
FairEmail is distributed in the hope that it will be useful,
|
2018-08-02 13:33:06 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2018-10-29 10:46:49 +00:00
|
|
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-02 13:33:06 +00:00
|
|
|
|
2020-01-05 17:32:53 +00:00
|
|
|
Copyright 2018-2020 by Marcel Bokhorst (M66B)
|
2018-08-02 13:33:06 +00:00
|
|
|
*/
|
|
|
|
|
2018-12-10 11:26:50 +00:00
|
|
|
import android.app.Notification;
|
|
|
|
import android.app.NotificationChannel;
|
2019-05-28 14:55:03 +00:00
|
|
|
import android.app.NotificationChannelGroup;
|
2018-12-10 11:26:50 +00:00
|
|
|
import android.app.NotificationManager;
|
|
|
|
import android.content.Context;
|
2019-06-08 07:34:29 +00:00
|
|
|
import android.os.Build;
|
2018-12-10 11:26:50 +00:00
|
|
|
|
2019-04-17 18:21:44 +00:00
|
|
|
import androidx.annotation.NonNull;
|
2019-06-08 07:34:29 +00:00
|
|
|
import androidx.annotation.RequiresApi;
|
2019-11-23 12:48:59 +00:00
|
|
|
import androidx.room.ColumnInfo;
|
2019-04-17 18:21:44 +00:00
|
|
|
import androidx.room.Entity;
|
|
|
|
import androidx.room.PrimaryKey;
|
|
|
|
|
2018-09-14 11:33:22 +00:00
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
2019-01-23 18:52:52 +00:00
|
|
|
import java.io.Serializable;
|
2019-05-06 20:34:18 +00:00
|
|
|
import java.text.Collator;
|
|
|
|
import java.util.Comparator;
|
|
|
|
import java.util.Locale;
|
2019-02-26 10:05:21 +00:00
|
|
|
import java.util.Objects;
|
2019-01-23 18:52:52 +00:00
|
|
|
|
2018-08-02 13:33:06 +00:00
|
|
|
@Entity(
|
|
|
|
tableName = EntityAccount.TABLE_NAME,
|
|
|
|
indices = {
|
|
|
|
}
|
|
|
|
)
|
2019-05-01 05:58:45 +00:00
|
|
|
public class EntityAccount extends EntityOrder implements Serializable {
|
2018-08-02 13:33:06 +00:00
|
|
|
static final String TABLE_NAME = "account";
|
|
|
|
|
2019-07-08 17:23:07 +00:00
|
|
|
// https://tools.ietf.org/html/rfc2177
|
2019-12-28 17:36:15 +00:00
|
|
|
static final int DEFAULT_KEEP_ALIVE_INTERVAL = 15; // minutes
|
|
|
|
static final int DEFAULT_POLL_INTERVAL = 15; // minutes
|
2019-03-14 10:47:19 +00:00
|
|
|
|
2019-11-23 12:48:59 +00:00
|
|
|
static final int TYPE_IMAP = 0;
|
|
|
|
static final int TYPE_POP = 1;
|
|
|
|
|
2018-08-02 13:33:06 +00:00
|
|
|
@PrimaryKey(autoGenerate = true)
|
|
|
|
public Long id;
|
2018-12-26 11:34:05 +00:00
|
|
|
|
2018-08-02 13:33:06 +00:00
|
|
|
@NonNull
|
2019-11-23 12:48:59 +00:00
|
|
|
@ColumnInfo(name = "pop")
|
|
|
|
public Integer protocol = TYPE_IMAP;
|
2019-02-09 21:03:53 +00:00
|
|
|
@NonNull
|
|
|
|
public String host; // POP3/IMAP
|
2018-08-02 13:33:06 +00:00
|
|
|
@NonNull
|
2018-10-23 07:52:20 +00:00
|
|
|
public Boolean starttls;
|
|
|
|
@NonNull
|
2019-09-18 14:34:07 +00:00
|
|
|
public Boolean insecure = false;
|
2018-10-23 07:52:20 +00:00
|
|
|
@NonNull
|
2018-08-02 13:33:06 +00:00
|
|
|
public Integer port;
|
|
|
|
@NonNull
|
2019-12-07 14:14:35 +00:00
|
|
|
public Integer auth_type; // immutable
|
2019-12-21 15:03:57 +00:00
|
|
|
public String provider;
|
2019-09-18 14:34:07 +00:00
|
|
|
@NonNull
|
2018-08-02 13:33:06 +00:00
|
|
|
public String user;
|
|
|
|
@NonNull
|
|
|
|
public String password;
|
2020-02-09 12:58:16 +00:00
|
|
|
@NonNull
|
2020-02-10 16:16:06 +00:00
|
|
|
public Boolean certificate = false; // obsolete
|
2020-02-10 15:35:14 +00:00
|
|
|
public String certificate_alias;
|
2019-01-10 18:24:20 +00:00
|
|
|
public String realm;
|
2019-12-16 18:09:49 +00:00
|
|
|
public String fingerprint;
|
2018-12-26 11:34:05 +00:00
|
|
|
|
|
|
|
public String name;
|
|
|
|
public String signature; // obsolete
|
|
|
|
public Integer color;
|
|
|
|
|
2018-08-27 14:31:45 +00:00
|
|
|
@NonNull
|
2018-08-02 13:33:06 +00:00
|
|
|
public Boolean synchronize;
|
2018-10-07 06:53:09 +00:00
|
|
|
@NonNull
|
2019-12-08 14:00:15 +00:00
|
|
|
public Boolean ondemand = false;
|
2019-02-17 18:29:00 +00:00
|
|
|
@NonNull
|
2020-01-12 17:48:26 +00:00
|
|
|
public Boolean poll_exempted = false;
|
|
|
|
@NonNull
|
2018-10-07 06:53:09 +00:00
|
|
|
public Boolean primary;
|
2018-12-23 18:20:08 +00:00
|
|
|
@NonNull
|
2019-09-18 14:34:07 +00:00
|
|
|
public Boolean notify = false;
|
2018-11-24 08:26:34 +00:00
|
|
|
@NonNull
|
2020-01-21 14:15:48 +00:00
|
|
|
public Boolean browse = true;
|
|
|
|
@NonNull
|
|
|
|
public Boolean leave_on_server = true;
|
|
|
|
@NonNull
|
|
|
|
public Boolean leave_on_device = false;
|
2020-02-26 12:16:09 +00:00
|
|
|
public Integer max_messages; // POP3
|
2019-09-23 13:58:53 +00:00
|
|
|
@NonNull
|
|
|
|
public Boolean auto_seen = true;
|
2019-06-26 06:13:39 +00:00
|
|
|
public Character separator;
|
2019-01-20 15:22:21 +00:00
|
|
|
public Long swipe_left;
|
|
|
|
public Long swipe_right;
|
2019-10-23 10:51:20 +00:00
|
|
|
public Long move_to;
|
2018-12-26 11:34:05 +00:00
|
|
|
@NonNull
|
2019-12-28 19:35:41 +00:00
|
|
|
public Integer poll_interval = DEFAULT_KEEP_ALIVE_INTERVAL;
|
|
|
|
@NonNull
|
|
|
|
public Boolean keep_alive_ok = false;
|
|
|
|
@NonNull
|
|
|
|
public Integer keep_alive_failed = 0;
|
2019-06-14 16:29:17 +00:00
|
|
|
@NonNull
|
|
|
|
public Boolean partial_fetch = true;
|
2019-10-09 12:01:26 +00:00
|
|
|
@NonNull
|
|
|
|
public Boolean ignore_size = false;
|
2019-12-01 13:18:24 +00:00
|
|
|
@NonNull
|
2020-02-06 21:35:36 +00:00
|
|
|
public Boolean use_date = false;
|
2019-05-28 11:42:19 +00:00
|
|
|
public String prefix; // namespace, obsolete
|
2018-12-26 11:34:05 +00:00
|
|
|
|
2020-01-07 16:43:27 +00:00
|
|
|
public Long quota_usage;
|
|
|
|
public Long quota_limit;
|
|
|
|
|
2018-11-06 16:45:52 +00:00
|
|
|
public Long created;
|
2018-12-06 12:43:00 +00:00
|
|
|
public Boolean tbd;
|
2020-03-08 10:08:28 +00:00
|
|
|
public Long thread;
|
2018-08-13 14:44:47 +00:00
|
|
|
public String state;
|
2019-03-27 08:19:11 +00:00
|
|
|
public String warning;
|
2018-08-11 08:28:54 +00:00
|
|
|
public String error;
|
2018-11-19 13:14:02 +00:00
|
|
|
public Long last_connected;
|
2018-08-02 13:33:06 +00:00
|
|
|
|
2019-02-09 21:03:53 +00:00
|
|
|
String getProtocol() {
|
2019-11-23 12:48:59 +00:00
|
|
|
switch (protocol) {
|
|
|
|
case TYPE_IMAP:
|
|
|
|
return "imap" + (starttls ? "" : "s");
|
|
|
|
case TYPE_POP:
|
|
|
|
return "pop3" + (starttls ? "" : "s");
|
|
|
|
default:
|
|
|
|
throw new IllegalArgumentException("Unknown protocol=" + protocol);
|
|
|
|
}
|
2019-02-09 21:03:53 +00:00
|
|
|
}
|
|
|
|
|
2019-05-16 07:08:06 +00:00
|
|
|
static String getNotificationChannelId(long id) {
|
|
|
|
return "notification" + (id == 0 ? "" : "." + id);
|
2018-12-10 11:26:50 +00:00
|
|
|
}
|
|
|
|
|
2019-06-08 07:34:29 +00:00
|
|
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
2018-12-10 11:26:50 +00:00
|
|
|
void createNotificationChannel(Context context) {
|
2019-06-08 07:34:29 +00:00
|
|
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
|
2019-06-08 07:51:00 +00:00
|
|
|
NotificationChannelGroup group = new NotificationChannelGroup("group." + id, name);
|
2019-06-08 07:34:29 +00:00
|
|
|
nm.createNotificationChannelGroup(group);
|
|
|
|
|
|
|
|
NotificationChannel channel = new NotificationChannel(
|
|
|
|
getNotificationChannelId(id), name,
|
|
|
|
NotificationManager.IMPORTANCE_HIGH);
|
2019-06-08 07:51:00 +00:00
|
|
|
channel.setGroup(group.getId());
|
2019-06-08 07:34:29 +00:00
|
|
|
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
|
|
|
channel.enableLights(true);
|
|
|
|
nm.createNotificationChannel(channel);
|
2018-12-10 11:26:50 +00:00
|
|
|
}
|
|
|
|
|
2019-06-08 07:34:29 +00:00
|
|
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
2018-12-10 11:26:50 +00:00
|
|
|
void deleteNotificationChannel(Context context) {
|
2019-06-08 07:34:29 +00:00
|
|
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
nm.deleteNotificationChannel(getNotificationChannelId(id));
|
2018-12-10 11:26:50 +00:00
|
|
|
}
|
|
|
|
|
2019-05-01 05:58:45 +00:00
|
|
|
@Override
|
|
|
|
Long getSortId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2019-05-01 11:08:15 +00:00
|
|
|
@Override
|
|
|
|
String[] getSortTitle(Context context) {
|
|
|
|
return new String[]{name, null};
|
|
|
|
}
|
|
|
|
|
2019-10-19 18:28:10 +00:00
|
|
|
boolean shouldPoll() {
|
2020-01-01 15:26:41 +00:00
|
|
|
return ("imap.gmail.com".equalsIgnoreCase(host) ||
|
|
|
|
"outlook.office365.com".equalsIgnoreCase(host));
|
2019-10-19 18:28:10 +00:00
|
|
|
}
|
|
|
|
|
2018-09-14 11:33:22 +00:00
|
|
|
public JSONObject toJSON() throws JSONException {
|
|
|
|
JSONObject json = new JSONObject();
|
2019-02-07 08:29:39 +00:00
|
|
|
json.put("id", id);
|
2019-06-13 20:08:43 +00:00
|
|
|
json.put("order", order);
|
2019-11-23 12:48:59 +00:00
|
|
|
json.put("protocol", protocol);
|
2018-09-14 11:33:22 +00:00
|
|
|
json.put("host", host);
|
2018-10-24 11:14:56 +00:00
|
|
|
json.put("starttls", starttls);
|
|
|
|
json.put("insecure", insecure);
|
2018-09-14 11:33:22 +00:00
|
|
|
json.put("port", port);
|
2019-09-18 14:34:07 +00:00
|
|
|
json.put("auth_type", auth_type);
|
2020-01-13 07:51:37 +00:00
|
|
|
json.put("provider", provider);
|
2018-09-14 11:33:22 +00:00
|
|
|
json.put("user", user);
|
2019-03-11 14:19:33 +00:00
|
|
|
json.put("password", password);
|
2020-02-10 15:35:14 +00:00
|
|
|
json.put("certificate_alias", certificate_alias);
|
2019-02-17 11:34:29 +00:00
|
|
|
json.put("realm", realm);
|
2020-01-13 07:51:37 +00:00
|
|
|
json.put("fingerprint", fingerprint);
|
2019-02-02 19:49:25 +00:00
|
|
|
|
|
|
|
json.put("name", name);
|
|
|
|
json.put("color", color);
|
|
|
|
|
2018-11-14 19:00:38 +00:00
|
|
|
json.put("synchronize", synchronize);
|
2019-12-10 19:37:12 +00:00
|
|
|
json.put("ondemand", ondemand);
|
2020-01-13 07:51:37 +00:00
|
|
|
json.put("poll_exempted", poll_exempted);
|
2018-10-07 08:08:01 +00:00
|
|
|
json.put("primary", primary);
|
2019-02-02 19:49:25 +00:00
|
|
|
json.put("notify", notify);
|
2018-12-23 18:20:08 +00:00
|
|
|
json.put("browse", browse);
|
2020-01-21 14:15:48 +00:00
|
|
|
json.put("leave_on_server", leave_on_server);
|
|
|
|
json.put("leave_on_device", leave_on_device);
|
2019-09-23 15:39:45 +00:00
|
|
|
json.put("auto_seen", auto_seen);
|
|
|
|
// not separator
|
2019-02-02 19:49:25 +00:00
|
|
|
|
2019-01-20 15:22:21 +00:00
|
|
|
json.put("swipe_left", swipe_left);
|
|
|
|
json.put("swipe_right", swipe_right);
|
2019-02-02 19:49:25 +00:00
|
|
|
|
2019-10-23 13:29:22 +00:00
|
|
|
json.put("move_to", move_to);
|
|
|
|
|
2018-09-14 11:33:22 +00:00
|
|
|
json.put("poll_interval", poll_interval);
|
2019-06-14 16:29:17 +00:00
|
|
|
json.put("partial_fetch", partial_fetch);
|
2019-10-09 12:01:26 +00:00
|
|
|
json.put("ignore_size", ignore_size);
|
2020-01-13 07:51:37 +00:00
|
|
|
json.put("use_date", use_date);
|
2019-09-23 15:39:45 +00:00
|
|
|
// not prefix
|
2018-11-10 10:45:03 +00:00
|
|
|
// not created
|
2019-09-23 15:39:45 +00:00
|
|
|
// not tbd
|
2018-11-10 10:45:03 +00:00
|
|
|
// not state
|
2019-09-23 15:39:45 +00:00
|
|
|
// not warning
|
2018-11-10 10:45:03 +00:00
|
|
|
// not error
|
2018-11-19 13:14:02 +00:00
|
|
|
// not last connected
|
2018-09-14 11:33:22 +00:00
|
|
|
return json;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static EntityAccount fromJSON(JSONObject json) throws JSONException {
|
|
|
|
EntityAccount account = new EntityAccount();
|
2019-07-29 18:05:23 +00:00
|
|
|
if (json.has("id"))
|
|
|
|
account.id = json.getLong("id");
|
2019-06-13 20:08:43 +00:00
|
|
|
|
|
|
|
if (json.has("order"))
|
|
|
|
account.order = json.getInt("order");
|
|
|
|
|
2019-11-23 12:48:59 +00:00
|
|
|
if (json.has("protocol"))
|
|
|
|
account.protocol = json.getInt("protocol");
|
|
|
|
else if (json.has("pop"))
|
|
|
|
account.protocol = (json.getBoolean("pop") ? TYPE_POP : TYPE_IMAP);
|
2019-09-19 15:41:26 +00:00
|
|
|
|
2018-09-14 11:33:22 +00:00
|
|
|
account.host = json.getString("host");
|
2018-10-24 11:14:56 +00:00
|
|
|
account.starttls = (json.has("starttls") && json.getBoolean("starttls"));
|
|
|
|
account.insecure = (json.has("insecure") && json.getBoolean("insecure"));
|
2018-09-14 11:33:22 +00:00
|
|
|
account.port = json.getInt("port");
|
2019-09-18 14:34:07 +00:00
|
|
|
account.auth_type = json.getInt("auth_type");
|
2020-01-13 07:51:37 +00:00
|
|
|
if (json.has("provider"))
|
|
|
|
account.provider = json.getString("provider");
|
2018-09-14 11:33:22 +00:00
|
|
|
account.user = json.getString("user");
|
2019-03-11 14:19:33 +00:00
|
|
|
account.password = json.getString("password");
|
2020-02-11 07:10:01 +00:00
|
|
|
if (json.has("certificate_alias"))
|
|
|
|
account.certificate_alias = json.getString("certificate_alias");
|
2019-02-02 19:49:25 +00:00
|
|
|
if (json.has("realm"))
|
|
|
|
account.realm = json.getString("realm");
|
2020-01-13 07:51:37 +00:00
|
|
|
if (json.has("fingerprint"))
|
|
|
|
account.fingerprint = json.getString("fingerprint");
|
2019-02-02 19:49:25 +00:00
|
|
|
|
2019-03-14 17:52:15 +00:00
|
|
|
if (json.has("name") && !json.isNull("name"))
|
2019-02-02 19:49:25 +00:00
|
|
|
account.name = json.getString("name");
|
|
|
|
if (json.has("color"))
|
|
|
|
account.color = json.getInt("color");
|
|
|
|
|
2018-09-14 11:33:22 +00:00
|
|
|
account.synchronize = json.getBoolean("synchronize");
|
2019-12-10 19:37:12 +00:00
|
|
|
if (json.has("ondemand"))
|
|
|
|
account.ondemand = json.getBoolean("ondemand");
|
2020-01-13 07:51:37 +00:00
|
|
|
if (json.has("poll_exempted"))
|
|
|
|
account.poll_exempted = json.getBoolean("poll_exempted");
|
2018-10-07 08:08:01 +00:00
|
|
|
account.primary = json.getBoolean("primary");
|
2019-02-02 19:49:25 +00:00
|
|
|
if (json.has("notify"))
|
|
|
|
account.notify = json.getBoolean("notify");
|
2018-12-23 18:20:08 +00:00
|
|
|
if (json.has("browse"))
|
|
|
|
account.browse = json.getBoolean("browse");
|
2020-01-21 14:15:48 +00:00
|
|
|
if (json.has("leave_on_server"))
|
|
|
|
account.leave_on_server = json.getBoolean("leave_on_server");
|
|
|
|
if (json.has("leave_on_device"))
|
|
|
|
account.leave_on_device = json.getBoolean("leave_on_device");
|
2019-09-23 15:39:45 +00:00
|
|
|
if (json.has("auto_seen"))
|
|
|
|
account.auto_seen = json.getBoolean("auto_seen");
|
2019-01-20 15:22:21 +00:00
|
|
|
|
|
|
|
if (json.has("swipe_left"))
|
|
|
|
account.swipe_left = json.getLong("swipe_left");
|
|
|
|
if (json.has("swipe_right"))
|
|
|
|
account.swipe_right = json.getLong("swipe_right");
|
|
|
|
|
2019-10-23 13:29:22 +00:00
|
|
|
if (json.has("move_to"))
|
|
|
|
account.move_to = json.getLong("move_to");
|
|
|
|
|
2018-09-14 11:33:22 +00:00
|
|
|
account.poll_interval = json.getInt("poll_interval");
|
2019-02-02 19:49:25 +00:00
|
|
|
|
2019-10-09 12:01:26 +00:00
|
|
|
account.partial_fetch = json.optBoolean("partial_fetch", true);
|
|
|
|
account.ignore_size = json.optBoolean("ignore_size", false);
|
2020-01-13 07:51:37 +00:00
|
|
|
account.use_date = json.optBoolean("use_date", false);
|
2019-06-14 16:29:17 +00:00
|
|
|
|
2018-09-14 11:33:22 +00:00
|
|
|
return account;
|
|
|
|
}
|
|
|
|
|
2018-11-10 10:45:03 +00:00
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (obj instanceof EntityAccount) {
|
|
|
|
EntityAccount other = (EntityAccount) obj;
|
2019-09-23 15:39:45 +00:00
|
|
|
return (Objects.equals(this.order, other.order) &&
|
2019-11-23 12:48:59 +00:00
|
|
|
this.protocol.equals(other.protocol) &&
|
2019-09-23 15:39:45 +00:00
|
|
|
this.host.equals(other.host) &&
|
2018-11-10 10:45:03 +00:00
|
|
|
this.starttls == other.starttls &&
|
|
|
|
this.insecure == other.insecure &&
|
|
|
|
this.port.equals(other.port) &&
|
2019-09-18 14:34:07 +00:00
|
|
|
this.auth_type.equals(other.auth_type) &&
|
2018-11-10 10:45:03 +00:00
|
|
|
this.user.equals(other.user) &&
|
2019-03-11 14:19:33 +00:00
|
|
|
this.password.equals(other.password) &&
|
2019-02-26 10:05:21 +00:00
|
|
|
Objects.equals(this.realm, other.realm) &&
|
|
|
|
Objects.equals(this.name, other.name) &&
|
|
|
|
Objects.equals(this.color, other.color) &&
|
2018-11-10 10:45:03 +00:00
|
|
|
this.synchronize.equals(other.synchronize) &&
|
|
|
|
this.primary.equals(other.primary) &&
|
2018-11-24 08:26:34 +00:00
|
|
|
this.notify.equals(other.notify) &&
|
2019-01-23 09:16:33 +00:00
|
|
|
this.browse.equals(other.browse) &&
|
2020-01-21 14:15:48 +00:00
|
|
|
this.leave_on_server.equals(other.leave_on_server) &&
|
|
|
|
this.leave_on_device.equals(other.leave_on_device) &&
|
2019-09-23 15:39:45 +00:00
|
|
|
this.auto_seen.equals(other.auto_seen) &&
|
2019-02-26 10:05:21 +00:00
|
|
|
Objects.equals(this.swipe_left, other.swipe_left) &&
|
|
|
|
Objects.equals(this.swipe_right, other.swipe_right) &&
|
2018-11-10 10:45:03 +00:00
|
|
|
this.poll_interval.equals(other.poll_interval) &&
|
2019-06-14 16:29:17 +00:00
|
|
|
this.partial_fetch == other.partial_fetch &&
|
2019-10-09 12:01:26 +00:00
|
|
|
this.ignore_size == other.ignore_size &&
|
2020-01-07 16:43:27 +00:00
|
|
|
Objects.equals(this.quota_usage, other.quota_usage) &&
|
|
|
|
Objects.equals(this.quota_limit, other.quota_limit) &&
|
2019-02-26 10:05:21 +00:00
|
|
|
Objects.equals(this.created, other.created) &&
|
|
|
|
Objects.equals(this.tbd, other.tbd) &&
|
|
|
|
Objects.equals(this.state, other.state) &&
|
2019-03-27 08:19:11 +00:00
|
|
|
Objects.equals(this.warning, other.warning) &&
|
2019-02-26 10:05:21 +00:00
|
|
|
Objects.equals(this.error, other.error) &&
|
|
|
|
Objects.equals(this.last_connected, other.last_connected));
|
2018-11-10 10:45:03 +00:00
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2018-12-28 07:40:27 +00:00
|
|
|
|
2019-05-06 20:34:18 +00:00
|
|
|
@Override
|
|
|
|
Comparator getComparator(final Context context) {
|
|
|
|
final Collator collator = Collator.getInstance(Locale.getDefault());
|
|
|
|
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
|
|
|
|
|
|
|
|
return new Comparator() {
|
|
|
|
@Override
|
|
|
|
public int compare(Object o1, Object o2) {
|
|
|
|
EntityAccount a1 = (EntityAccount) o1;
|
|
|
|
EntityAccount a2 = (EntityAccount) o2;
|
|
|
|
|
|
|
|
int o = Integer.compare(
|
|
|
|
a1.order == null ? -1 : a1.order,
|
|
|
|
a2.order == null ? -1 : a2.order);
|
|
|
|
if (o != 0)
|
|
|
|
return o;
|
|
|
|
|
|
|
|
String name1 = (a1.name == null ? "" : a1.name);
|
|
|
|
String name2 = (a2.name == null ? "" : a2.name);
|
|
|
|
return collator.compare(name1, name2);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-12-28 07:40:27 +00:00
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return name + (primary ? " ★" : "");
|
|
|
|
}
|
2018-08-02 13:33:06 +00:00
|
|
|
}
|