Skip to content

Commit

Permalink
Add QR Code readers
Browse files Browse the repository at this point in the history
  • Loading branch information
tolotrasmile committed Oct 23, 2017
1 parent 6d72e66 commit 13766f2
Show file tree
Hide file tree
Showing 19 changed files with 470 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
.idea
.DS_Store
/build
/app/build
/app/libs
/captures
.externalNativeBuild
3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ dependencies {
//Gson
compile 'com.google.code.gson:gson:2.7'

// QR Code

//https://github.com/dlazaro66/QRCodeReaderView
compile ('com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.2@aar'){
transitive = true
}

//https://github.com/dm77/barcodescanner
compile 'me.dm7.barcodescanner:zxing:1.9.8'

//https://github.com/journeyapps/zxing-android-embedded
compile 'com.journeyapps:zxing-android-embedded:3.5.0'

compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
8 changes: 7 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.admin.lifeapp">

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.autofocus" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<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=".presentation.activity.DlazaroDecoderActivity_" />
<activity android:name=".presentation.activity.ZXingDecoderActivity_" />
</application>

</manifest>
12 changes: 7 additions & 5 deletions app/src/main/java/com/example/admin/lifeapp/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.example.admin.lifeapp

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import org.androidannotations.annotations.Click
import org.androidannotations.annotations.EActivity

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
@EActivity(R.layout.activity_main)
open class MainActivity : AppCompatActivity() {

@Click(R.id.clickMe)
open fun clickMe() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.example.admin.lifeapp.presentation.activity

import android.app.Activity
import android.graphics.PointF
import android.widget.Toast
import com.dlazaro66.qrcodereaderview.QRCodeReaderView
import com.example.admin.lifeapp.R
import org.androidannotations.annotations.AfterViews
import org.androidannotations.annotations.EActivity
import org.androidannotations.annotations.ViewById

/**
* Created by admin on 23/10/2017.
*/

@EActivity(R.layout.activity_decoder)
open class DlazaroDecoderActivity : Activity(), QRCodeReaderView.OnQRCodeReadListener {

@ViewById(R.id.reader)
lateinit var reader: QRCodeReaderView

@AfterViews
fun afterViews() {
reader.setOnQRCodeReadListener(this);

// Use this function to enable/disable decoding
reader.setQRDecodingEnabled(true);

// Use this function to change the autofocus interval (default is 5 secs)
reader.setAutofocusInterval(2000L);

// Use this function to enable/disable Torch
reader.setTorchEnabled(true);

// Use this function to set front camera preview
reader.setFrontCamera();

// Use this function to set back camera preview
reader.setBackCamera();
}

override fun onQRCodeRead(text: String?, points: Array<out PointF>?) {
Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
}

override fun onResume() {
super.onResume()
reader.startCamera()
}

override fun onPause() {
super.onPause()
reader.stopCamera()
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.example.admin.lifeapp.presentation.activity

import android.os.Bundle
import android.app.Activity
import android.widget.Toast
import com.google.zxing.Result
import me.dm7.barcodescanner.zxing.ZXingScannerView
import org.androidannotations.annotations.EActivity


/**
* Created by admin on 23/10/2017.
*/
@EActivity
open class ZXingDecoderActivity : Activity(), ZXingScannerView.ResultHandler {

private var mScannerView: ZXingScannerView? = null

public override fun onCreate(state: Bundle?) {
super.onCreate(state)

// Programmatically initialize the scanner view
mScannerView = ZXingScannerView(this)

// Set the scanner view as the content view
setContentView(mScannerView)
}

public override fun onResume() {
super.onResume()
// Register ourselves as a handler for scan results.
mScannerView?.setResultHandler(this)
mScannerView?.startCamera() // Start camera on resume
}

public override fun onPause() {
super.onPause()
mScannerView?.stopCamera() // Stop camera on pause
}

override fun handleResult(result: Result?) {

Toast.makeText(this, result?.text, Toast.LENGTH_SHORT).show()
mScannerView?.resumeCameraPreview(this)
}

}
11 changes: 11 additions & 0 deletions app/src/main/res/layout/activity_decoder.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">


<com.dlazaro66.qrcodereaderview.QRCodeReaderView
android:id="@+id/reader"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
12 changes: 7 additions & 5 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout 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="com.example.admin.lifeapp.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="@+id/clickMe"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/click_me"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>
</RelativeLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">LifeApp</string>
<string name="click_me">Click me</string>
</resources>
18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
buildscript {
ext.kotlin_version = '1.1.4-3'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
17 changes: 17 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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.
org.gradle.jvmargs=-Xmx1536m

# 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
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Thu Oct 19 16:44:32 EAT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Loading

0 comments on commit 13766f2

Please sign in to comment.