Search in sources :

Example 6 with Record

use of de.baumann.browser.Database.Record 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 7 with Record

use of de.baumann.browser.Database.Record in project browser by scoute-dich.

the class Adapter_Record method getView.

@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    Holder holder;
    View view = convertView;
    if (view == null) {
        view = LayoutInflater.from(context).inflate(layoutResId, parent, false);
        holder = new Holder();
        holder.title = view.findViewById(R.id.record_item_title);
        holder.time = view.findViewById(R.id.record_item_time);
        holder.url = view.findViewById(R.id.record_item_url);
        view.setTag(holder);
    } else {
        holder = (Holder) view.getTag();
    }
    Record record = list.get(position);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
    holder.title.setText(record.getTitle());
    holder.time.setText(sdf.format(record.getTime()));
    holder.url.setText(record.getURL());
    return view;
}
Also used : Record(de.baumann.browser.Database.Record) TextView(android.widget.TextView) View(android.view.View) SimpleDateFormat(java.text.SimpleDateFormat) NonNull(android.support.annotation.NonNull)

Example 8 with Record

use of de.baumann.browser.Database.Record in project browser by scoute-dich.

the class CompleteAdapter method deDup.

private void deDup(List<Record> recordList) {
    for (Record record : recordList) {
        if (record.getTitle() != null && !record.getTitle().isEmpty() && record.getURL() != null && !record.getURL().isEmpty()) {
            originalList.add(new CompleteItem(record.getTitle(), record.getURL()));
        }
    }
    Set<CompleteItem> set = new HashSet<>(originalList);
    originalList.clear();
    originalList.addAll(set);
}
Also used : Record(de.baumann.browser.Database.Record) HashSet(java.util.HashSet)

Example 9 with Record

use of de.baumann.browser.Database.Record in project browser by scoute-dich.

the class BrowserActivity method showListMenu.

private void showListMenu(final Adapter_Record adapterRecord, final List<Record> recordList, final int location) {
    final Record record = recordList.get(location);
    bottomSheetDialog = new BottomSheetDialog(BrowserActivity.this);
    View dialogView = View.inflate(BrowserActivity.this, R.layout.dialog_menu_context, null);
    ninjaRelativeLayout = (NinjaRelativeLayout) currentAlbumController;
    tv2_menu_newTab = dialogView.findViewById(R.id.tv2_menu_newTab);
    tv2_menu_newTab.setVisibility(View.VISIBLE);
    tv2_menu_newTab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            addAlbum(getString(R.string.album_untitled), record.getURL(), false, null);
            NinjaToast.show(BrowserActivity.this, getString(R.string.toast_new_tab_successful));
            bottomSheetDialog.cancel();
        }
    });
    tv2_menu_newTab_open = dialogView.findViewById(R.id.tv2_menu_newTab_open);
    tv2_menu_newTab_open.setVisibility(View.VISIBLE);
    tv2_menu_newTab_open.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pinAlbums(record.getURL());
            bottomSheetDialog.cancel();
        }
    });
    tv2_menu_delete = dialogView.findViewById(R.id.tv2_menu_delete);
    tv2_menu_delete.setVisibility(View.VISIBLE);
    tv2_menu_delete.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            bottomSheetDialog.cancel();
            bottomSheetDialog = new BottomSheetDialog(BrowserActivity.this);
            View dialogView = View.inflate(BrowserActivity.this, R.layout.dialog_action, null);
            TextView textView = dialogView.findViewById(R.id.dialog_text);
            textView.setText(R.string.toast_titleConfirm_delete);
            Button action_ok = dialogView.findViewById(R.id.action_ok);
            action_ok.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    RecordAction action = new RecordAction(BrowserActivity.this);
                    action.open(true);
                    if (currentAlbumController.getFlag() == BrowserUnit.FLAG_BOOKMARKS) {
                        action.deleteBookmark(record);
                    } else if (currentAlbumController.getFlag() == BrowserUnit.FLAG_HISTORY) {
                        action.deleteHistory(record);
                    }
                    action.close();
                    recordList.remove(location);
                    adapterRecord.notifyDataSetChanged();
                    updateBookmarks();
                    updateAutoComplete();
                    bottomSheetDialog.cancel();
                    NinjaToast.show(BrowserActivity.this, getString(R.string.toast_delete_successful));
                }
            });
            Button action_cancel = dialogView.findViewById(R.id.action_cancel);
            action_cancel.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    bottomSheetDialog.cancel();
                }
            });
            bottomSheetDialog.setContentView(dialogView);
            bottomSheetDialog.show();
        }
    });
    tv2_menu_edit = dialogView.findViewById(R.id.tv2_menu_edit);
    if (ninjaRelativeLayout.getFlag() != BrowserUnit.FLAG_HISTORY) {
        tv2_menu_edit.setVisibility(View.VISIBLE);
        tv2_menu_edit.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                bottomSheetDialog.cancel();
                showEditDialog(adapterRecord, recordList, location);
            }
        });
    }
    bottomSheetDialog.setContentView(dialogView);
    bottomSheetDialog.show();
}
Also used : BottomSheetDialog(android.support.design.widget.BottomSheetDialog) FloatingActionButton(android.support.design.widget.FloatingActionButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) Record(de.baumann.browser.Database.Record) Adapter_Record(de.baumann.browser.View.Adapter_Record) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) 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)

Example 10 with Record

use of de.baumann.browser.Database.Record in project browser by scoute-dich.

the class BrowserActivity method initBHList.

private void initBHList(final NinjaRelativeLayout layout) {
    RecordAction action = new RecordAction(BrowserActivity.this);
    action.open(false);
    final List<Record> list;
    if (layout.getFlag() == BrowserUnit.FLAG_BOOKMARKS) {
        list = action.listBookmarks();
        Collections.sort(list, new Comparator<Record>() {

            @Override
            public int compare(Record first, Record second) {
                return first.getTitle().compareTo(second.getTitle());
            }
        });
    } else if (layout.getFlag() == BrowserUnit.FLAG_HISTORY) {
        list = action.listHistory();
    } else {
        list = new ArrayList<>();
    }
    action.close();
    listView = layout.findViewById(R.id.home_list);
    final Adapter_Record adapter = new Adapter_Record(BrowserActivity.this, list);
    listView.setAdapter(adapter);
    adapter.notifyDataSetChanged();
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            updateAlbum(list.get(position).getURL());
        }
    });
    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            showListMenu(adapter, list, position);
            return true;
        }
    });
}
Also used : Adapter_Record(de.baumann.browser.View.Adapter_Record) ArrayList(java.util.ArrayList) 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) RecordAction(de.baumann.browser.Database.RecordAction) Record(de.baumann.browser.Database.Record) Adapter_Record(de.baumann.browser.View.Adapter_Record) AdapterView(android.widget.AdapterView)

Aggregations

Record (de.baumann.browser.Database.Record)12 RecordAction (de.baumann.browser.Database.RecordAction)8 View (android.view.View)6 TextView (android.widget.TextView)6 WebView (android.webkit.WebView)5 AdapterView (android.widget.AdapterView)5 AutoCompleteTextView (android.widget.AutoCompleteTextView)5 HorizontalScrollView (android.widget.HorizontalScrollView)5 ImageView (android.widget.ImageView)5 ListView (android.widget.ListView)5 VideoView (android.widget.VideoView)5 Adapter_Record (de.baumann.browser.View.Adapter_Record)5 NinjaWebView (de.baumann.browser.View.NinjaWebView)5 DynamicGridView (org.askerov.dynamicgrid.DynamicGridView)5 Paint (android.graphics.Paint)4 Intent (android.content.Intent)3 DialogInterface (android.content.DialogInterface)2 AlertDialog (android.support.v7.app.AlertDialog)2 EditText (android.widget.EditText)2 File (java.io.File)2