use of de.baumann.browser.database.RecordAction in project browser by scoute-dich.
the class BrowserUnit method clearBookmarks.
public static void clearBookmarks(Context context) {
RecordAction action = new RecordAction(context);
action.open(true);
action.clearBookmarks();
action.close();
}
use of de.baumann.browser.database.RecordAction in project browser by scoute-dich.
the class BrowserUnit method clearHistory.
public static void clearHistory(Context context) {
RecordAction action = new RecordAction(context);
action.open(true);
action.clearHistory();
action.close();
}
use of de.baumann.browser.database.RecordAction in project browser by scoute-dich.
the class BrowserUnit method exportBookmarks.
public static String exportBookmarks(Context context) {
RecordAction action = new RecordAction(context);
action.open(false);
List<Record> list = action.listBookmarks();
action.close();
String filename = context.getString(R.string.export_bookmarks);
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "browser_backup//" + filename + SUFFIX_HTML);
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(file, false));
for (Record record : list) {
String type = BOOKMARK_TYPE;
type = type.replace(BOOKMARK_TITLE, record.getTitle());
type = type.replace(BOOKMARK_URL, record.getURL());
type = type.replace(BOOKMARK_TIME, String.valueOf(record.getTime()));
writer.write(type);
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 Whitelist_AdBlock method onCreate.
@SuppressWarnings("ConstantConditions")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
helper_main.setTheme(this);
setContentView(R.layout.whitelist);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
RecordAction action = new RecordAction(this);
action.open(false);
list = action.listDomains();
action.close();
ListView listView = findViewById(R.id.whitelist);
listView.setEmptyView(findViewById(R.id.whitelist_empty));
adapter = new Adapter_AbBlock(this, list);
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
Button button = findViewById(R.id.whitelist_add);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText editText = findViewById(R.id.whitelist_edit);
String domain = editText.getText().toString().trim();
if (domain.isEmpty()) {
NinjaToast.show(Whitelist_AdBlock.this, R.string.toast_input_empty);
} else if (!BrowserUnit.isURL(domain)) {
NinjaToast.show(Whitelist_AdBlock.this, R.string.toast_invalid_domain);
} else {
RecordAction action = new RecordAction(Whitelist_AdBlock.this);
action.open(true);
if (action.checkDomain(domain)) {
NinjaToast.show(Whitelist_AdBlock.this, R.string.toast_domain_already_exists);
} else {
AdBlock adBlock = new AdBlock(Whitelist_AdBlock.this);
adBlock.addDomain(domain.trim());
list.add(0, domain.trim());
adapter.notifyDataSetChanged();
NinjaToast.show(Whitelist_AdBlock.this, R.string.toast_add_whitelist_successful);
}
action.close();
}
}
});
}
use of de.baumann.browser.database.RecordAction in project browser by scoute-dich.
the class Whitelist_Javascript method onCreate.
@SuppressWarnings("ConstantConditions")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
helper_main.setTheme(this);
setContentView(R.layout.whitelist);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
RecordAction action = new RecordAction(this);
action.open(false);
list = action.listDomainsJS();
action.close();
ListView listView = findViewById(R.id.whitelist);
listView.setEmptyView(findViewById(R.id.whitelist_empty));
adapter = new Adapter_Javascript(this, list);
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
Button button = findViewById(R.id.whitelist_add);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText editText = findViewById(R.id.whitelist_edit);
String domain = editText.getText().toString().trim();
if (domain.isEmpty()) {
NinjaToast.show(Whitelist_Javascript.this, R.string.toast_input_empty);
} else if (!BrowserUnit.isURL(domain)) {
NinjaToast.show(Whitelist_Javascript.this, R.string.toast_invalid_domain);
} else {
RecordAction action = new RecordAction(Whitelist_Javascript.this);
action.open(true);
if (action.checkDomainJS(domain)) {
NinjaToast.show(Whitelist_Javascript.this, R.string.toast_domain_already_exists);
} else {
Javascript adBlock = new Javascript(Whitelist_Javascript.this);
adBlock.addDomain(domain.trim());
list.add(0, domain.trim());
adapter.notifyDataSetChanged();
NinjaToast.show(Whitelist_Javascript.this, R.string.toast_add_whitelist_successful);
}
action.close();
}
}
});
}
Aggregations