Search in sources :

Example 6 with RecordAction

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);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) RecordAction(de.baumann.browser.Database.RecordAction) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) NinjaWebView(de.baumann.browser.View.NinjaWebView) AutoCompleteTextView(android.widget.AutoCompleteTextView) DynamicGridView(org.askerov.dynamicgrid.DynamicGridView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) VideoView(android.widget.VideoView) Paint(android.graphics.Paint)

Example 7 with RecordAction

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);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) Record(de.baumann.browser.Database.Record) Adapter_Record(de.baumann.browser.View.Adapter_Record) RecordAction(de.baumann.browser.Database.RecordAction) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) NinjaWebView(de.baumann.browser.View.NinjaWebView) AutoCompleteTextView(android.widget.AutoCompleteTextView) DynamicGridView(org.askerov.dynamicgrid.DynamicGridView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) VideoView(android.widget.VideoView) Paint(android.graphics.Paint)

Example 8 with RecordAction

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();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) RecordAction(de.baumann.browser.Database.RecordAction) Record(de.baumann.browser.Database.Record)

Example 9 with RecordAction

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;
}
Also used : Cookie(de.baumann.browser.Browser.Cookie) BufferedReader(java.io.BufferedReader) RecordAction(de.baumann.browser.Database.RecordAction) FileReader(java.io.FileReader) File(java.io.File) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 10 with RecordAction

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();
}
Also used : ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) Record(de.baumann.browser.Database.Record) RecordAction(de.baumann.browser.Database.RecordAction) FileReader(java.io.FileReader) File(java.io.File) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

RecordAction (de.baumann.browser.Database.RecordAction)33 View (android.view.View)11 ListView (android.widget.ListView)11 TextView (android.widget.TextView)11 WebView (android.webkit.WebView)8 AdapterView (android.widget.AdapterView)8 AutoCompleteTextView (android.widget.AutoCompleteTextView)8 HorizontalScrollView (android.widget.HorizontalScrollView)8 ImageView (android.widget.ImageView)8 VideoView (android.widget.VideoView)8 Record (de.baumann.browser.Database.Record)8 NinjaWebView (de.baumann.browser.View.NinjaWebView)8 DynamicGridView (org.askerov.dynamicgrid.DynamicGridView)8 Paint (android.graphics.Paint)6 EditText (android.widget.EditText)6 File (java.io.File)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6 Button (android.widget.Button)5 Adapter_Record (de.baumann.browser.View.Adapter_Record)5 BufferedReader (java.io.BufferedReader)4