├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── build │ └── outputs │ │ └── apk │ │ └── app-debug.apk ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── shubhamnishad │ │ └── scanbarcodeqrcode │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ │ └── com │ │ │ └── shubhamnishad │ │ │ └── scanbarcodeqrcode │ │ │ ├── About.java │ │ │ ├── Code.java │ │ │ ├── ListItem.java │ │ │ ├── LocationFragment.java │ │ │ ├── MainActivity.java │ │ │ ├── MyAdapter.java │ │ │ ├── PracticeDatabaseHelper.java │ │ │ └── SettingsActivity.java │ └── res │ │ ├── layout │ │ ├── activity_about.xml │ │ ├── activity_main.xml │ │ ├── content_main.xml │ │ └── list_item.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ └── settings.xml │ └── test │ └── java │ └── com │ └── shubhamnishad │ └── scanbarcodeqrcode │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots ├── PhoneScreenshot1.jpg ├── PhoneScreenshot2.jpg ├── PhoneScreenshot3.jpg ├── PhoneScreenshot4.jpg ├── PhoneScreenshot5.jpg └── PhoneScreenshot6.jpg └── 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 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ScanBarcode-QRcode 2 | Scan Barcode & QR code is a simple and fast code scanner with all the features a modern android app. 3 | 4 | 5 | 6 | 7 | I completed the Udacity andriod course and decided to make my own app. 8 | 9 | Reasons to make the Scanner app : 10 | * The idea did not looked complex for a beginner to implement. 11 | * I already knew a barcode scanner library which was pretty popular. 12 | * All the similar apps on playstore had AD'S and I wanted a AD free version. 13 | * The UI of these apps was also old, not updated for a time now so a Material Design solution was needed. 14 | 15 | 16 | The libraries or resources used: 17 | * [Zxing-android-embedded](https://github.com/journeyapps/zxing-android-embedded): really easy to use and does what it says very efficently. 18 | * [cupboard](https://bitbucket.org/littlerobots/cupboard): makes SQL vey simple. you should atleast read it usage. [Read this for more info](http://guides.codepath.com/android/Easier-SQL-with-Cupboard) 19 | * [CodePath Android Cliffnotes](http://guides.codepath.com/android): A crowdsourced resource for complete and up-to-date practical Android developer guides for any topic. 20 | * youtube also helped as always. 21 | 22 | 23 | Things I learned and implemented: 24 | * RecyclerView with swipe actions. 25 | * Database connectivity using SQLite. 26 | * SharedPreferences. 27 | * Intents. 28 | * Countless hours of debugging and wow moments. 29 | 30 | 31 | the app is available at https://github.com/shubhamnishad97/ScanBarcode-QRcode/raw/master/app/build/outputs/apk/app-debug.apk 32 | 33 | tested to be working on 34 | * Oneplus 3T[API 25] 35 | * Pixel[API 25] 36 | * LG G3[API 19] 37 | * Nexus 4[API 19] 38 | * Nexus 5[API 23] 39 | * Moto E[API 19] 40 | * Redmi 4[API 25]. 41 | 42 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | build/generated 2 | build/tmp 3 | build/intermediates 4 | build/outputs/logs -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "26.0.0" 6 | defaultConfig { 7 | applicationId "com.shubhamnishad.scanbarcodeqrcode" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.2" 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:25.3.1' 28 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 29 | compile 'com.android.support:design:25.3.1' 30 | compile 'com.journeyapps:zxing-android-embedded:3.4.0' 31 | compile 'com.android.support:recyclerview-v7:25.3.1' 32 | compile 'com.android.support:cardview-v7:25.3.1' 33 | compile 'nl.qbusict:cupboard:2.2.0' 34 | compile 'com.android.support:preference-v7:25.3.1' 35 | testCompile 'junit:junit:4.12' 36 | } 37 | -------------------------------------------------------------------------------- /app/build/outputs/apk/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/build/outputs/apk/app-debug.apk -------------------------------------------------------------------------------- /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\Shubham\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 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/shubhamnishad/scanbarcodeqrcode/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.shubhamnishad.scanbarcodeqrcode; 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.shubhamnishad.scanbarcodeqrcode", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/shubhamnishad/scanbarcodeqrcode/About.java: -------------------------------------------------------------------------------- 1 | package com.shubhamnishad.scanbarcodeqrcode; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class About extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_about); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/shubhamnishad/scanbarcodeqrcode/Code.java: -------------------------------------------------------------------------------- 1 | package com.shubhamnishad.scanbarcodeqrcode; 2 | 3 | /** 4 | * Created by Shubham on 30-06-2017. 5 | */ 6 | 7 | public class Code { 8 | 9 | 10 | public Long _id; // for cupboard 11 | public String name; // bunny name 12 | public String type; 13 | 14 | 15 | public Code() { 16 | this.name = "noName"; 17 | this.type = "noType"; 18 | } 19 | 20 | public Code(String name, String type) { 21 | this.name = name; 22 | this.type = type; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/shubhamnishad/scanbarcodeqrcode/ListItem.java: -------------------------------------------------------------------------------- 1 | package com.shubhamnishad.scanbarcodeqrcode; 2 | 3 | /** 4 | * Created by Shubham on 29-06-2017. 5 | */ 6 | 7 | public class ListItem { 8 | private long _id; 9 | private String code; 10 | private String type; 11 | 12 | public ListItem(long _id,String code, String type) { 13 | this._id = _id; 14 | this.code = code; 15 | this.type = type; 16 | } 17 | public long get_Id() { 18 | return _id; 19 | } 20 | 21 | public String getCode() { 22 | return code; 23 | } 24 | 25 | public String getType() { 26 | return type; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/shubhamnishad/scanbarcodeqrcode/LocationFragment.java: -------------------------------------------------------------------------------- 1 | package com.shubhamnishad.scanbarcodeqrcode; 2 | 3 | import android.content.SharedPreferences; 4 | import android.os.Bundle; 5 | import android.preference.Preference; 6 | import android.preference.PreferenceFragment; 7 | 8 | /** 9 | * Created by Shubham on 30-06-2017. 10 | */ 11 | public class LocationFragment extends PreferenceFragment{ 12 | 13 | private final static String beep = "beep"; 14 | private final static String frontCamera = "frontCamera"; 15 | 16 | @Override 17 | public void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | 20 | addPreferencesFromResource(R.xml.settings); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/shubhamnishad/scanbarcodeqrcode/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.shubhamnishad.scanbarcodeqrcode; 2 | 3 | import android.content.Intent; 4 | import android.content.SharedPreferences; 5 | import android.database.Cursor; 6 | import android.database.sqlite.SQLiteDatabase; 7 | import android.os.Bundle; 8 | import android.preference.PreferenceFragment; 9 | import android.support.design.widget.FloatingActionButton; 10 | import android.support.design.widget.Snackbar; 11 | import android.support.v7.app.AppCompatActivity; 12 | import android.support.v7.preference.PreferenceManager; 13 | import android.support.v7.widget.CardView; 14 | import android.support.v7.widget.LinearLayoutManager; 15 | import android.support.v7.widget.RecyclerView; 16 | import android.support.v7.widget.Toolbar; 17 | import android.support.v7.widget.helper.ItemTouchHelper; 18 | import android.text.util.Linkify; 19 | import android.view.View; 20 | import android.view.Menu; 21 | import android.view.MenuItem; 22 | import android.widget.TextView; 23 | import android.widget.Toast; 24 | 25 | import com.google.zxing.integration.android.IntentIntegrator; 26 | import com.google.zxing.integration.android.IntentResult; 27 | 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | 31 | import nl.qbusict.cupboard.QueryResultIterable; 32 | 33 | import static nl.qbusict.cupboard.CupboardFactory.cupboard; 34 | 35 | public class MainActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener{ 36 | IntentIntegrator scan; 37 | RecyclerView recyclerView; 38 | RecyclerView.Adapter adapter; 39 | List listItems; 40 | @Override 41 | protected void onCreate(Bundle savedInstanceState) { 42 | super.onCreate(savedInstanceState); 43 | setContentView(R.layout.activity_main); 44 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 45 | setSupportActionBar(toolbar); 46 | final PracticeDatabaseHelper dbHelper = new PracticeDatabaseHelper(this); 47 | final SQLiteDatabase db = dbHelper.getWritableDatabase(); 48 | 49 | PreferenceManager.setDefaultValues(this, R.xml.settings, false); 50 | SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); 51 | Boolean beep = sharedPref.getBoolean("beep",true); 52 | Boolean frontCamera = sharedPref.getBoolean("frontCamera",false); 53 | int camId; 54 | if(frontCamera == false) 55 | camId = 0; 56 | else 57 | camId = 1; 58 | sharedPref.registerOnSharedPreferenceChangeListener(this); 59 | 60 | recyclerView =(RecyclerView)findViewById(R.id.recyclerView); 61 | recyclerView.setHasFixedSize(true); 62 | recyclerView.setLayoutManager(new LinearLayoutManager(this)); 63 | listItems = new ArrayList<>(); 64 | adapter = new MyAdapter(listItems, this); 65 | recyclerView.setAdapter(adapter); 66 | CardView cardView = (CardView)findViewById(R.id.cardView); 67 | 68 | Cursor codes = cupboard().withDatabase(db).query(Code.class).orderBy( "_id DESC").getCursor(); 69 | try { 70 | // Iterate Bunnys 71 | QueryResultIterable itr = cupboard().withCursor(codes).iterate(Code.class); 72 | for (Code bunny : itr) { 73 | // do something with bunny 74 | ListItem listItem = new ListItem( bunny._id,bunny.name,bunny.type); 75 | listItems.add(listItem); 76 | adapter = new MyAdapter(listItems, this); 77 | recyclerView.setAdapter(adapter); 78 | } 79 | } finally { 80 | // close the cursor 81 | codes.close(); 82 | } 83 | new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) { 84 | @Override 85 | public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { 86 | return false; 87 | } 88 | 89 | // Called when a user swipes left or right on a ViewHolder 90 | @Override 91 | public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) { 92 | final int position = viewHolder.getAdapterPosition(); 93 | ListItem item=listItems.get(position); 94 | 95 | cupboard().withDatabase(db).delete(Code.class,item.get_Id()); 96 | listItems.remove(position); 97 | adapter.notifyItemRemoved(position); 98 | adapter.notifyItemRangeChanged(position,listItems.size()); 99 | 100 | } 101 | }).attachToRecyclerView(recyclerView); 102 | scan = new IntentIntegrator(this); 103 | scan.setBeepEnabled(beep); 104 | scan.setCameraId(camId); 105 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 106 | fab.setOnClickListener(new View.OnClickListener() { 107 | @Override 108 | public void onClick(View view) { 109 | scan.initiateScan(); 110 | } 111 | }); 112 | 113 | } 114 | 115 | @Override 116 | public boolean onCreateOptionsMenu(Menu menu) { 117 | // Inflate the menu; this adds items to the action bar if it is present. 118 | getMenuInflater().inflate(R.menu.menu_main, menu); 119 | return true; 120 | } 121 | 122 | @Override 123 | public boolean onOptionsItemSelected(MenuItem item) { 124 | // Handle action bar item clicks here. The action bar will 125 | // automatically handle clicks on the Home/Up button, so long 126 | // as you specify a parent activity in AndroidManifest.xml. 127 | int id = item.getItemId(); 128 | 129 | //noinspection SimplifiableIfStatement 130 | if (id == R.id.action_settings) { 131 | Intent settingsIntent = new Intent(this, SettingsActivity.class); 132 | startActivity(settingsIntent); 133 | } 134 | if (id == R.id.action_clearAll) { 135 | PracticeDatabaseHelper dbHelper = new PracticeDatabaseHelper(this); 136 | SQLiteDatabase db = dbHelper.getWritableDatabase(); 137 | Cursor codes = cupboard().withDatabase(db).query(Code.class).orderBy( "_id DESC").getCursor(); 138 | try { 139 | if (codes.getCount() > 0) { 140 | cupboard().withDatabase(db).delete(Code.class, null); 141 | listItems.clear(); 142 | adapter.notifyDataSetChanged(); 143 | } else { 144 | return true; 145 | } 146 | }finally { 147 | codes.close(); 148 | } 149 | } 150 | if (id == R.id.action_about) { 151 | Intent aboutIntent = new Intent(this, About.class); 152 | startActivity(aboutIntent); 153 | } 154 | 155 | return super.onOptionsItemSelected(item); 156 | } 157 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 158 | IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); 159 | if (result != null) { 160 | 161 | if (result.getContents() == null) { 162 | Snackbar snackbar = Snackbar.make(findViewById(R.id.coordinate), "Result Not Found", Snackbar.LENGTH_LONG); 163 | 164 | snackbar.show(); 165 | } else { 166 | 167 | Code codeObj = new Code(result.getContents(),result.getFormatName()); 168 | PracticeDatabaseHelper dbHelper = new PracticeDatabaseHelper(this); 169 | SQLiteDatabase db = dbHelper.getWritableDatabase(); 170 | long id = cupboard().withDatabase(db).put(codeObj); 171 | listItems.clear(); 172 | adapter.notifyDataSetChanged(); 173 | Cursor codes = cupboard().withDatabase(db).query(Code.class).orderBy( "_id DESC").getCursor(); 174 | try { 175 | // Iterate Bunnys 176 | QueryResultIterable itr = cupboard().withCursor(codes).iterate(Code.class); 177 | for (Code bunny : itr) { 178 | // do something with bunny 179 | ListItem listItem = new ListItem( bunny._id,bunny.name,bunny.type); 180 | listItems.add(listItem); 181 | adapter = new MyAdapter(listItems, this); 182 | recyclerView.setAdapter(adapter); 183 | } 184 | } finally { 185 | // close the cursor 186 | codes.close(); 187 | } 188 | } 189 | } else { 190 | super.onActivityResult(requestCode, resultCode, data); 191 | } 192 | } 193 | public void cardClick(View card){ 194 | TextView textView = (TextView)findViewById(R.id.textViewCode); 195 | String code= textView.getText().toString(); 196 | Intent sendIntent = new Intent(); 197 | sendIntent.setAction(Intent.ACTION_SEND); 198 | sendIntent.putExtra(Intent.EXTRA_TEXT, code); 199 | sendIntent.setType("text/plain"); 200 | startActivity(sendIntent); 201 | } 202 | 203 | @Override 204 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { 205 | if (key.equals("beep")) { 206 | scan.setBeepEnabled(sharedPreferences.getBoolean(key,true)); 207 | } 208 | if (key.equals("frontCamera")) { 209 | int camId; 210 | if(sharedPreferences.getBoolean(key,false)== false) 211 | camId = 0; 212 | else 213 | camId = 1; 214 | scan.setCameraId(camId); 215 | } 216 | 217 | } 218 | @Override 219 | protected void onDestroy() { 220 | super.onDestroy(); 221 | PreferenceManager.getDefaultSharedPreferences(this) 222 | .unregisterOnSharedPreferenceChangeListener(this); 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /app/src/main/java/com/shubhamnishad/scanbarcodeqrcode/MyAdapter.java: -------------------------------------------------------------------------------- 1 | package com.shubhamnishad.scanbarcodeqrcode; 2 | 3 | import android.content.Context; 4 | import android.net.Uri; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.text.util.Linkify; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.TextView; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * Created by Shubham on 29-06-2017. 16 | */ 17 | 18 | public class MyAdapter extends RecyclerView.Adapter { 19 | List listItems; 20 | Context context; 21 | 22 | public MyAdapter(List listItems, Context context) { 23 | this.listItems = listItems; 24 | this.context = context; 25 | } 26 | 27 | @Override 28 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 29 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false); 30 | return new ViewHolder(v); 31 | } 32 | 33 | @Override 34 | public void onBindViewHolder(ViewHolder holder, int position) { 35 | ListItem listItem = listItems.get(position); 36 | holder.textView_Id.setText(String.valueOf(listItem.get_Id())); 37 | holder.textViewCode.setText(listItem.getCode()); 38 | holder.textViewType.setText(listItem.getType()); 39 | Linkify.addLinks(holder.textViewCode, Linkify.ALL); 40 | } 41 | 42 | @Override 43 | public int getItemCount() { 44 | return listItems.size(); 45 | } 46 | 47 | public class ViewHolder extends RecyclerView.ViewHolder{ 48 | public TextView textView_Id; 49 | public TextView textViewCode; 50 | public TextView textViewType; 51 | 52 | public TextView getTextView_Id() { 53 | return textView_Id; 54 | } 55 | 56 | public ViewHolder(View itemView) { 57 | super(itemView); 58 | textView_Id = (TextView)itemView.findViewById(R.id.textView_Id); 59 | textViewCode = (TextView)itemView.findViewById(R.id.textViewCode); 60 | textViewType = (TextView)itemView.findViewById(R.id.textViewType); 61 | } 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/shubhamnishad/scanbarcodeqrcode/PracticeDatabaseHelper.java: -------------------------------------------------------------------------------- 1 | package com.shubhamnishad.scanbarcodeqrcode; 2 | 3 | /** 4 | * Created by Shubham on 30-06-2017. 5 | */ 6 | import android.content.Context; 7 | import android.database.sqlite.SQLiteDatabase; 8 | import android.database.sqlite.SQLiteOpenHelper; 9 | import static nl.qbusict.cupboard.CupboardFactory.cupboard; 10 | 11 | public class PracticeDatabaseHelper extends SQLiteOpenHelper{ 12 | private static final String DATABASE_NAME = "cupboardTest.db"; 13 | private static final int DATABASE_VERSION = 1; 14 | 15 | public PracticeDatabaseHelper(Context context) { 16 | super(context, DATABASE_NAME, null, DATABASE_VERSION); 17 | } 18 | 19 | static { 20 | // register our models 21 | cupboard().register(Code.class); 22 | } 23 | 24 | @Override 25 | public void onCreate(SQLiteDatabase db) { 26 | // this will ensure that all tables are created 27 | cupboard().withDatabase(db).createTables(); 28 | // add indexes and other database tweaks in this method if you want 29 | 30 | } 31 | 32 | @Override 33 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 34 | // this will upgrade tables, adding columns and new tables. 35 | // Note that existing columns will not be converted 36 | cupboard().withDatabase(db).upgradeTables(); 37 | // do migration work if you have an alteration to make to your schema here 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/shubhamnishad/scanbarcodeqrcode/SettingsActivity.java: -------------------------------------------------------------------------------- 1 | package com.shubhamnishad.scanbarcodeqrcode; 2 | 3 | import android.preference.PreferenceActivity; 4 | import android.preference.PreferenceFragment; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | 8 | public class SettingsActivity extends PreferenceActivity { 9 | 10 | private final static String TAG = "SettingsAcitivity"; 11 | 12 | public SettingsActivity() {} 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | getFragmentManager().beginTransaction() 18 | .replace(android.R.id.content, new LocationFragment()).commit(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 17 | 26 | 32 | 40 | 49 | 55 | 63 | 72 | 78 | 79 | 85 | 86 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 18 | 19 | 24 | 25 | 39 | 49 | 50 | 59 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 15 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shubhamnishad97/ScanBarcode-QRcode/40ecbf4c10c398602357c9718f8d8648a6055036/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #9E9E9E 4 | #616161 5 | #FFC107 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16dp 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Scan Barcode & QR code 3 | Settings 4 | Clear All 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |