+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 63678ef..9a4a7b8 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,26 +8,41 @@
-
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 9f7eaed..7044e29 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -4,6 +4,9 @@
+
+
+
diff --git a/QRGenearator/build.gradle b/QRGenearator/build.gradle
index e6b9132..d2244e7 100644
--- a/QRGenearator/build.gradle
+++ b/QRGenearator/build.gradle
@@ -6,12 +6,12 @@ group = 'androidmads.library.qrgenearator' // Change this to match your package
version = '1.0.4' // Change this to match your version number
android {
- compileSdkVersion 28
+ compileSdkVersion 30
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 14
- targetSdkVersion 28
+ targetSdkVersion 30
versionCode 1
versionName "1.0"
}
@@ -24,7 +24,7 @@ android {
}
dependencies {
- implementation 'com.google.zxing:core:3.2.0'
+ implementation 'com.google.zxing:core:3.3.2'
}
Properties properties = new Properties()
diff --git a/QRGenearator/src/main/java/androidmads/library/qrgenearator/QRGContents.java b/QRGenearator/src/main/java/androidmads/library/qrgenearator/QRGContents.java
index f517c53..2ed14f8 100644
--- a/QRGenearator/src/main/java/androidmads/library/qrgenearator/QRGContents.java
+++ b/QRGenearator/src/main/java/androidmads/library/qrgenearator/QRGContents.java
@@ -30,14 +30,11 @@ public static final class Type {
public static final String LOCATION = "LOCATION_TYPE";
}
- public static final String URL_KEY = "URL_KEY";
-
- public static final String NOTE_KEY = "NOTE_KEY";
-
// When using Type.CONTACT, these arrays provide the keys for adding or retrieving multiple
// phone numbers and addresses.
public static final String[] PHONE_KEYS = {
- ContactsContract.Intents.Insert.PHONE, ContactsContract.Intents.Insert.SECONDARY_PHONE,
+ ContactsContract.Intents.Insert.PHONE,
+ ContactsContract.Intents.Insert.SECONDARY_PHONE,
ContactsContract.Intents.Insert.TERTIARY_PHONE
};
@@ -48,7 +45,8 @@ public static final class Type {
};
public static final String[] EMAIL_KEYS = {
- ContactsContract.Intents.Insert.EMAIL, ContactsContract.Intents.Insert.SECONDARY_EMAIL,
+ ContactsContract.Intents.Insert.EMAIL,
+ ContactsContract.Intents.Insert.SECONDARY_EMAIL,
ContactsContract.Intents.Insert.TERTIARY_EMAIL
};
diff --git a/QRGenearator/src/main/java/androidmads/library/qrgenearator/QRGEncoder.java b/QRGenearator/src/main/java/androidmads/library/qrgenearator/QRGEncoder.java
index d55450e..dd1fb99 100644
--- a/QRGenearator/src/main/java/androidmads/library/qrgenearator/QRGEncoder.java
+++ b/QRGenearator/src/main/java/androidmads/library/qrgenearator/QRGEncoder.java
@@ -113,17 +113,20 @@ private void encodeQRCodeContents(String data, Bundle bundle, String type) {
StringBuilder newContents = new StringBuilder(100);
StringBuilder newDisplayContents = new StringBuilder(100);
- newContents.append("VCARD:");
+ newContents.append("BEGIN:VCARD\n");
String name = trim(bundle.getString(ContactsContract.Intents.Insert.NAME));
if (name != null) {
newContents.append("N:").append(escapeVCard(name)).append(';');
newDisplayContents.append(name);
+ newContents.append("\n");
}
String address = trim(bundle.getString(ContactsContract.Intents.Insert.POSTAL));
if (address != null) {
- newContents.append("ADR:").append(escapeVCard(address)).append(';');
+ //the append ; is removed because it is unnecessary because we are breaking into new row
+ newContents.append("ADR:").append(escapeVCard(address));//.append(';')
+ newContents.append("\n");
newDisplayContents.append('\n').append(address);
}
@@ -135,7 +138,8 @@ private void encodeQRCodeContents(String data, Bundle bundle, String type) {
}
}
for (String phone : uniquePhones) {
- newContents.append("TEL:").append(escapeVCard(phone)).append(';');
+ newContents.append("TEL:").append(escapeVCard(phone));//.append(';')
+ newContents.append("\n");
//noinspection deprecation
newDisplayContents.append('\n').append(PhoneNumberUtils.formatNumber(phone));
}
@@ -148,25 +152,37 @@ private void encodeQRCodeContents(String data, Bundle bundle, String type) {
}
}
for (String email : uniqueEmails) {
- newContents.append("EMAIL:").append(escapeVCard(email)).append(';');
+ newContents.append("EMAIL:").append(escapeVCard(email));//.append(';')
+ newContents.append("\n");
newDisplayContents.append('\n').append(email);
}
- String url = trim(bundle.getString(QRGContents.URL_KEY));
+ String organization = trim(bundle.getString(ContactsContract.Intents.Insert.COMPANY));
+ if (organization != null) {
+ newContents.append("ORG:").append(organization);//.append(';')
+ newContents.append("\n");
+ newDisplayContents.append('\n').append(organization);
+ }
+
+ String url = trim(bundle.getString(ContactsContract.Intents.Insert.DATA));
if (url != null) {
- // escapeVCard(url) -> wrong escape e.g. http\://zxing.google.com
- newContents.append("URL:").append(url).append(';');
+ // in this field only the website name and the domain are necessary (example : somewebsite.com)
+ newContents.append("URL:").append(escapeVCard(url));//.append(';');
+ newContents.append("\n");
newDisplayContents.append('\n').append(url);
}
- String note = trim(bundle.getString(QRGContents.NOTE_KEY));
+ String note = trim(bundle.getString(ContactsContract.Intents.Insert.NOTES));
if (note != null) {
- newContents.append("NOTE:").append(escapeVCard(note)).append(';');
+ newContents.append("NOTE:").append(escapeVCard(note));//.append(';')
+ newContents.append("\n");
newDisplayContents.append('\n').append(note);
}
// Make sure we've encoded at least one field.
if (newDisplayContents.length() > 0) {
+ //this end vcard needs to be at the end in order for the default phone reader to recognize it as a contact
+ newContents.append("END:VCARD");
newContents.append(';');
contents = newContents.toString();
displayContents = newDisplayContents.toString();
diff --git a/app/build.gradle b/app/build.gradle
index b8ca172..0bae344 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -21,8 +21,9 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
- testImplementation 'junit:junit:4.12'
- implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
+ testImplementation 'junit:junit:4.13.1'
implementation project(':QRGenearator')
//implementation 'androidmads.library.qrgenearator:QRGenearator:1.0.3'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7c95d27..efec506 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,7 +2,7 @@
-
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/androidmads/example/GenDataActivity.java b/app/src/main/java/androidmads/example/GenDataActivity.java
new file mode 100644
index 0000000..e355332
--- /dev/null
+++ b/app/src/main/java/androidmads/example/GenDataActivity.java
@@ -0,0 +1,52 @@
+package androidmads.example;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+public class GenDataActivity extends AppCompatActivity {
+
+ EditText editTextName, editTextAddress, editTextPhone, editTextAddressMail, editTextNotes, editTextOrganization, editTextURL;
+ Button btnGenerate;
+
+ private static final String TAG = "MainActivity";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_gen_data);
+
+ editTextName = findViewById(R.id.editTextName);
+ editTextAddress = findViewById(R.id.editTextAddress);
+ editTextPhone = findViewById(R.id.editTextPhone);
+ editTextAddressMail = findViewById(R.id.editTextAddressMail);
+ btnGenerate = findViewById(R.id.btnGenerate);
+ editTextNotes = findViewById(R.id.editTextNotes);
+ editTextOrganization = findViewById(R.id.editTextOrganization);
+ editTextURL = findViewById(R.id.editTextURL);
+
+ btnGenerate.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+
+ //keys in bundle correspond to the fields in the ContactsContract.class
+ Intent intent = new Intent(getApplicationContext(), GenQRActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putString("name", editTextName.getText().toString());
+ bundle.putString("postal", editTextAddress.getText().toString());
+ bundle.putString("phone", editTextPhone.getText().toString());
+ bundle.putString("email", editTextAddressMail.getText().toString());
+ bundle.putString("notes", editTextNotes.getText().toString());
+ bundle.putString("company", editTextOrganization.getText().toString());
+ bundle.putString("data", editTextURL.getText().toString());
+ intent.putExtras(bundle);
+ startActivity(intent);
+ }
+ });
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/androidmads/example/GenQRActivity.java b/app/src/main/java/androidmads/example/GenQRActivity.java
new file mode 100644
index 0000000..0eaa69c
--- /dev/null
+++ b/app/src/main/java/androidmads/example/GenQRActivity.java
@@ -0,0 +1,50 @@
+package androidmads.example;
+
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import androidmads.library.qrgenearator.QRGContents;
+import androidmads.library.qrgenearator.QRGEncoder;
+
+public class GenQRActivity extends AppCompatActivity {
+
+ ImageView imageQR;
+ Bitmap bitmap;
+ private static final String TAG = "QRActivity";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_gen_q_r);
+
+ imageQR = findViewById(R.id.imageQR);
+
+ final Bundle bundle = getIntent().getExtras();
+// String name = bundle.getString("name");
+// String address = bundle.getString("postal");
+// String phone = bundle.getString("phone");
+// String email = bundle.getString("email");
+// String notes = bundle.getString("notes");
+// String organization = bundle.getString("company");
+// String url = bundle.getString("data");
+// Toast.makeText(this, name + address + phone, Toast.LENGTH_SHORT).show();
+
+
+ //setting the data as null and bundle of data from the previous activity because of the type of the QR
+ QRGEncoder qrgEncoder = new QRGEncoder(null, bundle, QRGContents.Type.CONTACT, 500);
+ try {
+ // Getting QR-Code as Bitmap
+ bitmap = qrgEncoder.getBitmap();
+ // Setting Bitmap to ImageView
+ imageQR.setImageBitmap(bitmap);
+ } catch (Exception e) {
+ Log.v(TAG, e.toString());
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/androidmads/example/MainActivity.java b/app/src/main/java/androidmads/example/MainActivity.java
index c6a867b..a0ab399 100644
--- a/app/src/main/java/androidmads/example/MainActivity.java
+++ b/app/src/main/java/androidmads/example/MainActivity.java
@@ -1,6 +1,11 @@
package androidmads.example;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+
import android.Manifest;
+import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
@@ -14,10 +19,6 @@
import android.widget.ImageView;
import android.widget.Toast;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.app.ActivityCompat;
-import androidx.core.content.ContextCompat;
-
import androidmads.library.qrgenearator.QRGContents;
import androidmads.library.qrgenearator.QRGEncoder;
import androidmads.library.qrgenearator.QRGSaver;
@@ -93,4 +94,7 @@ public void onClick(View v) {
}
-}
+ public void goto_CQBarcode(View view) {
+ startActivity(new Intent(getApplicationContext(), GenDataActivity.class));
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_gen_data.xml b/app/src/main/res/layout/activity_gen_data.xml
new file mode 100644
index 0000000..07fdd1d
--- /dev/null
+++ b/app/src/main/res/layout/activity_gen_data.xml
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_gen_q_r.xml b/app/src/main/res/layout/activity_gen_q_r.xml
new file mode 100644
index 0000000..b9e28fd
--- /dev/null
+++ b/app/src/main/res/layout/activity_gen_q_r.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 9135081..c9e57b8 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -23,18 +23,26 @@
android:orientation="horizontal">
+ android:layout_weight="1"
+ android:text="@string/generate" />
+ android:layout_weight="1"
+ android:text="@string/save" />
+
+
-
+
\ No newline at end of file
diff --git a/vCardQRGenerator/.gitignore b/vCardQRGenerator/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/vCardQRGenerator/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/vCardQRGenerator/build.gradle b/vCardQRGenerator/build.gradle
new file mode 100644
index 0000000..702b0f9
--- /dev/null
+++ b/vCardQRGenerator/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 30
+ buildToolsVersion "30.0.2"
+
+ defaultConfig {
+ minSdkVersion 24
+ targetSdkVersion 30
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: "libs", include: ["*.jar"])
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+
+}
\ No newline at end of file
diff --git a/vCardQRGenerator/consumer-rules.pro b/vCardQRGenerator/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/vCardQRGenerator/proguard-rules.pro b/vCardQRGenerator/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/vCardQRGenerator/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# 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 *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/vCardQRGenerator/src/androidTest/java/com/kodobit/vcardqrgenerator/ExampleInstrumentedTest.java b/vCardQRGenerator/src/androidTest/java/com/kodobit/vcardqrgenerator/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..31f4626
--- /dev/null
+++ b/vCardQRGenerator/src/androidTest/java/com/kodobit/vcardqrgenerator/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.kodobit.vcardqrgenerator;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("com.kodobit.vcardqrgenerator.test", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/vCardQRGenerator/src/main/AndroidManifest.xml b/vCardQRGenerator/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..38166e9
--- /dev/null
+++ b/vCardQRGenerator/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+ /
+
\ No newline at end of file
diff --git a/vCardQRGenerator/src/test/java/com/kodobit/vcardqrgenerator/ExampleUnitTest.java b/vCardQRGenerator/src/test/java/com/kodobit/vcardqrgenerator/ExampleUnitTest.java
new file mode 100644
index 0000000..22ccc20
--- /dev/null
+++ b/vCardQRGenerator/src/test/java/com/kodobit/vcardqrgenerator/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.kodobit.vcardqrgenerator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file