add optin and doku

This commit is contained in:
stubbfel
2013-08-08 13:51:20 +02:00
parent e8fe0bb041
commit 6ce158dc41
15 changed files with 283 additions and 52 deletions

View File

@@ -9,9 +9,10 @@ namespace CampusAppWP8.Feed.GeoApi
{
using CampusAppWP8.Model;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
/// <summary>
/// Class for sps api
/// Class for SPSAPI
/// </summary>
public class SpsApi : XmlModel<SpsModel>
{
@@ -19,7 +20,7 @@ namespace CampusAppWP8.Feed.GeoApi
/// Initializes a new instance of the <see cref="SpsApi" /> class.
/// </summary>
public SpsApi()
: base(ModelType.Feed, "http://141.43.76.140/service/sps")
: base(ModelType.Feed, Constants.UrlSpsService)
{
}
}

View File

@@ -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)

View File

@@ -103,6 +103,7 @@
<Compile Include="Model\GeoDb\PlaceModel.cs" />
<Compile Include="Model\GeoDb\SpsModel.cs" />
<Compile Include="Model\Mensa\MealModel.cs" />
<Compile Include="Model\Setting\AppSettings.cs" />
<Compile Include="Model\Setting\UserProfilModel.cs" />
<Compile Include="Model\Utility\CourseListPickerItemListModel.cs" />
<Compile Include="Model\Utility\DegreeListPickerItemListModel.cs" />

View File

@@ -1,20 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
//-----------------------------------------------------------------------
// <copyright file="PlaceModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>08.08.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.GeoDb
{
using System.Xml.Serialization;
/// <summary>
/// Model for a place of the SPSService
/// </summary>
public class PlaceModel
{
/// <summary>
/// Gets or sets the placeId
/// </summary>
[XmlAttribute("id")]
public string PlaceId { get; set; }
/// <summary>
/// Gets or sets the id of the "parent" of a place
/// </summary>
[XmlAttribute("parentId")]
public string ParentId { get; set; }
/// <summary>
/// Gets or sets the ReferencePoint of a place
/// </summary>
[XmlAttribute("refpoint")]
public string RefPoint { get; set; }
}

View File

@@ -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;
//-----------------------------------------------------------------------
// <copyright file="SpsModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>08.08.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.GeoDb
{
using System.Collections.ObjectModel;
using System.Xml.Serialization;
/// <summary>
/// Model for a xml-response of the SPSService
/// </summary>
[XmlRoot("root")]
public class SpsModel
{
/// <summary>
/// Gets or sets a list of places
/// </summary>
[XmlElement("place")]
public ObservableCollection<PlaceModel> Places { get; set; }
}

View File

@@ -0,0 +1,50 @@
//-----------------------------------------------------------------------
// <copyright file="AppSettings.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>08.08.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.Setting
{
using CampusAppWP8.Resources;
/// <summary>
/// Model for settings of the app
/// </summary>
public class AppSettings
{
/// <summary>
/// Gets or sets a value indicating whether the GeoWatch-Flag
/// </summary>
public bool GeoWatchEnable
{
get
{
return App.LoadFromAppState<bool>(Constants.AppSetting_GeoWatchEnable);
}
set
{
App.SaveToAppState<bool>(Constants.AppSetting_GeoWatchEnable, value);
}
}
/// <summary>
/// Gets or sets a value indicating whether the InitializationApp-Flag
/// </summary>
public bool InitApp
{
get
{
return App.LoadFromAppState<bool>(Constants.AppSetting_GeoWatchEnable);
}
set
{
App.SaveToAppState<bool>(Constants.AppSetting_GeoWatchEnable, value);
}
}
}
}

View File

@@ -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;
/// <summary>
/// Class for the MensaPage
@@ -31,7 +24,7 @@ namespace CampusAppWP8.Pages.Mensa
/// </summary>
private MensaFeed feed;
private SpsApi spsApi;
// private SpsApi spsApi;
/// <summary>
/// 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;
}
}*/
/// <summary>
/// Override the OnNavigatedFrom method

View File

@@ -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;
/// <summary>
/// Class for the StartPage
@@ -30,14 +26,20 @@ namespace CampusAppWP8.Pages
/// </summary>
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;
}
}
/// <summary>
/// Method handle OrientationPage
/// </summary>
@@ -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;
}
}
/// <summary>
/// Method Navigate to <see cref="Setting/UserProfil"/>
/// </summary>
/// <param name="sender">Caller of the function</param>
/// <param name="e">some EventArgs</param>
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);
}
/// <summary>
/// Method change the Opacity of the ApplicationBar
/// </summary>
/// <param name="sender">Caller of the function</param>
/// <param name="e">some EventArgs</param>
private void ApplicationBar_StateChanged(object sender, ApplicationBarStateChangedEventArgs e)
{
if (e.IsMenuVisible)
@@ -104,5 +114,31 @@ namespace CampusAppWP8.Pages
ApplicationBar.Opacity = 0.5;
}
}
/// <summary>
/// Method show all OptIns
/// </summary>
private void ShowOptIns()
{
this.GeoWatchOptIN();
}
/// <summary>
/// Method show the GeoWatchOptIn in a MessageBox
/// </summary>
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;
}
}
}
}

View File

@@ -204,6 +204,24 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Ortung ähnelt.
/// </summary>
public static string GeoWatch_OptInHeader {
get {
return ResourceManager.GetString("GeoWatch_OptInHeader", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Dürfen Positionsdaten enhober und verwendet werdet? ähnelt.
/// </summary>
public static string GeoWatch_OptInText {
get {
return ResourceManager.GetString("GeoWatch_OptInText", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Hinweis ähnelt.
/// </summary>

View File

@@ -359,4 +359,10 @@
<data name="MensaApp_Soup" xml:space="preserve">
<value>Suppe</value>
</data>
<data name="GeoWatch_OptInHeader" xml:space="preserve">
<value>Ortung</value>
</data>
<data name="GeoWatch_OptInText" xml:space="preserve">
<value>Dürfen Positionsdaten enhober und verwendet werdet?</value>
</data>
</root>

View File

@@ -60,6 +60,24 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die AppSetting.GeoWatchEnable ähnelt.
/// </summary>
public static string AppSetting_GeoWatchEnable {
get {
return ResourceManager.GetString("AppSetting_GeoWatchEnable", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die AppSetting.InitApp ähnelt.
/// </summary>
public static string AppSetting_InitApp {
get {
return ResourceManager.GetString("AppSetting_InitApp", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die DepartmentFavoriteFeed.xml ähnelt.
/// </summary>
@@ -150,6 +168,33 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Lat ähnelt.
/// </summary>
public static string GeoWatch_CurrentPosition_Lat {
get {
return ResourceManager.GetString("GeoWatch_CurrentPosition_Lat", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Long ähnelt.
/// </summary>
public static string GeoWatch_CurrentPosition_Long {
get {
return ResourceManager.GetString("GeoWatch_CurrentPosition_Long", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Time ähnelt.
/// </summary>
public static string GeoWatch_CurrentPosition_Time {
get {
return ResourceManager.GetString("GeoWatch_CurrentPosition_Time", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die IsolatedStorage_DepartmentFavoriteModel ähnelt.
/// </summary>
@@ -654,6 +699,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die http://141.43.76.140/service/sps ähnelt.
/// </summary>
public static string UrlSpsService {
get {
return ResourceManager.GetString("UrlSpsService", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/getdata.php?db=studentcouncils&amp;app=2&amp;appversion=1 ähnelt.
/// </summary>

View File

@@ -333,4 +333,22 @@
<data name="MealIconName_Wild" xml:space="preserve">
<value>WILD</value>
</data>
<data name="AppSetting_GeoWatchEnable" xml:space="preserve">
<value>AppSetting.GeoWatchEnable</value>
</data>
<data name="AppSetting_InitApp" xml:space="preserve">
<value>AppSetting.InitApp</value>
</data>
<data name="GeoWatch_CurrentPosition_Lat" xml:space="preserve">
<value>CurrentPosition.Lat</value>
</data>
<data name="GeoWatch_CurrentPosition_Long" xml:space="preserve">
<value>CurrentPosition.Long</value>
</data>
<data name="GeoWatch_CurrentPosition_Time" xml:space="preserve">
<value>CurrentPosition.Time</value>
</data>
<data name="UrlSpsService" xml:space="preserve">
<value>http://141.43.76.140/service/sps</value>
</data>
</root>

View File

@@ -9,6 +9,7 @@
namespace CampusAppWP8
{
using CampusAppWP8.File.Setting;
using CampusAppWP8.Model.Setting;
/// <summary>
/// Class handle all setting (files)
@@ -20,6 +21,11 @@ namespace CampusAppWP8
/// </summary>
private static UserProfilFile userProfil = new UserProfilFile();
/// <summary>
/// reference of the appSettings
/// </summary>
private static AppSettings appSetting = new AppSettings();
/// <summary>
/// Gets or sets the user-profile-file
/// </summary>
@@ -38,5 +44,24 @@ namespace CampusAppWP8
}
}
}
/// <summary>
/// Gets or sets the AppSetting
/// </summary>
public static AppSettings AppSetting
{
get
{
return Settings.appSetting;
}
set
{
if (value != Settings.appSetting)
{
Settings.appSetting = value;
}
}
}
}
}

View File

@@ -10,8 +10,6 @@ namespace CampusAppWP8.Utility
using System;
using System.IO;
using Windows.Storage;
// test using for bug #126
using System.Threading.Tasks;
/// <summary>
/// File class.

View File

@@ -15,6 +15,7 @@ namespace CampusAppWP8.Utility
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using CampusAppWP8.Resources;
/// <summary>
/// Collection of utility functions.
@@ -201,7 +202,11 @@ namespace CampusAppWP8.Utility
/// <returns>the position of the phone</returns>
public static GeoPosition<GeoCoordinate> 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<GeoCoordinate> 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<string>("CurrentPosition.Lat", lat);
App.SaveToAppState<string>("CurrentPosition.Long", log);
App.SaveToAppState<string>("CurrentPosition.Time", time);
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Lat, lat);
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Long, log);
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Time, time);
}
}
/// <summary>
/// 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
/// </summary>
public static void DetermineAndStoreCurrentPosition()
{
string lat = App.LoadFromAppState<string>("CurrentPosition.Lat");
string log = App.LoadFromAppState<string>("CurrentPosition.Long");
string time = App.LoadFromAppState<string>("CurrentPosition.Time");
string lat = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Lat);
string log = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Long);
string time = App.LoadFromAppState<string>(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();
}
}
}