+ static public void setOption(String name, String value) {
+ Log.d("option", String.format("%s := %s", name, value));
+ SQLiteDatabase db = MLDB.getDatabase();
+ db.execSQL("insert or replace into options(profile, name, value) values(?, ?, ?);",
+ new String[]{NO_PROFILE, name, value});
+ }
+ static public void setLongOption(String name, long value) {
+ setOption(name, String.valueOf(value));
+ }
+ @TargetApi(Build.VERSION_CODES.N)
+ public static void hookAutocompletionAdapter(final Context context,
+ final AutoCompleteTextView view,
+ final String table, final String field,
+ final boolean profileSpecific) {
+ hookAutocompletionAdapter(context, view, table, field, profileSpecific, null, null);
+ }
+ @TargetApi(Build.VERSION_CODES.N)
+ public static void hookAutocompletionAdapter(final Context context,
+ final AutoCompleteTextView view,
+ final String table, final String field,
+ final boolean profileSpecific, final View nextView,
+ final DescriptionSelectedCallback callback) {
+ String[] from = {field};
+ int[] to = {android.R.id.text1};
+ SimpleCursorAdapter adapter =
+ new SimpleCursorAdapter(context, android.R.layout.simple_dropdown_item_1line, null,
+ from, to, 0);
+ adapter.setStringConversionColumn(1);
+
+ FilterQueryProvider provider = constraint -> {
+ if (constraint == null) return null;
+
+ String str = constraint.toString().toUpperCase();
+ Log.d("autocompletion", "Looking for " + str);
+ String[] col_names = {FontsContract.Columns._ID, field};
+ MatrixCursor c = new MatrixCursor(col_names);