mirror of https://github.com/M66B/FairEmail.git
Small improvements
This commit is contained in:
parent
4d86ea2b2c
commit
757181958b
|
@ -26,6 +26,7 @@ import java.io.PrintStream;
|
|||
import java.security.GeneralSecurityException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
|
@ -396,7 +397,7 @@ public class Ntlm {
|
|||
type3flags |= NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY;
|
||||
byte[] nonce = new byte[8];
|
||||
// XXX - allow user to specify Random instance via properties?
|
||||
(new Random()).nextBytes(nonce);
|
||||
(new SecureRandom()).nextBytes(nonce);
|
||||
byte[] nthash = calcNTHash();
|
||||
lmresponse = calcV2Response(nthash, nonce, challenge);
|
||||
byte[] targetInfo = new byte[0];
|
||||
|
|
|
@ -166,7 +166,7 @@ public class LineInputStream extends FilterInputStream {
|
|||
// fall through and treat it as an 8-bit charset
|
||||
}
|
||||
}
|
||||
return new String(buf, 0, 0, offset);
|
||||
return new String(buf, 0, offset, StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -488,10 +488,8 @@ public class ActivityEML extends ActivityBase {
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException || ex instanceof FileNotFoundException)
|
||||
ToastEx.makeText(ActivityEML.this, ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getSupportFragmentManager(), ex);
|
||||
boolean report = !(ex instanceof IllegalArgumentException || ex instanceof FileNotFoundException);
|
||||
Log.unexpectedError(getSupportFragmentManager(), ex, report);
|
||||
}
|
||||
}.execute(this, args, "eml:attachment");
|
||||
}
|
||||
|
|
|
@ -511,10 +511,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
ToastEx.makeText(ActivitySetup.this, ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getSupportFragmentManager(), ex);
|
||||
boolean report = !(ex instanceof IllegalArgumentException);
|
||||
Log.unexpectedError(getSupportFragmentManager(), ex, report);
|
||||
}
|
||||
|
||||
}.execute(this, args, "debug:info");
|
||||
|
|
|
@ -1765,11 +1765,10 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (args.getBoolean("always"))
|
||||
if (ex instanceof IllegalArgumentException || ex instanceof IOException)
|
||||
ToastEx.makeText(ActivityView.this, ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getSupportFragmentManager(), ex);
|
||||
if (args.getBoolean("always")) {
|
||||
boolean report = !(ex instanceof IllegalArgumentException || ex instanceof IOException);
|
||||
Log.unexpectedError(getSupportFragmentManager(), ex, report);
|
||||
}
|
||||
}
|
||||
}.execute(this, args, "update:check");
|
||||
}
|
||||
|
@ -2323,10 +2322,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
ToastEx.makeText(ActivityView.this, ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getSupportFragmentManager(), ex);
|
||||
boolean report = !(ex instanceof IllegalArgumentException);
|
||||
Log.unexpectedError(getSupportFragmentManager(), ex, report);
|
||||
}
|
||||
|
||||
}.execute(this, args, "debug:info");
|
||||
|
|
|
@ -277,7 +277,7 @@ public class EditTextCompose extends FixedEditText {
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
ToastEx.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
// Ignored
|
||||
}
|
||||
}.execute(activity, args, "dictionary:modify");
|
||||
|
||||
|
|
|
@ -643,7 +643,7 @@ public class EntityMessage implements Serializable {
|
|||
long id = Long.parseLong(file.getName());
|
||||
File target = getFile(context, id);
|
||||
if (!file.renameTo(target))
|
||||
throw new IllegalArgumentException("Failed moving " + file);
|
||||
Log.e("Move failed: " + file);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
|
|
|
@ -634,12 +634,10 @@ public class FragmentBase extends Fragment {
|
|||
return;
|
||||
}
|
||||
|
||||
if (ex instanceof IllegalArgumentException ||
|
||||
boolean report = !(ex instanceof IllegalArgumentException ||
|
||||
ex instanceof FileNotFoundException ||
|
||||
ex instanceof SecurityException)
|
||||
ToastEx.makeText(getContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
ex instanceof SecurityException);
|
||||
Log.unexpectedError(getParentFragmentManager(), ex, report);
|
||||
}
|
||||
}.execute(this, args, "attachment:save");
|
||||
}
|
||||
|
@ -725,12 +723,10 @@ public class FragmentBase extends Fragment {
|
|||
return;
|
||||
}
|
||||
|
||||
if (ex instanceof IllegalArgumentException ||
|
||||
boolean report = !(ex instanceof IllegalArgumentException ||
|
||||
ex instanceof FileNotFoundException ||
|
||||
ex instanceof SecurityException)
|
||||
ToastEx.makeText(getContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
ex instanceof SecurityException);
|
||||
Log.unexpectedError(getParentFragmentManager(), ex, report);
|
||||
}
|
||||
}.execute(this, args, "attachments:save");
|
||||
}
|
||||
|
|
|
@ -820,10 +820,8 @@ public class FragmentContacts extends FragmentBase {
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
ToastEx.makeText(getContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
boolean report = !(ex instanceof IllegalArgumentException);
|
||||
Log.unexpectedError(getParentFragmentManager(), ex, report);
|
||||
}
|
||||
}.execute(this, args, "contacts:name");
|
||||
}
|
||||
|
|
|
@ -446,8 +446,8 @@ public class FragmentDialogPrint extends FragmentDialogBase {
|
|||
ex = new Throwable("A system app or component required for printing is missing." +
|
||||
" Is the print spooler still enabled?", ex);
|
||||
Log.unexpectedError(fm, ex, report);
|
||||
} catch (IllegalStateException exex) {
|
||||
ToastEx.makeText(context, Log.formatThrowable(ex), Toast.LENGTH_LONG).show();
|
||||
} catch (Throwable exex) {
|
||||
Log.e(exex);
|
||||
}
|
||||
} finally {
|
||||
printWebView = null;
|
||||
|
|
|
@ -136,10 +136,8 @@ public class FragmentDialogRuleCheck extends FragmentDialogBase {
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
ToastEx.makeText(getContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
boolean report = !(ex instanceof IllegalArgumentException);
|
||||
Log.unexpectedError(getParentFragmentManager(), ex, report);
|
||||
}
|
||||
}.execute(FragmentDialogRuleCheck.this, args, "rule:execute");
|
||||
}
|
||||
|
|
|
@ -1892,10 +1892,8 @@ public class FragmentMessages extends FragmentBase
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
ToastEx.makeText(getContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
boolean report = !(ex instanceof IllegalArgumentException);
|
||||
Log.unexpectedError(getParentFragmentManager(), ex, report);
|
||||
}
|
||||
}.execute(FragmentMessages.this, args, "messages:search");
|
||||
}
|
||||
|
|
|
@ -85,13 +85,13 @@ import org.json.JSONObject;
|
|||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.URL;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.mail.AuthenticationFailedException;
|
||||
|
@ -424,7 +424,7 @@ public class FragmentOAuth extends FragmentBase {
|
|||
Uri.parse(authorizationEndpoint),
|
||||
Uri.parse(tokenEndpoint));
|
||||
|
||||
int random = Math.abs(new Random().nextInt());
|
||||
int random = Math.abs(new SecureRandom().nextInt());
|
||||
AuthState authState = new AuthState(serviceConfig);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String key = "oauth." + provider.id + (graph ? ":graph" : "");
|
||||
|
|
|
@ -1933,8 +1933,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
ssb.append("\n");
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException ex) {
|
||||
ssb.append(ex.toString()).append("\n")
|
||||
.append(android.util.Log.getStackTraceString(ex)).append("\n");
|
||||
Log.e(ex);
|
||||
}
|
||||
|
||||
ssb.append("\n");
|
||||
|
|
|
@ -543,11 +543,8 @@ public class FragmentRules extends FragmentBase {
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException ||
|
||||
ex instanceof FileNotFoundException)
|
||||
ToastEx.makeText(getContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
boolean report = !(ex instanceof IllegalArgumentException || ex instanceof FileNotFoundException);
|
||||
Log.unexpectedError(getParentFragmentManager(), ex, report);
|
||||
}
|
||||
}.execute(this, args, "rules:export");
|
||||
}
|
||||
|
@ -675,11 +672,10 @@ public class FragmentRules extends FragmentBase {
|
|||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof NoStreamException)
|
||||
((NoStreamException) ex).report(getActivity());
|
||||
else if (ex instanceof FileNotFoundException ||
|
||||
ex instanceof JSONException)
|
||||
ToastEx.makeText(getContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
else {
|
||||
boolean report = !(ex instanceof FileNotFoundException || ex instanceof JSONException);
|
||||
Log.unexpectedError(getParentFragmentManager(), ex, report);
|
||||
}
|
||||
}
|
||||
}.execute(this, args, "rules:import");
|
||||
}
|
||||
|
|
|
@ -200,30 +200,50 @@ public class Fts4DbHelper extends SQLiteOpenHelper {
|
|||
String search = escape(processBreakText(query));
|
||||
|
||||
String select = "";
|
||||
if (account != null)
|
||||
select += "account = " + account + " AND ";
|
||||
if (folder != null)
|
||||
select += "folder = " + folder + " AND ";
|
||||
List<String> args = new ArrayList<>();
|
||||
|
||||
if (account != null) {
|
||||
select += "account = ? AND ";
|
||||
args.add(Long.toString(account));
|
||||
}
|
||||
|
||||
if (folder != null) {
|
||||
select += "folder = ? AND ";
|
||||
args.add(Long.toString(folder));
|
||||
}
|
||||
|
||||
if (exclude.length > 0) {
|
||||
select += "NOT folder IN (";
|
||||
for (int i = 0; i < exclude.length; i++) {
|
||||
if (i > 0)
|
||||
select += ", ";
|
||||
select += exclude[i];
|
||||
select += "?";
|
||||
args.add(Long.toString(exclude[i]));
|
||||
}
|
||||
select += ") AND ";
|
||||
}
|
||||
if (criteria.after != null)
|
||||
select += "time > " + criteria.after + " AND ";
|
||||
if (criteria.before != null)
|
||||
select += "time < " + criteria.before + " AND ";
|
||||
|
||||
Log.i("FTS select=" + select + " search=" + search + " query=" + query);
|
||||
if (criteria.after != null) {
|
||||
select += "time > ? AND ";
|
||||
args.add(Long.toString(criteria.after));
|
||||
}
|
||||
|
||||
if (criteria.before != null) {
|
||||
select += "time < ? AND ";
|
||||
args.add(Long.toString(criteria.before));
|
||||
}
|
||||
|
||||
select += "message MATCH ?";
|
||||
args.add(search);
|
||||
|
||||
Log.i("FTS select=" + select +
|
||||
" args=" + TextUtils.join(", ", args) +
|
||||
" query=" + query);
|
||||
List<Long> result = new ArrayList<>();
|
||||
try (Cursor cursor = db.query(
|
||||
"message", new String[]{"rowid"},
|
||||
select + "message MATCH ?",
|
||||
new String[]{search},
|
||||
select,
|
||||
args.toArray(new String[0]),
|
||||
null, null, "time DESC", null)) {
|
||||
while (cursor != null && cursor.moveToNext())
|
||||
result.add(cursor.getLong(0));
|
||||
|
|
|
@ -130,8 +130,8 @@ public class Fts5DbHelper extends SQLiteOpenHelper {
|
|||
"SELECT term FROM message_terms" +
|
||||
" WHERE term LIKE ?" +
|
||||
" ORDER BY cnt" +
|
||||
" LIMIT " + max,
|
||||
new String[]{query})) {
|
||||
" LIMIT ?",
|
||||
new String[]{query, Integer.toString(max)})) {
|
||||
while (cursor != null && cursor.moveToNext())
|
||||
result.add(cursor.getString(0));
|
||||
}
|
||||
|
@ -200,30 +200,50 @@ public class Fts5DbHelper extends SQLiteOpenHelper {
|
|||
String search = (sb.length() > 0 ? sb.toString() : escape(criteria.query));
|
||||
|
||||
String select = "";
|
||||
if (account != null)
|
||||
select += "account = " + account + " AND ";
|
||||
if (folder != null)
|
||||
select += "folder = " + folder + " AND ";
|
||||
List<String> args = new ArrayList<>();
|
||||
|
||||
if (account != null) {
|
||||
select += "account = ? AND ";
|
||||
args.add(Long.toString(account));
|
||||
}
|
||||
|
||||
if (folder != null) {
|
||||
select += "folder = ? AND ";
|
||||
args.add(Long.toString(folder));
|
||||
}
|
||||
|
||||
if (exclude.length > 0) {
|
||||
select += "NOT folder IN (";
|
||||
for (int i = 0; i < exclude.length; i++) {
|
||||
if (i > 0)
|
||||
select += ", ";
|
||||
select += exclude[i];
|
||||
select += "?";
|
||||
args.add(Long.toString(exclude[i]));
|
||||
}
|
||||
select += ") AND ";
|
||||
}
|
||||
if (criteria.after != null)
|
||||
select += "time > " + criteria.after + " AND ";
|
||||
if (criteria.before != null)
|
||||
select += "time < " + criteria.before + " AND ";
|
||||
|
||||
Log.i("FTS select=" + select + " search=" + search);
|
||||
if (criteria.after != null) {
|
||||
select += "time > ? AND ";
|
||||
args.add(Long.toString(criteria.after));
|
||||
}
|
||||
|
||||
if (criteria.before != null) {
|
||||
select += "time < ? AND ";
|
||||
args.add(Long.toString(criteria.before));
|
||||
}
|
||||
|
||||
select += "message MATCH ?";
|
||||
args.add(search);
|
||||
|
||||
Log.i("FTS select=" + select +
|
||||
" args=" + TextUtils.join(", ", args) +
|
||||
" query=" + criteria.query);
|
||||
List<Long> result = new ArrayList<>();
|
||||
try (Cursor cursor = db.query(
|
||||
"message", new String[]{"rowid"},
|
||||
select + "message MATCH ?",
|
||||
new String[]{search},
|
||||
select,
|
||||
args.toArray(new String[0]),
|
||||
null, null, "time DESC", null)) {
|
||||
while (cursor != null && cursor.moveToNext())
|
||||
result.add(cursor.getLong(0));
|
||||
|
|
|
@ -1787,7 +1787,6 @@ public class Helper {
|
|||
context.startActivity(intent);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -2649,8 +2648,9 @@ public class Helper {
|
|||
exists.put(dir, true);
|
||||
}
|
||||
|
||||
// CASA: External storage as well
|
||||
if (!dir.exists() && !dir.mkdirs())
|
||||
throw new IllegalArgumentException("Failed to create=" + dir);
|
||||
throw new IllegalArgumentException("Failed to create directory");
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
@ -2850,7 +2850,7 @@ public class Helper {
|
|||
if (file.exists()) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
if (!file.delete())
|
||||
throw new FileNotFoundException(file.getAbsolutePath());
|
||||
Log.w("File not found: " + file);
|
||||
} else
|
||||
Files.delete(Paths.get(file.getAbsolutePath()));
|
||||
}
|
||||
|
@ -3528,8 +3528,8 @@ public class Helper {
|
|||
Runtime.getRuntime().gc();
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3808,15 +3808,6 @@ public class HtmlHelper {
|
|||
setSpan(ssb, StyleHelper.getTypefaceSpan("Cousine", context), start, ssb.length());
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
if (BuildConfig.DEBUG || debug) {
|
||||
int s = ssb.length();
|
||||
ssb.append(ex.toString()).append('\n')
|
||||
.append(android.util.Log.getStackTraceString(ex)).append('\n');
|
||||
setSpan(ssb, StyleHelper.getTypefaceSpan("Cousine", context), s, ssb.length());
|
||||
setSpan(ssb, new RelativeSizeSpan(HtmlHelper.FONT_SMALL), s, ssb.length());
|
||||
int colorWarning = Helper.resolveColor(context, R.attr.colorWarning);
|
||||
setSpan(ssb, new ForegroundColorSpan(colorWarning), s, ssb.length());
|
||||
}
|
||||
}
|
||||
|
||||
if ("true".equals(element.attr("x-block")))
|
||||
|
|
|
@ -89,7 +89,6 @@ import android.view.ViewConfiguration;
|
|||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -300,7 +299,7 @@ public class Log {
|
|||
}
|
||||
});
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
Log.i(ex);
|
||||
}
|
||||
return android.util.Log.e(TAG, msg);
|
||||
}
|
||||
|
@ -323,7 +322,7 @@ public class Log {
|
|||
}
|
||||
});
|
||||
} catch (Throwable ex1) {
|
||||
ex1.printStackTrace();
|
||||
Log.i(ex1);
|
||||
}
|
||||
return android.util.Log.w(TAG, ex + "\n" + android.util.Log.getStackTraceString(ex));
|
||||
}
|
||||
|
@ -342,7 +341,7 @@ public class Log {
|
|||
}
|
||||
});
|
||||
} catch (Throwable ex1) {
|
||||
ex1.printStackTrace();
|
||||
Log.i(ex1);
|
||||
}
|
||||
return android.util.Log.e(TAG, ex + "\n" + android.util.Log.getStackTraceString(ex));
|
||||
}
|
||||
|
@ -362,7 +361,7 @@ public class Log {
|
|||
}
|
||||
});
|
||||
} catch (Throwable ex1) {
|
||||
ex1.printStackTrace();
|
||||
Log.i(ex1);
|
||||
}
|
||||
return android.util.Log.w(TAG, prefix + " " + ex + "\n" + android.util.Log.getStackTraceString(ex));
|
||||
}
|
||||
|
@ -378,7 +377,7 @@ public class Log {
|
|||
}
|
||||
});
|
||||
} catch (Throwable ex1) {
|
||||
ex1.printStackTrace();
|
||||
Log.i(ex1);
|
||||
}
|
||||
return android.util.Log.e(TAG, prefix + " " + ex + "\n" + android.util.Log.getStackTraceString(ex));
|
||||
}
|
||||
|
@ -402,7 +401,7 @@ public class Log {
|
|||
if (enabled)
|
||||
Bugsnag.startSession();
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
Log.i(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,7 +453,7 @@ public class Log {
|
|||
Log.i(sb.toString());
|
||||
Bugsnag.leaveBreadcrumb(name, ocrumb, BreadcrumbType.LOG);
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2020,10 +2019,7 @@ public class Log {
|
|||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
ToastEx.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
ToastEx.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
// Ignored
|
||||
}
|
||||
}.execute(getContext(), getActivity(), new Bundle(), "error:unexpected");
|
||||
}
|
||||
|
|
|
@ -1209,9 +1209,12 @@ public class MessageHelper {
|
|||
ContactsContract.CommonDataKinds.Website.TYPE,
|
||||
ContactsContract.CommonDataKinds.Website.URL
|
||||
},
|
||||
ContactsContract.Data.CONTACT_ID + " = " + contactId +
|
||||
" AND " + ContactsContract.Contacts.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE + "'",
|
||||
null, null)) {
|
||||
ContactsContract.Data.CONTACT_ID + " = ?" +
|
||||
" AND " + ContactsContract.Contacts.Data.MIMETYPE + " = ?",
|
||||
new String[]{
|
||||
contactId,
|
||||
ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE
|
||||
}, null)) {
|
||||
while (web.moveToNext()) {
|
||||
int type = web.getInt(0);
|
||||
String url = web.getString(1);
|
||||
|
@ -1226,8 +1229,10 @@ public class MessageHelper {
|
|||
ContactsContract.CommonDataKinds.Phone.TYPE,
|
||||
ContactsContract.CommonDataKinds.Phone.NUMBER
|
||||
},
|
||||
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId,
|
||||
null, null)) {
|
||||
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",
|
||||
new String[]{
|
||||
contactId
|
||||
}, null)) {
|
||||
while (phones.moveToNext()) {
|
||||
int type = phones.getInt(0);
|
||||
String number = phones.getString(1);
|
||||
|
|
|
@ -46,7 +46,6 @@ import android.view.inputmethod.EditorInfo;
|
|||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -388,7 +387,6 @@ public class ProtectedContent {
|
|||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}.execute(context, owner, args, "protect");
|
||||
}
|
||||
|
|
|
@ -34,8 +34,10 @@ import android.view.textclassifier.TextClassifier;
|
|||
import androidx.annotation.RequiresApi;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.parser.Parser;
|
||||
|
||||
import java.text.Normalizer;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
@ -53,13 +55,6 @@ import java.util.concurrent.Future;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
public class TextHelper {
|
||||
private static final int MIN_WORDS = 7;
|
||||
private static final int MAX_DETECT_SAMPLE_SIZE = 8192;
|
||||
|
@ -294,16 +289,9 @@ public class TextHelper {
|
|||
|
||||
public static String formatXml(String xml, int indent) {
|
||||
try {
|
||||
Source source = new StreamSource(new StringReader(xml));
|
||||
StringWriter writer = new StringWriter();
|
||||
StreamResult result = new StreamResult(writer);
|
||||
TransformerFactory factory = TransformerFactory.newInstance();
|
||||
Transformer transformer = factory.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", Integer.toString(indent));
|
||||
transformer.transform(source, result);
|
||||
return result.getWriter().toString();
|
||||
Document d = Jsoup.parse(xml, "", Parser.xmlParser());
|
||||
d.outputSettings().prettyPrint(true).outline(true).indentAmount(indent);
|
||||
return d.html();
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
return xml;
|
||||
|
|
Loading…
Reference in New Issue