Search in sources :

Example 21 with RecordAction

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

Example 22 with RecordAction

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

Example 23 with RecordAction

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

Example 24 with RecordAction

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

Example 25 with RecordAction

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;
}
Also used : Javascript(de.baumann.browser.Browser.Javascript) BufferedReader(java.io.BufferedReader) 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