Skip to content
This repository has been archived by the owner on Nov 10, 2019. It is now read-only.

Commit

Permalink
Add popup to say to the user when a offline departures update is avai…
Browse files Browse the repository at this point in the history
…lable
  • Loading branch information
Remy Da Costa Faro committed Dec 1, 2017
1 parent ac1676e commit 54b9fb6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions tpg offline/Departures/StopsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ class StopsTableViewController: UIViewController, UITableViewDelegate, UITableVi
}
}

Alamofire.request("https://raw.githubusercontent.com/RemyDCF/tpg-offline/master/JSON/departures.json.md5").responseString { (response) in
if let updatedMD5 = response.result.value, updatedMD5 != UserDefaults.standard.string(forKey: "departures.json.md5") {
UserDefaults.standard.set(true, forKey: "offlineDeparturesUpdateAvailable")
let alertController = UIAlertController(title: "New offline departures available".localized, message: "You can download them in Settings".localized, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK".localized, style: .default, handler: nil))
self.present(alertController, animated: true, completion: nil)
}
}

if #available(iOS 10.3, *), self.askForRating {
SKStoreReviewController.requestReview()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"Mark this stop as favorite" = "Mark this stop as favorite";
"Nearest Stops" = "Nearest Stops";
"Nearest stops" = "Nearest stops";
"New offline departures available" = "New offline departures available";
"No disruptions" = "No disruptions";
"No more bus will come to this stop today." = "No more bus will come to this stop today.";
"No results" = "No results";
Expand Down Expand Up @@ -100,13 +101,15 @@
"To..." = "To...";
"Unknow" = "Unknow";
"Unmark this stop as favorite" = "Unmark this stop as favorite";
"Update available" = "Update available";
"Update departures" = "Update departures";
"Urban map" = "Urban map";
"Walk" = "Walk";
"Walk %@m" = "Walk %@m";
"When do you want to be reminded" = "When do you want to be reminded";
"When do you want to be reminded?" = "When do you want to be reminded?";
"You are using timetables departures. So departures are subjects to change." = "You are using timetables departures. So departures are subjects to change.";
"You can download them in Settings" = "You can download them in Settings";
"You can't set a timer for this bus, but you should run to take it." = "You can't set a timer for this bus, but you should run to take it.";
"You don't downloaded offline departures, and you're not connected to internet" = "You don't downloaded offline departures, and you're not connected to internet";
"You will be reminded" = "You will be reminded";
Expand Down
5 changes: 5 additions & 0 deletions tpg offline/Project Requirements/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"Mark this stop as favorite" = "Marquer cet arrêt en favoris";
"Nearest Stops" = "Arrêts les plus proches";
"Nearest stops" = "Arrêts les plus proches";
"New offline departures available" = "Mise à jour des départs hors-ligne disponible";
"No disruptions" = "Pas de pertubations";
"No more bus will come to this stop today." = "Aucun bus ne viendra aujourd'hui à arrêt.";
"No results" = "Pas de résultats";
Expand Down Expand Up @@ -100,15 +101,19 @@
"To..." = "Vers...";
"Unknow" = "Inconnu";
"Unmark this stop as favorite" = "Enlever cet arrêt des favoris";
"Update available" = "Mise à jour disponible";
"Update departures" = "Réactualiser les départs";
"Urban map" = "Plan urbain";
"Walk" = "Marcher";
"Walk %@m" = "Marcher %@m";
"When do you want to be reminded" = "Quand voulez-vous être rappelés";
"When do you want to be reminded?" = "Quand voulez-vous être rappelé ?";
"You are using timetables departures. So departures are subjects to change." = "Vous êtes en mode hors-ligne. Les horaires sont donc des sujets à des modifications et sont donnés à titre indicatif.";
"You can download them in Settings" = "Vous pouvez la télécharger dans les paramètres";
"You can't set a timer for this bus, but you should run to take it." = "Vous ne pouvez pas ajouter de rappels à ce bus, mais vous devriez courir pour le prendre.";
"You don't downloaded offline departures, and you're not connected to internet" = "Vous n'avez pas téléchargé les départs hors ligne et vous n'êtes pas connecté à Internet";
"You will be reminded" = "Vous serez rappelés";
"at the time of departure." = "au départ";
"tpg offline" = "tpg offline";


9 changes: 8 additions & 1 deletion tpg offline/Settings/SettingsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class SettingsTableViewController: UITableViewController {
if setting.title == "Update departures".localized {
switch self.offlineDeparturesStatus {
case .notDownloading:
cell.detailTextLabel?.text = ""
cell.detailTextLabel?.text = UserDefaults.standard.bool(forKey: "offlineDeparturesUpdateAvailable") ?
"Update available".localized : ""
case .error:
cell.detailTextLabel?.text = "Error - Departures not downloaded".localized
case .downloading:
Expand Down Expand Up @@ -139,7 +140,13 @@ class SettingsTableViewController: UITableViewController {
} else {
self.offlineDeparturesStatus = .error
}
}
Alamofire.request("https://raw.githubusercontent.com/RemyDCF/tpg-offline/master/JSON/departures.json.md5").responseString { (response) in
if let updatedMD5 = response.result.value {
UserDefaults.standard.set(updatedMD5, forKey: "departures.json.md5")
UserDefaults.standard.set(false, forKey: "offlineDeparturesUpdateAvailable")
}
}
}
}

Expand Down

0 comments on commit 54b9fb6

Please sign in to comment.