Small improvements

pull/214/head
M66B 9 months ago
parent 56309888ef
commit e4840587a7

@ -115,7 +115,7 @@ public abstract class PagedListAdapter<T, VH extends RecyclerView.ViewHolder>
@Override
public void onCurrentListChanged(
@Nullable PagedList<T> previousList, @Nullable PagedList<T> currentList) {
PagedListAdapter.this.onCurrentListChanged(currentList);
//PagedListAdapter.this.onCurrentListChanged(currentList);
PagedListAdapter.this.onCurrentListChanged(previousList, currentList);
}
};

@ -483,7 +483,8 @@ public abstract class DB extends RoomDatabase {
if (cache_size != null) {
cache_size = -cache_size; // kibibytes
Log.i("Set PRAGMA cache_size=" + cache_size);
try (Cursor cursor = db.query(new SimpleSQLiteQuery("PRAGMA cache_size=" + cache_size + ";"))) {
// TODO CASA
try (Cursor cursor = db.query("PRAGMA cache_size=" + cache_size + ";")) {
cursor.moveToNext(); // required
}
}
@ -503,7 +504,8 @@ public abstract class DB extends RoomDatabase {
// https://www.sqlite.org/pragma.html
for (String pragma : DB_PRAGMAS)
if (!"compile_options".equals(pragma) || BuildConfig.DEBUG) {
try (Cursor cursor = db.query(new SimpleSQLiteQuery("PRAGMA " + pragma + ";"))) {
// TODO CASA
try (Cursor cursor = db.query("PRAGMA " + pragma + ";")) {
boolean has = false;
while (cursor.moveToNext()) {
has = true;

@ -2079,7 +2079,7 @@ public class FragmentMessages extends FragmentBase
StorageStrategy.createLongStorage())
.withSelectionPredicate(selectionPredicate)
// https://issuetracker.google.com/issues/154178289
.withGestureTooltypes(MotionEvent.TOOL_TYPE_FINGER, MotionEvent.TOOL_TYPE_STYLUS)
.withGestureTooltypes(MotionEvent.TOOL_TYPE_FINGER, MotionEvent.TOOL_TYPE_STYLUS) // TODO CASA
.build();
adapter.setSelectionTracker(selectionTracker);
@ -7137,7 +7137,7 @@ public class FragmentMessages extends FragmentBase
lastTime = time;
tvDebug.setText(utilization + "%\n" + perc + "% " + (nheap / (1024 * 1024)) + "M");
tvDebug.setText(utilization + "%\n" + perc + "% " + (nheap / (1024 * 1024)) + "M"); // TODO CASA
}
private boolean handleThreadActions(

@ -1751,7 +1751,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
? null : context.getDataDir());
File filesDir = context.getFilesDir();
File cacheDir = context.getCacheDir();
File externalDir = Helper.getExternalFilesDir(context);
if (dataDir != null)
ssb.append("Data: ").append(dataDir.getAbsolutePath()).append("\r\n");
@ -1759,8 +1758,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
ssb.append("Files: ").append(filesDir.getAbsolutePath()).append("\r\n");
if (cacheDir != null)
ssb.append("Cache: ").append(cacheDir.getAbsolutePath()).append("\r\n");
if (externalDir != null)
ssb.append("External: ").append(externalDir.getAbsolutePath()).append("\r\n");
ssb.append("\r\n");
for (File file : files) {
@ -2463,13 +2460,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
info.group = ex.toString();
}
ssb.append(info.name).append('\n');
ssb.append(info.name).append('\n'); // TODO CASA
if (granted)
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, ssb.length(), 0);
start = ssb.length();
if (info.group != null) {
ssb.append(info.group).append('\n');
ssb.append(info.group).append('\n'); // TODO CASA
ssb.setSpan(new IndentSpan(dp24), start, ssb.length(), 0);
start = ssb.length();
}
@ -2499,7 +2496,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
break;
}
ssb.append(Integer.toHexString(info.protectionLevel));
ssb.append(Integer.toHexString(info.protectionLevel)); // TODO CASA
if (info.flags != 0)
ssb.append(' ').append(Integer.toHexString(info.flags));

@ -240,7 +240,7 @@ public class Fts4DbHelper extends SQLiteOpenHelper {
" args=" + TextUtils.join(", ", args) +
" query=" + query);
List<Long> result = new ArrayList<>();
try (Cursor cursor = db.query(
try (Cursor cursor = db.query( // TODO CASA
"message", new String[]{"rowid"},
select,
args.toArray(new String[0]),

@ -240,7 +240,7 @@ public class Fts5DbHelper extends SQLiteOpenHelper {
" args=" + TextUtils.join(", ", args) +
" query=" + criteria.query);
List<Long> result = new ArrayList<>();
try (Cursor cursor = db.query(
try (Cursor cursor = db.query( // TODO CASA
"message", new String[]{"rowid"},
select,
args.toArray(new String[0]),

@ -2649,7 +2649,7 @@ public class Helper {
}
// CASA: External storage as well
if (!dir.exists() && !dir.mkdirs())
if (!dir.exists() && !dir.mkdirs()) // TODO CASA
throw new IllegalArgumentException("Failed to create directory");
return dir;
@ -2746,7 +2746,7 @@ public class Helper {
static void writeText(File file, String content) throws IOException {
try (FileOutputStream out = new FileOutputStream(file)) {
if (content != null)
out.write(content.getBytes());
out.write(content.getBytes()); // TODO CASA
}
}

@ -243,6 +243,8 @@ public class Log {
public static native int jni_safe_log(int prio, String tag, String msg);
public static native Process jni_safe_runtime_exec(Runtime runtime, String[] cmd);
public static void setLevel(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean debug = prefs.getBoolean("debug", false);
@ -275,7 +277,7 @@ public class Log {
public static int i(String msg) {
if (level <= android.util.Log.INFO || BuildConfig.DEBUG || BuildConfig.TEST_RELEASE)
return android.util.Log.i(TAG, msg);
return jni_safe_log(android.util.Log.INFO, TAG, msg);
else
return 0;
}
@ -294,7 +296,7 @@ public class Log {
public static int e(String msg) {
if (BuildConfig.BETA_RELEASE)
try {
Throwable ex = new ThrowableWrapper(msg);
Throwable ex = new ThrowableWrapper(msg); // TODO CASA
List<StackTraceElement> ss = new ArrayList<>(Arrays.asList(ex.getStackTrace()));
ss.remove(0);
ex.setStackTrace(ss.toArray(new StackTraceElement[0]));
@ -3134,7 +3136,7 @@ public class Log {
"-v", "threadtime",
//"-t", "1000",
Log.TAG + ":I"};
proc = Runtime.getRuntime().exec(cmd);
proc = proc = jni_safe_runtime_exec(Runtime.getRuntime(), cmd);
long size = 0;
try (BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
@ -3810,7 +3812,7 @@ public class Log {
private static int write(OutputStream os, String text) throws IOException {
byte[] bytes = text.getBytes();
os.write(bytes);
os.write(bytes); // TODO CASA
return bytes.length;
}

@ -64,7 +64,7 @@ public class NoStreamException extends SecurityException {
TextView tvUri = dview.findViewById(R.id.tvUri);
ImageButton ibInfo = dview.findViewById(R.id.ibInfo);
tvUri.setText(uri == null ? null : UriHelper.toSafeString(uri));
tvUri.setText(uri == null ? null : UriHelper.toSafeString(uri)); // TODO CASA
ibInfo.setOnClickListener(new View.OnClickListener() {
@Override

@ -64,9 +64,18 @@ Java_eu_faircode_email_ThrowableWrapper_jni_1get_1safe_1stack_1trace_1string(
"(Ljava/lang/Throwable;)Ljava/lang/String;");
return (jstring) env->CallStaticObjectMethod(cls, mid, ex);
}
extern "C"
JNIEXPORT jobject JNICALL
Java_eu_faircode_email_Log_jni_1safe_1runtime_1exec(JNIEnv *env, jclass clazz,
jobject runtime, jobjectArray cmd) {
jclass cls = env->FindClass("java/lang/Runtime");
jmethodID mid = env->GetMethodID(cls, "exec", "([Ljava/lang/String;)Ljava/lang/Process;");
return env->CallObjectMethod(runtime, mid, cmd);
}
extern "C"
JNIEXPORT jobject JNICALL
Java_eu_faircode_email_CharsetHelper_jni_1detect_1charset(
JNIEnv *env, jclass type,
jbyteArray _octets, jstring _ref, jstring _lang) {

Loading…
Cancel
Save