├── screenshot1.png
├── screenshot2.png
├── screenshot3.png
├── screenshot-en1.png
├── screenshot-en2.png
├── screenshot-en3.png
├── MyBand
├── MyBand.Shared
│ ├── Assets
│ │ ├── battery-Full.png
│ │ ├── battery-Low.png
│ │ ├── battery-None.png
│ │ ├── battery-Charging.png
│ │ └── battery-NotCharging.png
│ ├── App.xaml
│ ├── Entities
│ │ ├── SmallEntities.cs
│ │ ├── ActivityTracking
│ │ │ ├── Sleep
│ │ │ │ ├── DeepSleepBlock.cs
│ │ │ │ ├── LightSleepBlock.cs
│ │ │ │ ├── SleepBlock.cs
│ │ │ │ └── SleepPeriod.cs
│ │ │ └── Steps
│ │ │ │ ├── RunStepsBlock.cs
│ │ │ │ ├── WalkStepsBlock.cs
│ │ │ │ ├── StepsBlock.cs
│ │ │ │ └── StepsPeriod.cs
│ │ ├── Database
│ │ │ ├── ActivityFrame.cs
│ │ │ └── SQLiteAsync.cs
│ │ ├── LEParams.cs
│ │ ├── ColorTheme.cs
│ │ ├── BatteryInfo.cs
│ │ ├── UserInfo.cs
│ │ ├── Alarm.cs
│ │ ├── SensorData.cs
│ │ └── DeviceInfo.cs
│ ├── MyBand.Shared.shproj
│ ├── BindableBase.cs
│ ├── App.xaml.cs
│ ├── MyBand.Shared.projitems
│ └── ObservableDictionary.cs
├── MyBand.Windows
│ ├── Assets
│ │ ├── Logo.scale-100.png
│ │ ├── SmallLogo.scale-100.png
│ │ ├── StoreLogo.scale-100.png
│ │ └── SplashScreen.scale-100.png
│ ├── packages.config
│ ├── Main.xaml
│ ├── Main.xaml.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Package.appxmanifest
│ └── MyBand.Windows.csproj
└── MyBand.WindowsPhone
│ ├── Assets
│ ├── Logo300x300.png
│ ├── Logo.scale-240.png
│ ├── SmallLogo.scale-240.png
│ ├── StoreLogo.scale-240.png
│ ├── WideLogo.scale-240.png
│ ├── SplashScreen.scale-240.png
│ └── Square71x71Logo.scale-240.png
│ ├── packages.config
│ ├── StoreManifest.xml
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Pages
│ ├── SetDailyGoal.xaml.cs
│ ├── ActivityTracking.xaml.cs
│ ├── SetDailyGoal.xaml
│ ├── SetAlarm.xaml
│ ├── SetUserInfo.xaml.cs
│ ├── SetUserInfo.xaml
│ ├── SetAlarm.xaml.cs
│ ├── ActivityTracking.xaml
│ └── MainPageProperties.cs
│ ├── Package.appxmanifest
│ ├── MyBand.WindowsPhone.csproj
│ └── Package.StoreAssociation.xml
├── packages
├── sqlite-net.1.0.8
│ ├── sqlite-net.1.0.8.nupkg
│ └── content
│ │ └── SQLiteAsync.cs
└── repositories.config
├── LICENSE
├── README.md
└── MyBand.sln
/screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/screenshot1.png
--------------------------------------------------------------------------------
/screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/screenshot2.png
--------------------------------------------------------------------------------
/screenshot3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/screenshot3.png
--------------------------------------------------------------------------------
/screenshot-en1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/screenshot-en1.png
--------------------------------------------------------------------------------
/screenshot-en2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/screenshot-en2.png
--------------------------------------------------------------------------------
/screenshot-en3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/screenshot-en3.png
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Assets/battery-Full.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.Shared/Assets/battery-Full.png
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Assets/battery-Low.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.Shared/Assets/battery-Low.png
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Assets/battery-None.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.Shared/Assets/battery-None.png
--------------------------------------------------------------------------------
/MyBand/MyBand.Windows/Assets/Logo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.Windows/Assets/Logo.scale-100.png
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Assets/battery-Charging.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.Shared/Assets/battery-Charging.png
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Assets/Logo300x300.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.WindowsPhone/Assets/Logo300x300.png
--------------------------------------------------------------------------------
/packages/sqlite-net.1.0.8/sqlite-net.1.0.8.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/packages/sqlite-net.1.0.8/sqlite-net.1.0.8.nupkg
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Assets/battery-NotCharging.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.Shared/Assets/battery-NotCharging.png
--------------------------------------------------------------------------------
/MyBand/MyBand.Windows/Assets/SmallLogo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.Windows/Assets/SmallLogo.scale-100.png
--------------------------------------------------------------------------------
/MyBand/MyBand.Windows/Assets/StoreLogo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.Windows/Assets/StoreLogo.scale-100.png
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Assets/Logo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.WindowsPhone/Assets/Logo.scale-240.png
--------------------------------------------------------------------------------
/MyBand/MyBand.Windows/Assets/SplashScreen.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.Windows/Assets/SplashScreen.scale-100.png
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Assets/SmallLogo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.WindowsPhone/Assets/SmallLogo.scale-240.png
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Assets/StoreLogo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.WindowsPhone/Assets/StoreLogo.scale-240.png
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Assets/WideLogo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.WindowsPhone/Assets/WideLogo.scale-240.png
--------------------------------------------------------------------------------
/MyBand/MyBand.Windows/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Assets/SplashScreen.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.WindowsPhone/Assets/SplashScreen.scale-240.png
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Assets/Square71x71Logo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dahrkael/MiBand-Tracker/HEAD/MyBand/MyBand.WindowsPhone/Assets/Square71x71Logo.scale-240.png
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/StoreManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/repositories.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Windows/Main.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/SmallEntities.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MyBand.Entities
6 | {
7 | /*class SmallEntities
8 | {
9 | }*/
10 |
11 | class Vibration
12 | {
13 | public static byte WithLeds = 0x00;
14 | public static byte Normal = 0x01;
15 | public static byte Special = 0x02; // no se que diferencia hay con el normal
16 | }
17 |
18 | enum WearLocation
19 | {
20 | LeftHand,
21 | RightHand,
22 | Neck
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/ActivityTracking/Sleep/DeepSleepBlock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MyBand.Entities.ActivityTracking.Sleep
6 | {
7 | public class DeepSleepBlock
8 | {
9 | private DateTime start;
10 | private DateTime end;
11 |
12 | public DateTime Start
13 | {
14 | get { return start; }
15 | }
16 |
17 | public DateTime End
18 | {
19 | get { return end; }
20 | }
21 |
22 | public DeepSleepBlock(DateTime start, DateTime end)
23 | {
24 | this.start = start;
25 | this.end = end;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/ActivityTracking/Sleep/LightSleepBlock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MyBand.Entities.ActivityTracking.Sleep
6 | {
7 | public class LightSleepBlock
8 | {
9 | private DateTime start;
10 | private DateTime end;
11 |
12 | public DateTime Start
13 | {
14 | get { return start; }
15 | }
16 |
17 | public DateTime End
18 | {
19 | get { return end; }
20 | }
21 |
22 | public LightSleepBlock(DateTime start, DateTime end)
23 | {
24 | this.start = start;
25 | this.end = end;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Windows/Main.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.Foundation;
7 | using Windows.Foundation.Collections;
8 | using Windows.UI.Xaml;
9 | using Windows.UI.Xaml.Controls;
10 | using Windows.UI.Xaml.Controls.Primitives;
11 | using Windows.UI.Xaml.Data;
12 | using Windows.UI.Xaml.Input;
13 | using Windows.UI.Xaml.Media;
14 | using Windows.UI.Xaml.Navigation;
15 |
16 | // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
17 |
18 | namespace MyBand.Pages
19 | {
20 | ///
21 | /// An empty page that can be used on its own or navigated to within a Frame.
22 | ///
23 | public sealed partial class Main : Page
24 | {
25 | public Main()
26 | {
27 | this.InitializeComponent();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/MyBand.Shared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 8923dc15-b60b-4fb4-a5df-4e1662ef36c4
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/ActivityTracking/Steps/RunStepsBlock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MyBand.Entities.ActivityTracking.Steps
6 | {
7 | public class RunStepsBlock
8 | {
9 | private DateTime start;
10 | private DateTime end;
11 | private int steps;
12 | private int runs;
13 |
14 | public DateTime Start
15 | {
16 | get { return start; }
17 | }
18 |
19 | public DateTime End
20 | {
21 | get { return end; }
22 | }
23 |
24 | public int Steps
25 | {
26 | get { return steps; }
27 | }
28 |
29 | public int Runs
30 | {
31 | get { return runs; }
32 | }
33 |
34 | public RunStepsBlock(DateTime start, DateTime end, int steps, int runs)
35 | {
36 | this.start = start;
37 | this.end = end;
38 | this.steps = steps;
39 | this.runs = runs;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/ActivityTracking/Steps/WalkStepsBlock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MyBand.Entities.ActivityTracking.Steps
6 | {
7 | public class WalkStepsBlock
8 | {
9 | private DateTime start;
10 | private DateTime end;
11 | private int steps;
12 | private int runs;
13 |
14 | public DateTime Start
15 | {
16 | get { return start; }
17 | }
18 |
19 | public DateTime End
20 | {
21 | get { return end; }
22 | }
23 |
24 | public int Steps
25 | {
26 | get { return steps; }
27 | }
28 |
29 | public int Runs
30 | {
31 | get { return runs; }
32 | }
33 |
34 | public WalkStepsBlock(DateTime start, DateTime end, int steps, int runs)
35 | {
36 | this.start = start;
37 | this.end = end;
38 | this.steps = steps;
39 | this.runs = runs;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright Dahrkael (c) 2016
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("My MiBand")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("My MiBand")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Version information for an assembly consists of the following four values:
18 | //
19 | // Major Version
20 | // Minor Version
21 | // Build Number
22 | // Revision
23 | //
24 | // You can specify all the values or you can default the Build and Revision Numbers
25 | // by using the '*' as shown below:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.0.0")]
28 | [assembly: AssemblyFileVersion("1.0.0.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/MyBand/MyBand.Windows/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MyBand.Windows")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MyBand.Windows")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Version information for an assembly consists of the following four values:
18 | //
19 | // Major Version
20 | // Minor Version
21 | // Build Number
22 | // Revision
23 | //
24 | // You can specify all the values or you can default the Build and Revision Numbers
25 | // by using the '*' as shown below:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.0.0")]
28 | [assembly: AssemblyFileVersion("1.0.0.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/MyBand/MyBand.Windows/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | MyBand.Windows
6 | Santiago
7 | Assets\StoreLogo.png
8 |
9 |
10 | 6.3.0
11 | 6.3.0
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/Database/ActivityFrame.cs:
--------------------------------------------------------------------------------
1 | using SQLite;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace MyBand.Entities.Database
7 | {
8 | [Table("activity_frames")]
9 | public class ActivityFrame
10 | {
11 | /*[Column(IsDbGenerated = true, IsPrimaryKey = true)]
12 | public int ID { get; set; }*/
13 |
14 | [PrimaryKey, Column("timestamp")]
15 | public DateTime TimeStamp { get; set; }
16 |
17 | [Column("intensity")]
18 | public int Intensity { get; set; }
19 |
20 | [Column("steps")]
21 | public int Steps { get; set; }
22 |
23 | [Column("mode")]
24 | public byte Mode { get; set; }
25 |
26 | [Column("runs")]
27 | public byte Runs { get; set; }
28 |
29 | public ActivityFrame()
30 | { }
31 |
32 | public ActivityFrame(DateTime Moment, int Intensity, int Steps, byte Mode, byte Runs)
33 | {
34 | this.TimeStamp = Moment;
35 | this.Intensity = Intensity;
36 | this.Steps = Steps;
37 | this.Mode = Mode;
38 | this.Runs = Runs;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/ActivityTracking/Sleep/SleepBlock.cs:
--------------------------------------------------------------------------------
1 | using SQLite;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace MyBand.Entities.ActivityTracking.Sleep
7 | {
8 | [Table("sleep_blocks")]
9 | public class SleepBlock
10 | {
11 | [PrimaryKey, AutoIncrement, NotNull]
12 | public int ID { get; set; }
13 |
14 | [Column("period"), NotNull]
15 | public int Period
16 | {
17 | get;
18 | set;
19 | }
20 |
21 | [Column("mode"), NotNull]
22 | public int Mode
23 | {
24 | get;
25 | set;
26 | }
27 |
28 | [Column("start"), NotNull]
29 | public DateTime Start
30 | {
31 | get;
32 | set;
33 | }
34 |
35 | [Column("end"), NotNull]
36 | public DateTime End
37 | {
38 | get;
39 | set;
40 | }
41 |
42 | public SleepBlock()
43 | { }
44 |
45 | public SleepBlock(int period, int mode, DateTime start, DateTime end)
46 | {
47 | this.Start = start;
48 | this.End = end;
49 | this.Mode = mode;
50 | this.Period = period;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/ActivityTracking/Steps/StepsBlock.cs:
--------------------------------------------------------------------------------
1 | using SQLite;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace MyBand.Entities.ActivityTracking.Steps
7 | {
8 | [Table("steps_blocks")]
9 | public class StepsBlock
10 | {
11 | [PrimaryKey, AutoIncrement, NotNull]
12 | public int ID { get; set; }
13 |
14 | [Column("period"), NotNull]
15 | public int Period
16 | {
17 | get;
18 | set;
19 | }
20 |
21 | [Column("mode"), NotNull]
22 | public int Mode
23 | {
24 | get;
25 | set;
26 | }
27 |
28 | [Column("start"), NotNull]
29 | public DateTime Start
30 | {
31 | get;
32 | set;
33 | }
34 |
35 | [Column("end"), NotNull]
36 | public DateTime End
37 | {
38 | get;
39 | set;
40 | }
41 |
42 | [Column("steps"), NotNull]
43 | public int Steps
44 | {
45 | get;
46 | set;
47 | }
48 |
49 | [Column("runs"), NotNull]
50 | public int Runs
51 | {
52 | get;
53 | set;
54 | }
55 |
56 | public StepsBlock()
57 | { }
58 |
59 | public StepsBlock(int period, int mode, DateTime start, DateTime end, int steps, int runs)
60 | {
61 | this.Period = period;
62 | this.Mode = mode;
63 | this.Start = start;
64 | this.End = end;
65 | this.Steps = steps;
66 | this.Runs = runs;
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/LEParams.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MyBand.Entities
6 | {
7 | class LEParams
8 | {
9 | private int connIntMin;
10 | private int connIntMax;
11 | private int latency;
12 | private int timeout;
13 | private int connInt;
14 | private int advInt;
15 |
16 | public LEParams(Byte[] data)
17 | {
18 | if (data.Length != 12) { Valid = false; return; }
19 | this.connIntMin = data[0] | (data[1] << 8);
20 | this.connIntMax = data[2] | (data[3] << 8);
21 | this.latency = data[4] | (data[5] << 8);
22 | this.timeout = data[6] | (data[7] << 8);
23 | this.connInt = data[8] | (data[9] << 8);
24 | this.advInt = data[10] | (data[11] << 8);
25 |
26 | /*connIntMin * 1.25 milliseconds
27 | connIntMax * 1.25 milliseconds
28 | latency milliseconds
29 | timeout * 10 milliseconds
30 | connInt * 1.25 milliseconds
31 | advInt * 0.625 milliseconds*/
32 | Valid = true;
33 | }
34 |
35 | public bool Valid { get; set; }
36 | public int ConnIntMin { get { return this.connIntMin; } set {} }
37 | public int ConnIntMax { get { return this.connIntMax; } set {} }
38 | public int Latency { get { return this.latency; } set {} }
39 | public int Timeout { get { return this.timeout; } set {} }
40 | public int ConnInt { get { return this.connInt; } set {} }
41 | public int AdvInt { get { return this.advInt; } set {} }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MiBand Tracker
2 | Windows (8.1/10) & Windows Phone(8.1/10) app to interact with the Xiaomi Mi Band
3 |
4 | ## Explanation
5 | This was the first attempt at making the Xiaomi Mi Band work in the Windows environment (more specifically, Windows Phone).
6 | It appeared in technology blogs all around the world!
7 | * http://www.windowscentral.com/third-party-app-xiaomi-miband-wearable-works
8 | * http://www.windowscentral.com/miband-tracker-beta-windows-phone-now-english-and-open-all
9 |
10 | After releasing it, some others magically appeared out of nowhere (see: http://www.bindmiband.com/ still in active development),
11 | so I ceased development after reverse-engineering all the features and re-implement them for Windows, since that was the fun part.
12 |
13 | It also helped that Xiaomis firmware is pure garbage (and they are a software company? ha!), giving random errors and deleting data if you dont sync the band everyday.
14 |
15 | **If you want to know how everything works, or resume development where I left it, go ahead and fork it!**
16 |
17 | ## Features
18 | I developed it before the white-leds Mi Band and the Mi Band 2 were released, so its fully compatible only with the first batches and probably not with the latest firmwares.
19 |
20 | ### Done
21 | - Sync steps and sleep data (analyzed, split and saved to mysqlite)
22 | - Realtime steps
23 | - Setting time and date
24 | - Alarms
25 | - Daily target
26 | - selecting leds color
27 | - "Find my band", factory reset, full test
28 |
29 | ### Pending
30 | - Showing steps and sleep data (the charts and screen are half-done)
31 | - Updating firmware
32 |
33 | ## License
34 | I release the project under the MIT License, because I'm that kind of guy.
35 | Anyway if you use the code for something cool or you liked it, drop me a line!
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Pages/SetDailyGoal.xaml.cs:
--------------------------------------------------------------------------------
1 | using MyBand.Entities;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Runtime.InteropServices.WindowsRuntime;
7 | using Windows.Foundation;
8 | using Windows.Foundation.Collections;
9 | using Windows.UI.Popups;
10 | using Windows.UI.Xaml;
11 | using Windows.UI.Xaml.Controls;
12 | using Windows.UI.Xaml.Controls.Primitives;
13 | using Windows.UI.Xaml.Data;
14 | using Windows.UI.Xaml.Input;
15 | using Windows.UI.Xaml.Media;
16 | using Windows.UI.Xaml.Navigation;
17 |
18 | namespace MyBand.Pages
19 | {
20 | public sealed partial class SetDailyGoal : Page
21 | {
22 | private bool initialSetup = false;
23 |
24 | public SetDailyGoal()
25 | {
26 | this.InitializeComponent();
27 | }
28 |
29 | protected override void OnNavigatedTo(NavigationEventArgs e)
30 | {
31 | if ((e.Parameter as string) == "InitialSetup")
32 | {
33 | initialSetup = true;
34 | }
35 | }
36 |
37 | private async void btnSave_Click(object sender, RoutedEventArgs e)
38 | {
39 | var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
40 | int goal = 8000;
41 | string text = txtGoal.Text;
42 | if (Int32.TryParse(text, out goal))
43 | {
44 | bool ret = await MiBand.Band.SetGoal(goal);
45 | if (!ret)
46 | {
47 | // algo ha ido mal
48 |
49 | MessageDialog dialog = new MessageDialog(loader.GetString("SetGoalErrorText"), loader.GetString("SetGoalErrorTitle"));
50 | await dialog.ShowAsync();
51 | }
52 | this.Frame.Navigate(typeof(Main), initialSetup ? "InitialSetup" : null);
53 | }
54 | else
55 | {
56 | // algo ha ido mal
57 | MessageDialog dialog = new MessageDialog(loader.GetString("SetGoalRetryText"), loader.GetString("SetGoalErrorTitle"));
58 | await dialog.ShowAsync();
59 | }
60 |
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/BindableBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.CompilerServices;
4 | using Windows.Foundation.Metadata;
5 |
6 | namespace MyBand
7 | {
8 | ///
9 | /// Implementation of to simplify models.
10 | ///
11 | [WebHostHidden]
12 | public abstract class BindableBase : INotifyPropertyChanged
13 | {
14 | ///
15 | /// Multicast event for property change notifications.
16 | ///
17 | public event PropertyChangedEventHandler PropertyChanged;
18 |
19 | ///
20 | /// Checks if a property already matches a desired value. Sets the property and
21 | /// notifies listeners only when necessary.
22 | ///
23 | /// Type of the property.
24 | /// Reference to a property with both getter and setter.
25 | /// Desired value for the property.
26 | /// Name of the property used to notify listeners. This
27 | /// value is optional and can be provided automatically when invoked from compilers that
28 | /// support CallerMemberName.
29 | /// True if the value was changed, false if the existing value matched the
30 | /// desired value.
31 | protected bool SetProperty(ref T storage, T value, [CallerMemberName] String propertyName = null)
32 | {
33 | if (Equals(storage, value)) return false;
34 |
35 | storage = value;
36 | OnPropertyChanged(propertyName);
37 | return true;
38 | }
39 |
40 | ///
41 | /// Notifies listeners that a property value has changed.
42 | ///
43 | /// Name of the property used to notify listeners. This
44 | /// value is optional and can be provided automatically when invoked from compilers
45 | /// that support .
46 | protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
47 | {
48 | var eventHandler = PropertyChanged;
49 | if (eventHandler != null)
50 | {
51 | eventHandler(this, new PropertyChangedEventArgs(propertyName));
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/ColorTheme.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MyBand.Entities
6 | {
7 | class ColorTheme
8 | {
9 | public static byte MIN_BRIGHTNESS = 0x00;
10 | public static byte MID_BRIGTHNESS = 0x03;
11 | public static byte MAX_BRIGTHNESS = 0x06;
12 |
13 | public static ColorTheme Black = new ColorTheme(0, 0, 0);
14 | public static ColorTheme Blue = new ColorTheme(0, 0, 6);
15 | public static ColorTheme Green = new ColorTheme(0, 6, 0);
16 | public static ColorTheme Aqua = new ColorTheme(0, 6, 6);
17 | public static ColorTheme Red = new ColorTheme(6, 0, 0);
18 | public static ColorTheme Fuchsia = new ColorTheme(6, 0, 6);
19 | public static ColorTheme Yellow = new ColorTheme(6, 6, 0);
20 | public static ColorTheme Gray = new ColorTheme(3, 3, 3);
21 | public static ColorTheme White = new ColorTheme(6, 6, 6);
22 | public static ColorTheme Orange = new ColorTheme(6, 3, 0);
23 |
24 | private byte red;
25 | private byte green;
26 | private byte blue;
27 |
28 | public byte R { get { return this.red; } }
29 | public byte G { get { return this.green; } }
30 | public byte B { get { return this.blue; } }
31 |
32 | public ColorTheme(byte R, byte G, byte B)
33 | {
34 | this.red = R;
35 | this.green = G;
36 | this.blue = B;
37 | }
38 |
39 | public static ColorTheme FromInt32(int Integer)
40 | {
41 | return new ColorTheme((byte)((Integer >> 16) & 0xFF), (byte)((Integer >> 8) & 0xFF), (byte)(Integer & 0xFF));
42 | }
43 |
44 | public Int32 ToInt32()
45 | {
46 | int ret = (red << 16) | (green << 8) | blue;
47 | return ret;
48 | }
49 |
50 | public override string ToString()
51 | {
52 | var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
53 |
54 | if (this.ToInt32() == 0x000606) { return loader.GetString("ColorBlue"); }
55 | if (this.ToInt32() == 0x040500) { return loader.GetString("ColorGreen"); }
56 | if (this.ToInt32() == 0x060102) { return loader.GetString("ColorRed"); }
57 | if (this.ToInt32() == 0x060200) { return loader.GetString("ColorOrange"); }
58 | return "R:"+red+"G:"+green+"B:"+blue;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MiBand Tracker BETA
7 | Dahrkael
8 | Assets\StoreLogo.png
9 |
10 |
11 | 6.3.1
12 | 6.3.1
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Pages/ActivityTracking.xaml.cs:
--------------------------------------------------------------------------------
1 | using MyBand.Entities.ActivityTracking.Steps;
2 | using MyBand.Entities.Database;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Runtime.InteropServices.WindowsRuntime;
8 | using Windows.Foundation;
9 | using Windows.Foundation.Collections;
10 | using Windows.UI.Xaml;
11 | using Windows.UI.Xaml.Controls;
12 | using Windows.UI.Xaml.Controls.Primitives;
13 | using Windows.UI.Xaml.Data;
14 | using Windows.UI.Xaml.Input;
15 | using Windows.UI.Xaml.Media;
16 | using Windows.UI.Xaml.Navigation;
17 | using Windows.UI.Xaml.Shapes;
18 |
19 | namespace MyBand.Pages
20 | {
21 | public sealed partial class ActivityTracking : Page
22 | {
23 | private StepsPeriod currentSelected = new StepsPeriod();
24 |
25 | private ObservableDictionary dataBindings = new ObservableDictionary();
26 | public ObservableDictionary DataBindings
27 | {
28 | get { return dataBindings; }
29 | }
30 |
31 |
32 | public ActivityTracking()
33 | {
34 | this.InitializeComponent();
35 |
36 | reloadChart();
37 | DataBindings.Add("CurrentDay", currentSelected);
38 | }
39 |
40 | protected override void OnNavigatedTo(NavigationEventArgs e)
41 | {
42 | }
43 |
44 | private void reloadChart()
45 | {
46 | // cargamos los periodos de los ultimos siete dias
47 | List periods = DB.GetStepsPeriods(DateTime.Today.AddDays(-7), DateTime.Today);
48 |
49 | // referencia para escalar las barras luego
50 | int maxSteps = 0;
51 | for (int i = 0; i < 7; i++)
52 | {
53 | // buscamos si hay un periodo o no guardado
54 | var period = periods.Find(p => p.Start == DateTime.Today.AddDays(-i));
55 | Bar bar = new Bar();
56 | bar.Date = DateTime.Today.AddDays(-i).Date;
57 | bar.Period = period;
58 | bar.ScaleY = 0.0;
59 | // actualizamos los pasos maximos de estos dias para el escalado
60 | if (period != null) { maxSteps = period.TotalSteps > maxSteps ? period.TotalSteps : maxSteps; }
61 | // FIXME no se si el acceso por clave al diccionario crea una entrada si no existe
62 | if (DataBindings.ContainsKey("Bar"+(i+1)))
63 | {
64 | DataBindings["Bar" + (i + 1)] = bar;
65 | }
66 | else
67 | {
68 | DataBindings.Add("Bar" + (i + 1), bar);
69 | }
70 | currentSelected = bar.Period;
71 | }
72 | // una vez asignadas las barras, calculamos el escalado
73 | for (int i = 0; i < 7; i++)
74 | {
75 | Bar bar = ((Bar)DataBindings["Bar" + (i + 1)]);
76 | if (bar.Period != null)
77 | {
78 | bar.ScaleY = (bar.Period.TotalSteps * 100) / maxSteps;
79 | }
80 | }
81 | }
82 |
83 | private void Rectangle_Tapped(object sender, TappedRoutedEventArgs e)
84 | {
85 | var selected = ((Bar)DataBindings[((Rectangle)sender).Name]).Period;
86 | currentSelected = selected;
87 | DataBindings["CurrentDay"] = currentSelected;
88 | }
89 | }
90 |
91 | class Bar
92 | {
93 | public DateTime Date { get; set; }
94 | public StepsPeriod Period { get; set; }
95 | public double ScaleY { get; set; }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/MyBand/MyBand.WindowsPhone/Pages/SetDailyGoal.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.ApplicationModel;
7 | using Windows.ApplicationModel.Activation;
8 | using Windows.Foundation;
9 | using Windows.Foundation.Collections;
10 | using Windows.Storage;
11 | using Windows.UI.Popups;
12 | using Windows.UI.Xaml;
13 | using Windows.UI.Xaml.Controls;
14 | using Windows.UI.Xaml.Controls.Primitives;
15 | using Windows.UI.Xaml.Data;
16 | using Windows.UI.Xaml.Input;
17 | using Windows.UI.Xaml.Media;
18 | using Windows.UI.Xaml.Media.Animation;
19 | using Windows.UI.Xaml.Navigation;
20 |
21 | namespace MyBand
22 | {
23 | public sealed partial class App : Application
24 | {
25 | public App()
26 | {
27 | this.InitializeComponent();
28 | this.Suspending += this.OnSuspending;
29 | UnhandledException += Application_UnhandledException;
30 | #if WINDOWS_PHONE_APP
31 | Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
32 | #endif
33 | }
34 |
35 | protected override void OnLaunched(LaunchActivatedEventArgs e)
36 | {
37 | #if DEBUG
38 | if (System.Diagnostics.Debugger.IsAttached)
39 | {
40 | this.DebugSettings.EnableFrameRateCounter = true;
41 | }
42 | #endif
43 |
44 | Frame rootFrame = Window.Current.Content as Frame;
45 |
46 | if (rootFrame == null)
47 | {
48 | rootFrame = new Frame();
49 |
50 | rootFrame.CacheSize = 1;
51 |
52 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
53 | {
54 |
55 | }
56 |
57 | Window.Current.Content = rootFrame;
58 | }
59 |
60 | if (rootFrame.Content == null)
61 | {
62 | if (!rootFrame.Navigate(typeof(Pages.Main), e.Arguments))
63 | {
64 | throw new Exception("Failed to create initial page");
65 | }
66 | }
67 | Window.Current.Activate();
68 | }
69 |
70 | private void OnSuspending(object sender, SuspendingEventArgs e)
71 | {
72 | }
73 | #if WINDOWS_PHONE_APP
74 | private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
75 | {
76 | Frame frame = Window.Current.Content as Frame;
77 | if (frame == null)
78 | {
79 | return;
80 | }
81 |
82 | var page = frame.Content as Page;
83 |
84 | if (page.GetType() == typeof(Pages.Main))
85 | {
86 | // salir de la app
87 | Application.Current.Exit();
88 | return;
89 | }
90 |
91 | if (frame.CanGoBack)
92 | {
93 | frame.GoBack();
94 | e.Handled = true;
95 | }
96 | }
97 | #endif
98 |
99 |
100 | private async void Application_UnhandledException(object sender, UnhandledExceptionEventArgs e)
101 | {
102 | string errorString = "Error: \r\n" + e.Exception.Message + "\r\nStack Trace: \r\n" + e.Exception.StackTrace;
103 | //MessageDialog dialog = new MessageDialog(errorString, "Error crítico");
104 | //await dialog.ShowAsync();
105 |
106 | if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
107 | }
108 | }
109 | }
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/MyBand.Shared.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | 8923dc15-b60b-4fb4-a5df-4e1662ef36c4
7 |
8 |
9 | MyBand
10 |
11 |
12 |
13 | Designer
14 |
15 |
16 | App.xaml
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/Entities/BatteryInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using Windows.Storage;
5 |
6 | namespace MyBand.Entities
7 | {
8 | class BatteryInfo
9 | {
10 | private byte percentage = 0;
11 | private int charges = 0;
12 | private BatteryStatus status = BatteryStatus.None;
13 | private DateTime lastCharged = DateTime.Now.Date.AddDays(-1);
14 |
15 | public BatteryInfo(byte Percentage, int Charges, BatteryStatus Status, DateTime LastCharged)
16 | {
17 | this.percentage = Percentage;
18 | this.charges = Charges;
19 | this.status = Status;
20 | this.lastCharged = LastCharged;
21 | Valid = true;
22 | }
23 |
24 | public BatteryInfo(Byte[] Data)
25 | {
26 | if (Data.Length != 10) { Valid = false; return; }
27 |
28 | this.percentage = Data[0];
29 | this.charges = 0xffff & (0xff & Data[7] | (0xff & Data[8]) << 8);
30 | this.status = (BatteryStatus)Data[9];
31 | try
32 | {
33 | this.lastCharged = new DateTime(Data[1] + 2000, Data[2] + 1, Data[3], Data[4], Data[5], Data[6]);
34 | }
35 | catch(Exception)
36 | {
37 | this.lastCharged = DateTime.MinValue;
38 | }
39 | Valid = true;
40 | }
41 |
42 | public bool Valid { get; set; }
43 | public byte Level { get { return this.percentage; } }
44 | public int Charges { get { return this.charges; } }
45 | public BatteryStatus Status { get { return this.status; } }
46 | public DateTime LastCharged { get { return this.lastCharged; } }
47 |
48 | public static BatteryInfo FromSetting(ApplicationDataCompositeValue setting)
49 | {
50 | BatteryInfo info = new BatteryInfo((byte)setting["percentage"], (int)setting["charges"], (BatteryStatus)setting["status"], DateTime.FromBinary((long)setting["lastCharged"]));
51 | return info;
52 | }
53 |
54 | public ApplicationDataCompositeValue ToSetting()
55 | {
56 | ApplicationDataCompositeValue setting = new ApplicationDataCompositeValue();
57 | setting["percentage"] = this.percentage;
58 | setting["charges"] = this.charges;
59 | setting["status"] = (int)this.status;
60 | setting["lastCharged"] = this.lastCharged.ToBinary();
61 |
62 | return setting;
63 | }
64 |
65 | public String LastChargedS
66 | {
67 | get
68 | {
69 | var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
70 | if (Valid)
71 | {
72 | if (lastCharged == DateTime.MinValue) { return loader.GetString("BatteryNeverCharged"); }
73 | TimeSpan lastCharge = new TimeSpan(LastCharged.Ticks);
74 | TimeSpan today = new TimeSpan(DateTime.Now.Ticks);
75 | var span = today - lastCharge;
76 | double days = Math.Truncate(span.TotalDays);
77 | double hours = Math.Truncate(span.TotalHours);
78 | double minutes = Math.Truncate(span.TotalMinutes);
79 | if (days > 0)
80 | {
81 | return loader.GetString("BatteryChargedSince") + days + loader.GetString("BatteryDays");
82 |
83 | }
84 | else if (hours > 0)
85 | {
86 | return loader.GetString("BatteryChargedSince") + hours + loader.GetString("BatteryHours");
87 | }
88 | else if (minutes > 0)
89 | {
90 | return loader.GetString("BatteryChargedSince") + minutes + loader.GetString("BatteryMinutes");
91 | }
92 | else
93 | {
94 | return loader.GetString("BatteryRecent");
95 | }
96 | }
97 | return loader.GetString("BatteryMissing");
98 | }
99 | }
100 | }
101 |
102 | enum BatteryStatus
103 | {
104 | None = 0,
105 | Low = 1,
106 | Charging = 2,
107 | Full = 3,
108 | NotCharging = 4
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/MyBand/MyBand.Shared/ObservableDictionary.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Windows.Foundation.Collections;
6 |
7 | namespace MyBand
8 | {
9 | ///
10 | /// Implementation of IObservableMap that supports reentrancy for use as a default view
11 | /// model.
12 | ///
13 | public class ObservableDictionary : IObservableMap
14 | {
15 | private class ObservableDictionaryChangedEventArgs : IMapChangedEventArgs
16 | {
17 | public ObservableDictionaryChangedEventArgs(CollectionChange change, string key)
18 | {
19 | CollectionChange = change;
20 | Key = key;
21 | }
22 |
23 | public CollectionChange CollectionChange { get; private set; }
24 | public string Key { get; private set; }
25 | }
26 |
27 | private Dictionary _dictionary = new Dictionary();
28 | public event MapChangedEventHandler MapChanged;
29 |
30 | private void InvokeMapChanged(CollectionChange change, string key)
31 | {
32 | var eventHandler = MapChanged;
33 | if (eventHandler != null)
34 | {
35 | eventHandler(this, new ObservableDictionaryChangedEventArgs(change, key));
36 | }
37 | }
38 |
39 | public void Add(string key, object value)
40 | {
41 | _dictionary.Add(key, value);
42 | InvokeMapChanged(CollectionChange.ItemInserted, key);
43 | }
44 |
45 | public void Add(KeyValuePair item)
46 | {
47 | Add(item.Key, item.Value);
48 | }
49 |
50 | public bool Remove(string key)
51 | {
52 | if (_dictionary.Remove(key))
53 | {
54 | InvokeMapChanged(CollectionChange.ItemRemoved, key);
55 | return true;
56 | }
57 | return false;
58 | }
59 |
60 | public bool Remove(KeyValuePair item)
61 | {
62 | object currentValue;
63 | if (_dictionary.TryGetValue(item.Key, out currentValue) &&
64 | Equals(item.Value, currentValue) && _dictionary.Remove(item.Key))
65 | {
66 | InvokeMapChanged(CollectionChange.ItemRemoved, item.Key);
67 | return true;
68 | }
69 | return false;
70 | }
71 |
72 | public object this[string key]
73 | {
74 | get
75 | {
76 | return _dictionary[key];
77 | }
78 | set
79 | {
80 | _dictionary[key] = value;
81 | InvokeMapChanged(CollectionChange.ItemChanged, key);
82 | }
83 | }
84 |
85 | public void Clear()
86 | {
87 | var priorKeys = _dictionary.Keys.ToArray();
88 | _dictionary.Clear();
89 | foreach (var key in priorKeys)
90 | {
91 | InvokeMapChanged(CollectionChange.ItemRemoved, key);
92 | }
93 | }
94 |
95 | public ICollection Keys
96 | {
97 | get { return _dictionary.Keys; }
98 | }
99 |
100 | public bool ContainsKey(string key)
101 | {
102 | return _dictionary.ContainsKey(key);
103 | }
104 |
105 | public bool TryGetValue(string key, out object value)
106 | {
107 | return _dictionary.TryGetValue(key, out value);
108 | }
109 |
110 | public ICollection