Skip to content

Commit ff6ed8c

Browse files
authored
Merge pull request #221 from qccoders/develop
Phone validation, mobile spinner
2 parents 0721e28 + 3afd767 commit ff6ed8c

File tree

9 files changed

+44
-20
lines changed

9 files changed

+44
-20
lines changed

api/QCVOC.Api/Veterans/Data/DTO/VeteranEnrollRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class VeteranEnrollRequest
4949
/// Gets or sets the primary phone number of the Veteran.
5050
/// </summary>
5151
[Required]
52-
[Phone]
52+
[RegularExpression(@"^[1-9][0-9]{9}$")]
5353
public string PrimaryPhone { get; set; }
5454

5555
/// <summary>

api/QCVOC.Api/Veterans/Data/DTO/VeteranUpdateRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class VeteranUpdateRequest
4949
/// Gets or sets the primary phone number of the Veteran.
5050
/// </summary>
5151
[Required]
52-
[Phone]
52+
[RegularExpression(@"^[1-9][0-9]{9}$")]
5353
public string PrimaryPhone { get; set; }
5454

5555
/// <summary>

mobile-new/app/src/main/java/org/qccoders/qcvoc/MainActivity.java

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,50 @@
66
package org.qccoders.qcvoc;
77

88
import android.content.Intent;
9+
import android.graphics.Bitmap;
910
import android.support.v7.app.AppCompatActivity;
1011
import android.os.Bundle;
1112
import android.util.Log;
12-
import android.view.KeyCharacterMap;
13-
import android.view.KeyEvent;
13+
import android.view.View;
1414
import android.webkit.JavascriptInterface;
1515
import android.webkit.WebView;
1616
import android.webkit.WebViewClient;
17+
import android.widget.ProgressBar;
1718

1819
import com.google.android.gms.samples.vision.barcodereader.BarcodeCaptureActivity;
1920
import com.google.android.gms.vision.barcode.Barcode;
2021

2122
public class MainActivity extends AppCompatActivity {
2223
private WebView webview;
24+
private ProgressBar progressBar;
2325

2426
@Override
2527
protected void onCreate(Bundle savedInstanceState) {
2628
super.onCreate(savedInstanceState);
2729
setContentView(R.layout.activity_main);
2830

31+
progressBar = findViewById(R.id.loading_spinner);
32+
progressBar.setVisibility(View.GONE);
33+
2934
webview = findViewById(R.id.webView);
35+
webview.setWebViewClient(new WebViewClient() {
36+
@Override
37+
public void onPageStarted(WebView view, String url, Bitmap favicon) {
38+
super.onPageStarted(view, url, favicon);
39+
progressBar.setVisibility(View.VISIBLE);
40+
}
41+
42+
@Override
43+
public void onPageFinished(WebView view, String url) {
44+
super.onPageFinished(view, url);
45+
progressBar.setVisibility(View.GONE);
46+
}
47+
});
48+
3049
webview.addJavascriptInterface(this, "Android");
31-
webview.setWebViewClient(new WebViewClient());
3250
webview.getSettings().setJavaScriptEnabled(true);
3351
webview.getSettings().setDomStorageEnabled(true);
34-
webview.loadUrl("http://dev.qcvoc.qccoders.org");
52+
webview.loadUrl("http://qcvoc-dev.s3-website-us-east-1.amazonaws.com");
3553
}
3654

3755
@JavascriptInterface
@@ -45,17 +63,13 @@ public void scanBarcode() {
4563
@Override
4664
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
4765
if (data != null) {
48-
KeyCharacterMap keymap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
49-
5066
Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);
51-
String outputString = "^" + barcode.displayValue + "$";
52-
KeyEvent[] outputKeyEvents = keymap.getEvents(outputString.toCharArray());
5367

54-
Log.d("MainActivity", outputString);
68+
Log.d("MainActivity", barcode.displayValue);
5569

56-
for (int i = 0; i < outputKeyEvents.length; i++) {
57-
dispatchKeyEvent(outputKeyEvents[i]);
58-
}
70+
webview.evaluateJavascript(
71+
"window.barcodeScanned(" + barcode.displayValue + ");",
72+
null);
5973
}
6074
}
6175
}

mobile-new/app/src/main/res/layout/activity_main.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,14 @@
1111
android:layout_width="match_parent"
1212
android:layout_height="match_parent"/>
1313

14+
<ProgressBar
15+
android:id="@+id/loading_spinner"
16+
style="?android:attr/progressBarStyle"
17+
android:layout_width="wrap_content"
18+
android:layout_height="wrap_content"
19+
app:layout_constraintLeft_toLeftOf="parent"
20+
app:layout_constraintRight_toRightOf="parent"
21+
app:layout_constraintTop_toTopOf="parent"
22+
app:layout_constraintBottom_toBottomOf="parent"/>
23+
1424
</android.support.constraint.ConstraintLayout>

mobile-new/app/src/main/res/values/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<resources>
22

33
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
4+
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
55
<!-- Customize your theme here. -->
66
<item name="colorPrimary">@color/colorPrimary</item>
77
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

mobile-new/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.1.4'
10+
classpath 'com.android.tools.build:gradle:3.2.0'
1111

1212

1313
// NOTE: Do not place your application dependencies here; they belong
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Sep 22 20:58:31 CDT 2018
1+
#Mon Sep 24 21:18:07 CDT 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

web/src/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const validateEmail = (email) => {
5050

5151
export const validatePhoneNumber = (phoneNumber) => {
5252
// eslint-disable-next-line
53-
var re = /\(\d{3}\) \d{3}-\d{4}/;
53+
var re = /^[1-9][0-9]{9}$/;
5454
return re.test(phoneNumber);
5555
}
5656

web/src/veterans/VeteranDialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class VeteranDialog extends Component {
227227
result.primaryPhone = 'The Primary Phone field is required.';
228228
}
229229
else if (!validatePhoneNumber(primaryPhone)) {
230-
result.primaryPhone = 'Enter a valid phone number in the format (555) 555-5555.';
230+
result.primaryPhone = 'Enter a valid phone number in the format \'555555555\'';
231231
}
232232

233233
if ((email !== '' && email !== undefined) && !validateEmail(email)) {

0 commit comments

Comments
 (0)