Search in sources :

Example 11 with RecordAction

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

Example 12 with RecordAction

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

Example 13 with RecordAction

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

Example 14 with RecordAction

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();
            }
        }
    });
}
Also used : EditText(android.widget.EditText) ListView(android.widget.ListView) Adapter_AbBlock(de.baumann.browser.View.Adapter_AbBlock) AdBlock(de.baumann.browser.Browser.AdBlock) Button(android.widget.Button) RecordAction(de.baumann.browser.Database.RecordAction) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView) Toolbar(android.support.v7.widget.Toolbar)

Example 15 with RecordAction

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();
            }
        }
    });
}
Also used : EditText(android.widget.EditText) ListView(android.widget.ListView) Adapter_Javascript(de.baumann.browser.View.Adapter_Javascript) Button(android.widget.Button) Adapter_Javascript(de.baumann.browser.View.Adapter_Javascript) Javascript(de.baumann.browser.Browser.Javascript) RecordAction(de.baumann.browser.Database.RecordAction) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView) Toolbar(android.support.v7.widget.Toolbar)

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