-
Notifications
You must be signed in to change notification settings - Fork 540
Offline manager #286
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
Offline manager #286
Conversation
At the moment I am using |
private void launchDownload(String regName) { | ||
// Set up an observer to handle download progress and | ||
// notify the user when the region is finished downloading | ||
final NotificationCompat.Builder downloadNotification = new NotificationCompat.Builder(context, CHANNEL_1_ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best to expose at least notification title into Flutter, so that users of the library have control over that. Example usage would be to have localized titles, for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, users of the library would probably want to have their own icon on the download notification
https://docs.mapbox.com/accounts/overview/pricing/#adjust-the-tile-limit-per-user |
}); | ||
|
||
setStyleString(styleStringInitial); | ||
mapboxOfflineManager = new MapboxOfflineManager(context,this.mapboxMap,registrar); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know exactly the details, but is this map controller destroyed on rotation?
Would this mean that MapboxOfflineManager
will also be destroyed with all it's callbacks inside loosing the download state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not destroyed, but it would be preferable to be able to download regions independent from any maps. For example, a dev might want to always download a certain city the first time a "local guide" app is launched.
|
||
@Override | ||
public void onError(OfflineRegionError error) { | ||
Log.d(TAG,"error: "+error.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a way to listen on download state from the flutter side?
if let channel = channel { | ||
channel.invokeMethod("map#onStyleLoaded", arguments: nil) | ||
} | ||
_ = OfflineManager(mapview:mapView,registrar: registrar) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as on Android. What would happen with OfflineManager instance on rotation and calls?
ios/Classes/OfflineManager.swift
Outdated
func deleteRegion(index:Int){ | ||
var result :[AnyObject] = [] | ||
if let offlinePacks = MGLOfflineStorage.shared.packs { | ||
// let allPacks = offlinePacks[index] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably can be removed
@hafiz703 Thank you a lot for contributing this important feature!
Also feel free to let me know if you'd like me to help out with this, as it's not an easy feature! |
Thanks for the review @m0nac0 @AAverin. I will work on providing the callback to flutter, removing unnecessary file commits and also expose the method for tile limits. As for handling the downloading in GlobalMethodHandler, would it be possible for @maximumbuster to merge this later on? |
when will this feature get live into master we required it for our app please merge this commit as soon as possible |
Hi, I have refactored the codes for the offlineManager into MapboxController, exposed download progress and setting of tile limits in dart/flutter. As for the download of offline tiles independent of maps, it probably could be a future PR but I think this is a good starting point. |
@hafiz703 I'm really sorry about this, but I wanted to give a heads up that @kleeb and you seem to have worked on this feature in parallel, unfortunately. After taking a closer look at both, at this time #336 is closer to being merged IMHO. (I don't want to anticipate the review or anyone else's opinion, just letting you know so you can evaluate if you want to put more effort into this.) |
Please approve this, :(, its really necessary |
Apologies for the duplicated work but we are moving forward with #366. I do really appreciate the time and effort put into moving this project further! |
With reference to #88 , I have implemented the following,
The implementations are localised in MapboxOfflineManager.java and OfflineManager.swift respectively.
Areas to improve:
Download progress bar currently done natively (UIProgressView in ios and Notification Progress in android) can be implemented in flutter
Once download has started, another concurrent download should be prevented,