Initial commit
This commit is contained in:
commit
a01d4b81c7
42 changed files with 2646 additions and 0 deletions
65
.gitignore
vendored
Normal file
65
.gitignore
vendored
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
# Built application files
|
||||||
|
*.apk
|
||||||
|
*.ap_
|
||||||
|
|
||||||
|
# Files for the ART/Dalvik VM
|
||||||
|
*.dex
|
||||||
|
|
||||||
|
# Java class files
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
bin/
|
||||||
|
gen/
|
||||||
|
out/
|
||||||
|
|
||||||
|
# Gradle files
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Local configuration file (sdk path, etc)
|
||||||
|
local.properties
|
||||||
|
|
||||||
|
# Proguard folder generated by Eclipse
|
||||||
|
proguard/
|
||||||
|
|
||||||
|
# Log Files
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Android Studio Navigation editor temp files
|
||||||
|
.navigation/
|
||||||
|
|
||||||
|
# Android Studio captures folder
|
||||||
|
captures/
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
*.iml
|
||||||
|
.idea/workspace.xml
|
||||||
|
.idea/tasks.xml
|
||||||
|
.idea/gradle.xml
|
||||||
|
.idea/assetWizardSettings.xml
|
||||||
|
.idea/dictionaries
|
||||||
|
.idea/libraries
|
||||||
|
.idea/caches
|
||||||
|
|
||||||
|
# Keystore files
|
||||||
|
# Uncomment the following line if you do not want to check your keystore files in.
|
||||||
|
#*.jks
|
||||||
|
|
||||||
|
# External native build folder generated in Android Studio 2.2 and later
|
||||||
|
.externalNativeBuild
|
||||||
|
|
||||||
|
# Google Services (e.g. APIs or Firebase)
|
||||||
|
google-services.json
|
||||||
|
|
||||||
|
# Freeline
|
||||||
|
freeline.py
|
||||||
|
freeline/
|
||||||
|
freeline_project_description.json
|
||||||
|
|
||||||
|
# fastlane
|
||||||
|
fastlane/report.xml
|
||||||
|
fastlane/Preview.html
|
||||||
|
fastlane/screenshots
|
||||||
|
fastlane/test_output
|
||||||
|
fastlane/readme.md
|
29
.idea/codeStyles/Project.xml
Normal file
29
.idea/codeStyles/Project.xml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<Objective-C-extensions>
|
||||||
|
<file>
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||||
|
</file>
|
||||||
|
<class>
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||||
|
</class>
|
||||||
|
<extensions>
|
||||||
|
<pair source="cpp" header="h" fileNamingConvention="NONE" />
|
||||||
|
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||||
|
</extensions>
|
||||||
|
</Objective-C-extensions>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
34
.idea/misc.xml
Normal file
34
.idea/misc.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="NullableNotNullManager">
|
||||||
|
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||||
|
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||||
|
<option name="myNullables">
|
||||||
|
<value>
|
||||||
|
<list size="5">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="myNotNulls">
|
||||||
|
<value>
|
||||||
|
<list size="4">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
9
.idea/modules.xml
Normal file
9
.idea/modules.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Auditor.iml" filepath="$PROJECT_DIR$/Auditor.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
12
.idea/runConfigurations.xml
Normal file
12
.idea/runConfigurations.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 Varvet
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
4
README.md
Normal file
4
README.md
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# BarcodeReaderSample
|
||||||
|
A barcode scanner example using Google Play services.
|
||||||
|
|
||||||
|
[This tutorial](https://www.varvet.com/blog/android-qr-code-reader-made-easy/) should be of interest :).
|
1
app/.gitignore
vendored
Normal file
1
app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/build
|
36
app/build.gradle
Normal file
36
app/build.gradle
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 26
|
||||||
|
buildToolsVersion '27.0.3'
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "uk.ac.lancaster.auditor"
|
||||||
|
minSdkVersion 19
|
||||||
|
targetSdkVersion 26
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
implementation 'com.android.support:design:26.1.0'
|
||||||
|
testImplementation 'junit:junit:4.12'
|
||||||
|
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||||
|
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||||
|
implementation 'com.google.android.gms:play-services-vision:15.0.2'
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
17
app/proguard-rules.pro
vendored
Normal file
17
app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# By default, the flags in this file are appended to flags specified
|
||||||
|
# in /Users/algar/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||||
|
# You can edit the include path and order by changing the proguardFiles
|
||||||
|
# directive in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# Add any project specific keep options here:
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package uk.ac.lancaster.auditor;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.test.ApplicationTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||||
|
*/
|
||||||
|
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||||
|
public ApplicationTest() {
|
||||||
|
super(Application.class);
|
||||||
|
}
|
||||||
|
}
|
39
app/src/main/AndroidManifest.xml
Normal file
39
app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="uk.ac.lancaster.auditor">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".barcode.BarcodeScanActivity"
|
||||||
|
android:label="@string/title_activity_barcode_scan"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
|
/>
|
||||||
|
<activity
|
||||||
|
android:name=".barcode.BarcodeCaptureActivity"
|
||||||
|
android:label="@string/title_activity_barcode_capture"
|
||||||
|
android:theme="@style/Theme.AppCompat.NoActionBar"
|
||||||
|
/>
|
||||||
|
<activity
|
||||||
|
android:name=".BallotVerifyActivity"
|
||||||
|
android:label="@string/title_activity_ballot_verify"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
|
/>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
|
@ -0,0 +1,27 @@
|
||||||
|
package uk.ac.lancaster.auditor
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
|
import android.webkit.WebView
|
||||||
|
|
||||||
|
import kotlinx.android.synthetic.main.activity_ballot_verify.*
|
||||||
|
|
||||||
|
class BallotVerifyActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_ballot_verify)
|
||||||
|
setSupportActionBar(toolbar)
|
||||||
|
|
||||||
|
val extras = intent.extras
|
||||||
|
if (extras != null) {
|
||||||
|
val ballotHandle = extras.getString("ballotHandle")
|
||||||
|
val myWebView: WebView = findViewById(R.id.webview)
|
||||||
|
// myWebView.loadUrl("http://127.0.0.1:8000/event/audit?handle=$ballotHandle")
|
||||||
|
myWebView.loadUrl("https://en.wikipedia.org/")
|
||||||
|
myWebView.settings.javaScriptEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
23
app/src/main/java/uk/ac/lancaster/auditor/MainActivity.kt
Normal file
23
app/src/main/java/uk/ac/lancaster/auditor/MainActivity.kt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package uk.ac.lancaster.auditor
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.TextView
|
||||||
|
import uk.ac.lancaster.auditor.barcode.BarcodeScanActivity
|
||||||
|
|
||||||
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private lateinit var mResultTextView: TextView
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_main)
|
||||||
|
|
||||||
|
findViewById<Button>(R.id.scan_ballot_qr).setOnClickListener {
|
||||||
|
val intent = Intent(applicationContext, BarcodeScanActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,285 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* This file and all BarcodeXXX and CameraXXX files in this project edited by
|
||||||
|
* Daniell Algar (included due to copyright reason)
|
||||||
|
*/
|
||||||
|
package uk.ac.lancaster.auditor.barcode;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.hardware.Camera;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.android.gms.common.ConnectionResult;
|
||||||
|
import com.google.android.gms.common.GoogleApiAvailability;
|
||||||
|
import com.google.android.gms.common.api.CommonStatusCodes;
|
||||||
|
import com.google.android.gms.vision.MultiProcessor;
|
||||||
|
import com.google.android.gms.vision.barcode.Barcode;
|
||||||
|
import com.google.android.gms.vision.barcode.BarcodeDetector;
|
||||||
|
|
||||||
|
import uk.ac.lancaster.auditor.R;
|
||||||
|
import uk.ac.lancaster.auditor.camera.CameraSource;
|
||||||
|
import uk.ac.lancaster.auditor.camera.CameraSourcePreview;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public final class BarcodeCaptureActivity extends AppCompatActivity
|
||||||
|
implements BarcodeTracker.BarcodeGraphicTrackerCallback {
|
||||||
|
|
||||||
|
private static final String TAG = "Barcode-reader";
|
||||||
|
|
||||||
|
// Intent request code to handle updating play services if needed.
|
||||||
|
private static final int RC_HANDLE_GMS = 9001;
|
||||||
|
|
||||||
|
// Permission request codes need to be < 256
|
||||||
|
private static final int RC_HANDLE_CAMERA_PERM = 2;
|
||||||
|
|
||||||
|
// Constants used to pass extra data in the intent
|
||||||
|
public static final String BarcodeObject = "Barcode";
|
||||||
|
|
||||||
|
private CameraSource mCameraSource;
|
||||||
|
private CameraSourcePreview mPreview;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the UI and creates the detector pipeline.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle icicle) {
|
||||||
|
super.onCreate(icicle);
|
||||||
|
setContentView(R.layout.barcode_capture);
|
||||||
|
|
||||||
|
mPreview = (CameraSourcePreview) findViewById(R.id.preview);
|
||||||
|
|
||||||
|
boolean autoFocus = true;
|
||||||
|
boolean useFlash = false;
|
||||||
|
|
||||||
|
// Check for the camera permission before accessing the camera. If the
|
||||||
|
// permission is not granted yet, request permission.
|
||||||
|
int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
|
||||||
|
if (rc == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
createCameraSource(autoFocus, useFlash);
|
||||||
|
} else {
|
||||||
|
requestCameraPermission();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetectedQrCode(Barcode barcode) {
|
||||||
|
if (barcode != null) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(BarcodeObject, barcode);
|
||||||
|
setResult(CommonStatusCodes.SUCCESS, intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handles the requesting of the camera permission.
|
||||||
|
private void requestCameraPermission() {
|
||||||
|
Log.w(TAG, "Camera permission is not granted. Requesting permission");
|
||||||
|
|
||||||
|
final String[] permissions = new String[]{Manifest.permission.CAMERA};
|
||||||
|
|
||||||
|
if (!ActivityCompat.shouldShowRequestPermissionRationale(this,
|
||||||
|
Manifest.permission.CAMERA)) {
|
||||||
|
ActivityCompat.requestPermissions(this, permissions, RC_HANDLE_CAMERA_PERM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and starts the camera.
|
||||||
|
*
|
||||||
|
* Suppressing InlinedApi since there is a check that the minimum version is met before using
|
||||||
|
* the constant.
|
||||||
|
*/
|
||||||
|
@SuppressLint("InlinedApi")
|
||||||
|
private void createCameraSource(boolean autoFocus, boolean useFlash) {
|
||||||
|
Context context = getApplicationContext();
|
||||||
|
|
||||||
|
// A barcode detector is created to track barcodes. An associated multi-processor instance
|
||||||
|
// is set to receive the barcode detection results, track the barcodes, and maintain
|
||||||
|
// graphics for each barcode on screen. The factory is used by the multi-processor to
|
||||||
|
// create a separate tracker instance for each barcode.
|
||||||
|
BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context)
|
||||||
|
.setBarcodeFormats(Barcode.ALL_FORMATS)
|
||||||
|
.build();
|
||||||
|
BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(this);
|
||||||
|
barcodeDetector.setProcessor(new MultiProcessor.Builder<>(barcodeFactory).build());
|
||||||
|
|
||||||
|
if (!barcodeDetector.isOperational()) {
|
||||||
|
// Note: The first time that an app using the barcode or face API is installed on a
|
||||||
|
// device, GMS will download a native libraries to the device in order to do detection.
|
||||||
|
// Usually this completes before the app is run for the first time. But if that
|
||||||
|
// download has not yet completed, then the above call will not detect any barcodes
|
||||||
|
// and/or faces.
|
||||||
|
//
|
||||||
|
// isOperational() can be used to check if the required native libraries are currently
|
||||||
|
// available. The detectors will automatically become operational once the library
|
||||||
|
// downloads complete on device.
|
||||||
|
Log.w(TAG, "Detector dependencies are not yet available.");
|
||||||
|
|
||||||
|
// Check for low storage. If there is low storage, the native library will not be
|
||||||
|
// downloaded, so detection will not become operational.
|
||||||
|
IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
|
||||||
|
boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
|
||||||
|
|
||||||
|
if (hasLowStorage) {
|
||||||
|
Toast.makeText(this, R.string.low_storage_error,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
Log.w(TAG, getString(R.string.low_storage_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creates and starts the camera. Note that this uses a higher resolution in comparison
|
||||||
|
// to other detection examples to enable the barcode detector to detect small barcodes
|
||||||
|
// at long distances.
|
||||||
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
|
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||||
|
|
||||||
|
CameraSource.Builder builder = new CameraSource.Builder(getApplicationContext(), barcodeDetector)
|
||||||
|
.setFacing(CameraSource.CAMERA_FACING_BACK)
|
||||||
|
.setRequestedPreviewSize(metrics.widthPixels, metrics.heightPixels)
|
||||||
|
.setRequestedFps(24.0f);
|
||||||
|
|
||||||
|
// make sure that auto focus is an available option
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
|
builder = builder.setFocusMode(
|
||||||
|
autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
mCameraSource = builder
|
||||||
|
.setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restarts the camera
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
startCameraSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stops the camera
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (mPreview != null) {
|
||||||
|
mPreview.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the resources associated with the camera source, the associated detectors, and the
|
||||||
|
* rest of the processing pipeline.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (mPreview != null) {
|
||||||
|
mPreview.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for the result from requesting permissions. This method
|
||||||
|
* is invoked for every call on {@link #requestPermissions(String[], int)}.
|
||||||
|
* <p>
|
||||||
|
* <strong>Note:</strong> It is possible that the permissions request interaction
|
||||||
|
* with the user is interrupted. In this case you will receive empty permissions
|
||||||
|
* and results arrays which should be treated as a cancellation.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param requestCode The request code passed in {@link #requestPermissions(String[], int)}.
|
||||||
|
* @param permissions The requested permissions. Never null.
|
||||||
|
* @param grantResults The grant results for the corresponding permissions
|
||||||
|
* which is either {@link PackageManager#PERMISSION_GRANTED}
|
||||||
|
* or {@link PackageManager#PERMISSION_DENIED}. Never null.
|
||||||
|
* @see #requestPermissions(String[], int)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
|
@NonNull String[] permissions,
|
||||||
|
@NonNull int[] grantResults) {
|
||||||
|
if (requestCode != RC_HANDLE_CAMERA_PERM) {
|
||||||
|
Log.d(TAG, "Got unexpected permission result: " + requestCode);
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
Log.d(TAG, "Camera permission granted - initialize the camera source");
|
||||||
|
// we have permission, so create the camerasource
|
||||||
|
boolean autoFocus = true;
|
||||||
|
boolean useFlash = false;
|
||||||
|
createCameraSource(autoFocus, useFlash);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.e(TAG, "Permission not granted: results len = " + grantResults.length +
|
||||||
|
" Result code = " + (grantResults.length > 0 ? grantResults[0] : "(empty)"));
|
||||||
|
|
||||||
|
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("Multitracker sample")
|
||||||
|
.setMessage(R.string.no_camera_permission)
|
||||||
|
.setPositiveButton(R.string.ok, listener)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts or restarts the camera source, if it exists. If the camera source doesn't exist yet
|
||||||
|
* (e.g., because onResume was called before the camera source was created), this will be called
|
||||||
|
* again when the camera source is created.
|
||||||
|
*/
|
||||||
|
private void startCameraSource() throws SecurityException {
|
||||||
|
// check that the device has play services available.
|
||||||
|
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
|
||||||
|
getApplicationContext());
|
||||||
|
if (code != ConnectionResult.SUCCESS) {
|
||||||
|
Dialog dlg =
|
||||||
|
GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
|
||||||
|
dlg.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mCameraSource != null) {
|
||||||
|
try {
|
||||||
|
mPreview.start(mCameraSource);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "Unable to start camera source.", e);
|
||||||
|
mCameraSource.release();
|
||||||
|
mCameraSource = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package uk.ac.lancaster.auditor.barcode
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.TextView
|
||||||
|
import com.google.android.gms.common.api.CommonStatusCodes
|
||||||
|
import com.google.android.gms.vision.barcode.Barcode
|
||||||
|
import uk.ac.lancaster.auditor.BallotVerifyActivity
|
||||||
|
import uk.ac.lancaster.auditor.MainActivity
|
||||||
|
import uk.ac.lancaster.auditor.R
|
||||||
|
|
||||||
|
class BarcodeScanActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private lateinit var mResultTextView: TextView
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_barcode_scan)
|
||||||
|
|
||||||
|
mResultTextView = findViewById(R.id.result_textview)
|
||||||
|
|
||||||
|
findViewById<Button>(R.id.scan_barcode_button).setOnClickListener {
|
||||||
|
val intent = Intent(applicationContext, BarcodeCaptureActivity::class.java)
|
||||||
|
startActivityForResult(intent, BARCODE_READER_REQUEST_CODE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
if (requestCode == BARCODE_READER_REQUEST_CODE) {
|
||||||
|
if (resultCode == CommonStatusCodes.SUCCESS) {
|
||||||
|
if (data != null) {
|
||||||
|
val barcode = data.getParcelableExtra<Barcode>(BarcodeCaptureActivity.BarcodeObject)
|
||||||
|
val p = barcode.cornerPoints
|
||||||
|
mResultTextView.text = barcode.displayValue
|
||||||
|
|
||||||
|
//if some test of the QR = ballot handle
|
||||||
|
val intent = Intent(baseContext, BallotVerifyActivity::class.java)
|
||||||
|
intent.putExtra("ballotHandle", barcode.displayValue)
|
||||||
|
startActivity(intent)
|
||||||
|
} else
|
||||||
|
mResultTextView.setText(R.string.no_barcode_captured)
|
||||||
|
} else
|
||||||
|
Log.e(LOG_TAG, String.format(getString(R.string.barcode_error_format),
|
||||||
|
CommonStatusCodes.getStatusCodeString(resultCode)))
|
||||||
|
} else
|
||||||
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val LOG_TAG = MainActivity::class.java.simpleName
|
||||||
|
private val BARCODE_READER_REQUEST_CODE = 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package uk.ac.lancaster.auditor.barcode;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.google.android.gms.vision.Tracker;
|
||||||
|
import com.google.android.gms.vision.barcode.Barcode;
|
||||||
|
|
||||||
|
class BarcodeTracker extends Tracker<Barcode> {
|
||||||
|
private BarcodeGraphicTrackerCallback mListener;
|
||||||
|
|
||||||
|
public interface BarcodeGraphicTrackerCallback {
|
||||||
|
void onDetectedQrCode(Barcode barcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
BarcodeTracker(Context listener) {
|
||||||
|
mListener = (BarcodeGraphicTrackerCallback) listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNewItem(int id, Barcode item) {
|
||||||
|
if (item.displayValue != null) {
|
||||||
|
mListener.onDetectedQrCode(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package uk.ac.lancaster.auditor.barcode;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.google.android.gms.vision.MultiProcessor;
|
||||||
|
import com.google.android.gms.vision.Tracker;
|
||||||
|
import com.google.android.gms.vision.barcode.Barcode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory for creating a tracker and associated graphic to be associated with a new barcode. The
|
||||||
|
* multi-processor uses this factory to create barcode trackers as needed -- one for each barcode.
|
||||||
|
*/
|
||||||
|
class BarcodeTrackerFactory implements MultiProcessor.Factory<Barcode> {
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
BarcodeTrackerFactory(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tracker<Barcode> create(Barcode barcode) {
|
||||||
|
return new BarcodeTracker(mContext);
|
||||||
|
}
|
||||||
|
}
|
1212
app/src/main/java/uk/ac/lancaster/auditor/camera/CameraSource.java
Normal file
1212
app/src/main/java/uk/ac/lancaster/auditor/camera/CameraSource.java
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,182 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package uk.ac.lancaster.auditor.camera;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.support.annotation.RequiresPermission;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.SurfaceHolder;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.google.android.gms.common.images.Size;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class CameraSourcePreview extends ViewGroup {
|
||||||
|
private static final String TAG = CameraSourcePreview.class.getSimpleName();
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private SurfaceView mSurfaceView;
|
||||||
|
private boolean mStartRequested;
|
||||||
|
private boolean mSurfaceAvailable;
|
||||||
|
private CameraSource mCameraSource;
|
||||||
|
|
||||||
|
public CameraSourcePreview(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
mContext = context;
|
||||||
|
mStartRequested = false;
|
||||||
|
mSurfaceAvailable = false;
|
||||||
|
|
||||||
|
mSurfaceView = new SurfaceView(context);
|
||||||
|
mSurfaceView.getHolder().addCallback(new SurfaceCallback());
|
||||||
|
addView(mSurfaceView);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresPermission(Manifest.permission.CAMERA)
|
||||||
|
public void start(CameraSource cameraSource) throws IOException, SecurityException {
|
||||||
|
if (cameraSource == null) {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
mCameraSource = cameraSource;
|
||||||
|
|
||||||
|
if (mCameraSource != null) {
|
||||||
|
mStartRequested = true;
|
||||||
|
startIfReady();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
if (mCameraSource != null) {
|
||||||
|
mCameraSource.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void release() {
|
||||||
|
if (mCameraSource != null) {
|
||||||
|
mCameraSource.release();
|
||||||
|
mCameraSource = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresPermission(Manifest.permission.CAMERA)
|
||||||
|
private void startIfReady() throws IOException, SecurityException {
|
||||||
|
if (mStartRequested && mSurfaceAvailable) {
|
||||||
|
mCameraSource.start(mSurfaceView.getHolder());
|
||||||
|
mStartRequested = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SurfaceCallback implements SurfaceHolder.Callback {
|
||||||
|
@Override
|
||||||
|
public void surfaceCreated(SurfaceHolder surface) {
|
||||||
|
mSurfaceAvailable = true;
|
||||||
|
try {
|
||||||
|
startIfReady();
|
||||||
|
} catch (SecurityException se) {
|
||||||
|
Log.e(TAG,"Do not have permission to start the camera", se);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "Could not start camera source.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceDestroyed(SurfaceHolder surface) {
|
||||||
|
mSurfaceAvailable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
|
int previewWidth = 320;
|
||||||
|
int previewHeight = 240;
|
||||||
|
if (mCameraSource != null) {
|
||||||
|
Size size = mCameraSource.getPreviewSize();
|
||||||
|
if (size != null) {
|
||||||
|
previewWidth = size.getWidth();
|
||||||
|
previewHeight = size.getHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap width and height sizes when in portrait, since it will be rotated 90 degrees
|
||||||
|
if (isPortraitMode()) {
|
||||||
|
int tmp = previewWidth;
|
||||||
|
previewWidth = previewHeight;
|
||||||
|
previewHeight = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int viewWidth = right - left;
|
||||||
|
final int viewHeight = bottom - top;
|
||||||
|
|
||||||
|
int childWidth;
|
||||||
|
int childHeight;
|
||||||
|
int childXOffset = 0;
|
||||||
|
int childYOffset = 0;
|
||||||
|
float widthRatio = (float) viewWidth / (float) previewWidth;
|
||||||
|
float heightRatio = (float) viewHeight / (float) previewHeight;
|
||||||
|
|
||||||
|
// To fill the view with the camera preview, while also preserving the correct aspect ratio,
|
||||||
|
// it is usually necessary to slightly oversize the child and to crop off portions along one
|
||||||
|
// of the dimensions. We scale up based on the dimension requiring the most correction, and
|
||||||
|
// compute a crop offset for the other dimension.
|
||||||
|
if (widthRatio > heightRatio) {
|
||||||
|
childWidth = viewWidth;
|
||||||
|
childHeight = (int) ((float) previewHeight * widthRatio);
|
||||||
|
childYOffset = (childHeight - viewHeight) / 2;
|
||||||
|
} else {
|
||||||
|
childWidth = (int) ((float) previewWidth * heightRatio);
|
||||||
|
childHeight = viewHeight;
|
||||||
|
childXOffset = (childWidth - viewWidth) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < getChildCount(); ++i) {
|
||||||
|
// One dimension will be cropped. We shift child over or up by this offset and adjust
|
||||||
|
// the size to maintain the proper aspect ratio.
|
||||||
|
getChildAt(i).layout(
|
||||||
|
-1 * childXOffset, -1 * childYOffset,
|
||||||
|
childWidth - childXOffset, childHeight - childYOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
startIfReady();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "Could not start camera source.", e);
|
||||||
|
} catch (SecurityException se) {
|
||||||
|
Log.e(TAG, "Does not have permission to start the camera.", se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPortraitMode() {
|
||||||
|
int orientation = mContext.getResources().getConfiguration().orientation;
|
||||||
|
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.d(TAG, "isPortraitMode returning false by default");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
33
app/src/main/res/layout/activity_ballot_verify.xml
Normal file
33
app/src/main/res/layout/activity_ballot_verify.xml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".BallotVerifyActivity">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/content_ballot_verify" />
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
34
app/src/main/res/layout/activity_barcode_scan.xml
Normal file
34
app/src/main/res/layout/activity_barcode_scan.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.constraint.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
tools:context="uk.ac.lancaster.auditor.barcode.BarcodeScanActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/result_textview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/no_barcode_captured"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:autoLink="all"
|
||||||
|
android:freezesText="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/scan_barcode_button"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/scan_barcode_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/scan_barcode_button"
|
||||||
|
android:layout_below="@id/result_textview"
|
||||||
|
android:background="@color/colorAccent"
|
||||||
|
android:textColor="@color/colorWhite"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.7"/>
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
31
app/src/main/res/layout/activity_main.xml
Normal file
31
app/src/main/res/layout/activity_main.xml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.constraint.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/scan_hash_qr"
|
||||||
|
android:layout_width="218dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="Scan Hash QR"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/scan_ballot_qr"
|
||||||
|
android:layout_width="218dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="Scan Ballot QR"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/scan_hash_qr" />
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
16
app/src/main/res/layout/barcode_capture.xml
Normal file
16
app/src/main/res/layout/barcode_capture.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/topLayout"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:keepScreenOn="true">
|
||||||
|
|
||||||
|
<uk.ac.lancaster.auditor.camera.CameraSourcePreview
|
||||||
|
android:id="@+id/preview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
</uk.ac.lancaster.auditor.camera.CameraSourcePreview>
|
||||||
|
</LinearLayout>
|
23
app/src/main/res/layout/content_ballot_verify.xml
Normal file
23
app/src/main/res/layout/content_ballot_verify.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:context=".BallotVerifyActivity"
|
||||||
|
tools:showIn="@layout/activity_ballot_verify">
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/webview"
|
||||||
|
android:layout_width="368dp"
|
||||||
|
android:layout_height="439dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<resources>
|
||||||
|
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||||
|
(such as screen margins) for screens with more than 820dp of available width. This
|
||||||
|
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||||
|
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||||
|
</resources>
|
7
app/src/main/res/values/colors.xml
Normal file
7
app/src/main/res/values/colors.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
|
<color name="colorAccent">#FF3F80</color>
|
||||||
|
<color name="colorWhite">#FFFFFF</color>
|
||||||
|
</resources>
|
6
app/src/main/res/values/dimens.xml
Normal file
6
app/src/main/res/values/dimens.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<resources>
|
||||||
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
|
</resources>
|
17
app/src/main/res/values/strings.xml
Normal file
17
app/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Demos 2 Auditor</string>
|
||||||
|
|
||||||
|
<!-- Strings related to MainActivity-->
|
||||||
|
<string name="scan_barcode_button">Scan barcode</string>
|
||||||
|
<string name="no_barcode_captured">No barcode captured</string>
|
||||||
|
<string name="barcode_error_format">"Error reading barcode: %1$s"</string>
|
||||||
|
|
||||||
|
<!-- Strings related to barcode scanner -->
|
||||||
|
<string name="ok">OK</string>
|
||||||
|
<string name="title_activity_barcode_scan">Scan QR Code</string>
|
||||||
|
<string name="title_activity_barcode_capture">Capture Ballot</string>
|
||||||
|
<string name="title_activity_ballot_verify">Verify Ballot</string>
|
||||||
|
<string name="permission_camera_rationale">Access to the camera is needed for detection</string>
|
||||||
|
<string name="no_camera_permission">This application cannot run because it does not have the camera permission. The application will now exit.</string>
|
||||||
|
<string name="low_storage_error">Face detector dependencies cannot be downloaded due to low device storage</string>
|
||||||
|
</resources>
|
20
app/src/main/res/values/styles.xml
Normal file
20
app/src/main/res/values/styles.xml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.NoActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
|
||||||
|
</resources>
|
34
build.gradle
Normal file
34
build.gradle
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.2.10'
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url 'https://maven.google.com/'
|
||||||
|
name 'Google'
|
||||||
|
}
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:3.1.4'
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url 'https://maven.google.com/'
|
||||||
|
name 'Google'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
18
gradle.properties
Normal file
18
gradle.properties
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Project-wide Gradle settings.
|
||||||
|
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||||
|
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||||
|
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#Sat Jul 28 19:19:25 BST 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
|
160
gradlew
vendored
Normal file
160
gradlew
vendored
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn ( ) {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die ( ) {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||||
|
function splitJvmOpts() {
|
||||||
|
JVM_OPTS=("$@")
|
||||||
|
}
|
||||||
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
gradlew.bat
vendored
Normal file
90
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windowz variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
goto execute
|
||||||
|
|
||||||
|
:4NT_args
|
||||||
|
@rem Get arguments from the 4NT Shell from JP Software
|
||||||
|
set CMD_LINE_ARGS=%$
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
1
settings.gradle
Normal file
1
settings.gradle
Normal file
|
@ -0,0 +1 @@
|
||||||
|
include ':app'
|
Reference in a new issue