Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

Commit

Permalink
Implemented Native Persistent Storage
Browse files Browse the repository at this point in the history
Uses NSUserDefaults and Sharedprefs (ios and and android, respectively)
I think all the bugs have been ironed out, but we may find some later on...
  • Loading branch information
shreystechtips committed Feb 13, 2019
1 parent bd35761 commit d2a59c6
Show file tree
Hide file tree
Showing 28 changed files with 1,233 additions and 1,776 deletions.
10 changes: 10 additions & 0 deletions Droid/NRGScoutingApp.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@
<Reference Include="Xamarin.Forms.Xaml">
<HintPath>..\packages\Xamarin.Forms.3.5.0.129452\lib\MonoAndroid81\Xamarin.Forms.Xaml.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Android.Support.CustomTabs">
<HintPath>..\packages\Xamarin.Android.Support.CustomTabs.28.0.0\lib\monoandroid81\Xamarin.Android.Support.CustomTabs.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Essentials">
<HintPath>..\packages\Xamarin.Essentials.1.0.1\lib\monoandroid81\Xamarin.Essentials.dll</HintPath>
</Reference>
<Reference Include="Java.Interop" />
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand Down Expand Up @@ -296,4 +305,5 @@
<Import Project="..\packages\Xamarin.Android.Support.Design.28.0.0\build\monoandroid81\Xamarin.Android.Support.Design.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Design.28.0.0\build\monoandroid81\Xamarin.Android.Support.Design.targets')" />
<Import Project="..\packages\Xamarin.Android.Support.v7.MediaRouter.28.0.0\build\monoandroid81\Xamarin.Android.Support.v7.MediaRouter.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.MediaRouter.28.0.0\build\monoandroid81\Xamarin.Android.Support.v7.MediaRouter.targets')" />
<Import Project="..\packages\Xamarin.Forms.3.5.0.129452\build\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.3.5.0.129452\build\Xamarin.Forms.targets')" />
<Import Project="..\packages\Xamarin.Android.Support.CustomTabs.28.0.0\build\monoandroid81\Xamarin.Android.Support.CustomTabs.targets" Condition="Exists('..\packages\Xamarin.Android.Support.CustomTabs.28.0.0\build\monoandroid81\Xamarin.Android.Support.CustomTabs.targets')" />
</Project>
3 changes: 3 additions & 0 deletions Droid/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<packages>
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="monoandroid81" />
<package id="Rg.Plugins.Popup" version="1.1.4.168" targetFramework="monoandroid81" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="monoandroid81" />
<package id="Xam.Plugin.Connectivity" version="3.2.0" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Arch.Core.Common" version="1.1.1" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Arch.Lifecycle.Common" version="1.1.1" targetFramework="monoandroid81" />
Expand All @@ -11,6 +12,7 @@
<package id="Xamarin.Android.Support.Compat" version="28.0.0" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Core.UI" version="28.0.0" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Core.Utils" version="28.0.0" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.CustomTabs" version="28.0.0" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Design" version="28.0.0" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Fragment" version="28.0.0" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Media.Compat" version="28.0.0" targetFramework="monoandroid81" />
Expand All @@ -22,6 +24,7 @@
<package id="Xamarin.Android.Support.v7.Palette" version="28.0.0" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="28.0.0" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="28.0.0" targetFramework="monoandroid81" />
<package id="Xamarin.Essentials" version="1.0.1" targetFramework="monoandroid81" />
<package id="Xamarin.Forms" version="3.5.0.129452" targetFramework="monoandroid81" />
<package id="Xamarin.Plugins.Clipboard" version="2.2.1" targetFramework="monoandroid81" />
</packages>
23 changes: 10 additions & 13 deletions NRGScoutingApp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using System.ComponentModel;
using System.Security.Principal;
using Xamarin.Forms;

namespace NRGScoutingApp
{
public partial class App : Application
{
namespace NRGScoutingApp {
public partial class App : Application {
public static bool UseMockDataStore = true;
public static string BackendUrl = "https://localhost:5000";

public App()
{
InitializeComponent();
Application.Current.MainPage = new NavigationPage(new NavTab());
MainPage = new NavigationPage(new NavTab());
public App () {
InitializeComponent ();
Application.Current.MainPage = new NavigationPage (new NavTab ());
MainPage = new NavigationPage (new NavTab ());
if (UseMockDataStore)
DependencyService.Register<MockDataStore>();
DependencyService.Register<MockDataStore> ();
else
DependencyService.Register<CloudDataStore>();
DependencyService.Register<CloudDataStore> ();
}

}
}
}
41 changes: 19 additions & 22 deletions NRGScoutingApp/Helper Classes/ConstantVars.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
namespace NRGScoutingApp
{
public class ConstantVars
{
namespace NRGScoutingApp {
public class ConstantVars {
/*
* IMPORTANT NOTE:
* VARIABLES CONTAINING "LIVE" ARE USED IN the NewMatchStart page
Expand Down Expand Up @@ -79,11 +77,10 @@ public class ConstantVars
public static readonly String LVL_2_CLIMB = "Level 2";
public static readonly String LVL_3_CLIMB = "Level 3";


/*
* RANKER VALUES
* NOTE: THE LOWER THE VALUES FOR RANK, THE BETTER
*/
*/
//Autonomous
public static readonly int AUTO_LENGTH = 15000;
public static readonly double MULT_SANDSTORM_MANUAL = 1;
Expand All @@ -93,7 +90,7 @@ public class ConstantVars
public static readonly double PTS_BASELINE_LVL_2 = 3;

//Game Piece Manipulation
public static readonly double PTS_GAME_PIECE= 1;
public static readonly double PTS_GAME_PIECE = 1;
public static readonly double PTS_DROP_LVL_1 = 1;
public static readonly double PTS_DROP_LVL_2 = 2;
public static readonly double PTS_DROP_LVL_3 = 3;
Expand All @@ -117,11 +114,10 @@ public class ConstantVars
public static readonly double PTS_HELPED_LVL_2 = 1;
public static readonly double PTS_HELPED_LVL_3 = 2;


/*
* Rankings Detail View Page
*/
public static readonly String[] scoreBaseVals = { "Overall: ", "Cargo: ", "Hatch: ", "Climb: ", "Low: ", "Medium: ", "High: ", "Ship: "};
public static readonly String[] scoreBaseVals = { "Overall: ", "Cargo: ", "Hatch: ", "Climb: ", "Low: ", "Medium: ", "High: ", "Ship: " };
public static readonly int numRankTypes = scoreBaseVals.Length;
public static readonly String noVal = "Empty";

Expand All @@ -130,17 +126,18 @@ public class ConstantVars
*/
//Separates the entries if same team was scouted twice
public static readonly String entrySeparator = "\nANOTHER PIT ENTRY:::::::\n";
public static readonly String[] QUESTIONS =
{"Hours practiced?",
"Drive base?",
"How many hatch panels/cargo do you average per match?",
"What do you focus on (rocket/cargo ship)?",
"What level(s) can your bot reach?",
"All positions in auto for sandstorm?",
"Auto vs tele for sandstorm?",
"Can you get to the highest platform in the hab? What is your prefered method in endgame?",
"Speed?",
"Mechanism?",
"Placement?" };
public static readonly String[] QUESTIONS = {
"Hours practiced?",
"Drive base?",
"How many hatch panels/cargo do you average per match?",
"What do you focus on (rocket/cargo ship)?",
"What level(s) can your bot reach?",
"All positions in auto for sandstorm?",
"Auto vs tele for sandstorm?",
"Can you get to the highest platform in the hab? What is your prefered method in endgame?",
"Speed?",
"Mechanism?",
"Placement?"
};
}
}
}
86 changes: 41 additions & 45 deletions NRGScoutingApp/Helper Classes/MatchFormat.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace NRGScoutingApp
{
public class MatchFormat
{
namespace NRGScoutingApp {
public class MatchFormat {
//Object to store all params
public class EntryParams
{
public class EntryParams {
public String team { get; set; }
public int matchNum { get; set; }
public int side { get; set; }
Expand All @@ -34,15 +31,13 @@ public class EntryParams

}

public enum DEATH_TYPE
{
public enum DEATH_TYPE {
noDeath,
halfDeath,
fullDeath
}

public enum ACTION
{
public enum ACTION {
dropNone, //Drop None
drop1, //Rocket lvl 1
drop2, //Rocket lvl 2
Expand All @@ -53,8 +48,7 @@ public enum ACTION
startClimb //Start Climb
}

public enum CHOOSE_RANK_TYPE
{
public enum CHOOSE_RANK_TYPE {
overallRank, //Overall Team Rank
drop1, //Lvl1
drop2, //Lvl2
Expand All @@ -65,8 +59,7 @@ public enum CHOOSE_RANK_TYPE
climb //Climb
}

public enum MATCH_SIDES
{
public enum MATCH_SIDES {
Red1,
Red2,
Red3,
Expand All @@ -80,35 +73,40 @@ public class Data //One MatchEvent (When it happened and what happened
public int time { get; set; }
public int type { get; set; }
}
public static JObject eventsListToJSONEvents(List<Data> datas)
{

JObject events = new JObject();
Data[] eventArray = sortListByTime(datas);
events.Add("numEvents", eventArray.Length);
for (int i = 0; i < eventArray.Length; i++)
{
events.Add("TE" + i + "_0", eventArray[i].time);
events.Add("TE" + i + "_1", eventArray[i].type);
public static List<Data> JSONEventsToObject (JObject val) {
List<Data> toGive = new List<Data> ();
for (int i = 0; i < Convert.ToInt32 (val.Property ("numEvents").Value); i++) {
toGive.Add (new MatchFormat.Data {
time = Convert.ToInt32 (val.Property ("TE" + i + "_0").Value),
type = Convert.ToInt32 (val.Property ("TE" + i + "_1").Value)
});
}
return toGive;
}

public static JObject eventsListToJSONEvents (List<Data> datas) {

JObject events = new JObject ();
Data[] eventArray = sortListByTime (datas);
events.Add ("numEvents", eventArray.Length);
for (int i = 0; i < eventArray.Length; i++) {
events.Add ("TE" + i + "_0", eventArray[i].time);
events.Add ("TE" + i + "_1", eventArray[i].type);
}
return events;
}

public static Data[] sortListByTime(List<Data> datas)
{
Data[] input = datas.ToArray();
public static Data[] sortListByTime (List<Data> datas) {
Data[] input = datas.ToArray ();
Data[] outputArray = new Data[input.Length];
for (int i = 0; i < input.Length; i++)
{
for (int i = 0; i < input.Length; i++) {
outputArray[i] = input[i];
}
for (int i = 0; i < input.Length; i++)
{
for (int j = 0; j < input.Length - i; j++)
{
for (int i = 0; i < input.Length; i++) {
for (int j = 0; j < input.Length - i; j++) {
// Use ">" for ascending and "<" for descending
if (outputArray[i].time > outputArray[j + i].time)
{
if (outputArray[i].time > outputArray[j + i].time) {
MatchFormat.Data c = outputArray[i];
MatchFormat.Data d = outputArray[j + i];
outputArray[i] = d;
Expand All @@ -120,21 +118,19 @@ public static Data[] sortListByTime(List<Data> datas)
return outputArray;
}

public static String matchSideFromEnum(int side)
{
switch (side)
{
case (int)MATCH_SIDES.Red1:
public static String matchSideFromEnum (int side) {
switch (side) {
case (int) MATCH_SIDES.Red1:
return ConstantVars.RED_1_TEXT;
case (int)MATCH_SIDES.Red2:
case (int) MATCH_SIDES.Red2:
return ConstantVars.RED_2_TEXT;
case (int)MATCH_SIDES.Red3:
case (int) MATCH_SIDES.Red3:
return ConstantVars.RED_3_TEXT;
case (int)MATCH_SIDES.Blue1:
case (int) MATCH_SIDES.Blue1:
return ConstantVars.BLUE_1_TEXT;
case (int)MATCH_SIDES.Blue2:
case (int) MATCH_SIDES.Blue2:
return ConstantVars.BLUE_2_TEXT;
case (int)MATCH_SIDES.Blue3:
case (int) MATCH_SIDES.Blue3:
return ConstantVars.BLUE_3_TEXT;
}
return "Error";
Expand Down
Loading

0 comments on commit d2a59c6

Please sign in to comment.