Skip to content

Claude/implement multi tabs 011 cu jxn b7 pw bui7k ptdg9zv#7

Merged
oyvindbso merged 8 commits intomainfrom
claude/implement-multi-tabs-011CUJxnB7PWBui7kPTDG9zv
Oct 22, 2025
Merged

Claude/implement multi tabs 011 cu jxn b7 pw bui7k ptdg9zv#7
oyvindbso merged 8 commits intomainfrom
claude/implement-multi-tabs-011CUJxnB7PWBui7kPTDG9zv

Conversation

@oyvindbso
Copy link
Copy Markdown
Owner

Claude tabs implementation

This update adds support for multiple tabs in the app, allowing users to
have different collections open simultaneously and switch between them.

Key changes:
- Created CollectionFragment: Extracted collection viewing logic from
  MainActivity into a reusable fragment that can be displayed in tabs
- Created TabStateManager: Manages tab state persistence using
  SharedPreferences with support for up to 10 tabs
- Created CollectionTabAdapter: ViewPager2 adapter for managing
  collection fragments across tabs
- Refactored MainActivity: Now acts as a tab container managing
  TabLayout and ViewPager2 instead of directly displaying collections
- Updated activity_main.xml: Replaced RecyclerView with TabLayout,
  ViewPager2, and FloatingActionButton for tab management
- Added fragment_collection.xml: Layout for individual collection tabs
- Enhanced EpubCoverRepository: Added getFilteredCoversForCollection()
  method to support filtering covers by specific collection keys
- Updated build.gradle: Added ViewPager2 dependency

Features:
- Users can open multiple collections in separate tabs
- Tabs persist across app restarts
- Long-press on tabs to close them (minimum 1 tab required)
- FAB button to add new tabs by selecting collections
- Swipe between tabs with native Android gestures
- Each tab maintains its own state independently

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixed critical initialization bug where tabs weren't set up if credentials
were missing on first launch. This caused the app to show a blank screen
after users added their credentials.

Changes:
- Move setupTabs() and setupFab() before credential check in onCreate
- Remove early return that prevented tab initialization
- Add isFirstResume flag to avoid unnecessary refreshes on initial load
- Improve refreshCurrentTab() with null checks and ViewPager2 lifecycle awareness
- Add refresh in onResume to reload data when returning from settings

This ensures tabs are always initialized and fragments can handle the
"no credentials" state gracefully, then automatically refresh when
credentials become available.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added sorting feature that allows users to sort book covers by title or
author. The sort button in the menu now displays a dialog where users can
choose their preferred sort order.

Changes:
- Added action_sort case handler in MainActivity.onOptionsItemSelected()
- Created showSortDialog() method to display sort options dialog
- Created applySortingToCurrentTab() method to apply sorting to active tab
- Added applySorting() method in CollectionFragment to sort and refresh items
- Modified updateUI() in CollectionFragment to automatically apply current
  sort mode when loading covers
- Utilizes existing CoverSorter class for title and author-based sorting
- Sort preference is persisted via UserPreferences

Features:
- Sort by Title (default) - alphabetical with smart article handling
- Sort by Author - sorts by first author's last name
- Sort setting persists across app sessions
- Instant visual feedback with toast notification
- Sorts current tab when user changes preference

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added comprehensive tag filtering functionality that allows users to
create tabs filtered by Zotero tags. Users can now filter items by
tags, collections, or a combination of both.

Key changes:
- Updated TabStateManager.TabInfo to support tags in addition to
  collections with three tab types: collection-only, tag-only, or both
- Added getDisplayName() method to show appropriate tab titles based
  on filter type (e.g., "Tags: fiction; history")
- Extended ZoteroApiClient API methods to accept tag query parameters
  for filtering Zotero API requests
- Modified getAllEbookItemsWithMetadata and related methods to support
  tag-based filtering via Zotero API
- Updated CollectionFragment to handle tag filtering in addition to
  collection filtering
- Modified CollectionTabAdapter to pass tags to fragment instances
- Enhanced MainActivity with tag input dialog allowing semicolon-
  separated tag entry
- Updated FAB to show "Add New Tab" dialog with options: "By Collection"
  or "By Tags"
- Updated all tab display names to use getDisplayName() for consistent
  labeling

Features:
- Create tabs filtered by tags only
- Create tabs filtered by collection + tags
- Multiple tags supported (semicolon-separated)
- Tab titles clearly indicate filter type
- Tags persist across app restarts
- Zotero API filters items matching all specified tags

Users can now:
1. Click FAB → "By Tags" → Enter "fiction; sci-fi" → See only books
   with both tags
2. Create multiple tag-based tabs alongside collection tabs
3. Mix and match filtering approaches as needed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixed critical issues with tag filtering and enhanced functionality:

1. Fixed Tags API Integration:
   - Changed tag parameter from String to List<String> in ZoteroService
   - Added parseTagsToList() helper to convert semicolon-separated tags
   - Zotero API now receives multiple tag parameters for proper AND logic
   - Tags are properly split and trimmed before API calls

2. Fixed Tab Text Case Sensitivity:
   - Added TabTextStyle with textAllCaps=false to themes.xml
   - Applied style to TabLayout in activity_main.xml
   - Tab titles now preserve original case (e.g., "fiction" not "FICTION")
   - Critical for matching case-sensitive Zotero tags

3. Added Collection + Tags Combined Filtering:
   - New third option in Add Tab dialog: "By Collection + Tags"
   - Two-step flow: Enter tags first, then select collection
   - Added REQUEST_CODE_SELECT_COLLECTION_WITH_TAGS constant
   - Added pendingTags field to store tags between dialogs
   - Enhanced onActivityResult to handle combined filtering
   - Tab displays as: "Collection Name [tag1; tag2]"

Features now available:
- Filter by tags only: Enter "fiction; sci-fi" → See all matching items
- Filter by collection only: Select a collection
- Filter by both: Enter tags, then select collection → See only items
  in that collection matching ALL tags

Bug fixes:
- Tags now work correctly with Zotero API
- Tab names preserve case for readability
- Multiple tags properly combined with AND logic

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Improved tag filtering with better error handling and separated API methods:

Changes:
- Split Retrofit API methods into separate versions with/without tags
  to prevent passing null/empty tag parameters to Zotero API
- Added getItemsPaginatedWithTags() for tag-filtered requests
- Added getItemsByCollectionPaginatedWithTags() for combined filtering
- Conditional API method selection based on whether tags are present
- Enhanced error logging to show actual Zotero API error responses
- Added detailed logging of tag parsing and API URLs for debugging
- Improved error messages shown to users with actual error content

The separate API methods ensure clean URL generation:
- Without tags: /users/{id}/items?format=json&itemType=attachment
- With tags: /users/{id}/items?format=json&itemType=attachment&tag=fiction&tag=sci-fi

This prevents Retrofit from adding tag=null which could cause API errors.

Debugging improvements:
- Log shows parsed tag list before API call
- Log shows complete API request URL
- Error messages now include HTTP response body from Zotero
- Better error context for troubleshooting tag issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit addresses the issue where tag filtering errors were impossible
to read because they appeared on top of book covers. It also adds detailed
diagnostic information to help troubleshoot tag filtering issues.

Changes:
- Created DiagnosticInfo.java to track API call details
- Modified CollectionFragment to show errors in AlertDialog instead of TextView
- Added "Show Diagnostics" button in error dialogs when using tags
- Diagnostics include:
  - API URL being called
  - Tags and collection being filtered
  - HTTP response codes
  - Number of items received and filtered
  - Helpful suggestions for why tags might not match
- Added ability to copy diagnostics to clipboard for bug reporting
- Improved empty results handling with specific guidance for tag issues
- Construct approximate API URL for diagnostic display

Users can now clearly see error messages and understand why tag filtering
might not be working (case sensitivity, non-existent tags, etc.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@oyvindbso oyvindbso merged commit 4574c86 into main Oct 22, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants