Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f308ec2

Browse files
author
Nayan
committedDec 31, 2016
initial commit
0 parents  commit f308ec2

34 files changed

+778
-0
lines changed
 

‎.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

‎.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/gradle.xml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/misc.xml

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

‎app/build.gradle

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 24
5+
buildToolsVersion "25.0.0"
6+
defaultConfig {
7+
applicationId "dns.adhaarscanner"
8+
minSdkVersion 15
9+
targetSdkVersion 24
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25+
exclude group: 'com.android.support', module: 'support-annotations'
26+
})
27+
compile 'com.android.support:appcompat-v7:24.2.1'
28+
testCompile 'junit:junit:4.12'
29+
compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
30+
compile 'com.google.zxing:core:3.2.0'
31+
compile 'com.android.support:recyclerview-v7:24.2.1'
32+
}

‎app/libs/java-json.jar

82.7 KB
Binary file not shown.

‎app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /home/nayan/Android/Sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package dns.adhaarscanner;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("dns.adhaarscanner", appContext.getPackageName());
25+
}
26+
}

‎app/src/main/AndroidManifest.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="dns.adhaarscanner">
3+
4+
<application
5+
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
7+
android:label="@string/app_name"
8+
android:supportsRtl="true"
9+
android:theme="@style/AppTheme">
10+
<activity android:name=".Screen.HomeScreen"
11+
android:screenOrientation="portrait">
12+
<intent-filter android:label="@string/app_name" >
13+
<action android:name="android.intent.action.MAIN" />
14+
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
<activity android:name=".Screen.ResultScreen"/>
19+
</application>
20+
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package dns.adhaarscanner.Screen;
2+
3+
import android.content.Intent;
4+
import android.content.pm.PackageManager;
5+
import android.os.Bundle;
6+
import android.support.annotation.NonNull;
7+
import android.support.annotation.Nullable;
8+
import android.support.v4.app.ActivityCompat;
9+
import android.support.v7.app.AppCompatActivity;
10+
import android.util.Log;
11+
import android.view.View;
12+
import android.widget.Button;
13+
import android.widget.Toast;
14+
15+
import com.google.zxing.integration.android.IntentIntegrator;
16+
import com.journeyapps.barcodescanner.CaptureActivity;
17+
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
21+
import dns.adhaarscanner.R;
22+
23+
/**
24+
* Created by nayan on 12/31/16.
25+
*/
26+
27+
public class HomeScreen extends AppCompatActivity implements View.OnClickListener {
28+
29+
Button scanButton;
30+
31+
private static final String CAMERA_PERMISSION = "android.permission.CAMERA";
32+
private static final String FLASH_PERMISSION = "android.permission.FLASHLIGHT";
33+
34+
private static final int PERMISSION_REQ_CODE = 11;
35+
36+
@Override
37+
protected void onCreate(@Nullable Bundle savedInstanceState) {
38+
super.onCreate(savedInstanceState);
39+
setContentView(R.layout.home);
40+
scanButton = (Button) findViewById(R.id.scan_btn);
41+
scanButton.setOnClickListener(this);
42+
}
43+
44+
45+
@Override
46+
public void onClick(View v) {
47+
int permission1 = checkCallingOrSelfPermission(CAMERA_PERMISSION);
48+
List<String> permissions = new ArrayList<>();
49+
50+
if (permission1 == PackageManager.PERMISSION_DENIED) {
51+
permissions.add(CAMERA_PERMISSION);
52+
}
53+
54+
if (permissions.isEmpty()) {
55+
Intent intent = new Intent(this, CaptureActivity.class);
56+
intent.setAction("com.google.zxing.client.android.SCAN");
57+
intent.putExtra("SAVE_HISTORY", false);
58+
startActivityForResult(intent, 0);
59+
} else {
60+
ActivityCompat.requestPermissions(this, permissions.toArray(new String[permissions.size()]), 11);
61+
}
62+
}
63+
64+
65+
@Override
66+
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
67+
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
68+
for (int res : grantResults) {
69+
if (res == PackageManager.PERMISSION_DENIED) {
70+
return;
71+
}
72+
}
73+
74+
onClick(scanButton);
75+
}
76+
77+
@Override
78+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
79+
super.onActivityResult(requestCode, resultCode, data);
80+
if (resultCode == RESULT_OK) {
81+
String contents = data.getStringExtra("SCAN_RESULT");
82+
Intent intent = new Intent(this, ResultScreen.class);
83+
intent.putExtra("data", contents);
84+
startActivity(intent);
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)
Please sign in to comment.