Commit 3c44b8a2 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Added a function legacyString() which also removed new lines from strings

parent 7e70107c
......@@ -79,7 +79,7 @@ public class DatabaseHelper extends com.frostnerd.utils.database.DatabaseHelper
if(cursor.moveToFirst()){
int i = 0;
do{
shortcuts.add(new Shortcut(cursor.getString(0, "Name " + i++),
shortcuts.add(new Shortcut(legacyString(0, cursor, "Name " + i++),
IPPortPair.wrap(cursor.getString(1, ""), 53),
IPPortPair.wrap(cursor.getString(2 ), 53),
IPPortPair.wrap(cursor.getString(3, ""), 53),
......@@ -92,8 +92,8 @@ public class DatabaseHelper extends com.frostnerd.utils.database.DatabaseHelper
int i = 0;
do{
DNSEntry found = DNSEntry.findDefaultEntryByLongName(cursor.getString(0));
if(found == null)entries.add(new DNSEntry(cursor.getStringNonEmpty(0, "Name " + i++),
cursor.getStringNonEmpty(0, "Name " + i),
if(found == null)entries.add(new DNSEntry(legacyString(0, cursor, "Name " + i++),
legacyString(0, cursor,"Name " + i),
IPPortPair.wrap(cursor.getString(1, ""), 53),
IPPortPair.wrap(cursor.getString(2), 53),
IPPortPair.wrap(cursor.getString(3, ""), 53),
......@@ -113,6 +113,16 @@ public class DatabaseHelper extends com.frostnerd.utils.database.DatabaseHelper
}
}
private String legacyString(@NonNull String column, @NonNull CursorWithDefaults cursor, @NonNull String defaultValue){
return legacyString(cursor.getColumnIndex(column), cursor, defaultValue);
}
private String legacyString(int column, @NonNull CursorWithDefaults cursor, @NonNull String defaultValue){
String fromDB = cursor.getStringNonEmpty(column, defaultValue);
fromDB = fromDB.replaceAll("\\r|\\n", "");
return Utils.notEmptyOrDefault(fromDB, defaultValue);
}
@Override
public void onAfterUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
int version;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment