diff --git a/app/src/main/java/fr/utc/simde/jessy/QRCodeReaderActivity.java b/app/src/main/java/fr/utc/simde/jessy/QRCodeReaderActivity.java
index 99acfcab53e1ce99eb57ace4edfe260d92665c38..ce9a2e77b47fdd0d6d150ae80cff7838782a3feb 100644
--- a/app/src/main/java/fr/utc/simde/jessy/QRCodeReaderActivity.java
+++ b/app/src/main/java/fr/utc/simde/jessy/QRCodeReaderActivity.java
@@ -4,12 +4,14 @@ import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
+import android.graphics.Color;
import android.os.Bundle;
import android.os.Vibrator;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
+import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
@@ -113,14 +115,6 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
@Override
public void onIdentification(final String badgeId) {
this.scannerView.stopCamera();
-/*
- dialog.infoDialog(QRCodeReaderActivity.this, "Badge", badgeId, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- resumeReading();
- }
- });
- */
new Thread() {
@Override
@@ -153,7 +147,7 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
}
}
- handleAPI(gingerResponse.getLogin(), apiIndex, gingerResponse.getBadge_uid(), false);
+ handleAPI(gingerResponse.getLogin(), apiIndex, gingerResponse, false);
}
}.start();
}
@@ -226,12 +220,12 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
}
}
- handleAPI(qrCodeResponse.getId(), apiIndex, gingerResponse == null ? null : gingerResponse.getBadge_uid(), true);
+ handleAPI(qrCodeResponse.getId(), apiIndex, gingerResponse, true);
}
}.start();
}
- protected void handleAPI(final String info, final Integer apiIndex, final String badgeId, final boolean byQRCode) {
+ protected void handleAPI(final String info, final Integer apiIndex, final GingerResponse gingerResponse, final boolean byQRCode) {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -277,17 +271,17 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
switch (apiIndex) {
case 0:
- payWithBottomatik(api, (BottomatikResponse) apiResponse, badgeId);
+ payWithBottomatik(api, (BottomatikResponse) apiResponse, gingerResponse);
break;
case 1:
case 2:
- checkReservation(api, (ReservationResponse) apiResponse);
+ checkReservation(api, (ReservationResponse) apiResponse, gingerResponse);
break;
}
}
- public void payWithBottomatik(final API api, final BottomatikResponse bottomatikResponse, final String badgeId) {
+ public void payWithBottomatik(final API api, final BottomatikResponse bottomatikResponse, final GingerResponse gingerResponse) {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -357,7 +351,7 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
try {
if (!bottomatikResponse.isPaid()) {
- nemopaySession.setTransaction(badgeId, bottomatikResponse.getArticleList(), bottomatikResponse.getFun_id());
+ nemopaySession.setTransaction(gingerResponse.getBadge_uid(), bottomatikResponse.getArticleList(), bottomatikResponse.getFun_id());
Thread.sleep(100);
}
@@ -525,7 +519,7 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
}
}
- protected void checkReservation(final API api, final ReservationResponse reservationResponse) {
+ protected void checkReservation(final API api, final ReservationResponse reservationResponse, final GingerResponse gingerResponse) {
long currentTimestamp = (System.currentTimeMillis() / 1000);
Log.d(LOG_TAG, "Current time: " + currentTimestamp);
@@ -547,7 +541,7 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
.setNeutralButton(R.string.more, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- seeReservation(api, reservationResponse);
+ seeReservation(api, reservationResponse, gingerResponse);
}
});
@@ -577,7 +571,7 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
.setNeutralButton(R.string.more, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- seeReservation(api, reservationResponse);
+ seeReservation(api, reservationResponse, gingerResponse);
}
});
@@ -592,27 +586,47 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
runOnUiThread(new Runnable() {
@Override
public void run() {
- seeReservation(api, reservationResponse);
+ seeReservation(api, reservationResponse, gingerResponse);
}
});
}
- protected void seeReservation(final API api, final ReservationResponse reservationResponse) {
+ protected void seeReservation(final API api, final ReservationResponse reservationResponse, final GingerResponse gingerResponse) {
final View keyView = getLayoutInflater().inflate(R.layout.dialog_reservation_info, null);
final TextView nameText = keyView.findViewById(R.id.text_name);
final TextView seanceText = keyView.findViewById(R.id.text_seance);
final TextView priceText = keyView.findViewById(R.id.text_price);
+ final TextView adultText = keyView.findViewById(R.id.text_adult);
+ final TextView contributerText = keyView.findViewById(R.id.text_cotisant);
nameText.setText(reservationResponse.getUsername());
seanceText.setText(reservationResponse.getSeance());
priceText.setText(reservationResponse.getType());
+ if (gingerResponse == null)
+ ((LinearLayout) keyView.findViewById(R.id.more_info)).setVisibility(View.GONE);
+ else {
+ if (gingerResponse.getIs_adulte())
+ adultText.setText(getString(R.string.yes));
+ else {
+ adultText.setText(getString(R.string.no));
+ adultText.setTextColor(Color.RED);
+ }
+
+ if (gingerResponse.getIs_adulte())
+ contributerText.setText(getString(R.string.yes));
+ else {
+ contributerText.setText(getString(R.string.no));
+ contributerText.setTextColor(Color.RED);
+ }
+ }
+
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(QRCodeReaderActivity.this);
alertDialogBuilder
.setTitle(getString(R.string.reservation_number) + reservationResponse.getReservation_id())
.setView(keyView)
.setCancelable(false)
- .setPositiveButton(R.string.register, new DialogInterface.OnClickListener() {
+ .setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int id) {dialog.startLoading(QRCodeReaderActivity.this, getResources().getString(R.string.paiement), getResources().getString(R.string.ticket_in_validation));
new Thread() {
@Override
diff --git a/app/src/main/java/fr/utc/simde/jessy/tools/API.java b/app/src/main/java/fr/utc/simde/jessy/tools/API.java
index 5f45277cf1664b1e5d474ab2e50dee23d3e32219..1b5183f9a00e2768e60fcb8b333f7f8fa4de5688 100644
--- a/app/src/main/java/fr/utc/simde/jessy/tools/API.java
+++ b/app/src/main/java/fr/utc/simde/jessy/tools/API.java
@@ -26,6 +26,7 @@ public class API {
private String notFound;
private String badRequest;
private String internalError;
+ private String goneRequest;
private String errorRequest;
public API(final Activity activity, final String name, final String url) {
@@ -40,6 +41,7 @@ public class API {
this.badRequest = activity.getString(R.string.bad_request);
this.internalError = activity.getString(R.string.internal_error);
this.errorRequest = activity.getString(R.string.error_request);
+ this.goneRequest = activity.getString(R.string.gone_request);
}
public void setKey(final String key) { this.key = key; }
@@ -96,13 +98,14 @@ public class API {
else if (responseCode == 403)
throw new Exception(this.noRight);
else if (responseCode == 404)
- throw new Exception(this.name + " " + this.notFound);
+ throw new Exception(this.serviceText + " " + this.name + " " + this.notFound);
else if (responseCode == 400)
- throw new Exception(this.name + " " + this.badRequest);
- else if (responseCode == 500 || responseCode == 503) {
- throw new Exception(this.name + " " + this.internalError);
- }
+ throw new Exception(this.serviceText + " " + this.name + " " + this.badRequest);
+ else if (responseCode == 500 || responseCode == 503)
+ throw new Exception(this.serviceText + " " + this.name + " " + this.internalError);
+ else if (responseCode == 410)
+ throw new Exception(this.serviceText + " " + this.name + " " + this.goneRequest);
else
- throw new Exception(this.name + " " + this.errorRequest + " " + responseCode);
+ throw new Exception(this.serviceText + " " + this.name + " " + this.errorRequest + " " + responseCode);
}
}
diff --git a/app/src/main/res/layout/dialog_reservation_info.xml b/app/src/main/res/layout/dialog_reservation_info.xml
index f3efe4224541404e205ae1fa247951427502f8d5..d762224a0f05c6fd2459568ebb8679a1a3a67454 100644
--- a/app/src/main/res/layout/dialog_reservation_info.xml
+++ b/app/src/main/res/layout/dialog_reservation_info.xml
@@ -63,4 +63,51 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/rights.xml b/app/src/main/res/values/rights.xml
index 6098be2570fad5644a124b26a79d5519cbbec2b3..191b058b2e3330fa135d5df1edd9889e6cd52205 100644
--- a/app/src/main/res/values/rights.xml
+++ b/app/src/main/res/values/rights.xml
@@ -11,6 +11,7 @@
n\'a pas réussi à trouver l\'élement souhaité
n\'a pas compris la requête reçue
a renvoyé une erreur interne (contacter un adminstrateur si cela se reproduit)
+ a indiqué que le ticket n\'était plus valide
a renvoyé l\'erreur HTTP suivante:
- SALESKEYBOARD