diff --git a/AvH Plan/Base.lproj/Main.storyboard b/AvH Plan/Base.lproj/Main.storyboard
index 0f020d4..d1b5243 100644
--- a/AvH Plan/Base.lproj/Main.storyboard
+++ b/AvH Plan/Base.lproj/Main.storyboard
@@ -62,103 +62,151 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
+
-
+
+
+
+
+
+
-
+
@@ -173,29 +221,54 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
+
-
+
+
+
@@ -210,14 +283,15 @@
+
-
+
@@ -233,7 +307,6 @@
-
@@ -245,23 +318,26 @@
+
-
+
+
-
+
+
-
-
-
+
+
+
@@ -504,7 +580,6 @@ If you have logged in successfully, but the setup does not continue, please go b
-
@@ -514,6 +589,7 @@ If you have logged in successfully, but the setup does not continue, please go b
+
@@ -682,7 +758,7 @@ Tell me your name.
-
+
diff --git a/AvH Plan/CustomizationViewController.swift b/AvH Plan/CustomizationViewController.swift
index 999e3b3..92113a3 100644
--- a/AvH Plan/CustomizationViewController.swift
+++ b/AvH Plan/CustomizationViewController.swift
@@ -23,6 +23,8 @@ class CustomizationViewController: UIViewController, UICollectionViewDataSource,
@IBOutlet weak var txtCourses: UITextField!
@IBOutlet weak var defaultSegments: UISegmentedControl!
@IBOutlet weak var textToolbar: UIToolbar!
+ @IBOutlet weak var orderingSegments: UISegmentedControl!
+ @IBOutlet weak var autoRefreshToggle: UISwitch!
@IBOutlet weak var inputsView: UIView!
@IBOutlet weak var colourView: UIView!
@@ -39,6 +41,10 @@ class CustomizationViewController: UIViewController, UICollectionViewDataSource,
self.present(self.df.getInfoAlert(for: "course"), animated: true)
}
+ @IBAction func orderHelpButton(_ sender: UIButton) {
+ self.present(self.df.getInfoAlert(for: "order"), animated: true)
+ }
+
func textFieldDidBeginEditing(_ textField: UITextField) {
textField.inputAccessoryView = textToolbar
}
@@ -56,6 +62,8 @@ class CustomizationViewController: UIViewController, UICollectionViewDataSource,
self.prefs.set(self.txtClasses.text, forKey: "classes")
self.prefs.set(self.txtCourses.text, forKey: "courses")
self.prefs.set(self.defaultSegments.selectedSegmentIndex, forKey: "default-plan")
+ self.prefs.set(self.orderingSegments.selectedSegmentIndex == 1, forKey: "original_sorting")
+ self.prefs.set(self.autoRefreshToggle.isOn, forKey: "auto_refresh")
self.prefs.synchronize()
self.dismiss(animated: true, completion: nil)
@@ -72,6 +80,14 @@ class CustomizationViewController: UIViewController, UICollectionViewDataSource,
self.txtClasses.text = prefs.string(forKey: "classes")
self.txtCourses.text = prefs.string(forKey: "courses")
self.defaultSegments.selectedSegmentIndex = prefs.integer(forKey: "default-plan")
+ var order: Int
+ if self.prefs.bool(forKey: "original_sorting") {
+ order = 1
+ } else {
+ order = 0
+ }
+ self.orderingSegments.selectedSegmentIndex = order
+ self.autoRefreshToggle.isOn = self.prefs.bool(forKey: "auto_refresh")
NotificationCenter.default.addObserver(self, selector: #selector(loadList), name: NSNotification.Name(rawValue: "load"), object: nil)
}
diff --git a/AvH Plan/DataFetcher.swift b/AvH Plan/DataFetcher.swift
index 178ca9e..d0c149e 100644
--- a/AvH Plan/DataFetcher.swift
+++ b/AvH Plan/DataFetcher.swift
@@ -20,6 +20,12 @@ class DataFetcher {
let prefs = UserDefaults.standard
let juniors = ["5", "6", "7", "8", "9"]
+ var shouldRefresh: Bool
+
+ init() {
+ shouldRefresh = self.prefs.bool(forKey: "auto_refresh")
+ }
+
let substitutions = Table("substitutions")
let personal = Table("personal")
let information = Table("information")
@@ -136,7 +142,9 @@ class DataFetcher {
return -30
} else if a == "1" || a == "2" {
if group.count > 1 {
+
let b = Int(String(group[group.index(group.startIndex, offsetBy: 1)...group.index(group.startIndex, offsetBy: 1)]))
+
if b == nil {
return 0
} else {
diff --git a/AvH Plan/FirstTimeViewController.swift b/AvH Plan/FirstTimeViewController.swift
index bd97998..789e600 100644
--- a/AvH Plan/FirstTimeViewController.swift
+++ b/AvH Plan/FirstTimeViewController.swift
@@ -34,7 +34,7 @@ class FirstTimeViewController: UIViewController {
self.prefs.set(self.courseTextField.text, forKey: "courses")
self.prefs.set(self.defaultPlanSegmentedControl.selectedSegmentIndex, forKey: "default-plan")
self.prefs.set(true, forKey: "setup_finished")
- self.prefs.synchronize()
+ self.prefs.set(true, forKey: "auto_refresh")
if let s = storyboard?.instantiateViewController(withIdentifier: "AppTabBarController") as? CustomTabBarController {
self.present(s, animated: true)
diff --git a/AvH Plan/MenuViewController.swift b/AvH Plan/MenuViewController.swift
index a72fefe..1cbf718 100644
--- a/AvH Plan/MenuViewController.swift
+++ b/AvH Plan/MenuViewController.swift
@@ -63,7 +63,11 @@ class MenuViewController : UICollectionViewController, UICollectionViewDelegateM
@objc private func objDoAsync(_ sender: Any) {
df.doAsync(do: "menu") { menuItems in
self.items = menuItems as! [String]
- self.collectionView.reloadData()
+
+ DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
+ self.collectionView.reloadData()
+ }
+
self.refreshControl.endRefreshing()
self.df.setTabBarBadge(for: self.tabBarController?.tabBar.items)
}
diff --git a/AvH Plan/PlanViewController.swift b/AvH Plan/PlanViewController.swift
index d76d753..113c909 100644
--- a/AvH Plan/PlanViewController.swift
+++ b/AvH Plan/PlanViewController.swift
@@ -30,7 +30,6 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
override func viewWillAppear(_ animated: Bool) {
-
if !self.prefs.bool(forKey: "logged_in") {
if let s = storyboard?.instantiateViewController(withIdentifier: "Login") as? UINavigationController {
self.present(s, animated: true)
@@ -47,7 +46,7 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
Messaging.messaging().subscribe(toTopic: "substitutions-ios")
Messaging.messaging().subscribe(toTopic: "substitutions-broadcast")
Crashlytics.sharedInstance().setUserIdentifier(UserDefaults.standard.string(forKey: "username"))
- // check if these can be put in AppDelegate
+ // TODO: check if these can be put in AppDelegate
}
view.addSubview(collectionView)
@@ -57,7 +56,7 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.superview!.topAnchor),
- collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
+ collectionView.bottomAnchor.constraint(equalTo: view.superview!.bottomAnchor),
])
collectionView.register(UINib(nibName: "PlanViewCell", bundle: nil), forCellWithReuseIdentifier: identifier)
collectionView.dataSource = self
@@ -74,14 +73,20 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
refreshControl.attributedTitle = NSAttributedString(string: getRefreshViewString())
self.tabBarController?.delegate = self
- self.substs = getFromDatabase()
+ self.substs = self.getFromDatabase()
self.collectionView.reloadData()
+
+ if self.df.shouldRefresh {
+ self.collectionView.setContentOffset(CGPoint(x: 0, y: -self.refreshControl.frame.size.height), animated: true)
+ self.refreshControl.beginRefreshing()
+ self.refreshControl.sendActions(for: .valueChanged)
+ self.df.shouldRefresh = false
+ }
}
override func viewDidLoad() {
super.viewDidLoad()
- self.extendedLayoutIncludesOpaqueBars = true
self.collectionView.contentInsetAdjustmentBehavior = .always
self.df.setTabBarBadge(for: self.tabBarController?.tabBar.items)
}
diff --git a/AvH Plan/de.lproj/Localizable.strings b/AvH Plan/de.lproj/Localizable.strings
index 3e4eadb..1c3c510 100644
--- a/AvH Plan/de.lproj/Localizable.strings
+++ b/AvH Plan/de.lproj/Localizable.strings
@@ -79,5 +79,7 @@
"enter_grade_title" = "Wie du deine Klasse eintragen kannst";
"enter_course_title" = "Wie du deine Kurse eintragen kannst";
+"enter_order_title" = "Informationen über Sortierweisen";
"enter_grade_help" = "Trage deine derzeitige Klasse ein, damit sie in deinem persönlichen Plan auftaucht.\n\nAnmerkung:\n\nIn der Mittelstufe müssen Nummer und Buchstabe zusammen geschrieben werden, Beispiel: \"5a\".\n\nIn der E-Phase müssen diese durch ein Leerzeichen getrennt werden, Beispiel: \"18 a\".\n\nIn der Q1/Q2 sollen nur die Nummern eingetragen werden, Beispiel: \"17\".\n\nMehrere Klassen können nur eingetragen werden, wenn keine Kurse eingetragen sind.";
"enter_course_help" = "Trag die Kürzel für die Kurse ein, welche in deinem persönlichen Plan auftauchen sollen. Du kannst diese auf deinem Stundenplan finden.\n\nHier sind einige Beispiele:\n\nMathe in der 5. Klasse (Mittelstufe) wäre MAT.\n\nDer Englisch-Profilkurs in der E-Phase könnte ENP1 sein.\n\nDer Bio-Grundkurs in der Q1 ist z.B. bio1.\n\nMeist müssen Kurse für Mittelstufenschüler nicht eingetragen werden.\nTrenne mehrere Kurse mit Leerzeichen, Kommas sind optional.\nGroß- und Kleinschreibung wird beachtet.";
+"enter_order_help" = "Du kannst zwischen zwei Sortierweisen auswählen, welche die Reihenfolge der Einträge auf dem Vertretungsplan bestimmen.\n\nStandardmäßig ist \'App-spezifisch\' ausgewählt; dies bietet einen konsistenten Plan sortiert nach Klassen, dann nach Stunden.\n\n\'Website-Original\' bietet die Original-Reihenfolge der Website. Diese ist jedoch nicht konsistent, weswegen \'App-spezifisch\' standardmäßig ausgewählt ist.";
diff --git a/AvH Plan/de.lproj/Main.strings b/AvH Plan/de.lproj/Main.strings
index 4340e6d..10b6dc2 100644
--- a/AvH Plan/de.lproj/Main.strings
+++ b/AvH Plan/de.lproj/Main.strings
@@ -109,3 +109,23 @@
/* Class = "UIBarButtonItem"; title = "Customize"; ObjectID = "zsF-Jh-U3n"; */
"zsF-Jh-U3n.title" = "Anpassen";
+
+"ZCm-7a-IUx.placeholder" = "Dein Name";
+
+"gOX-RF-Brg.placeholder" = "Deine Klasse";
+
+"EDB-Mm-gGh.placeholder" = "Deine Kurse";
+
+"JMH-JV-eMe.text" = "Standardplan";
+
+"DPm-52-1Ww.segmentTitles[0]" = "Allgemein";
+
+"DPm-52-1Ww.segmentTitles[1]" = "Persönlich";
+
+"3iB-va-Cjs.text" = "Sortierweise";
+
+"ol8-tW-I69.segmentTitles[0]" = "App-spezifisch";
+
+"ol8-tW-I69.segmentTitles[1]" = "Website-Original";
+
+"YlM-R8-zk5.text" = "Aktualisiere Plan automatisch";
diff --git a/AvH Plan/en.lproj/Localizable.strings b/AvH Plan/en.lproj/Localizable.strings
index 2502fdc..d8bdfab 100644
--- a/AvH Plan/en.lproj/Localizable.strings
+++ b/AvH Plan/en.lproj/Localizable.strings
@@ -80,5 +80,7 @@
"enter_grade_title" = "How to enter your grade";
"enter_course_title" = "How to enter your courses";
+"enter_order_title" = "Information on ordering systems";
"enter_grade_help" = "Enter your current grade to have it appear in your personal plan.\n\nNote:\n\nIn junior phase, put the number and letter together, as in \"5a\".\n\nIn E-Phase, separate them by a space, as in \"18 a\".\n\nIn Q1/Q2, only put in the number, as in \"17\".\n\nMultiple grades can only be entered when no courses have been entered.";
"enter_course_help" = "You need to enter the course abbreviation for every course you want in your personal plan. You can find them on your time table.\n\nHere\'s a few examples:\n\nMathematics in 5th grade (juniors) would be MAT.\n\nAdvanced English in E-Phase (seniors) for the English profile may be ENP1.\n\nBasic Biology in Q1 could be bio1.\n\nIn most cases, entering courses while in junior phase is redundant.\nSeparate multiple courses by spaces, commas are optional.\nCapitalisation is required.";
+"enter_order_help" = "You may pick between two ordering systems that dictate the order in which the items on the substitution plan will appear in.\n\nThe default \'app-specific\' is an algorithm implemented in this app that provides a consistently-sorted substitution plan ordered just like the substitution plan on the website used to; sorted by classes, then by time.\n\n\'Website original\' offers the items on the substitution plan just like they\'re presented on the school website, but since these are not guaranteed to be consistent, \'app-specific\' is picked by default.";