Commit 1b7223f6 authored by Nastuzzi Samy's avatar Nastuzzi Samy

Add shotgun management

Can now interact with ShotgunUTC
Add unvalidate ticket management
Print Ginger information for API which use it
parent dcdcb6b6
......@@ -4,6 +4,7 @@ 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;
......@@ -113,14 +114,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 +146,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 +219,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 +270,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 +350,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 +518,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 +540,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 +570,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 +585,49 @@ 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) {
adultText.setVisibility(View.GONE);
contributerText.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
......
......@@ -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);
}
}
......@@ -63,4 +63,50 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:orientation="horizontal">
<TextView
android:layout_width="100dp"
android:textColor="#000000"
android:layout_height="wrap_content"
android:text="@string/adult" />
<TextView
android:id="@+id/text_adult"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:orientation="horizontal">
<TextView
android:layout_width="100dp"
android:textColor="#000000"
android:layout_height="wrap_content"
android:text="@string/cotisant" />
<TextView
android:id="@+id/text_cotisant"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -11,6 +11,7 @@
<string name="not_found">n\'a pas réussi à trouver l\'élement souhaité</string>
<string name="bad_request">n\'a pas compris la requête reçue</string>
<string name="internal_error">a renvoyé une erreur interne (contacter un adminstrateur si cela se reproduit)</string>
<string name="gone_request">a indiqué que le ticket n\'était plus valide</string>
<string name="error_request">a renvoyé l\'erreur HTTP suivante: </string>
<string-array name="rights_keys">
<item>SALESKEYBOARD</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment