-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve sorting functionality of Track folders / Tracks #21310
Open
nazar-kutz
wants to merge
17
commits into
r4.9
Choose a base branch
from
fix_19634_reopen_v2
base: r4.9
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+610
−402
Conversation
This file contains 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
nazar-kutz
changed the title
Use TracksComparator to sort TrackTab instances
Improve sorting functionality of Track folders / Tracks
Nov 19, 2024
# Conflicts: # OsmAnd/src/net/osmand/plus/myplaces/tracks/dialogs/BaseTrackFolderFragment.java
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.
Summary of Changes and Future Considerations
1. Unified Interfaces
Implemented shared interfaces TracksGroup and ComparableTracksGroup for:
TrackTab
,TracksFolder
,SmartFolder
.Added a
getId()
method to TracksGroup, returning:TrackFolder
: Relative path (e.g., "A/B/C" for "tracks/A/B/C"). Relative path doesn't include global tracks root folder ("tracks" in Adnroid, "GPX" in iOS).SmartFolder
: Prefixed name, e.g., for "test" folder name, id is "SMART_FOLDER___test". The prefixe "SMART_FOLDERS___" is used to determine whether a given id belongs to a smart folder or not.TrackTab
: Replaces previously implemented method getTypeName() on getId() to return folder/smart folder ID or type name (ON_MAP
,ALL
,FOLDERS
).2. Enhanced TrackFolder Functionality
getRootFolder()
returns root folder ("tracks" for Android, "GPX" for iOS).Updated
getDirName()
to support an extended name format (useExtendedName
parameter):TrackFolder
: Returns relative path.SmartFolder
: Unaffected by parameter.TrackTab
: Includes parent folder if not root.3. Optimized PreselectedTabParams
Replaced name with id field and removed redundant code for parsing
SmartFolder
IDs.4. Refactored TrackTabsHelper
Created
SelectTrackTabsHelper
subclass for logic specific toSelectTrackTabsFragment
.5. TrackFolder ID Methodology
Replaced usage of folder name as ID with the getId() method that will return a relative path to the folder from the root folder ("tracks" for Android, "GPX" for "iOS"). Also fixed relative path retrieving to always exclude root folder name. It meens that previously for root folder
getRelativePath()
returned a string "tracks". Now it returns an empty string "". It was implemented because of different names of root tracks forlder for Android and iOS for implementing consistency between these platforms.6. TrackSortModesCollection Wrapper
Implemented a new class
TrackSortModesCollection
. It centralized sort mode management:askUpgradeCachedKeys
during runtime. We try to update the keys each time we requestTrackSortModesCollection
fromOsmandSettings
. To ensure the keys are updated correctly, access to allTrackFolders
is required. This means that at the time of the update, all track folders must be loaded usingTrackFolderLoaderTask
. The key upgrade to the new version occurs only once per application session. This is done to avoid redundant operations, as all cached keys are updated during the first run, and new keys are immediately added in the form of a relative path.7. Improved TrackTab sorting functionality
TrackFolderAnalysis
. Currently without recalculating on tracks changes, such as moving track to another folder or remove it.8. Sorting Logic depends on context
Sorting is applied differently depending on the context:
My Places
→Tracks
screenConfigure Map
→Tracks
(tabs and bottom sheet)ON_MAP
andALL
), followed by sorted smart folders and regular folders.To account for tab type during sorting, the
ComparableTracksGroup
class introduces thegetDefaultOrder()
method:TrackTab
and returns the index of the tab type viaTrackTabType.ordinal()
.Suggestions for iOS
Unifying sort modes handling across Android and iOS
To ensure better compatibility between Android and iOS, consider implementing functionality similar to
TrackSortModesCollection
. While it doesn’t have to be an identical bundle, the following should be ensured:folder name
tofolder path
as implemented in methodaskUpgradeKeysWithSync
.This will help maintain consistency across Android and iOS implementations, improving support for shared features.
Updating the getRelativePath method for TrackFolder
The getRelativePath method in
TrackFolder
has been modified to no longer return "GPX" as the relative path for the root folder. This change ensures key consistency between Android and iOS.However, on iOS, it is necessary to verify whether this update disrupts existing logic. Other settings might have used the path as a key, and if so, they should be adjusted accordingly.
Replacing getRelativePath with getId
It is recommended to replace all calls to getRelativePath() with
getId()
for TrackFolder. Although both methods currently return the same value, using getId explicitly makes the code clearer and better reflects its purpose.