Added QRCode Generator
Added QRCode Generator which generate a QR code with destination address and amount
This commit is contained in:
parent
110e7794fd
commit
1d2bdf0808
Binary file not shown.
|
@ -25,7 +25,7 @@
|
|||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -11,6 +11,10 @@ android {
|
|||
versionName "1.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
|
@ -35,5 +39,6 @@ dependencies {
|
|||
implementation 'com.j256.ormlite:ormlite-core:5.1'
|
||||
implementation 'com.j256.ormlite:ormlite-jdbc:5.1'
|
||||
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.5'
|
||||
|
||||
implementation 'com.google.zxing:core:3.2.1'
|
||||
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<activity android:name="monnethic.mobile.homepage.HomepageActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
@ -29,7 +30,9 @@
|
|||
<activity android:name="monnethic.mobile.user.UserAccountActivity" />
|
||||
<activity android:name="monnethic.mobile.demo.DemoActivity" />
|
||||
<activity android:name="monnethic.mobile.wallet.WalletPresenterActivity" />
|
||||
<activity android:name="monnethic.mobile.transaction.TransactionActivity"></activity>
|
||||
<activity android:name="monnethic.mobile.transaction.TransactionActivity" />
|
||||
<activity android:name="monnethic.mobile.qrcode.QrCodeActivity" />
|
||||
<activity android:name="monnethic.mobile.transaction.ReceivePayementActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,64 @@
|
|||
package monnethic.mobile.qrcode;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.monnthic.monnethicmobile.R;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.journeyapps.barcodescanner.BarcodeEncoder;
|
||||
|
||||
public class QrCodeActivity extends AppCompatActivity {
|
||||
ImageView qrCode;
|
||||
Button closeButton;
|
||||
TextView adresseView;
|
||||
TextView amountView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_qr_code);
|
||||
qrCode=findViewById(R.id.qrCodeViewer);
|
||||
closeButton=findViewById(R.id.buttonClose);
|
||||
adresseView=findViewById(R.id.textViewAdresseDisplay);
|
||||
amountView=findViewById(R.id.textViewAmountDisplay);
|
||||
|
||||
Intent intent = getIntent();
|
||||
String adresse = intent.getStringExtra("adresse");
|
||||
String value = intent.getStringExtra("value");
|
||||
try{
|
||||
generateQrCode(adresse,value);
|
||||
}catch(Exception e){
|
||||
e.getMessage();
|
||||
}
|
||||
closeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void generateQrCode(String adresse, String value) throws WriterException {
|
||||
BitMatrix bitMatrix;
|
||||
String valueToEncode = adresse+";"+value;
|
||||
try{
|
||||
bitMatrix = new MultiFormatWriter().encode(valueToEncode, BarcodeFormat.QR_CODE,450,450);
|
||||
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
|
||||
Bitmap bitmap = barcodeEncoder.createBitmap(bitMatrix);
|
||||
qrCode.setImageBitmap(bitmap);
|
||||
adresseView.setText(adresse);
|
||||
amountView.setText(value);
|
||||
}catch (Exception e){
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package monnethic.mobile.transaction;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.example.monnthic.monnethicmobile.R;
|
||||
|
||||
import monnethic.mobile.qrcode.QrCodeActivity;
|
||||
|
||||
public class ReceivePayementActivity extends AppCompatActivity {
|
||||
Button cancelButton;
|
||||
Button validateButton;
|
||||
EditText amountValueEdit;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_receive_payement);
|
||||
cancelButton=findViewById(R.id.buttonCancel);
|
||||
validateButton=findViewById(R.id.buttonValidate);
|
||||
amountValueEdit=findViewById(R.id.amountValue);
|
||||
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
validateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
generateQrCodeWithValue(amountValueEdit.getText().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void generateQrCodeWithValue(String value){
|
||||
Intent generateQrIntent = new Intent(ReceivePayementActivity.this, QrCodeActivity.class);
|
||||
generateQrIntent.putExtra("adresse","addresseAAAA");
|
||||
generateQrIntent.putExtra("value",value);
|
||||
ReceivePayementActivity.this.startActivity(generateQrIntent);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package monnethic.mobile.user;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
@ -9,6 +10,8 @@ import android.widget.Toast;
|
|||
|
||||
import com.example.monnthic.monnethicmobile.R;
|
||||
|
||||
import monnethic.mobile.transaction.ReceivePayementActivity;
|
||||
|
||||
public class UserAccountActivity extends AppCompatActivity {
|
||||
private TextView solde;
|
||||
|
||||
|
@ -23,7 +26,6 @@ public class UserAccountActivity extends AppCompatActivity {
|
|||
Button buttonSettings = findViewById(R.id.buttonSettings);
|
||||
|
||||
//refreshSolde();
|
||||
|
||||
buttonPayement.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -48,6 +50,8 @@ public class UserAccountActivity extends AppCompatActivity {
|
|||
}
|
||||
public void receivePayement(){
|
||||
Toast.makeText(this, "Coming soon", Toast.LENGTH_SHORT).show();
|
||||
Intent receivePayementIntent = new Intent(UserAccountActivity.this, ReceivePayementActivity.class);
|
||||
UserAccountActivity.this.startActivity(receivePayementIntent);
|
||||
}
|
||||
public void settings(){
|
||||
Toast.makeText(this, "Coming soon", Toast.LENGTH_SHORT).show();
|
||||
|
|
75
app/src/main/res/layout/activity_qr_code.xml
Normal file
75
app/src/main/res/layout/activity_qr_code.xml
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout 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="monnethic.mobile.qrcode.QrCodeActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/qrCodeViewer"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="307dp"
|
||||
android:layout_marginBottom="204dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonClose"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="56dp"
|
||||
android:layout_marginEnd="148dp"
|
||||
android:text="CLOSE"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewAdresse"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="48dp"
|
||||
android:text="Adresse :"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textViewAmount"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textViewAdresseDisplay"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewAdresseDisplay"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginEnd="96dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textViewAmountDisplay"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewAmount"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginBottom="140dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="48dp"
|
||||
android:text="Montant :"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textViewAmountDisplay"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewAmountDisplay"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginBottom="140dp"
|
||||
android:layout_marginEnd="96dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
42
app/src/main/res/layout/activity_receive_payement.xml
Normal file
42
app/src/main/res/layout/activity_receive_payement.xml
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout 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="monnethic.mobile.transaction.ReceivePayementActivity">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/amountValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="184dp"
|
||||
android:ems="10"
|
||||
android:inputType="numberDecimal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.568"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonValidate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="176dp"
|
||||
android:layout_marginEnd="72dp"
|
||||
android:text="Validate"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonCancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="176dp"
|
||||
android:layout_marginStart="92dp"
|
||||
android:text="Cancel"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
Loading…
Reference in a new issue