Small improvements

pull/146/head
M66B 6 years ago
parent 439a1cc627
commit a9450edc3f

@ -17,9 +17,9 @@ android {
} }
} }
//lintOptions { lintOptions {
// disable 'MissingTranslation' disable 'MissingTranslation'
//} }
buildTypes { buildTypes {
release { release {

@ -66,27 +66,6 @@ public class EntityAccount {
public String state; public String state;
public String error; public String error;
@Override
public boolean equals(Object obj) {
if (obj instanceof EntityAccount) {
EntityAccount other = (EntityAccount) obj;
return ((this.name == null ? other.name == null : this.name.equals(other.name)) &&
(this.signature == null ? other.signature == null : this.signature.equals(other.signature)) &&
this.host.equals(other.host) &&
this.port.equals(other.port) &&
this.user.equals(other.user) &&
this.password.equals(other.password) &&
this.auth_type.equals(other.auth_type) &&
this.synchronize.equals(other.synchronize) &&
this.primary.equals(other.primary) &&
(this.color == null ? other.color == null : this.color.equals(other.color)) &&
this.poll_interval.equals(other.poll_interval) &&
(this.state == null ? other.state == null : this.state.equals(other.state)) &&
(this.error == null ? other.error == null : this.error.equals(other.error)));
} else
return false;
}
public JSONObject toJSON() throws JSONException { public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("name", name); json.put("name", name);
@ -103,6 +82,9 @@ public class EntityAccount {
if (color != null) if (color != null)
json.put("color", color); json.put("color", color);
json.put("poll_interval", poll_interval); json.put("poll_interval", poll_interval);
// not created
// not state
// not error
return json; return json;
} }
@ -127,6 +109,30 @@ public class EntityAccount {
return account; return account;
} }
@Override
public boolean equals(Object obj) {
if (obj instanceof EntityAccount) {
EntityAccount other = (EntityAccount) obj;
return ((this.name == null ? other.name == null : this.name.equals(other.name)) &&
(this.signature == null ? other.signature == null : this.signature.equals(other.signature)) &&
this.host.equals(other.host) &&
this.starttls == other.starttls &&
this.insecure == other.insecure &&
this.port.equals(other.port) &&
this.user.equals(other.user) &&
this.password.equals(other.password) &&
this.auth_type.equals(other.auth_type) &&
this.synchronize.equals(other.synchronize) &&
this.primary.equals(other.primary) &&
(this.color == null ? other.color == null : this.color.equals(other.color)) &&
this.poll_interval.equals(other.poll_interval) &&
(this.created == null ? other.created == null : this.created.equals(other.created)) &&
(this.state == null ? other.state == null : this.state.equals(other.state)) &&
(this.error == null ? other.error == null : this.error.equals(other.error)));
} else
return false;
}
@Override @Override
public String toString() { public String toString() {
return name + (primary ? " ★" : ""); return name + (primary ? " ★" : "");

@ -79,16 +79,19 @@ public class EntityIdentity {
json.put("name", name); json.put("name", name);
json.put("email", email); json.put("email", email);
json.put("replyto", replyto); json.put("replyto", replyto);
// not account
json.put("host", host); json.put("host", host);
json.put("port", port);
json.put("starttls", starttls); json.put("starttls", starttls);
json.put("insecure", insecure); json.put("insecure", insecure);
json.put("port", port);
json.put("user", user); json.put("user", user);
json.put("password", ""); json.put("password", "");
json.put("auth_type", auth_type); json.put("auth_type", auth_type);
json.put("primary", primary); json.put("primary", primary);
json.put("synchronize", false); json.put("synchronize", false);
json.put("store_sent", store_sent); json.put("store_sent", store_sent);
// not state
// not error
return json; return json;
} }
@ -99,9 +102,9 @@ public class EntityIdentity {
if (json.has("replyto")) if (json.has("replyto"))
identity.replyto = json.getString("replyto"); identity.replyto = json.getString("replyto");
identity.host = json.getString("host"); identity.host = json.getString("host");
identity.port = json.getInt("port");
identity.starttls = json.getBoolean("starttls"); identity.starttls = json.getBoolean("starttls");
identity.insecure = (json.has("insecure") && json.getBoolean("insecure")); identity.insecure = (json.has("insecure") && json.getBoolean("insecure"));
identity.port = json.getInt("port");
identity.user = json.getString("user"); identity.user = json.getString("user");
identity.password = json.getString("password"); identity.password = json.getString("password");
identity.auth_type = json.getInt("auth_type"); identity.auth_type = json.getInt("auth_type");
@ -120,8 +123,9 @@ public class EntityIdentity {
(this.replyto == null ? other.replyto == null : this.replyto.equals(other.replyto)) && (this.replyto == null ? other.replyto == null : this.replyto.equals(other.replyto)) &&
this.account.equals(other.account) && this.account.equals(other.account) &&
this.host.equals(other.host) && this.host.equals(other.host) &&
this.port.equals(other.port) &&
this.starttls.equals(other.starttls) && this.starttls.equals(other.starttls) &&
this.insecure.equals(other.insecure) &&
this.port.equals(other.port) &&
this.user.equals(other.user) && this.user.equals(other.user) &&
this.password.equals(other.password) && this.password.equals(other.password) &&
this.primary.equals(other.primary) && this.primary.equals(other.primary) &&

@ -40,7 +40,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
public class FragmentOptions extends FragmentEx { public class FragmentOptions extends FragmentEx implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swEnabled; private SwitchCompat swEnabled;
private SwitchCompat swAvatars; private SwitchCompat swAvatars;
private SwitchCompat swIdenticons; private SwitchCompat swIdenticons;
@ -233,6 +233,20 @@ public class FragmentOptions extends FragmentEx {
swLight.setVisibility(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE); swLight.setVisibility(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE);
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view; return view;
} }
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if ("enabled".equals(key))
swEnabled.setChecked(prefs.getBoolean(key, true));
}
@Override
public void onDestroyView() {
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
super.onDestroyView();
}
} }

@ -60,7 +60,6 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -104,21 +103,6 @@ public class FragmentSetup extends FragmentEx {
Manifest.permission.READ_CONTACTS Manifest.permission.READ_CONTACTS
}; };
static final List<String> EXPORT_SETTINGS = Arrays.asList(
"enabled",
"compact",
"avatars",
"identicons",
"preview",
"light",
"browse",
"swipe",
"navigation",
"sender",
"insecure",
"sort"
);
@Override @Override
@Nullable @Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -582,7 +566,7 @@ public class FragmentSetup extends FragmentEx {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
JSONArray jsettings = new JSONArray(); JSONArray jsettings = new JSONArray();
for (String key : prefs.getAll().keySet()) for (String key : prefs.getAll().keySet())
if (EXPORT_SETTINGS.contains(key)) { if (!"pro".equals(key)) {
JSONObject jsetting = new JSONObject(); JSONObject jsetting = new JSONObject();
jsetting.put("key", key); jsetting.put("key", key);
jsetting.put("value", prefs.getAll().get(key)); jsetting.put("value", prefs.getAll().get(key));
@ -688,10 +672,14 @@ public class FragmentSetup extends FragmentEx {
for (int s = 0; s < jsettings.length(); s++) { for (int s = 0; s < jsettings.length(); s++) {
JSONObject jsetting = (JSONObject) jsettings.get(s); JSONObject jsetting = (JSONObject) jsettings.get(s);
String key = jsetting.getString("key"); String key = jsetting.getString("key");
if (EXPORT_SETTINGS.contains(key)) { if (!"pro".equals(key)) {
Object value = jsetting.get("value"); Object value = jsetting.get("value");
if (value instanceof Boolean) if (value instanceof Boolean)
editor.putBoolean(key, (Boolean) value); editor.putBoolean(key, (Boolean) value);
else if (value instanceof Integer)
editor.putInt(key, (Integer) value);
else if (value instanceof Long)
editor.putLong(key, (Long) value);
else if (value instanceof String) else if (value instanceof String)
editor.putString(key, (String) value); editor.putString(key, (String) value);
else else

Loading…
Cancel
Save