Redesign shared deck download UI with Material 3#20962
Open
ColbyCabrera wants to merge 29 commits into
Open
Conversation
Replaced the legacy AppCompat `ProgressBar` with `LinearProgressIndicator` in `fragment_shared_decks_download.xml` to match modern Material Design styling. Also cleaned up minor whitespace issues.
- Added `layout_constraintWidth_max` to UI elements to improve appearance on large screens. - Changed text alignment from center to start for the title and info text. - Adjusted margins and text sizes for better visual hierarchy. - Restricted button widths to a maximum of 320dp.
Updated `fragment_shared_decks_download.xml` to use `com.google.android.material.button.MaterialButton` instead of `android.widget.Button`. - Switched to Material3 styles (`Widget.Material3.Button`, `Widget.Material3.Button.TonalButton`, `Widget.Material3.Button.TextButton`). - Replaced `android:background` with `app:backgroundTint` for custom colors. - Removed explicit padding in favor of style defaults.
- Remove hardcoded hex colors and use theme attributes - Change `cancel_download_button` style to standard `MaterialButton` - Use semantic theme colors for consistency with Material 3 guidelines
Replaced `paddingStart`/`paddingEnd` with `layout_marginStart`/`layout_marginEnd` for the title and progress message in `fragment_shared_decks_download.xml`.
Updated `fragment_shared_decks_download.xml` to use themed attributes: - Set `download_dialog_info_text` color to `?attr/colorOnSurfaceVariant` - Set `download_progress_percentage` color to `?attr/colorSecondary`
- Center-align text components and adjust margins/spacing. - Update text sizes and styles for better visual hierarchy. - Refine progress indicator thickness and corner radius. - Use theme attributes for colors (e.g., `colorError`, `colorPrimary`). - Implement vertical chaining for improved positioning.
- Redesigned `fragment_shared_decks_download.xml` using a `CircularProgressIndicator` and Material3 cards. - Implemented real-time calculation and display of download speed and estimated time remaining. - Added a `MaterialCardView` to inform users that it is safe to leave the screen during a download. - Reorganized action buttons using a `Flow` constraint helper for better adaptive positioning. - Updated button styles to use Material3 `OutlinedButton`, `TonalButton`, and standard `MaterialButton`. - Modified `SharedDecksActivity` to dynamically update the toolbar title and background when the download fragment is visible. - Added new string resources for download metrics and status labels.
Updated `fragment_shared_decks_download.xml` to set `android:importantForAccessibility="no"` on the decorative icon to improve screen reader behavior.
- Wrap content in a `NestedScrollView` to support smaller screens and landscape orientation. - Introduce a `main_content_wrapper` with `layout_constraintWidth_max="600dp"` to improve readability on large screens. - Reorganize the view hierarchy to accommodate the new scrolling and width-constrained containers. - Remove redundant `layout_constraintWidth_max` from `downloading_title` as it is now handled by the parent wrapper.
- Change `cancel_download_button` style to `Widget.Material3.Button.TonalButton`. - Use theme attributes `colorErrorContainer` for background and `colorOnErrorContainer` for text. - Set ripple color to `?attr/colorError`.
- Enable tabular figures (`fontFeatureSettings="tnum"`) for download metrics to prevent text jumping during updates. - Replace the square background with a circular background for the status icon using a new `ic_circle_background.xml` drawable. - Update UI strings to use sentence case for better consistency (e.g., "Speed", "Time left", "Import deck").
- Increase `download_percentage_text` size to 56sp for better visibility. - Add `android:accessibilityLiveRegion="polite"` to the error message text view. - Remove explicit color attributes from the import deck button to rely on theme defaults.
- Reduce the size of the '%' symbol to 60% of the base text size using `RelativeSizeSpan`. - Implement a `setPercentageText` helper function using `buildSpannedString` to apply styling. - Update progress, completion, and error states to use the new styled text formatting.
- Increase `downloading_label_text` size to 16sp and decrease letter spacing. - Remove bold weight and reduce top margin for `deck_title_text`. - Decrease bottom margin for the stats card container. - Reduce horizontal spacing between the progress and speed cards.
Removed the `downloading_file` string resource from `02-strings.xml`.
- Introduce `DownloadSpeedCalculator` using Exponential Moving Average (EMA) to smooth speed fluctuations. - Refactor `SharedDecksDownloadFragment` to delegate speed and time-left calculations to the new utility. - Remove manual byte and time tracking from the fragment. - Add unit tests for `DownloadSpeedCalculator` covering EMA logic, download stalls, and non-uniform time steps. - Improve UI feedback for zero-speed and initial measurement states.
…ment - Use string resources with placeholders for download speed and unknown states. - Replace manual time calculation and formatting with `DateUtils.formatElapsedTime`. - Use `getString()` instead of hardcoded string concatenation for speed units. - Refine logic for displaying zero or unknown download speeds. - Remove unused `java.util.Locale` import.
- Use imported `TypedValue` instead of the fully qualified name. - Remove redundant comments regarding toolbar background restoration.
Constrain the bottom of download_info_card to check_network_info_text instead of bottom_buttons_flow. This prevents the card from overlapping with the red "waiting for network" warning text when a download is paused due to a network connection loss, ensuring the card pushes up and chains vertically as intended.
- Refactored `fragment_shared_decks_download.xml` to use a continuous vertical constraint chain. - Replaced the `0dp` (match constraints) height of the progress container with `wrap_content` to prevent layout collapsing and overlapping on small screens. - Introduced vertical `Space` springs with `layout_constraintVertical_weight="1"` above and below the progress indicator to maintain perfect centering on larger screens. - These changes ensure `NestedScrollView` correctly detects when the content exceeds the viewport, allowing it to become scrollable in landscape mode or on devices with smaller heights.
- Added `android:paddingHorizontal="12dp"` to the download percentage text. - Set `android:textAlignment="center"`
- Add validation to ensure `alpha` is between 0.0 and 1.0. - Change `lastTimeChecked` to a nullable type to more accurately represent the initial state. - Update `update()` to use null-safe checks for `lastTimeChecked` instead of range comparisons. - Remove `@VisibleForTesting` annotation from `reset()` to allow for general usage.
- Update EMA test to use asymmetric alpha and verify smoothing calculations. - Expand `reset()` test to ensure speed calculation recovers correctly after a reset. - Add test case for handling duplicate timestamps via baseline rebasing. - Add test case for handling downloaded byte regressions.
- Unregister onComplete BroadcastReceiver in onDestroy() to prevent leaking both the Fragment and its parent SharedDecksActivity. - Register onBackPressedCallback in onViewCreated() to ensure the cancel confirmation dialog appears when the back button is pressed. - Properly stop the download progress checker and dismiss the cancel confirmation dialog in onDestroy() to ensure clean lifecycle teardown.
- Added a descriptive `comment` attribute to the `download_speed_unknown` resource in `02-strings.xml` to provide context for localization.
Contributor
|
Important Maintainers: This PR contains Strings changes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Assisted-by: Gemini 3.1 Pro, 3 Flash, and Opus 4.6
Purpose / Description
The purpose is to redesign the shared decks screen to be more in line with the rest of AnkiDroid's UI. It includes speed and time left cards, M3 components and a redesigned circular progress display.
Approach
The goal was to improve the 'feel' and initial impression, without changing the underlying code or logic much. David shared a concept design that I implemented, this required that I add download speed and time left logic. In my own testing I found that download speeds were very jumpy, so used a smoothing algorithm to improve this.
How Has This Been Tested?
Tested on a Pixel 9 Pro XL and verified the layout on a 10" Samsung tablet. Verified all buttons maintain previous behavior. Toggled Wi-Fi and mobile data to cause error states to appear. Tested in landscape and portrait configurations. Ran unit tests and all passed.
Checklist
Please, go through these checks before submitting the PR.