Skip to content

Conversation

shubham7109
Copy link
Collaborator

@shubham7109 shubham7109 commented Jul 7, 2025

Related to issue: #6117

Description:

PR to fix the issue of a valid OfflineMapInfo item persists with no areas.

Feel free to test using the demo app branch.

Summary of changes:

With the changes made in this PR when component is launched in offline mode, we have a valid portalItem which is required for the removeOfflineMapInfo when we remove downloaded map area for preplanned or on-demand state. This worked for online mode previously as we have a valid portalItem, and this PR provides one for offline mode:

internal fun removeDownloadedMapArea(shouldRemoveOfflineMapInfo: () -> Boolean) {
    if (OfflineRepository.deleteContentsForDirectory(mobileMapPackage.path)) {
        Log.d(TAG, "Deleted preplanned map area: ${mobileMapPackage.path}")
        // Reset the status to reflect the deletion
        _status = PreplannedStatus.NotLoaded
        if (shouldRemoveOfflineMapInfo()) {
            OfflineRepository.removeOfflineMapInfo(
                context = context,
                portalItemID = item.itemId
            )
        }
        val localScope = CoroutineScope(Dispatchers.IO)
        localScope.launch {
            initialize()
            localScope.cancel()
        }
    } else {
        Log.e(TAG, "Failed to delete preplanned map area: ${mobileMapPackage.path}")
    }
}

Pre-merge Checklist

@shubham7109 shubham7109 self-assigned this Jul 7, 2025
@shubham7109 shubham7109 marked this pull request as ready for review July 7, 2025 22:23
@shubham7109 shubham7109 requested a review from puneet-pdx July 7, 2025 22:24
@shubham7109 shubham7109 merged commit 41ed570 into feature-branches/offline-map-areas Jul 8, 2025
@shubham7109 shubham7109 deleted the shubham/offline-map-info-bug-fix branch July 8, 2025 18:46
shubham7109 added a commit that referenced this pull request Jul 11, 2025
* Create offline toolkit module & microapp (#835)

* Changes to initialize preplanned map area (#843)

* Changes to initialize preplanned map area

* update apiDump file

* add newline and copyright header

* remove initializer for modifier

* address code review comments

* remove spacer

* Enhance preplanned area list (#846)

* Changes to enhance the preplanned map areas list

* Add preplanned areas state, offlineMapInfo

* add newline
add strings.xml to t9nmanifest.txt

* update api file
remove composableSingletons

* address code review comments

* Add Workmanager to OfflineMapAreas (#844)

* Wire workmanager with UI (#849)

* Add backing properties (#850)

* Add backing properties

* remove commented code

* remove unused imports

* Add WorkManagerRepository (#851)

* WIP

* pair programming progress

* clean up app code

* Make parent directory if absent

* more pair programming progress

* Monday refactor work, updated workmanager to observe UUID, updated OfflineMapState to initialize with Context, changed microapp to use ViewModel

* add newline and TODO

* add portalItemId of the webmap's portalItem to the file download path

---------

Co-authored-by: Shubham Sharma <shubhamsharma@esri.com>

* OfflineMapAreas: Doc rework (#852)

* Add fix so that we always run the workManagerRepository funs in viewModel scope (#856)

* Add fix so that we always run the workManagerRepository fun in the viewModel scope
so the long running collect operations survive orientation changes

* update api file
remove unused code

* address code review comments

* update api file

* removed unused import

* Update feature branch with latest v.next changes (#864)

* Add additional functionality (#859)

* Add fix so that we always run the workManagerRepository fun in the viewModel scope
so the long running collect operations survive orientation changes

* update api file
remove unused code

* WIP

* WIP

* some clean up and added currently open message

* remove unused fun
update api file

* update api file

* remove unused import

* address code review comments

* revert notification changes

* move WorkManagerRepository to workmanager package

* Switch between online and offline map (#865)

* Add fix so that we always run the workManagerRepository fun in the viewModel scope
so the long running collect operations survive orientation changes

* update api file
remove unused code

* WIP

* WIP

* some clean up and added currently open message

* remove unused fun
update api file

* update api file

* remove unused import

* Add changes to toggle between online and offline map

* remove unused code

* refactor onSelectionChangedListerner name in PreplannedMapAreaState

* Notification cancel fix (#866)

* Offline map info (#870)

* OfflineMapInfo patch changes & cleanup (#876)

* Add MapAreaDetails screen (#875)

* WIP

* WIP

* Changes to show map area details in a modal bottomsheet

* copy info file only if it exists in the pending directory

* add scroll to bottomsheet
add logic to delete offlinemapinfo along with the last map area to be deleted

* refactor MapAreaDetailsScreen

* add newline

* update build.gradle to omit composableSingleton for MapAreaDetailsScreen

* cancel scope after initialization

* Add remove download methods to OfflineRepository
rename delete download button Text

* update offlineMapInfos

* address code review comments

* address code review comments

* apply feedback

* Changes to make OfflineRepository Singleton, to support single instan… (#883)

* Changes to make OfflineRepository Singleton, to support single instance of OfflineMapInfos to work as a SnapShotStateList

* some clean up

* update api file

* Remove usage of ExperimentalMaterial3Api and copy ModalBottomSheet (#888)

* WIP

* clean up

* remove Experimental api usage
add style for ComponentDialog

* update build.gradle

* update offline.api

* Support map areas various fail reasons and errors (#885)

* Enhance OfflineMapAreas microapp (#893)

* Add sheetGesturesEnabled (#894)

Add Modifications to copyright

* Init on demand map areas selector screen (#895)

* Init OnDemand map areas screen (#900)

* refactor common code

* WIP

* add newline

* update build.gradle

* address code review comments

* Level of detail (#902)

* Add functionality to OnDemand (#904)

* Support in-progress download restoration (#907)

* Offline Map Areas: Cleanup changes.  (#913)

* Add bug fix (#924)

* update check to determine if the device is offline (#925)

* update check to determine if the device is offline

* update logic

* address code review feedback

* update micro app
upate offlineMapState

* Offline API ref documentation (#929)

* Update feature branch using v.next (#933)

* Revert "Update feature branch using v.next (#933)" (#938)

This reverts commit f332467.

* Resolve merge by removing duplicate singleVariant

---------

Co-authored-by: Puneet Prakash <puneet_prakash@esri.com>
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