diff --git a/Orarend/API.cs b/Orarend/API.cs
index d8685a6..d8da4b3 100644
--- a/Orarend/API.cs
+++ b/Orarend/API.cs
@@ -20,11 +20,13 @@ namespace Orarend
///
public static Osztály[] Osztályok { get; private set; }
public static List<Órarend> Órarendek { get; } = new List<Órarend>();
- public static Settings Beállítások { get; private set; } //TODO: Settings
+ public static Settings Beállítások { get; private set; } = new Settings();
+ public static List Helyettesítések { get; } = new List();
///
/// Frissíti az osztálylistát és az eredeti órarendet, első megnyitásnál, és egy órarend hozzáadásánál/szerkesztésénél, majd hetente elegendő meghívni
+ /// A file stream, ahova mentse az adatokat, hogy ne kelljen külön meghívni
///
- public static async Task Frissítés()
+ public static async Task Frissítés(Stream s)
{
Func> load = async (url) =>
{
@@ -52,6 +54,7 @@ namespace Orarend
var doc = await load("http://deri.enaplo.net/ajax/orarend/orarendoszt.php?p=" + Uri.EscapeDataString(órarend.Osztály.Azonosító));
await Task.Run(() =>
{
+ Osztályok = doc.GetElementbyId("uok").ChildNodes.Where(node => node.HasAttributes).Select(node => new Osztály { Azonosító = node.GetAttributeValue("value", ""), Név = node.NextSibling.InnerText }).ToArray();
bool ahét = true;
foreach (var node in doc.GetElementbyId("oda").FirstChild.FirstChild.ChildNodes[1].ChildNodes)
{
@@ -68,8 +71,8 @@ namespace Orarend
int x = int.Parse(node.FirstChild.InnerText) - 1;
órarend.Órakezdetek[x] = TimeSpan.Parse(node.FirstChild.Attributes["title"].Value.Split('-')[0].Trim());
for (int i = 0; i < 5; i++) //Napok
- { //TODO: for ciklus az egy időben tartott órákhoz
- var óranode = node.ChildNodes[i + 1].FirstChild;
+ { //TODO: for ciklus az egy időben tartott órákhoz
+ var óranode = node.ChildNodes[i + 1].FirstChild;
var óra = (ahét ? órarend.ÓrákAHét : órarend.ÓrákBHét)[i, x];
if (óranode.ChildNodes.Count == 0)
continue;
@@ -78,7 +81,6 @@ namespace Orarend
continue;
if (óra == null)
(ahét ? órarend.ÓrákAHét : órarend.ÓrákBHét)[i, x] = óra = new Óra();
- óra.Sorszám = x + 1;
óra.Csoportok = new string[] { csoport }; //Az állandó órarendben osztályonként csak egy csoport van egy órán
óra.Azonosító = óranode.ChildNodes[2].InnerText;
óra.TeljesNév = óranode.ChildNodes[2].Attributes["title"].Value;
@@ -93,15 +95,18 @@ namespace Orarend
}
}
}
+ ÓrarendMentés(s);
+ OsztályMentés(s);
+ Thread.Sleep(10);
});
- Thread.Sleep(10);
}
}
///
/// Frissíti a helyettesítéseket, naponta, indításkor vagy gombnyommásra frissítse (minden nap az első előtérbe kerüléskor)
+ /// A file stream, ahova mentse az adatokat, hogy ne kelljen külön meghívni
///
- public static async Task HelyettesítésFrissítés()
+ public static async Task HelyettesítésFrissítés(Stream s)
{
HtmlDocument doc = new HtmlDocument();
var req = WebRequest.CreateHttp("http://deri.enaplo.net/ajax/print/htlista.php");
@@ -110,7 +115,7 @@ namespace Orarend
{
using (var sr = new StreamReader(resp.GetResponseStream()))
doc.LoadHtml(sr.ReadToEnd());
- });
+ }); //TODO
}
public static void ÓrarendBetöltés(Stream s)
@@ -140,7 +145,16 @@ namespace Orarend
}
}
- public static void ÓrarendMentés(Stream s)
+ public static void HelyettesítésBetöltés(Stream s)
+ {
+ using (s)
+ {
+ var serializer = new DataContractJsonSerializer(typeof(Helyettesítés[])); //TODO: Tényleges órarendből állapítsa meg azt is, hogyha egyáltalán nincs ott egy óra, és máshol sincs, és ezt írja ki
+ Helyettesítések.AddRange((Helyettesítés[])serializer.ReadObject(s));
+ }
+ }
+
+ private static void ÓrarendMentés(Stream s)
{
using (s)
{
@@ -149,7 +163,7 @@ namespace Orarend
}
}
- public static void OsztályMentés(Stream s)
+ private static void OsztályMentés(Stream s)
{
using (s)
{
@@ -166,5 +180,14 @@ namespace Orarend
serializer.WriteObject(s, Beállítások);
}
}
+
+ private static void HelyettesítésMentés(Stream s)
+ {
+ using (s)
+ {
+ var serializer = new DataContractJsonSerializer(typeof(Helyettesítés[]));
+ serializer.WriteObject(s, Helyettesítések);
+ }
+ }
}
}
diff --git a/Orarend/Helyettesítés.cs b/Orarend/Helyettesítés.cs
new file mode 100644
index 0000000..5f9ab35
--- /dev/null
+++ b/Orarend/Helyettesítés.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Orarend
+{
+ public class Helyettesítés
+ {
+ public byte EredetiNap { get; set; }
+ public byte EredetiSorszám { get; set; }
+ public Óra EredetiÓra { get; set; }
+ public byte ÚjNap { get; set; }
+ public byte ÚjSorszám { get; set; }
+ public Óra ÚjÓra { get; set; }
+ }
+}
diff --git a/Orarend/Orarend.csproj b/Orarend/Orarend.csproj
index 23c3f58..a43c543 100644
--- a/Orarend/Orarend.csproj
+++ b/Orarend/Orarend.csproj
@@ -35,6 +35,7 @@
+
diff --git a/Orarend/Settings.cs b/Orarend/Settings.cs
index 631d280..8e08aaf 100644
--- a/Orarend/Settings.cs
+++ b/Orarend/Settings.cs
@@ -8,5 +8,25 @@ namespace Orarend
{
public class Settings
{
+ public bool DarkTheme { get; set; }
+ public void UseCommonNames()
+ {
+ set("mateme", "Matek");
+ set("prgelm", "Programozás elmélet");
+ set("magny", "Nyelvtan");
+ set(";prggy", "Programozás gyakorlat");
+ set("testns", "Tesi");
+ set("tapism", "Töri");
+ set("matema", "Matek");
+ set("bioege", "Biosz");
+ set("foldra", "Föci");
+ set(";halgy", "Hálózat gyakorlat");
+ }
+
+ private void set(string id, string name)
+ {
+ if (ÓraTípus.Típusok.ContainsKey(id))
+ ÓraTípus.Típusok[id].EgyediNév = name;
+ }
}
}
diff --git a/Orarend/Óra.cs b/Orarend/Óra.cs
index 158251f..5e70a54 100644
--- a/Orarend/Óra.cs
+++ b/Orarend/Óra.cs
@@ -10,7 +10,6 @@ namespace Orarend
{
private ÓraTípus Típus { get; set; }
public Tanár Tanár { get; set; }
- public int Sorszám { get; set; }
public string Terem { get; set; }
///
/// Az órán résztvevő csoportok
@@ -59,5 +58,19 @@ namespace Orarend
Típus.EgyediNév = value;
}
}
+
+ public bool VanEgyediNév
+ {
+ get
+ {
+ return Típus?.EgyediNév == null;
+ }
+ }
+
+ public void EgyediNévTörlése()
+ {
+ if (Típus != null)
+ Típus.EgyediNév = null;
+ }
}
}
diff --git a/Orarend/ÓraTípus.cs b/Orarend/ÓraTípus.cs
index 2882013..a51867e 100644
--- a/Orarend/ÓraTípus.cs
+++ b/Orarend/ÓraTípus.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Generic;
namespace Orarend
{
@@ -12,6 +8,9 @@ namespace Orarend
public string Azonosító { get; set; }
public string EgyediNév { get; set; }
+ ///
+ /// A kulcs az óra azonosítója
+ ///
public static Dictionary Típusok { get; } = new Dictionary();
}
}
diff --git a/OrarendAndroidApp/MainActivity.cs b/OrarendAndroidApp/MainActivity.cs
index 0611daa..d124186 100644
--- a/OrarendAndroidApp/MainActivity.cs
+++ b/OrarendAndroidApp/MainActivity.cs
@@ -26,6 +26,8 @@ namespace OrarendAndroidApp
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MainLayout);
+ ActionBar.SetDisplayShowTitleEnabled(false);
+ ActionBar.CustomView = FindViewById(Resource.Id.spinner);
handler = new Handler();
string[] list = FileList();
if (list.Contains("beallitasok"))
@@ -34,56 +36,55 @@ namespace OrarendAndroidApp
API.ÓrarendBetöltés(OpenFileInput("orarend"));
if (list.Contains("osztaly"))
API.OsztályBetöltés(OpenFileInput("osztaly"));
- API.Frissítés().ContinueWith(t =>
- {
- handler.Post(() =>
- {
- TaskHiba(t);
- });
- órarend = new Órarend("Teszt", API.Osztályok.First(), "gy1");
- API.Órarendek.Add(órarend);
- API.Frissítés().ContinueWith(tt => HelyettesítésFrissítés());
- });
+ if (list.Contains("osztaly"))
+ API.OsztályBetöltés(OpenFileInput("osztaly"));
+ if (API.Osztályok == null || API.Osztályok.Length == 0)
+ ÓrarendFrissítés();
var timer = new Timer(CsengőTimer, null, TimeSpan.Zero, new TimeSpan(0, 0, 1));
}
+ private void addCell(string text, Color color, TableRow tr1, bool clickable = false, int[] tag = null)
+ {
+ TextView textview = new TextView(this);
+ textview.SetText(text, TextView.BufferType.Normal);
+ textview.SetTextColor(color);
+ textview.SetPadding(10, 10, 10, 10);
+ textview.SetBackgroundResource(Resource.Drawable.cell_shape_light);
+ textview.Tag = tag;
+ if (textview.Clickable = clickable)
+ textview.Click += ÓraClick;
+ tr1.AddView(textview);
+ }
+
private void HelyettesítésFrissítés()
{
- var table = FindViewById(Resource.Id.tableLayout1);
- Action addCell = (text, color, tr1, clickable, tag) =>
- {
- TextView textview = new TextView(this);
- textview.SetText(text, TextView.BufferType.Normal);
- textview.SetTextColor(color);
- textview.SetPadding(10, 10, 10, 10);
- textview.SetBackgroundResource(Resource.Drawable.cell_shape_light);
- textview.Tag = tag;
- if (textview.Clickable = clickable)
- textview.Click += ÓraClick;
- tr1.AddView(textview);
- };
API.HelyettesítésFrissítés().ContinueWith(t =>
{ //TODO: Ezt ne itt, ne így
+ }); //TODO: Tárolja el a helyettesített órarendeket is valahogyan, akár külön osztály, hogy csak a változásokat tárolja
+ }
+
+ private void ÓrarendFrissítés()
+ { //TODO: Meghívni minden tervezett alkalommal; hozzáadásnál csak a hozzáadott órarendet frissítse
+ API.Frissítés(OpenFileOutput("orarend", FileCreationMode.Private)).ContinueWith(t =>
+ {
handler.Post(() =>
{
- TaskHiba(t);
+ if(TaskHiba(t))
{
+ var table = FindViewById(Resource.Id.tableLayout1);
+ table.RemoveViews(0, table.ChildCount); //TODO: Test
TableRow tr = new TableRow(this);
- addCell("", Color.Black, tr, false, null);
- addCell("Hétfő", Color.Black, tr, false, null);
- addCell("Kedd", Color.Black, tr, false, null);
- addCell("Szerda", Color.Black, tr, false, null);
- addCell("Csütörtök", Color.Black, tr, false, null);
- addCell("Péntek", Color.Black, tr, false, null);
- addCell("Szombat", Color.Black, tr, false, null);
+ addCell("", Color.Black, tr);
+ addCell("Hétfő", Color.Black, tr);
+ addCell("Kedd", Color.Black, tr);
+ addCell("Szerda", Color.Black, tr);
+ addCell("Csütörtök", Color.Black, tr);
+ addCell("Péntek", Color.Black, tr);
+ addCell("Szombat", Color.Black, tr);
table.AddView(tr, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
-
- }
- if ((t.Exception?.InnerExceptions?.Count ?? 0) == 0)
- {
for (int j = 0; j < órarend.ÓrákAHét.GetLength(1); j++)
{
- TableRow tr = new TableRow(this);
+ tr = new TableRow(this);
bool notnull = false;
for (int i = 0; i < órarend.ÓrákAHét.GetLength(0); i++)
{ //Kihagyja az üres sorokat
@@ -95,7 +96,7 @@ namespace OrarendAndroidApp
}
if (notnull)
{
- addCell((j + 1).ToString(), Color.Black, tr, false, null);
+ addCell((j + 1).ToString(), Color.Black, tr);
for (int i = 0; i < órarend.ÓrákAHét.GetLength(0); i++)
addCell(órarend.ÓrákAHét[i, j] != null ? órarend.ÓrákAHét[i, j].EgyediNév : "", Color.Black, tr, true, new int[2] { i, j });
table.AddView(tr, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
@@ -103,7 +104,7 @@ namespace OrarendAndroidApp
}
}
});
- }); //TODO: Tárolja el a helyettesített órarendeket is valahogyan, akár külön osztály, hogy csak a változásokat tárolja
+ });
}
private TextView selected;
@@ -180,10 +181,20 @@ namespace OrarendAndroidApp
new AlertDialog.Builder(this).SetMessage(msg).SetNeutralButton("OK", (s, e) => { ((AlertDialog)s).Dismiss(); ((AlertDialog)s).Dispose(); }).SetTitle("Hiba").Show();
}
- private void TaskHiba(Task t)
+ ///
+ /// Az összes hibát kiírja, ami a futása közben keletkezett
+ ///
+ ///
+ /// Igaz, ha nem volt hiba
+ private bool TaskHiba(Task t)
{
+ bool ret = true;
foreach (var ex in (IEnumerable)t.Exception?.InnerExceptions ?? new System.Exception[0])
+ {
Hiba(ex.ToString());
+ ret = false;
+ }
+ return ret;
}
private void CsengőTimer(object state)
diff --git a/OrarendAndroidApp/Resources/Resource.Designer.cs b/OrarendAndroidApp/Resources/Resource.Designer.cs
index 7a66130..589c816 100644
--- a/OrarendAndroidApp/Resources/Resource.Designer.cs
+++ b/OrarendAndroidApp/Resources/Resource.Designer.cs
@@ -93,47 +93,53 @@ namespace OrarendAndroidApp
// aapt resource value: 0x7f060001
public const int horizontalView = 2131099649;
- // aapt resource value: 0x7f060009
- public const int idoTV = 2131099657;
-
// aapt resource value: 0x7f06000a
- public const int kezdvegTV = 2131099658;
+ public const int idoTV = 2131099658;
// aapt resource value: 0x7f06000b
- public const int kovoraTV = 2131099659;
-
- // aapt resource value: 0x7f06000d
- public const int menu_add = 2131099661;
-
- // aapt resource value: 0x7f06000e
- public const int menu_edit = 2131099662;
-
- // aapt resource value: 0x7f060010
- public const int menu_fullrefresh = 2131099664;
-
- // aapt resource value: 0x7f06000f
- public const int menu_preferences = 2131099663;
+ public const int kezdvegTV = 2131099659;
// aapt resource value: 0x7f06000c
- public const int menu_refresh = 2131099660;
+ public const int kovoraTV = 2131099660;
+
+ // aapt resource value: 0x7f06000f
+ public const int menu_add = 2131099663;
+
+ // aapt resource value: 0x7f060010
+ public const int menu_edit = 2131099664;
+
+ // aapt resource value: 0x7f060012
+ public const int menu_fullrefresh = 2131099666;
+
+ // aapt resource value: 0x7f060011
+ public const int menu_preferences = 2131099665;
+
+ // aapt resource value: 0x7f06000e
+ public const int menu_refresh = 2131099662;
+
+ // aapt resource value: 0x7f060007
+ public const int nevTV = 2131099655;
// aapt resource value: 0x7f060006
- public const int nevTV = 2131099654;
-
- // aapt resource value: 0x7f060005
- public const int pozTV = 2131099653;
+ public const int pozTV = 2131099654;
// aapt resource value: 0x7f060003
public const int progressBar1 = 2131099651;
+ // aapt resource value: 0x7f060005
+ public const int spiner_id = 2131099653;
+
+ // aapt resource value: 0x7f06000d
+ public const int spinner = 2131099661;
+
// aapt resource value: 0x7f060002
public const int tableLayout1 = 2131099650;
- // aapt resource value: 0x7f060008
- public const int tanarTV = 2131099656;
+ // aapt resource value: 0x7f060009
+ public const int tanarTV = 2131099657;
- // aapt resource value: 0x7f060007
- public const int teremTV = 2131099655;
+ // aapt resource value: 0x7f060008
+ public const int teremTV = 2131099656;
static Id()
{
diff --git a/OrarendAndroidApp/Resources/layout/MainLayout.axml b/OrarendAndroidApp/Resources/layout/MainLayout.axml
index 52b65a1..bebb739 100644
--- a/OrarendAndroidApp/Resources/layout/MainLayout.axml
+++ b/OrarendAndroidApp/Resources/layout/MainLayout.axml
@@ -43,6 +43,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/actionMenuView1" />
+
\ No newline at end of file