Skip to content

Commit

Permalink
Merge pull request #221 from qccoders/develop
Browse files Browse the repository at this point in the history
Phone validation, mobile spinner
  • Loading branch information
wburklund authored Oct 3, 2018
2 parents 0721e28 + 3afd767 commit ff6ed8c
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 20 deletions.
2 changes: 1 addition & 1 deletion api/QCVOC.Api/Veterans/Data/DTO/VeteranEnrollRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class VeteranEnrollRequest
/// Gets or sets the primary phone number of the Veteran.
/// </summary>
[Required]
[Phone]
[RegularExpression(@"^[1-9][0-9]{9}$")]
public string PrimaryPhone { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion api/QCVOC.Api/Veterans/Data/DTO/VeteranUpdateRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class VeteranUpdateRequest
/// Gets or sets the primary phone number of the Veteran.
/// </summary>
[Required]
[Phone]
[RegularExpression(@"^[1-9][0-9]{9}$")]
public string PrimaryPhone { get; set; }

/// <summary>
Expand Down
38 changes: 26 additions & 12 deletions mobile-new/app/src/main/java/org/qccoders/qcvoc/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,50 @@
package org.qccoders.qcvoc;

import android.content.Intent;
import android.graphics.Bitmap;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

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

public class MainActivity extends AppCompatActivity {
private WebView webview;
private ProgressBar progressBar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

progressBar = findViewById(R.id.loading_spinner);
progressBar.setVisibility(View.GONE);

webview = findViewById(R.id.webView);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(View.VISIBLE);
}

@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);
}
});

webview.addJavascriptInterface(this, "Android");
webview.setWebViewClient(new WebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
webview.loadUrl("http://dev.qcvoc.qccoders.org");
webview.loadUrl("http://qcvoc-dev.s3-website-us-east-1.amazonaws.com");
}

@JavascriptInterface
Expand All @@ -45,17 +63,13 @@ public void scanBarcode() {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
KeyCharacterMap keymap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);

Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);
String outputString = "^" + barcode.displayValue + "$";
KeyEvent[] outputKeyEvents = keymap.getEvents(outputString.toCharArray());

Log.d("MainActivity", outputString);
Log.d("MainActivity", barcode.displayValue);

for (int i = 0; i < outputKeyEvents.length; i++) {
dispatchKeyEvent(outputKeyEvents[i]);
}
webview.evaluateJavascript(
"window.barcodeScanned(" + barcode.displayValue + ");",
null);
}
}
}
10 changes: 10 additions & 0 deletions mobile-new/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<ProgressBar
android:id="@+id/loading_spinner"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>

</android.support.constraint.ConstraintLayout>
2 changes: 1 addition & 1 deletion mobile-new/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
Expand Down
2 changes: 1 addition & 1 deletion mobile-new/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.0'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions mobile-new/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Sep 22 20:58:31 CDT 2018
#Mon Sep 24 21:18:07 CDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
2 changes: 1 addition & 1 deletion web/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const validateEmail = (email) => {

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

Expand Down
2 changes: 1 addition & 1 deletion web/src/veterans/VeteranDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class VeteranDialog extends Component {
result.primaryPhone = 'The Primary Phone field is required.';
}
else if (!validatePhoneNumber(primaryPhone)) {
result.primaryPhone = 'Enter a valid phone number in the format (555) 555-5555.';
result.primaryPhone = 'Enter a valid phone number in the format \'555555555\'';
}

if ((email !== '' && email !== undefined) && !validateEmail(email)) {
Expand Down

0 comments on commit ff6ed8c

Please sign in to comment.