Skip to content

Commit 1f720cd

Browse files
committed
prepare for publication
1 parent e6e9e3e commit 1f720cd

12 files changed

Lines changed: 94 additions & 11 deletions

Allow2/Allow2CheckResult.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,20 @@ namespace Allow2
8282
//{
8383
//}
8484

85+
/// <summary>
86+
/// Convenience method.
87+
/// </summary>
88+
/// <value>The activities.</value>
8589
public JSONNode Activities {
8690
get {
8791
return this["activities"];
8892
}
8993
}
9094

95+
/// <summary>
96+
/// Convenience method.
97+
/// </summary>
98+
/// <value>The subscription.</value>
9199
public JSONNode Subscription
92100
{
93101
get
@@ -96,6 +104,10 @@ public JSONNode Subscription
96104
}
97105
}
98106

107+
/// <summary>
108+
/// When does the validity of this result expire? (cache expiry).
109+
/// </summary>
110+
/// <value>The expiry Date/Time</value>
99111
public DateTime Expires {
100112
get {
101113
int unixTimeStamp = ((Activities != null) && (Activities[0] != null)) ?
@@ -104,6 +116,10 @@ public DateTime Expires {
104116
}
105117
}
106118

119+
/// <summary>
120+
/// Returns <see langword="null"/> if the user is financial or within free usage tier, otherwise returns a message indicating they need a subscription
121+
/// </summary>
122+
/// <value>The need subscription.</value>
107123
public string NeedSubscription {
108124
get {
109125
if (!Subscription["financial"].AsBool) {
@@ -123,12 +139,20 @@ public string NeedSubscription {
123139
}
124140
}
125141

142+
/// <summary>
143+
/// A simple top level result, the child is currently allowed or not based on the activity time and quotas.
144+
/// </summary>
145+
/// <value><c>true</c> if is allowed; otherwise, <c>false</c>.</value>
126146
public bool IsAllowed {
127147
get {
128148
return this["allowed"].AsBool;
129149
}
130150
}
131151

152+
/// <summary>
153+
/// A Summary explanation of the current reasons they may not be allowed at this time.
154+
/// </summary>
155+
/// <value>The explanation.</value>
132156
public string Explanation {
133157
get {
134158
List<string> reasons = new List<string>();
@@ -158,6 +182,10 @@ public string Explanation {
158182
}
159183
}
160184

185+
/// <summary>
186+
/// A list of the current bans in place for this child.
187+
/// </summary>
188+
/// <value>The current bans.</value>
161189
public Allow2Ban[] CurrentBans {
162190
get {
163191
List<Allow2Ban> bans = new List<Allow2Ban>();
@@ -184,6 +212,10 @@ public Allow2Ban[] CurrentBans {
184212
}
185213
}
186214

215+
/// <summary>
216+
/// The type of day it is today.
217+
/// </summary>
218+
/// <value>The day type.</value>
187219
public Allow2Day Today
188220
{
189221
get
@@ -193,6 +225,10 @@ public Allow2Day Today
193225
}
194226
}
195227

228+
/// <summary>
229+
/// The type of day it will be tomorrow.
230+
/// </summary>
231+
/// <value>The day type.</value>
196232
public Allow2Day Tomorrow
197233
{
198234
get
@@ -202,6 +238,10 @@ public Allow2Day Tomorrow
202238
}
203239
}
204240

241+
/// <summary>
242+
/// All Day Types the parent has set on their account that the child should be aware of or can choose from for a request.
243+
/// </summary>
244+
/// <value>All day types.</value>
205245
public Allow2Day[] AllDayTypes
206246
{
207247
get

Allow2/Examples/CheckButton.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class CheckButton : MonoBehaviour
2727
(int)Activity.Computer
2828
};
2929

30+
/// <summary>
31+
/// Check once and log activity for the given child and activities.
32+
/// </summary>
3033
public void Check()
3134
{
3235
Debug.Log("Check");
@@ -50,6 +53,9 @@ public void Check()
5053
true);
5154
}
5255

56+
/// <summary>
57+
/// Start a continuous check (and logging usage) for the given child and activities.
58+
/// </summary>
5359
public void StartChecking()
5460
{
5561
Debug.Log("Start Checking");
@@ -73,6 +79,9 @@ public void StartChecking()
7379
true);
7480
}
7581

82+
/// <summary>
83+
/// Stop checking and logging.
84+
/// </summary>
7685
public void StopChecking()
7786
{
7887
Debug.Log("Stop Checking");

Allow2/Examples/DeviceNameInput.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,26 @@ public class DeviceNameInput : MonoBehaviour
2323
{
2424

2525
public InputField inputField;
26-
public Image qrImage;
26+
public RawImage qrImage;
2727

28+
/// <summary>
29+
/// On creating the field, we pre-populate it with the system device name.
30+
/// This will auto-trigger the "InputValueChanged" and update the QR Code for pairing.
31+
/// </summary>
2832
void Awake()
2933
{
3034
inputField.text = SystemInfo.deviceName;
3135
}
3236

37+
/// <summary>
38+
/// When the input value changes, generate a new QR Code, so the user can interactively edit the name and the pairing process uses that name.
39+
/// </summary>
40+
/// <param name="input">Input.</param>
3341
public void InputValueChanged(string input)
3442
{
3543
Allow2.GetQR(this, input, delegate (string err, Texture2D qrCode)
3644
{
37-
Debug.Log("qrcode error: " + (err ?? "No Error") + " : " + (qrCode != null ? qrCode.dimension.ToString() : "no"));
45+
Debug.Log("Input Value qrcode error: " + (err ?? "No Error") + " : " + (qrCode != null ? qrCode.width.ToString() + "," + qrCode.height.ToString() : "no"));
3846
qrImage.GetComponent<RawImage>().texture = qrCode;
3947
});
4048
}

Allow2/Examples/PairButton.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@ namespace Allow2.Allow2Examples
2121

2222
public class PairButton : MonoBehaviour
2323
{
24+
25+
public InputField UsernameField;
26+
public InputField PasswordField;
27+
public InputField DeviceNameField;
28+
29+
/// <summary>
30+
/// Manually pair with Allow2 by providing the username and password entered by the user in your pairing interface.
31+
/// </summary>
2432
public void Pair()
2533
{
2634
Debug.Log("Start Pairing");
2735
Allow2.Pair(
2836
this,
29-
"andrew@imagineit.com.au",
30-
"2}LJA84$3y88H]o",
31-
"Unity Test",
37+
UsernameField.text,
38+
PasswordField.text,
39+
DeviceNameField.text,
3240
delegate (string err, Allow2CheckResult result)
3341
{
3442
Debug.Log("Stop Pairing");

Allow2/Examples/RequestButton.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public class RequestButton : MonoBehaviour
2424
public int dayTypeId = 23;
2525
public int[] bansToLift = {};
2626

27+
/// <summary>
28+
/// Send a request on behalf of the child.
29+
/// </summary>
2730
public void Request()
2831
{
2932
Debug.Log("Request");

Allow2/Examples/SceneClass.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Allow2.Allow2Examples
2222
public class SceneClass : MonoBehaviour
2323
{
2424

25-
public Image qrImage;
25+
public RawImage qrImage;
2626

2727
void Awake()
2828
{
@@ -41,12 +41,27 @@ void Awake()
4141
Debug.Log("isPaired: " + Allow2.IsPaired);
4242
Debug.Log("Children: " + Allow2.Children);
4343

44+
// Not Required if the textfield sets the name on display, it will also trigger an update of the QR Code
4445
// and in the pairing interface, we need a QR code to make the process simple for our users
45-
Allow2.GetQR(this, SystemInfo.deviceName, delegate (string err, Texture2D qrCode)
46-
{
47-
Debug.Log("qrcode error: " + (err ?? "No Error") + " : " + (qrCode ? "yes" : "no"));
48-
Debug.Log(qrImage.GetComponent<RawImage>());
49-
qrImage.GetComponent<RawImage>().texture = qrCode;
46+
//Allow2.GetQR(this, SystemInfo.deviceName, delegate (string err, Texture2D qrCode)
47+
//{
48+
// Debug.Log("qrcode error: " + (err ?? "No Error") + " : " + (qrCode ? "yes" : "no"));
49+
// Debug.Log(qrImage.GetComponent<RawImage>());
50+
// qrImage.GetComponent<RawImage>().texture = qrCode;
51+
//});
52+
53+
// usually start the pairing background process here,
54+
// unless you have opted to not allow pairing with QR Code (but this is highly recommended for a better user experience)
55+
Allow2.StartPairing(this, delegate (string err, Allow2CheckResult result) {
56+
// this may be called several times with errors
57+
if (err != null) {
58+
Debug.Log(err);
59+
return;
60+
}
61+
// once paired, the pairing process will automatically stop itself
62+
// you should close off the pairing interface here and display success to the end user
63+
Debug.Log("isPaired: " + Allow2.IsPaired);
64+
Debug.Log("Children: " + Allow2.Children);
5065
});
5166
}
5267
}

Images/Allow2Logo500.png

62.8 KB
Loading

Images/Allow2Logo_200x258.png

13.6 KB
Loading

Images/Allow2Logo_860x389.png

47.9 KB
Loading

Images/Allow2_200x124.png

7.19 KB
Loading

0 commit comments

Comments
 (0)