diff --git a/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs b/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs
index af0b1dae..3dcff447 100644
--- a/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs
+++ b/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs
@@ -9,9 +9,10 @@ namespace CampusAppWP8.Feed.GeoApi
{
using CampusAppWP8.Model;
using CampusAppWP8.Model.GeoDb;
+ using CampusAppWP8.Resources;
///
- /// Class for sps api
+ /// Class for SPSAPI
///
public class SpsApi : XmlModel
{
@@ -19,7 +20,7 @@ namespace CampusAppWP8.Feed.GeoApi
/// Initializes a new instance of the class.
///
public SpsApi()
- : base(ModelType.Feed, "http://141.43.76.140/service/sps")
+ : base(ModelType.Feed, Constants.UrlSpsService)
{
}
}
diff --git a/CampusAppWP8/CampusAppWP8/App.xaml.cs b/CampusAppWP8/CampusAppWP8/App.xaml.cs
index 891f1230..46d1bfa0 100644
--- a/CampusAppWP8/CampusAppWP8/App.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/App.xaml.cs
@@ -130,6 +130,7 @@ namespace CampusAppWP8
}
return default(T);
}
+
// Code, der beim Starten der Anwendung ausgeführt werden soll (z. B. über "Start")
// Dieser Code wird beim Reaktivieren der Anwendung nicht ausgeführt
private void Application_Launching(object sender, LaunchingEventArgs e)
diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
index c2bee0e0..bc1fd99d 100644
--- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
+++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
@@ -103,6 +103,7 @@
+
diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs
index 5e808398..68acbbbe 100644
--- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs
@@ -1,20 +1,35 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Xml.Serialization;
+//-----------------------------------------------------------------------
+//
+// Company copyright tag.
+//
+// stubbfel
+// 08.08.2013
+//----------------------------------------------------------------------
namespace CampusAppWP8.Model.GeoDb
{
+ using System.Xml.Serialization;
+
+ ///
+ /// Model for a place of the SPSService
+ ///
public class PlaceModel
{
+ ///
+ /// Gets or sets the placeId
+ ///
[XmlAttribute("id")]
public string PlaceId { get; set; }
+ ///
+ /// Gets or sets the id of the "parent" of a place
+ ///
[XmlAttribute("parentId")]
public string ParentId { get; set; }
+ ///
+ /// Gets or sets the ReferencePoint of a place
+ ///
[XmlAttribute("refpoint")]
public string RefPoint { get; set; }
}
diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs
index 5e8ac642..0b4fea86 100644
--- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs
@@ -1,16 +1,25 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Xml.Serialization;
+//-----------------------------------------------------------------------
+//
+// Company copyright tag.
+//
+// stubbfel
+// 08.08.2013
+//----------------------------------------------------------------------
namespace CampusAppWP8.Model.GeoDb
{
+ using System.Collections.ObjectModel;
+ using System.Xml.Serialization;
+
+ ///
+ /// Model for a xml-response of the SPSService
+ ///
[XmlRoot("root")]
public class SpsModel
{
+ ///
+ /// Gets or sets a list of places
+ ///
[XmlElement("place")]
public ObservableCollection Places { get; set; }
}
diff --git a/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs
new file mode 100644
index 00000000..aadf0ad0
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs
@@ -0,0 +1,50 @@
+//-----------------------------------------------------------------------
+//
+// Company copyright tag.
+//
+// stubbfel
+// 08.08.2013
+//----------------------------------------------------------------------
+
+namespace CampusAppWP8.Model.Setting
+{
+ using CampusAppWP8.Resources;
+
+ ///
+ /// Model for settings of the app
+ ///
+ public class AppSettings
+ {
+ ///
+ /// Gets or sets a value indicating whether the GeoWatch-Flag
+ ///
+ public bool GeoWatchEnable
+ {
+ get
+ {
+ return App.LoadFromAppState(Constants.AppSetting_GeoWatchEnable);
+ }
+
+ set
+ {
+ App.SaveToAppState(Constants.AppSetting_GeoWatchEnable, value);
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the InitializationApp-Flag
+ ///
+ public bool InitApp
+ {
+ get
+ {
+ return App.LoadFromAppState(Constants.AppSetting_GeoWatchEnable);
+ }
+
+ set
+ {
+ App.SaveToAppState(Constants.AppSetting_GeoWatchEnable, value);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
index a28f78f2..f415ccc9 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
@@ -11,13 +11,6 @@ namespace CampusAppWP8.Pages.Mensa
using System.Windows.Navigation;
using CampusAppWP8.Feed.Mensa;
using Microsoft.Phone.Controls;
- using CampusAppWP8.Feed.GeoApi;
- using System.Collections.Generic;
- using CampusAppWP8.Model.Utility;
- using Windows.Devices.Geolocation;
- using System.Threading.Tasks;
- using System.Globalization;
- using CampusAppWP8.Utility;
///
/// Class for the MensaPage
@@ -31,7 +24,7 @@ namespace CampusAppWP8.Pages.Mensa
///
private MensaFeed feed;
- private SpsApi spsApi;
+ // private SpsApi spsApi;
///
/// Index representing the weekday of today
@@ -81,9 +74,11 @@ namespace CampusAppWP8.Pages.Mensa
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
this.feed.LoadData();
- this.determinCurrentPosition();
+
+ // this.determinCurrentPosition();
}
+/* need for later feature (#147)
private void determinCurrentPosition()
{
Utilities.DetermineAndStoreCurrentPosition();
@@ -103,7 +98,7 @@ namespace CampusAppWP8.Pages.Mensa
private void ApiIsReady()
{
string i = this.spsApi.Model.Places[0].PlaceId;
- }
+ }*/
///
/// Override the OnNavigatedFrom method
diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs
index 79325c14..9835260f 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs
@@ -12,13 +12,9 @@ namespace CampusAppWP8.Pages
using System.Windows.Controls;
using System.Windows.Navigation;
using CampusAppWP8.Resources;
+ using CampusAppWP8.Utility;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
- using Windows.Devices.Geolocation;
- using CampusAppWP8.Utility;
- using System.Globalization;
- using System.Threading.Tasks;
- using System.Device.Location;
///
/// Class for the StartPage
@@ -30,14 +26,20 @@ namespace CampusAppWP8.Pages
///
public StartPage()
{
- this.InitializeComponent();
+ this.InitializeComponent();
ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem;
if (menuItem1 != null)
{
menuItem1.Text = AppResources.Setting_UserProfilAppBarTitle;
}
+
+ if (Settings.AppSetting.InitApp)
+ {
+ this.ShowOptIns();
+ Settings.AppSetting.InitApp = true;
+ }
}
-
+
///
/// Method handle OrientationPage
///
@@ -62,8 +64,8 @@ namespace CampusAppWP8.Pages
HomeworkAppButtonText.Text = AppResources.HomeworkApp_Title;
ContentPanel.RowDefinitions[3].Height = GridLength.Auto;
- ContentPanel.ColumnDefinitions[3].Width = new GridLength(1, GridUnitType.Star);
- }
+ ContentPanel.ColumnDefinitions[3].Width = new GridLength(1, GridUnitType.Star);
+ }
else
{
// If not in portrait, move buttonList content to visible row and column.
@@ -80,19 +82,27 @@ namespace CampusAppWP8.Pages
HomeworkAppButtonText.Text = AppResources.HomeworkApp_Title2;
- ContentPanel.RowDefinitions[3].Height = new GridLength(1,GridUnitType.Star);
+ ContentPanel.RowDefinitions[3].Height = new GridLength(1, GridUnitType.Star);
ContentPanel.ColumnDefinitions[3].Width = GridLength.Auto;
}
-
}
+ ///
+ /// Method Navigate to
+ ///
+ /// Caller of the function
+ /// some EventArgs
private void ApplicationBarMenuItem_Click(object sender, EventArgs e)
{
- //Uri url = new Uri(Constants.PathSetting_User, UriKind.Relative);
- //NavigationService.Navigate(url);
- Utilities.DetermineAndStoreCurrentPosition();
+ Uri url = new Uri(Constants.PathSetting_User, UriKind.Relative);
+ NavigationService.Navigate(url);
}
+ ///
+ /// Method change the Opacity of the ApplicationBar
+ ///
+ /// Caller of the function
+ /// some EventArgs
private void ApplicationBar_StateChanged(object sender, ApplicationBarStateChangedEventArgs e)
{
if (e.IsMenuVisible)
@@ -104,5 +114,31 @@ namespace CampusAppWP8.Pages
ApplicationBar.Opacity = 0.5;
}
}
+
+ ///
+ /// Method show all OptIns
+ ///
+ private void ShowOptIns()
+ {
+ this.GeoWatchOptIN();
+ }
+
+ ///
+ /// Method show the GeoWatchOptIn in a MessageBox
+ ///
+ private void GeoWatchOptIN()
+ {
+ MessageBoxResult result = MessageBox.Show(AppResources.GeoWatch_OptInText, AppResources.GeoWatch_OptInHeader, MessageBoxButton.OKCancel);
+
+ if (result == MessageBoxResult.OK)
+ {
+ Settings.AppSetting.GeoWatchEnable = true;
+ Utilities.DetermineAndStoreCurrentPosition();
+ }
+ else
+ {
+ Settings.AppSetting.GeoWatchEnable = false;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs
index e9372b2d..b2d6dccd 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs
+++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs
@@ -204,6 +204,24 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Ortung ähnelt.
+ ///
+ public static string GeoWatch_OptInHeader {
+ get {
+ return ResourceManager.GetString("GeoWatch_OptInHeader", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Dürfen Positionsdaten enhober und verwendet werdet? ähnelt.
+ ///
+ public static string GeoWatch_OptInText {
+ get {
+ return ResourceManager.GetString("GeoWatch_OptInText", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Hinweis ähnelt.
///
diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx
index af5596e0..4677210c 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx
@@ -359,4 +359,10 @@
Suppe
+
+ Ortung
+
+
+ Dürfen Positionsdaten enhober und verwendet werdet?
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs
index 1b6ef17d..950c81cb 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs
@@ -60,6 +60,24 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die AppSetting.GeoWatchEnable ähnelt.
+ ///
+ public static string AppSetting_GeoWatchEnable {
+ get {
+ return ResourceManager.GetString("AppSetting_GeoWatchEnable", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die AppSetting.InitApp ähnelt.
+ ///
+ public static string AppSetting_InitApp {
+ get {
+ return ResourceManager.GetString("AppSetting_InitApp", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die DepartmentFavoriteFeed.xml ähnelt.
///
@@ -150,6 +168,33 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Lat ähnelt.
+ ///
+ public static string GeoWatch_CurrentPosition_Lat {
+ get {
+ return ResourceManager.GetString("GeoWatch_CurrentPosition_Lat", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Long ähnelt.
+ ///
+ public static string GeoWatch_CurrentPosition_Long {
+ get {
+ return ResourceManager.GetString("GeoWatch_CurrentPosition_Long", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Time ähnelt.
+ ///
+ public static string GeoWatch_CurrentPosition_Time {
+ get {
+ return ResourceManager.GetString("GeoWatch_CurrentPosition_Time", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die IsolatedStorage_DepartmentFavoriteModel ähnelt.
///
@@ -654,6 +699,15 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die http://141.43.76.140/service/sps ähnelt.
+ ///
+ public static string UrlSpsService {
+ get {
+ return ResourceManager.GetString("UrlSpsService", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/getdata.php?db=studentcouncils&app=2&appversion=1 ähnelt.
///
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
index 8520e922..99e8808a 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
@@ -333,4 +333,22 @@
WILD
+
+ AppSetting.GeoWatchEnable
+
+
+ AppSetting.InitApp
+
+
+ CurrentPosition.Lat
+
+
+ CurrentPosition.Long
+
+
+ CurrentPosition.Time
+
+
+ http://141.43.76.140/service/sps
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Settings.cs b/CampusAppWP8/CampusAppWP8/Settings.cs
index efb0f5b6..3e22f380 100644
--- a/CampusAppWP8/CampusAppWP8/Settings.cs
+++ b/CampusAppWP8/CampusAppWP8/Settings.cs
@@ -9,6 +9,7 @@
namespace CampusAppWP8
{
using CampusAppWP8.File.Setting;
+ using CampusAppWP8.Model.Setting;
///
/// Class handle all setting (files)
@@ -20,6 +21,11 @@ namespace CampusAppWP8
///
private static UserProfilFile userProfil = new UserProfilFile();
+ ///
+ /// reference of the appSettings
+ ///
+ private static AppSettings appSetting = new AppSettings();
+
///
/// Gets or sets the user-profile-file
///
@@ -38,5 +44,24 @@ namespace CampusAppWP8
}
}
}
+
+ ///
+ /// Gets or sets the AppSetting
+ ///
+ public static AppSettings AppSetting
+ {
+ get
+ {
+ return Settings.appSetting;
+ }
+
+ set
+ {
+ if (value != Settings.appSetting)
+ {
+ Settings.appSetting = value;
+ }
+ }
+ }
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Utility/File.cs b/CampusAppWP8/CampusAppWP8/Utility/File.cs
index 8e51ba53..6b6349a5 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/File.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/File.cs
@@ -10,8 +10,6 @@ namespace CampusAppWP8.Utility
using System;
using System.IO;
using Windows.Storage;
- // test using for bug #126
- using System.Threading.Tasks;
///
/// File class.
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
index afb542e1..70fe8fdd 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
@@ -15,6 +15,7 @@ namespace CampusAppWP8.Utility
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
+ using CampusAppWP8.Resources;
///
/// Collection of utility functions.
@@ -201,7 +202,11 @@ namespace CampusAppWP8.Utility
/// the position of the phone
public static GeoPosition DetermineCurrentPosition(uint accuracy = 50)
{
- //Utilities.DetermineAndStoreCurrentPosition();
+ if (!Settings.AppSetting.GeoWatchEnable)
+ {
+ return null;
+ }
+
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
bool success = watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
GeoPosition geoposition = null;
@@ -209,6 +214,7 @@ namespace CampusAppWP8.Utility
{
geoposition = watcher.Position;
}
+
watcher.Stop();
return geoposition;
}
@@ -224,20 +230,20 @@ namespace CampusAppWP8.Utility
string lat = geoposition.Location.Latitude.ToString(CultureInfo.InvariantCulture);
string log = geoposition.Location.Longitude.ToString(CultureInfo.InvariantCulture);
string time = geoposition.Timestamp.Ticks.ToString();
- App.SaveToAppState("CurrentPosition.Lat", lat);
- App.SaveToAppState("CurrentPosition.Long", log);
- App.SaveToAppState("CurrentPosition.Time", time);
+ App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Lat, lat);
+ App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Long, log);
+ App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Time, time);
}
}
///
- /// Method determine and store the current position of the phone, in 15 min intcavv
+ /// Method determine and store the current position of the phone, in 15 min interval
///
public static void DetermineAndStoreCurrentPosition()
{
- string lat = App.LoadFromAppState("CurrentPosition.Lat");
- string log = App.LoadFromAppState("CurrentPosition.Long");
- string time = App.LoadFromAppState("CurrentPosition.Time");
+ string lat = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat);
+ string log = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Long);
+ string time = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Time);
if (lat == null || log == null || time == null || lat.Equals(string.Empty) || log.Equals(string.Empty) || time.Equals(string.Empty))
{
Utilities.DetermineAndStoreCurrentPositionForce();
@@ -245,7 +251,7 @@ namespace CampusAppWP8.Utility
else
{
long longTime = 0;
- if(!long.TryParse(time, out longTime))
+ if (!long.TryParse(time, out longTime))
{
return;
}
@@ -253,9 +259,7 @@ namespace CampusAppWP8.Utility
DateTime expired = new DateTime(longTime).AddMinutes(15);
if (DateTime.Now.Ticks > expired.Ticks)
{
-
Utilities.DetermineAndStoreCurrentPositionForce();
-
}
}
}