├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── google-services.json
├── proguard-rules.pro
├── release
│ ├── app-release.apk
│ ├── fastest_barcode_and_qr_code_V_2.0.apk
│ ├── fastest_barcode_and_qr_code_v_2.1.apk
│ └── output.json
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── nextinnovation
│ │ └── pt
│ │ └── barcodereaderforplaystore
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── nextinnovation
│ │ │ └── pt
│ │ │ └── barcodescanner
│ │ │ ├── activity
│ │ │ ├── MainActivity.java
│ │ │ ├── SplashActivity.java
│ │ │ └── WebViewActivity.java
│ │ │ ├── adapter
│ │ │ └── ProductAdapter.java
│ │ │ ├── database
│ │ │ └── DatabaseHelper.java
│ │ │ ├── fragment
│ │ │ ├── BarcodeFragment.java
│ │ │ ├── LicenseFragment.java
│ │ │ └── ProductListFragment.java
│ │ │ ├── model
│ │ │ └── Product.java
│ │ │ └── utils
│ │ │ ├── ClipBoardManager.java
│ │ │ └── Utils.java
│ └── res
│ │ ├── drawable
│ │ ├── barcode_icon_2_png.png
│ │ ├── button_background.xml
│ │ ├── button_focus.xml
│ │ ├── button_press.xml
│ │ ├── button_unfocus.xml
│ │ ├── ic_access_time_black_24dp.xml
│ │ ├── ic_barcode.xml
│ │ ├── ic_content_copy_white_24dp.xml
│ │ ├── ic_search_white_24dp.xml
│ │ ├── ic_share_black_24dp.xml
│ │ ├── ic_warning_black_24dp.xml
│ │ ├── splash_drawable.xml
│ │ └── style_toggle_button.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_splash.xml
│ │ ├── activity_web_view.xml
│ │ ├── fragment_barcode_scanner.xml
│ │ ├── fragment_license.xml
│ │ ├── fragment_prduct_list.xml
│ │ ├── row_barcode.xml
│ │ └── row_native_express_add.xml
│ │ ├── menu
│ │ └── main_menu.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── nextinnovation
│ └── pt
│ └── barcodereaderforplaystore
│ └── ExampleUnitTest.java
├── build.gradle
├── google_play_screenshots
├── copy_share_search.png
├── home_screen.png
├── scan_result_screen.png
├── scan_screen.png
└── web_search.png
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BarcodeAndQRReaderAndroid
2 | ## Best Barcode And QR Code Reder for Android . ##
3 | ### Google Play - https://play.google.com/store/apps/details?id=com.nextinnovation.pt.barcodescanner
4 | #### Android Fastest Barcode & QR Code Reader is the best tool for scanning Barcode & QR code instantly within 2-5 Seconds. Below are some features of this app ####
5 |
6 | 1. Scan QR Code faster than other tool.
7 | 2. Scan Barcode faster than other tool.
8 | 3. Flashlight support for night scanning.
9 | 4. Save result for future use.
10 | 5. Share your Barcode or QR Code.
11 | 6. Search for your barcode result or Direct link opening.
12 | 7. Copy as a plain text to use.
13 | 8. Can able to scan different formats of QR Codes, Data Matrix, PDF-417, and Aztec values
14 | 9. Supports 1D barcodes: EAN-13, EAN-8, UPC-A, UPC-E, Code-39, Code-93, Code-128, ITF, Codabar
15 | 10. Supports 2D barcodes: QR Code, Data Matrix, PDF-417, Aztec
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | ### For developer preview Fastest Barcode & QR Code Reader covered different Android Topics & Library. ###
26 |
27 | #### Android Topics Covered in This App: ####
28 |
29 | 1. Activity & Fragment
30 | 2. Android Material Design Cocepts
31 | 3. Android View Pager With TAB .
32 | 4. Using RecylerView & CardView.
33 | 5. Toolbar Menu
34 | 6. Android WebView
35 | 7. Android Share Intent & Copy To Clipboard
36 |
37 | #### Usages Library & Purpose ####
38 |
39 | **1. Material Barcode Scanner** - For Barcode & QR Code Scan.
40 |
41 | Dependency : `com.edwardvanraak:MaterialBarcodeScanner:0.0.6-ALPHA`
42 |
43 | GitHub : https://github.com/EdwardvanRaak/MaterialBarcodeScanner
44 |
45 | **2. Firebase Core & Ads** - For analytics & Google Adsense
46 |
47 | Dependecies :
48 |
49 | `compile 'com.google.firebase:firebase-core:11.6.0'`
50 |
51 | `compile 'com.google.firebase:firebase-ads:11.6.0'`
52 |
53 | Firebase : https://firebase.google.com/
54 |
55 | **3. Fabric Crash Analytics** : For reporting crash.
56 |
57 | Dependency : `com.crashlytics.sdk.android:crashlytics:2.7.1@aar`
58 |
59 | Fabric : https://fabric.io/
60 |
61 |
62 | ### Follow Me : ###
63 |
64 | Github : https://github.com/Piashsarker
65 |
66 | Linkedin : https://www.linkedin.com/in/piashsarker/
67 |
68 | Quora : https://www.quora.com/profile/Piash-Sarker-1
69 |
70 | Twitter : https://twitter.com/PiashSarker
71 |
72 | Gmail : sarkerpt@gmail.com
73 |
74 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'io.fabric'
3 |
4 |
5 | repositories {
6 | maven { url 'https://maven.fabric.io/public' }
7 | }
8 |
9 | android {
10 | compileSdkVersion 26
11 | buildToolsVersion '26.0.2'
12 | defaultConfig {
13 | applicationId "com.nextinnovation.pt.barcodescanner"
14 | minSdkVersion 15
15 | targetSdkVersion 26
16 | versionCode 3
17 | versionName "2.1"
18 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | }
27 |
28 | dependencies {
29 | compile fileTree(dir: 'libs', include: ['*.jar'])
30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
31 | exclude group: 'com.android.support', module: 'support-annotations'
32 | })
33 | compile 'com.android.support:appcompat-v7:26.1.0'
34 | compile 'com.android.support:cardview-v7:26.1.0'
35 | compile 'com.android.support:recyclerview-v7:26.1.0'
36 | compile 'com.android.support:design:26.1.0'
37 | compile 'com.edwardvanraak:MaterialBarcodeScanner:0.0.6-ALPHA'
38 | compile 'com.google.firebase:firebase-core:11.6.0'
39 | compile 'com.google.firebase:firebase-ads:11.6.0'
40 | compile 'com.google.android.gms:play-services-base:11.6.0'
41 | compile 'com.google.android.gms:play-services-vision:11.6.0'
42 | testCompile 'junit:junit:4.12'
43 | compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
44 | transitive = true
45 | }
46 |
47 | }
48 | apply plugin: 'com.google.gms.google-services'
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "54135562732",
4 | "firebase_url": "https://publishedappsplay.firebaseio.com",
5 | "project_id": "publishedappsplay",
6 | "storage_bucket": "publishedappsplay.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:54135562732:android:dd94de8c2fb5d640",
12 | "android_client_info": {
13 | "package_name": "com.nextinnovation.pt.barcodescanner"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "54135562732-lgmk1l24ceq7qi4kicr7in3siee7537m.apps.googleusercontent.com",
19 | "client_type": 1,
20 | "android_info": {
21 | "package_name": "com.nextinnovation.pt.barcodescanner",
22 | "certificate_hash": "44fe06ab8398f0835871e42ec35418f40a4fbc9e"
23 | }
24 | },
25 | {
26 | "client_id": "54135562732-cjohia0msut8qrisfuh0ta707bulfki2.apps.googleusercontent.com",
27 | "client_type": 3
28 | }
29 | ],
30 | "api_key": [
31 | {
32 | "current_key": "AIzaSyCrkEgM5RYDCegLKzrR9N4nfnGoMELbdFw"
33 | }
34 | ],
35 | "services": {
36 | "analytics_service": {
37 | "status": 1
38 | },
39 | "appinvite_service": {
40 | "status": 2,
41 | "other_platform_oauth_client": [
42 | {
43 | "client_id": "54135562732-cjohia0msut8qrisfuh0ta707bulfki2.apps.googleusercontent.com",
44 | "client_type": 3
45 | }
46 | ]
47 | },
48 | "ads_service": {
49 | "status": 2
50 | }
51 | }
52 | }
53 | ],
54 | "configuration_version": "1"
55 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\PT\AppData\Local\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 | #}
18 |
--------------------------------------------------------------------------------
/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piashsarker/BarcodeAndQRReaderAndroid/1ec33217d55016c726d5a1a5f3a62963edfdcac1/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/release/fastest_barcode_and_qr_code_V_2.0.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piashsarker/BarcodeAndQRReaderAndroid/1ec33217d55016c726d5a1a5f3a62963edfdcac1/app/release/fastest_barcode_and_qr_code_V_2.0.apk
--------------------------------------------------------------------------------
/app/release/fastest_barcode_and_qr_code_v_2.1.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piashsarker/BarcodeAndQRReaderAndroid/1ec33217d55016c726d5a1a5f3a62963edfdcac1/app/release/fastest_barcode_and_qr_code_v_2.1.apk
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":3},"path":"app-release.apk","properties":{"packageId":"com.nextinnovation.pt.barcodescanner","split":"","minSdkVersion":"15"}}]
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/nextinnovation/pt/barcodereaderforplaystore/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.nextinnovation.pt.barcodereaderforplaystore;
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 Testing documentation
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("com.example.pt.barcodereaderforplaystore", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
31 |
34 |
35 |
36 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nextinnovation/pt/barcodescanner/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.nextinnovation.pt.barcodescanner.activity;
2 |
3 | import android.Manifest;
4 | import android.content.ActivityNotFoundException;
5 | import android.content.Context;
6 | import android.content.DialogInterface;
7 | import android.content.Intent;
8 | import android.content.pm.PackageManager;
9 | import android.net.Uri;
10 | import android.os.Bundle;
11 | import android.support.annotation.NonNull;
12 | import android.support.design.widget.Snackbar;
13 | import android.support.design.widget.TabLayout;
14 | import android.support.v4.app.ActivityCompat;
15 | import android.support.v4.app.Fragment;
16 | import android.support.v4.app.FragmentManager;
17 | import android.support.v4.app.FragmentPagerAdapter;
18 | import android.support.v4.content.ContextCompat;
19 | import android.support.v4.view.ViewPager;
20 | import android.support.v7.app.AlertDialog;
21 | import android.support.v7.app.AppCompatActivity;
22 | import android.support.v7.widget.Toolbar;
23 | import android.util.Log;
24 | import android.view.Menu;
25 | import android.view.MenuItem;
26 | import android.widget.Toast;
27 |
28 | import com.edwardvanraak.materialbarcodescanner.MaterialBarcodeScanner;
29 | import com.edwardvanraak.materialbarcodescanner.MaterialBarcodeScannerBuilder;
30 | import com.google.android.gms.vision.barcode.Barcode;
31 | import com.nextinnovation.pt.barcodescanner.R;
32 | import com.nextinnovation.pt.barcodescanner.database.DatabaseHelper;
33 | import com.nextinnovation.pt.barcodescanner.fragment.BarcodeFragment;
34 | import com.nextinnovation.pt.barcodescanner.fragment.LicenseFragment;
35 | import com.nextinnovation.pt.barcodescanner.fragment.ProductListFragment;
36 | import com.nextinnovation.pt.barcodescanner.model.Product;
37 |
38 | import java.text.DateFormat;
39 | import java.text.SimpleDateFormat;
40 | import java.util.ArrayList;
41 | import java.util.Date;
42 | import java.util.List;
43 | import java.util.Locale;
44 |
45 | public class MainActivity extends AppCompatActivity implements BarcodeFragment.ScanRequest {
46 |
47 | private Context context ;
48 | private Toolbar toolbar;
49 | private TabLayout tabLayout;
50 | private ViewPager viewPager;
51 | public static final String BARCODE_KEY = "BARCODE";
52 | private Barcode barcodeResult;
53 | private final String TAG = MainActivity.class.getSimpleName() ;
54 | private final int MY_PERMISSION_REQUEST_CAMERA = 1001;
55 | private ItemScanned itemScanned ;
56 |
57 |
58 |
59 |
60 |
61 | @Override
62 | protected void onCreate(Bundle savedInstanceState) {
63 | super.onCreate(savedInstanceState);
64 | setContentView(R.layout.activity_main);
65 | context = this;
66 | toolbar = findViewById(R.id.toolbar);
67 | setSupportActionBar(toolbar);
68 | viewPager = findViewById(R.id.viewpager);
69 | setupViewPager(viewPager);
70 | tabLayout = findViewById(R.id.tabs);
71 | tabLayout.setupWithViewPager(viewPager);
72 |
73 | }
74 |
75 | @Override
76 | protected void onResume() {
77 | super.onResume();
78 |
79 | }
80 |
81 |
82 | private void setupViewPager(ViewPager viewPager) {
83 | ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
84 | adapter.addFragment(new BarcodeFragment(), "Barcode Scanner");
85 | adapter.addFragment(new ProductListFragment(), "Scan Item");
86 | viewPager.setAdapter(adapter);
87 | }
88 |
89 | public String getScanTime() {
90 | DateFormat timeFormat = new SimpleDateFormat("hh:mm a" , Locale.getDefault());
91 | return timeFormat.format(new Date());
92 | }
93 |
94 | public String getScanDate() {
95 | DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy",Locale.getDefault());
96 | return dateFormat.format(new Date());
97 | }
98 |
99 | @Override
100 | public void scanBarcode() {
101 | /** This method will listen the button clicked passed form the fragment **/
102 | checkPermission();
103 | }
104 |
105 | class ViewPagerAdapter extends FragmentPagerAdapter {
106 | private final List mFragmentList = new ArrayList<>();
107 | private final List mFragmentTitleList = new ArrayList<>();
108 |
109 | public ViewPagerAdapter(FragmentManager manager) {
110 | super(manager);
111 | }
112 |
113 |
114 | @Override
115 | public Fragment getItem(int position) {
116 | return mFragmentList.get(position);
117 | }
118 |
119 |
120 | @Override
121 | public int getCount() {
122 | return mFragmentList.size();
123 | }
124 |
125 | public void addFragment(Fragment fragment, String title) {
126 | mFragmentList.add(fragment);
127 | mFragmentTitleList.add(title);
128 | }
129 |
130 | @Override
131 | public CharSequence getPageTitle(int position) {
132 | return mFragmentTitleList.get(position);
133 | }
134 | }
135 | @Override
136 | public boolean onCreateOptionsMenu(Menu menu) {
137 | getMenuInflater().inflate(R.menu.main_menu,menu);
138 | return true ;
139 | }
140 |
141 | @Override
142 | public boolean onOptionsItemSelected(MenuItem item) {
143 |
144 | int id = item.getItemId();
145 | switch (id){
146 | case R.id.item_share:
147 | openShare();
148 | break;
149 | case R.id.item_rate_app:
150 | openRate();
151 | break ;
152 | case R.id.item_submit_bug:
153 | openSubmitBug();
154 | break ;
155 | case R.id.item_license:
156 | openLisence();
157 | break;
158 | }
159 |
160 | return super.onOptionsItemSelected(item);
161 | }
162 |
163 | private void openSubmitBug() {
164 | String to = "sarkerpt@gmail.com";
165 | String subject = "Barcode Reader For Android - Bug Report";
166 |
167 | Intent email = new Intent(Intent.ACTION_SEND);
168 | email.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
169 | email.putExtra(Intent.EXTRA_SUBJECT, subject);
170 | email.setType("message/rfc822");
171 | startActivity(Intent.createChooser(email, "Choose an Email client :"));
172 | }
173 |
174 | private void openRate() {
175 | Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
176 | Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
177 | goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
178 | Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
179 | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
180 | try {
181 | startActivity(goToMarket);
182 | } catch (ActivityNotFoundException e) {
183 | startActivity(new Intent(Intent.ACTION_VIEW,
184 | Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName())));
185 | }
186 | }
187 |
188 | private void openShare() {
189 | Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
190 | String appLink = "https://play.google.com/store/apps/details?id="+context.getPackageName();
191 | sharingIntent.setType("text/plain");
192 | String shareBodyText = "Check Out The Cool Barcode Reader App \n Link: "+appLink +" \n" +
193 | " #Barcode #Android";
194 | sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Barcode Reader Android App");
195 | sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBodyText);
196 | startActivity(Intent.createChooser(sharingIntent, "Share"));
197 | }
198 |
199 | private void openLisence() {
200 | LicenseFragment licensesFragment = new LicenseFragment();
201 | licensesFragment.show(getSupportFragmentManager().beginTransaction(), "dialog_licenses");
202 | }
203 |
204 | private void showDialog(final String scanContent, final String currentTime, final String currentDate) {
205 | AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
206 |
207 | builder.setMessage(scanContent)
208 | .setTitle(R.string.dialog_title);
209 | builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
210 | public void onClick(DialogInterface dialog, int id) {
211 | DatabaseHelper databaseHelper = new DatabaseHelper(context);
212 | databaseHelper.addProduct(new Product(scanContent,currentTime,currentDate));
213 | Toast.makeText(MainActivity.this, "Saved", Toast.LENGTH_SHORT).show();
214 | viewPager.setCurrentItem(1);
215 |
216 |
217 | }
218 | });
219 | builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
220 | public void onClick(DialogInterface dialog, int id) {
221 | Toast.makeText(MainActivity.this, "Not Saved", Toast.LENGTH_SHORT).show();
222 | }
223 | });
224 |
225 | builder.show();
226 | }
227 |
228 | @Override
229 | public void onBackPressed() {
230 | AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
231 | builder.setMessage("Are You Sure? ")
232 | .setTitle(R.string.exit_title);
233 | builder.setPositiveButton(R.string.ok_title, new DialogInterface.OnClickListener() {
234 | public void onClick(DialogInterface dialog, int id) {
235 | MainActivity.this.finish();
236 | }
237 | });
238 | builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
239 | public void onClick(DialogInterface dialog, int id) {
240 | dialog.dismiss();
241 | }
242 | });
243 |
244 | builder.show();
245 | }
246 |
247 | private void checkPermission() {
248 | if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
249 | Log.d(TAG , getResources().getString(R.string.camera_permission_granted));
250 | startScanningBarcode();
251 | } else {
252 | requestCameraPermission();
253 |
254 | }
255 | }
256 |
257 | private void requestCameraPermission() {
258 | if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
259 |
260 | ActivityCompat.requestPermissions(MainActivity.this, new String[] {Manifest.permission.CAMERA}, MY_PERMISSION_REQUEST_CAMERA);
261 |
262 | } else{
263 | ActivityCompat.requestPermissions(MainActivity.this,new String[] {Manifest.permission.CAMERA}, MY_PERMISSION_REQUEST_CAMERA);
264 | }
265 | }
266 |
267 | private void startScanningBarcode() {
268 | /**
269 | * Build a new MaterialBarcodeScanner
270 | */
271 | final MaterialBarcodeScanner materialBarcodeScanner = new MaterialBarcodeScannerBuilder()
272 | .withActivity(MainActivity.this)
273 | .withEnableAutoFocus(true)
274 | .withBleepEnabled(true)
275 | .withBackfacingCamera()
276 | .withCenterTracker()
277 | .withText("Scanning...")
278 | .withResultListener(new MaterialBarcodeScanner.OnResultListener() {
279 | @Override
280 | public void onResult(Barcode barcode) {
281 | barcodeResult = barcode;
282 | showDialog(barcode.rawValue , getScanTime(),getScanDate());
283 | }
284 | })
285 | .build();
286 | materialBarcodeScanner.startScan();
287 | }
288 |
289 | @Override
290 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
291 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
292 | if (requestCode==MY_PERMISSION_REQUEST_CAMERA && grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
293 | startScanningBarcode();
294 | } else {
295 | Snackbar.make(findViewById(android.R.id.content), getResources().getString(R.string.sorry_for_not_permission), Snackbar.LENGTH_SHORT)
296 | .show();
297 | }
298 |
299 | }
300 |
301 |
302 | public interface ItemScanned{
303 | void itemUpdated();
304 | }
305 |
306 | }
307 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nextinnovation/pt/barcodescanner/activity/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.nextinnovation.pt.barcodescanner.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 | import com.crashlytics.android.Crashlytics;
8 | import com.google.android.gms.ads.MobileAds;
9 | import com.nextinnovation.pt.barcodescanner.R;
10 |
11 | import io.fabric.sdk.android.Fabric;
12 |
13 | public class SplashActivity extends Activity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_splash);
19 | /** Initialize Fabrice **/
20 | Fabric.with(SplashActivity.this , new Crashlytics());
21 | /** Initialize Firebase Ads **/
22 | MobileAds.initialize(this, getResources().getString(R.string.app_ad_id));
23 | startMainActivity();
24 | finish();
25 | }
26 |
27 | private void startMainActivity() {
28 | Intent intent = new Intent(SplashActivity.this, MainActivity.class);
29 | startActivity(intent);
30 |
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nextinnovation/pt/barcodescanner/activity/WebViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.nextinnovation.pt.barcodescanner.activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.webkit.WebView;
8 | import android.webkit.WebViewClient;
9 | import android.widget.Button;
10 | import android.widget.Toast;
11 |
12 | import com.google.android.gms.ads.AdRequest;
13 | import com.google.android.gms.ads.AdView;
14 | import com.nextinnovation.pt.barcodescanner.R;
15 | import com.nextinnovation.pt.barcodescanner.utils.Utils;
16 |
17 | public class WebViewActivity extends AppCompatActivity {
18 | Button btnRetry ;
19 | String barCode = "" ;
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_web_view);
24 | btnRetry = findViewById(R.id.btnRetry);
25 | loadAdd();
26 |
27 | Intent intent = getIntent();
28 | if(intent.getExtras()!=null){
29 | barCode= intent.getStringExtra("product_id");
30 | loadWebView(barCode);
31 | }
32 |
33 | btnRetry.setOnClickListener(new View.OnClickListener() {
34 | @Override
35 | public void onClick(View v) {
36 | loadWebView(barCode);
37 | }
38 | });
39 |
40 | }
41 |
42 | private void loadAdd() {
43 | AdView mAdView = findViewById(R.id.adView);
44 | AdRequest adRequest = new AdRequest.Builder().build();
45 | mAdView.loadAd(adRequest);
46 |
47 | }
48 |
49 |
50 | private void loadWebView(String barCode) {
51 | if(Utils.isNetworkAvailable(this)){
52 | btnRetry.setVisibility(View.INVISIBLE);
53 | WebView myWebView = findViewById(R.id.google_webview);
54 | myWebView.setWebViewClient(new WebViewClient());
55 | myWebView.getSettings().setJavaScriptEnabled(true);
56 |
57 | if(Utils.isValidURL(barCode)){
58 | myWebView.loadUrl(barCode);
59 | }else{
60 | myWebView.loadUrl("https://www.google.com/search?q="+barCode);
61 | }
62 |
63 | }
64 | else{
65 | btnRetry.setVisibility(View.VISIBLE);
66 | Toast.makeText(this, "No Internet Connection", Toast.LENGTH_SHORT).show();
67 | }
68 |
69 |
70 |
71 | }
72 |
73 |
74 |
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nextinnovation/pt/barcodescanner/adapter/ProductAdapter.java:
--------------------------------------------------------------------------------
1 | package com.nextinnovation.pt.barcodescanner.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.Button;
11 | import android.widget.LinearLayout;
12 | import android.widget.RelativeLayout;
13 | import android.widget.TextView;
14 |
15 | import com.google.android.gms.ads.NativeExpressAdView;
16 | import com.nextinnovation.pt.barcodescanner.R;
17 | import com.nextinnovation.pt.barcodescanner.activity.WebViewActivity;
18 | import com.nextinnovation.pt.barcodescanner.model.Product;
19 | import com.nextinnovation.pt.barcodescanner.utils.ClipBoardManager;
20 |
21 | import java.util.ArrayList;
22 |
23 | /**
24 | * Created by PT on 2/9/2017.
25 | */
26 |
27 | public class ProductAdapter extends RecyclerView.Adapter {
28 | private Context context;
29 | private ArrayList