use of de.baumann.browser.Database.RecordAction in project browser by scoute-dich.
the class BrowserActivity method showEditDialog.
private void showEditDialog(final GridItem gridItem) {
AlertDialog.Builder builder = new AlertDialog.Builder(BrowserActivity.this);
View dialogView = View.inflate(BrowserActivity.this, R.layout.dialog_edit, null);
final EditText editText = dialogView.findViewById(R.id.dialog_edit);
editText.setHint(R.string.dialog_title_hint);
editText.setText(gridItem.getTitle());
editText.setSelection(gridItem.getTitle().length());
builder.setView(dialogView);
builder.setTitle(R.string.menu_edit);
builder.setPositiveButton(R.string.app_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String text = editText.getText().toString().trim();
if (text.isEmpty()) {
NinjaToast.show(BrowserActivity.this, getString(R.string.toast_input_empty));
} else {
RecordAction action = new RecordAction(BrowserActivity.this);
action.open(true);
gridItem.setTitle(text);
action.updateGridItem(gridItem);
action.close();
hideSoftInput(editText);
}
}
});
builder.setNegativeButton(R.string.app_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
hideSoftInput(editText);
}
});
final AlertDialog dialog = builder.create();
// Display the custom alert dialog on interface
dialog.show();
showSoftInput(editText);
}
use of de.baumann.browser.Database.RecordAction in project browser by scoute-dich.
the class BrowserActivity method showEditDialog.
private void showEditDialog(final Adapter_Record adapterRecord, List<Record> recordList, int location) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View dialogView = View.inflate(BrowserActivity.this, R.layout.dialog_edit, null);
final Record record = recordList.get(location);
final EditText editText = dialogView.findViewById(R.id.dialog_edit);
editText.setHint(R.string.dialog_title_hint);
editText.setText(record.getTitle());
editText.setSelection(record.getTitle().length());
builder.setView(dialogView);
builder.setTitle(R.string.menu_edit);
builder.setPositiveButton(R.string.app_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String text = editText.getText().toString().trim();
if (text.isEmpty()) {
NinjaToast.show(BrowserActivity.this, getString(R.string.toast_input_empty));
}
RecordAction action = new RecordAction(BrowserActivity.this);
action.open(true);
record.setTitle(text);
action.updateBookmark(record);
action.close();
adapterRecord.notifyDataSetChanged();
hideSoftInput(editText);
}
});
builder.setNegativeButton(R.string.app_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
hideSoftInput(editText);
}
});
AlertDialog dialog = builder.create();
dialog.show();
showSoftInput(editText);
}
use of de.baumann.browser.Database.RecordAction in project browser by scoute-dich.
the class NinjaWebViewClient method onPageFinished.
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if (!ninjaWebView.getSettings().getLoadsImagesAutomatically()) {
ninjaWebView.getSettings().setLoadsImagesAutomatically(true);
}
if (view.getTitle() == null || view.getTitle().isEmpty()) {
ninjaWebView.update(context.getString(R.string.album_untitled), url);
} else {
ninjaWebView.update(view.getTitle(), url);
}
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
if (sp.getBoolean("saveHistory", true)) {
RecordAction action = new RecordAction(context);
action.open(true);
if (action.checkHistory(url)) {
action.deleteHistoryOld(url);
action.addHistory(new Record(ninjaWebView.getTitle(), ninjaWebView.getUrl(), System.currentTimeMillis()));
} else {
action.addHistory(new Record(ninjaWebView.getTitle(), ninjaWebView.getUrl(), System.currentTimeMillis()));
}
action.close();
}
if (ninjaWebView.isForeground()) {
ninjaWebView.invalidate();
} else {
ninjaWebView.postInvalidate();
}
}
use of de.baumann.browser.Database.RecordAction in project browser by scoute-dich.
the class BrowserUnit method importWhitelistCookie.
public static int importWhitelistCookie(Context context) {
String filename = context.getString(R.string.export_whitelistCookie);
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "browser_backup//" + filename + SUFFIX_TXT);
Cookie cookie = new Cookie(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.checkDomainCookie(line)) {
cookie.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 importBookmarks.
public static int importBookmarks(Context context) {
String filename = context.getString(R.string.export_bookmarks);
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "browser_backup//" + filename + SUFFIX_HTML);
List<Record> list = new ArrayList<>();
try {
RecordAction action = new RecordAction(context);
action.open(true);
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
if (!((line.startsWith("<dt><a ") && line.endsWith("</a>")) || (line.startsWith("<DT><A ") && line.endsWith("</A>")))) {
continue;
}
String title = getBookmarkTitle(line);
String url = getBookmarkURL(line);
if (title.trim().isEmpty() || url.trim().isEmpty()) {
continue;
}
Record record = new Record();
record.setTitle(title);
record.setURL(url);
record.setTime(System.currentTimeMillis());
if (!action.checkBookmark(record)) {
list.add(record);
}
}
reader.close();
Collections.sort(list, new Comparator<Record>() {
@Override
public int compare(Record first, Record second) {
return first.getTitle().compareTo(second.getTitle());
}
});
for (Record record : list) {
action.addBookmark(record);
}
action.close();
} catch (Exception e) {
Log.w("Browser", "Error adding record", e);
}
return list.size();
}
Aggregations