diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 70d9f63..9087a93 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/misc.xml b/.idea/misc.xml index 99202cc..c0f68ed 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,7 +25,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index c7b10a6..a6abae5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 460c664..13aea5a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,7 +3,7 @@ package="com.example.monnthic.monnethicmobile"> - + @@ -20,6 +20,7 @@ + @@ -29,7 +30,9 @@ - + + + \ No newline at end of file diff --git a/app/src/main/java/monnethic/mobile/qrcode/QrCodeActivity.java b/app/src/main/java/monnethic/mobile/qrcode/QrCodeActivity.java new file mode 100644 index 0000000..f0b9532 --- /dev/null +++ b/app/src/main/java/monnethic/mobile/qrcode/QrCodeActivity.java @@ -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(); + } + } +} diff --git a/app/src/main/java/monnethic/mobile/transaction/ReceivePayementActivity.java b/app/src/main/java/monnethic/mobile/transaction/ReceivePayementActivity.java new file mode 100644 index 0000000..0e21f07 --- /dev/null +++ b/app/src/main/java/monnethic/mobile/transaction/ReceivePayementActivity.java @@ -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); + } +} diff --git a/app/src/main/java/monnethic/mobile/user/UserAccountActivity.java b/app/src/main/java/monnethic/mobile/user/UserAccountActivity.java index 3c79cb7..906ae76 100644 --- a/app/src/main/java/monnethic/mobile/user/UserAccountActivity.java +++ b/app/src/main/java/monnethic/mobile/user/UserAccountActivity.java @@ -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(); diff --git a/app/src/main/res/layout/activity_qr_code.xml b/app/src/main/res/layout/activity_qr_code.xml new file mode 100644 index 0000000..24b6a9d --- /dev/null +++ b/app/src/main/res/layout/activity_qr_code.xml @@ -0,0 +1,75 @@ + + + + + +