Search in sources :

Example 1 with STARTSITE_ITEM

use of de.baumann.browser.database.RecordAction.STARTSITE_ITEM in project browser by scoute-dich.

the class BrowserActivity method initOverview.

// Views
@SuppressLint("ClickableViewAccessibility")
private void initOverview() {
    bottomSheetDialog_OverView = findViewById(R.id.bottomSheetDialog_OverView);
    ListView listView = bottomSheetDialog_OverView.findViewById(R.id.list_overView);
    tab_container = bottomSheetDialog_OverView.findViewById(R.id.listOpenedTabs);
    AtomicInteger intPage = new AtomicInteger();
    NavigationBarView.OnItemSelectedListener navListener = menuItem -> {
        if (menuItem.getItemId() == R.id.page_1) {
            tab_container.setVisibility(View.GONE);
            listView.setVisibility(View.VISIBLE);
            omniBox_overview.setImageResource(R.drawable.icon_web);
            overViewTab = getString(R.string.album_title_home);
            intPage.set(R.id.page_1);
            RecordAction action = new RecordAction(context);
            action.open(false);
            final List<Record> list = action.listStartSite(activity);
            action.close();
            adapter = new AdapterRecord(context, list);
            listView.setAdapter(adapter);
            adapter.notifyDataSetChanged();
            listView.setOnItemClickListener((parent, view, position, id) -> {
                if (list.get(position).getType() == BOOKMARK_ITEM || list.get(position).getType() == STARTSITE_ITEM) {
                    if (list.get(position).getDesktopMode() != ninjaWebView.isDesktopMode())
                        ninjaWebView.toggleDesktopMode(false);
                    if (list.get(position).getNightMode() == ninjaWebView.isNightMode() && !isNightMode) {
                        ninjaWebView.toggleNightMode();
                        isNightMode = ninjaWebView.isNightMode();
                    }
                }
                ninjaWebView.loadUrl(list.get(position).getURL());
                hideOverview();
            });
            listView.setOnItemLongClickListener((parent, view, position, id) -> {
                showContextMenuList(list.get(position).getTitle(), list.get(position).getURL(), adapter, list, position);
                return true;
            });
        } else if (menuItem.getItemId() == R.id.page_2) {
            tab_container.setVisibility(View.GONE);
            listView.setVisibility(View.VISIBLE);
            omniBox_overview.setImageResource(R.drawable.icon_bookmark);
            overViewTab = getString(R.string.album_title_bookmarks);
            intPage.set(R.id.page_2);
            RecordAction action = new RecordAction(context);
            action.open(false);
            final List<Record> list;
            list = action.listBookmark(activity, filter, filterBy);
            action.close();
            adapter = new AdapterRecord(context, list);
            listView.setAdapter(adapter);
            adapter.notifyDataSetChanged();
            filter = false;
            listView.setOnItemClickListener((parent, view, position, id) -> {
                if (list.get(position).getType() == BOOKMARK_ITEM || list.get(position).getType() == STARTSITE_ITEM) {
                    if (list.get(position).getDesktopMode() != ninjaWebView.isDesktopMode())
                        ninjaWebView.toggleDesktopMode(false);
                    if (list.get(position).getNightMode() == ninjaWebView.isNightMode() && !isNightMode) {
                        ninjaWebView.toggleNightMode();
                        isNightMode = ninjaWebView.isNightMode();
                    }
                }
                ninjaWebView.loadUrl(list.get(position).getURL());
                hideOverview();
            });
            listView.setOnItemLongClickListener((parent, view, position, id) -> {
                showContextMenuList(list.get(position).getTitle(), list.get(position).getURL(), adapter, list, position);
                return true;
            });
        } else if (menuItem.getItemId() == R.id.page_3) {
            tab_container.setVisibility(View.GONE);
            listView.setVisibility(View.VISIBLE);
            omniBox_overview.setImageResource(R.drawable.icon_history);
            overViewTab = getString(R.string.album_title_history);
            intPage.set(R.id.page_3);
            RecordAction action = new RecordAction(context);
            action.open(false);
            final List<Record> list;
            list = action.listHistory();
            action.close();
            // noinspection NullableProblems
            adapter = new AdapterRecord(context, list) {

                @Override
                public View getView(int position, View convertView, @NonNull ViewGroup parent) {
                    View v = super.getView(position, convertView, parent);
                    TextView record_item_time = v.findViewById(R.id.dateView);
                    record_item_time.setVisibility(View.VISIBLE);
                    TextView record_item_title = v.findViewById(R.id.titleView);
                    record_item_title.setPadding(0, 0, 150, 0);
                    return v;
                }
            };
            listView.setAdapter(adapter);
            adapter.notifyDataSetChanged();
            listView.setOnItemClickListener((parent, view, position, id) -> {
                if (list.get(position).getType() == BOOKMARK_ITEM || list.get(position).getType() == STARTSITE_ITEM) {
                    if (list.get(position).getDesktopMode() != ninjaWebView.isDesktopMode())
                        ninjaWebView.toggleDesktopMode(false);
                    if (list.get(position).getNightMode() == ninjaWebView.isNightMode() && !isNightMode) {
                        ninjaWebView.toggleNightMode();
                        isNightMode = ninjaWebView.isNightMode();
                    }
                }
                ninjaWebView.loadUrl(list.get(position).getURL());
                hideOverview();
            });
            listView.setOnItemLongClickListener((parent, view, position, id) -> {
                showContextMenuList(list.get(position).getTitle(), list.get(position).getURL(), adapter, list, position);
                return true;
            });
        } else if (menuItem.getItemId() == R.id.page_4) {
            PopupMenu popup = new PopupMenu(this, bottom_navigation.findViewById(R.id.page_2));
            if (bottom_navigation.getSelectedItemId() == R.id.page_1)
                popup.inflate(R.menu.menu_list_start);
            else if (bottom_navigation.getSelectedItemId() == R.id.page_2)
                popup.inflate(R.menu.menu_list_bookmark);
            else if (bottom_navigation.getSelectedItemId() == R.id.page_3)
                popup.inflate(R.menu.menu_list_history);
            else if (bottom_navigation.getSelectedItemId() == R.id.page_0)
                popup.inflate(R.menu.menu_list_tabs);
            popup.setOnMenuItemClickListener(item -> {
                if (item.getItemId() == R.id.menu_delete) {
                    MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
                    builder.setIcon(R.drawable.icon_alert);
                    builder.setTitle(R.string.menu_delete);
                    builder.setMessage(R.string.hint_database);
                    builder.setPositiveButton(R.string.app_ok, (dialog, whichButton) -> {
                        if (overViewTab.equals(getString(R.string.album_title_home))) {
                            BrowserUnit.clearHome(context);
                            bottom_navigation.setSelectedItemId(R.id.page_1);
                        } else if (overViewTab.equals(getString(R.string.album_title_bookmarks))) {
                            BrowserUnit.clearBookmark(context);
                            bottom_navigation.setSelectedItemId(R.id.page_2);
                        } else if (overViewTab.equals(getString(R.string.album_title_history))) {
                            BrowserUnit.clearHistory(context);
                            bottom_navigation.setSelectedItemId(R.id.page_3);
                        }
                    });
                    builder.setNegativeButton(R.string.app_cancel, (dialog, whichButton) -> dialog.cancel());
                    AlertDialog dialog = builder.create();
                    dialog.show();
                    HelperUnit.setupDialog(context, dialog);
                } else if (item.getItemId() == R.id.menu_sortName) {
                    if (overViewTab.equals(getString(R.string.album_title_bookmarks))) {
                        sp.edit().putString("sort_bookmark", "title").apply();
                        bottom_navigation.setSelectedItemId(R.id.page_2);
                    } else if (overViewTab.equals(getString(R.string.album_title_home))) {
                        sp.edit().putString("sort_startSite", "title").apply();
                        bottom_navigation.setSelectedItemId(R.id.page_1);
                    }
                } else if (item.getItemId() == R.id.menu_sortIcon) {
                    sp.edit().putString("sort_bookmark", "time").apply();
                    bottom_navigation.setSelectedItemId(R.id.page_2);
                } else if (item.getItemId() == R.id.menu_sortDate) {
                    sp.edit().putString("sort_startSite", "ordinal").apply();
                    bottom_navigation.setSelectedItemId(R.id.page_1);
                } else if (item.getItemId() == R.id.menu_filter) {
                    showDialogFilter();
                } else if (item.getItemId() == R.id.menu_help) {
                    Uri webpage = Uri.parse("https://github.com/scoute-dich/browser/wiki/Overview");
                    BrowserUnit.intentURL(this, webpage);
                }
                return true;
            });
            popup.show();
            popup.setOnDismissListener(v -> {
                if (intPage.intValue() == R.id.page_1)
                    bottom_navigation.setSelectedItemId(R.id.page_1);
                else if (intPage.intValue() == R.id.page_2)
                    bottom_navigation.setSelectedItemId(R.id.page_2);
                else if (intPage.intValue() == R.id.page_3)
                    bottom_navigation.setSelectedItemId(R.id.page_3);
                else if (intPage.intValue() == R.id.page_0)
                    bottom_navigation.setSelectedItemId(R.id.page_0);
            });
        } else if (menuItem.getItemId() == R.id.page_0) {
            intPage.set(R.id.page_0);
            tab_container.setVisibility(View.VISIBLE);
            listView.setVisibility(View.GONE);
        }
        return true;
    };
    bottom_navigation = bottomSheetDialog_OverView.findViewById(R.id.bottom_navigation);
    bottom_navigation.setOnItemSelectedListener(navListener);
    bottom_navigation.findViewById(R.id.page_2).setOnLongClickListener(v -> {
        showDialogFilter();
        return true;
    });
    setSelectedTab();
}
Also used : Chip(com.google.android.material.chip.Chip) Arrays(java.util.Arrays) Bundle(android.os.Bundle) PrintManager(android.print.PrintManager) List_trusted(de.baumann.browser.browser.List_trusted) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) PrintAttributes(android.print.PrintAttributes) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) BadgeDrawable(com.google.android.material.badge.BadgeDrawable) AdapterRecord(de.baumann.browser.view.AdapterRecord) Manifest(android.Manifest) SRC_ANCHOR_TYPE(android.webkit.WebView.HitTestResult.SRC_ANCHOR_TYPE) Handler(android.os.Handler) ClipboardManager(android.content.ClipboardManager) DataURIParser(de.baumann.browser.browser.DataURIParser) ContextCompat(androidx.core.content.ContextCompat) Log(android.util.Log) HelperUnit(de.baumann.browser.unit.HelperUnit) CardView(androidx.cardview.widget.CardView) GridAdapter(de.baumann.browser.view.GridAdapter) BottomAppBar(com.google.android.material.bottomappbar.BottomAppBar) IMAGE_TYPE(android.webkit.WebView.HitTestResult.IMAGE_TYPE) LinearProgressIndicator(com.google.android.material.progressindicator.LinearProgressIndicator) IntentFilter(android.content.IntentFilter) WindowInsetsController(android.view.WindowInsetsController) FaviconHelper(de.baumann.browser.database.FaviconHelper) Message(android.os.Message) PrintDocumentAdapter(android.print.PrintDocumentAdapter) TextWatcher(android.text.TextWatcher) MaterialCardView(com.google.android.material.card.MaterialCardView) TextInputLayout(com.google.android.material.textfield.TextInputLayout) Dialog(android.app.Dialog) Editable(android.text.Editable) ArrayList(java.util.ArrayList) Toast(android.widget.Toast) BrowserUnit(de.baumann.browser.unit.BrowserUnit) Record(de.baumann.browser.database.Record) TAG(android.content.ContentValues.TAG) WebChromeClient(android.webkit.WebChromeClient) ValueCallback(android.webkit.ValueCallback) KeyListener(android.text.method.KeyListener) TextUtils(android.text.TextUtils) Gravity(android.view.Gravity) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) Configuration(android.content.res.Configuration) PreferenceManager(androidx.preference.PreferenceManager) RecordUnit(de.baumann.browser.unit.RecordUnit) EditText(android.widget.EditText) ImageButton(android.widget.ImageButton) LinearLayout(android.widget.LinearLayout) GridView(android.widget.GridView) PackageManager(android.content.pm.PackageManager) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) WindowManager(android.view.WindowManager) BrowserController(de.baumann.browser.browser.BrowserController) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) View(android.view.View) WebBackForwardList(android.webkit.WebBackForwardList) Button(android.widget.Button) STARTSITE_ITEM(de.baumann.browser.database.RecordAction.STARTSITE_ITEM) WebView(android.webkit.WebView) GridItem(de.baumann.browser.view.GridItem) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) NotificationManager(android.app.NotificationManager) SRC_IMAGE_ANCHOR_TYPE(android.webkit.WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) ObjectAnimator(android.animation.ObjectAnimator) R(de.baumann.browser.R) List_protected(de.baumann.browser.browser.List_protected) WebStorage(android.webkit.WebStorage) BroadcastReceiver(android.content.BroadcastReceiver) ViewGroup(android.view.ViewGroup) DownloadManager(android.app.DownloadManager) Objects(java.util.Objects) List(java.util.List) TextView(android.widget.TextView) WindowInsets(android.view.WindowInsets) RelativeLayout(android.widget.RelativeLayout) BOOKMARK_ITEM(de.baumann.browser.database.RecordAction.BOOKMARK_ITEM) ListView(android.widget.ListView) OrientationEventListener(android.view.OrientationEventListener) BrowserContainer(de.baumann.browser.browser.BrowserContainer) SearchManager(android.app.SearchManager) Window(android.view.Window) Context(android.content.Context) ContextMenu(android.view.ContextMenu) TextInputEditText(com.google.android.material.textfield.TextInputEditText) List_standard(de.baumann.browser.browser.List_standard) KeyEvent(android.view.KeyEvent) AlertDialog(androidx.appcompat.app.AlertDialog) NinjaWebView(de.baumann.browser.view.NinjaWebView) Intent(android.content.Intent) MediaPlayer(android.media.MediaPlayer) NinjaToast(de.baumann.browser.view.NinjaToast) NavigationBarView(com.google.android.material.navigation.NavigationBarView) ClipData(android.content.ClipData) RecordAction(de.baumann.browser.database.RecordAction) SuppressLint(android.annotation.SuppressLint) SwipeTouchListener(de.baumann.browser.view.SwipeTouchListener) Build(android.os.Build) LinkedList(java.util.LinkedList) VideoView(android.widget.VideoView) BadgeUtils(com.google.android.material.badge.BadgeUtils) ActivityCompat(androidx.core.app.ActivityCompat) AlbumController(de.baumann.browser.browser.AlbumController) PopupMenu(androidx.appcompat.widget.PopupMenu) HandlerThread(android.os.HandlerThread) Bitmap(android.graphics.Bitmap) AdapterSearch(de.baumann.browser.view.AdapterSearch) Activity(android.app.Activity) Resources(android.content.res.Resources) AlertDialog(androidx.appcompat.app.AlertDialog) NavigationBarView(com.google.android.material.navigation.NavigationBarView) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) CardView(androidx.cardview.widget.CardView) MaterialCardView(com.google.android.material.card.MaterialCardView) GridView(android.widget.GridView) View(android.view.View) WebView(android.webkit.WebView) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) TextView(android.widget.TextView) ListView(android.widget.ListView) NinjaWebView(de.baumann.browser.view.NinjaWebView) NavigationBarView(com.google.android.material.navigation.NavigationBarView) VideoView(android.widget.VideoView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Uri(android.net.Uri) ListView(android.widget.ListView) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NonNull(androidx.annotation.NonNull) RecordAction(de.baumann.browser.database.RecordAction) ArrayList(java.util.ArrayList) WebBackForwardList(android.webkit.WebBackForwardList) List(java.util.List) LinkedList(java.util.LinkedList) AdapterRecord(de.baumann.browser.view.AdapterRecord) Record(de.baumann.browser.database.Record) TextView(android.widget.TextView) AdapterRecord(de.baumann.browser.view.AdapterRecord) PopupMenu(androidx.appcompat.widget.PopupMenu) SuppressLint(android.annotation.SuppressLint)

Aggregations

Manifest (android.Manifest)1 ObjectAnimator (android.animation.ObjectAnimator)1 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 Dialog (android.app.Dialog)1 DownloadManager (android.app.DownloadManager)1 NotificationManager (android.app.NotificationManager)1 SearchManager (android.app.SearchManager)1 BroadcastReceiver (android.content.BroadcastReceiver)1 ClipData (android.content.ClipData)1 ClipboardManager (android.content.ClipboardManager)1 TAG (android.content.ContentValues.TAG)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 SharedPreferences (android.content.SharedPreferences)1 PackageManager (android.content.pm.PackageManager)1 Configuration (android.content.res.Configuration)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1