|
|
|
@ -73,18 +73,14 @@ import com.google.android.material.bottomnavigation.BottomNavigationView;
|
|
|
|
|
import com.sun.mail.iap.ConnectionException;
|
|
|
|
|
import com.sun.mail.util.FolderClosedIOException;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedInputStream;
|
|
|
|
|
import java.io.BufferedOutputStream;
|
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.security.MessageDigest;
|
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
@ -114,6 +110,7 @@ public class Helper {
|
|
|
|
|
static final int NOTIFICATION_UPDATE = 4;
|
|
|
|
|
|
|
|
|
|
static final float LOW_LIGHT = 0.6f;
|
|
|
|
|
static final int BUFFER_SIZE = 8192; // Same as in Files class
|
|
|
|
|
|
|
|
|
|
static final String FAQ_URI = "https://github.com/M66B/FairEmail/blob/master/FAQ.md";
|
|
|
|
|
static final String XDA_URI = "https://forum.xda-developers.com/android/apps-games/source-email-t3824168";
|
|
|
|
@ -536,14 +533,15 @@ public class Helper {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void writeText(File file, String content) throws IOException {
|
|
|
|
|
try (BufferedWriter out = new BufferedWriter(new FileWriter(file))) {
|
|
|
|
|
out.write(content == null ? "" : content);
|
|
|
|
|
try (FileOutputStream out = new FileOutputStream(file)) {
|
|
|
|
|
if (content != null)
|
|
|
|
|
out.write(content.getBytes());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String readStream(InputStream is, String charset) throws IOException {
|
|
|
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
|
byte[] buffer = new byte[16384];
|
|
|
|
|
byte[] buffer = new byte[BUFFER_SIZE];
|
|
|
|
|
for (int len = is.read(buffer); len != -1; len = is.read(buffer))
|
|
|
|
|
os.write(buffer, 0, len);
|
|
|
|
|
return new String(os.toByteArray(), charset);
|
|
|
|
@ -551,14 +549,14 @@ public class Helper {
|
|
|
|
|
|
|
|
|
|
static String readText(File file) throws IOException {
|
|
|
|
|
try (FileInputStream in = new FileInputStream(file)) {
|
|
|
|
|
return readStream(in, "UTF-8");
|
|
|
|
|
return readStream(in, StandardCharsets.UTF_8.name());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void copy(File src, File dst) throws IOException {
|
|
|
|
|
try (InputStream in = new BufferedInputStream(new FileInputStream(src))) {
|
|
|
|
|
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(dst))) {
|
|
|
|
|
byte[] buf = new byte[4096];
|
|
|
|
|
try (InputStream in = new FileInputStream(src)) {
|
|
|
|
|
try (FileOutputStream out = new FileOutputStream(dst)) {
|
|
|
|
|
byte[] buf = new byte[BUFFER_SIZE];
|
|
|
|
|
int len;
|
|
|
|
|
while ((len = in.read(buf)) > 0)
|
|
|
|
|
out.write(buf, 0, len);
|
|
|
|
|