use of de.baumann.browser.Database.RecordAction in project browser by scoute-dich.
the class Javascript method loadDomains.
private static synchronized void loadDomains(Context context) {
RecordAction action = new RecordAction(context);
action.open(false);
whitelistJS.clear();
whitelistJS.addAll(action.listDomainsJS());
action.close();
}
use of de.baumann.browser.Database.RecordAction in project browser by scoute-dich.
the class Javascript method addDomain.
public synchronized void addDomain(String domain) {
RecordAction action = new RecordAction(context);
action.open(true);
action.addDomainJS(domain);
action.close();
whitelistJS.add(domain);
}
use of de.baumann.browser.Database.RecordAction in project browser by scoute-dich.
the class BrowserUnit method exportWhitelist.
public static String exportWhitelist(Context context, int i) {
RecordAction action = new RecordAction(context);
List<String> list;
String filename;
action.open(false);
if (i == 0) {
list = action.listDomains();
filename = context.getString(R.string.export_whitelistAdBlock);
} else if (i == 1) {
list = action.listDomainsJS();
filename = context.getString(R.string.export_whitelistJS);
} else {
list = action.listDomainsCookie();
filename = context.getString(R.string.export_whitelistCookie);
}
action.close();
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "browser_backup//" + filename + SUFFIX_TXT);
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(file, false));
for (String domain : list) {
writer.write(domain);
writer.newLine();
}
writer.close();
return file.getAbsolutePath();
} catch (Exception e) {
return null;
}
}
use of de.baumann.browser.Database.RecordAction in project browser by scoute-dich.
the class BrowserUnit method importWhitelist.
public static int importWhitelist(Context context) {
String filename = context.getString(R.string.export_whitelistAdBlock);
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "browser_backup//" + filename + SUFFIX_TXT);
AdBlock adBlock = new AdBlock(context);
int count = 0;
try {
RecordAction action = new RecordAction(context);
action.open(true);
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null) {
if (!action.checkDomain(line)) {
adBlock.addDomain(line);
count++;
}
}
reader.close();
action.close();
} catch (Exception e) {
Log.w("Browser", "Error reading file", e);
}
return count;
}
use of de.baumann.browser.Database.RecordAction in project browser by scoute-dich.
the class BrowserUnit method importWhitelistJS.
public static int importWhitelistJS(Context context) {
String filename = context.getString(R.string.export_whitelistJS);
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "browser_backup//" + filename + SUFFIX_TXT);
Javascript js = new Javascript(context);
int count = 0;
try {
RecordAction action = new RecordAction(context);
action.open(true);
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null) {
if (!action.checkDomainJS(line)) {
js.addDomain(line);
count++;
}
}
reader.close();
action.close();
} catch (Exception e) {
Log.w("Browser", "Error reading file", e);
}
return count;
}
Aggregations