Fixed warnings

pull/146/head
M66B 7 years ago
parent 70b5c51db9
commit d73544c584

@ -1223,7 +1223,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<EntityFolder>() { new SimpleTask<EntityFolder>() {
@Override @Override
protected EntityFolder onLoad(Context context, Bundle args) throws Throwable { protected EntityFolder onLoad(Context context, Bundle args) {
EntityMessage message = (EntityMessage) args.getSerializable("message"); EntityMessage message = (EntityMessage) args.getSerializable("message");
return DB.getInstance(context).folder().getFolder(message.folder); return DB.getInstance(context).folder().getFolder(message.folder);
} }
@ -1265,7 +1265,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Void>() { new SimpleTask<Void>() {
@Override @Override
protected Void onLoad(Context context, Bundle args) throws Throwable { protected Void onLoad(Context context, Bundle args) {
EntityMessage message = (EntityMessage) args.getSerializable("message"); EntityMessage message = (EntityMessage) args.getSerializable("message");
String[] keywords = args.getStringArray("keywords"); String[] keywords = args.getStringArray("keywords");
boolean[] selected = args.getBooleanArray("selected"); boolean[] selected = args.getBooleanArray("selected");
@ -1312,7 +1312,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Void>() { new SimpleTask<Void>() {
@Override @Override
protected Void onLoad(Context context, Bundle args) throws Throwable { protected Void onLoad(Context context, Bundle args) {
EntityMessage message = (EntityMessage) args.getSerializable("message"); EntityMessage message = (EntityMessage) args.getSerializable("message");
String keyword = args.getString("keyword"); String keyword = args.getString("keyword");

@ -153,7 +153,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
new SimpleTask<Void>() { new SimpleTask<Void>() {
@Override @Override
protected Void onLoad(Context context, Bundle args) throws Throwable { protected Void onLoad(Context context, Bundle args) {
DB.getInstance(context).operation().deleteOperation(args.getLong("id")); DB.getInstance(context).operation().deleteOperation(args.getLong("id"));
return null; return null;
} }

@ -96,7 +96,7 @@ public abstract class DB extends RoomDatabase {
return sInstance; return sInstance;
} }
static String exec(DB db, String command) { private static String exec(DB db, String command) {
Cursor cursor = null; Cursor cursor = null;
try { try {
cursor = db.query(command, new Object[0]); cursor = db.query(command, new Object[0]);
@ -309,26 +309,25 @@ public abstract class DB extends RoomDatabase {
if (addresses == null) if (addresses == null)
return null; return null;
JSONArray jaddresses = new JSONArray(); JSONArray jaddresses = new JSONArray();
if (addresses != null) for (Address address : addresses)
for (Address address : addresses) try {
try { if (address instanceof InternetAddress) {
if (address instanceof InternetAddress) { String a = ((InternetAddress) address).getAddress();
String a = ((InternetAddress) address).getAddress(); String p = ((InternetAddress) address).getPersonal();
String p = ((InternetAddress) address).getPersonal(); JSONObject jaddress = new JSONObject();
JSONObject jaddress = new JSONObject(); if (a != null)
if (a != null) jaddress.put("address", a);
jaddress.put("address", a); if (p != null)
if (p != null) jaddress.put("personal", p);
jaddress.put("personal", p); jaddresses.put(jaddress);
jaddresses.put(jaddress); } else {
} else { JSONObject jaddress = new JSONObject();
JSONObject jaddress = new JSONObject(); jaddress.put("address", address.toString());
jaddress.put("address", address.toString()); jaddresses.put(jaddress);
jaddresses.put(jaddress);
}
} catch (JSONException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
} }
} catch (JSONException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
return jaddresses.toString(); return jaddresses.toString();
} }

@ -59,10 +59,6 @@ public interface DaoAttachment {
" AND cid = :cid") " AND cid = :cid")
EntityAttachment getAttachment(long message, String cid); EntityAttachment getAttachment(long message, String cid);
@Query("SELECT * FROM attachment" +
" WHERE id = :id")
EntityAttachment getAttachment(long id);
@Query("UPDATE attachment" + @Query("UPDATE attachment" +
" SET progress = :progress" + " SET progress = :progress" +
" WHERE id = :id") " WHERE id = :id")

@ -180,7 +180,4 @@ public interface DaoFolder {
@Query("DELETE FROM folder WHERE id = :id") @Query("DELETE FROM folder WHERE id = :id")
void deleteFolder(long id); void deleteFolder(long id);
@Query("DELETE FROM folder WHERE account= :account AND name = :name")
void deleteFolder(long account, String name);
} }

@ -142,7 +142,7 @@ public class EntityMessage implements Serializable {
public Long last_attempt; // send public Long last_attempt; // send
static String generateMessageId() { static String generateMessageId() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append('<') sb.append('<')
.append(Math.abs(new Random().nextInt())).append('.') .append(Math.abs(new Random().nextInt())).append('.')
.append(System.currentTimeMillis()).append('.') .append(System.currentTimeMillis()).append('.')

@ -60,18 +60,18 @@ public class EntityOperation {
public Long created; public Long created;
public String error; public String error;
public static final String ADD = "add"; static final String ADD = "add";
public static final String MOVE = "move"; static final String MOVE = "move";
public static final String DELETE = "delete"; static final String DELETE = "delete";
public static final String SEND = "send"; static final String SEND = "send";
public static final String SEEN = "seen"; static final String SEEN = "seen";
public static final String ANSWERED = "answered"; static final String ANSWERED = "answered";
public static final String FLAG = "flag"; static final String FLAG = "flag";
public static final String KEYWORD = "keyword"; static final String KEYWORD = "keyword";
public static final String HEADERS = "headers"; static final String HEADERS = "headers";
public static final String BODY = "body"; static final String BODY = "body";
public static final String ATTACHMENT = "attachment"; static final String ATTACHMENT = "attachment";
public static final String SYNC = "sync"; static final String SYNC = "sync";
static void queue(DB db, EntityMessage message, String name) { static void queue(DB db, EntityMessage message, String name) {
JSONArray jargs = new JSONArray(); JSONArray jargs = new JSONArray();

@ -1452,7 +1452,7 @@ public class FragmentCompose extends FragmentEx {
// Select account // Select account
for (int pos = 0; pos < accounts.size(); pos++) for (int pos = 0; pos < accounts.size(); pos++)
if (accounts.get(pos).id == result.draft.account) { if (accounts.get(pos).id.equals(result.draft.account)) {
spAccount.setSelection(pos); spAccount.setSelection(pos);
break; break;
} }

@ -33,8 +33,6 @@ public class FragmentLegend extends FragmentEx {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
setSubtitle(R.string.menu_legend); setSubtitle(R.string.menu_legend);
View view = inflater.inflate(R.layout.fragment_legend, container, false); return inflater.inflate(R.layout.fragment_legend, container, false);
return view;
} }
} }

@ -58,6 +58,7 @@ import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
@ -673,8 +674,10 @@ public class FragmentSetup extends FragmentEx {
byte[] salt = new byte[16]; byte[] salt = new byte[16];
byte[] prefix = new byte[16]; byte[] prefix = new byte[16];
raw.read(salt); if (raw.read(salt) != salt.length)
raw.read(prefix); throw new IOException("length");
if (raw.read(prefix) != prefix.length)
throw new IOException("length");
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, KEY_ITERATIONS, KEY_LENGTH); KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, KEY_ITERATIONS, KEY_LENGTH);

@ -48,6 +48,7 @@ import org.jsoup.nodes.Element;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -148,7 +149,8 @@ public class FragmentWebView extends FragmentEx {
fis = new FileInputStream(file); fis = new FileInputStream(file);
byte[] bytes = new byte[(int) file.length()]; byte[] bytes = new byte[(int) file.length()];
fis.read(bytes); if (fis.read(bytes) != bytes.length)
throw new IOException("length");
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("data:"); sb.append("data:");

@ -272,7 +272,7 @@ public class Helper {
} }
static String canonicalAddress(String address) { static String canonicalAddress(String address) {
String[] a = address.split("\\@"); String[] a = address.split("@");
if (a.length > 0) if (a.length > 0)
a[0] = a[0].split("\\+")[0]; a[0] = a[0].split("\\+")[0];
return TextUtils.join("@", a); return TextUtils.join("@", a);

@ -34,7 +34,7 @@ import java.util.regex.Pattern;
public class HtmlHelper { public class HtmlHelper {
private static Pattern pattern = Pattern.compile("([http|https]+://[\\w\\S(\\.|:|/)]+)"); private static Pattern pattern = Pattern.compile("([http|https]+://[\\w\\S(\\.|:|/)]+)");
public static String sanitize(String html) { static String sanitize(String html) {
Document document = Jsoup.parse(Jsoup.clean(html, Whitelist.relaxed().addProtocols("img", "src", "cid"))); Document document = Jsoup.parse(Jsoup.clean(html, Whitelist.relaxed().addProtocols("img", "src", "cid")));
for (Element tr : document.select("tr")) for (Element tr : document.select("tr"))

@ -28,7 +28,7 @@ import javax.mail.internet.MimeMessage;
public class MimeMessageEx extends MimeMessage { public class MimeMessageEx extends MimeMessage {
private String msgid; private String msgid;
public MimeMessageEx(Session session, String msgid) { MimeMessageEx(Session session, String msgid) {
super(session); super(session);
this.msgid = msgid; this.msgid = msgid;
} }

@ -118,8 +118,6 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
this.stored = null; this.stored = null;
owner.getLifecycle().addObserver(this); owner.getLifecycle().addObserver(this);
onInit(args);
// Run in background thread // Run in background thread
executor.submit(new Runnable() { executor.submit(new Runnable() {
@Override @Override
@ -164,9 +162,6 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
} }
} }
protected void onInit(Bundle args) {
}
protected T onLoad(Context context, Bundle args) throws Throwable { protected T onLoad(Context context, Bundle args) throws Throwable {
// Be careful not to access members in outer scopes // Be careful not to access members in outer scopes
return null; return null;

Loading…
Cancel
Save