Commit e350a761 authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

API bug fix

parent a224c32c
...@@ -134,6 +134,8 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -134,6 +134,8 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
return; return;
} }
dialog.startLoading(APIActivity.this, getString(R.string.badge_read), getString(R.string.user_ginger_info_collecting));
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
...@@ -277,8 +279,8 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -277,8 +279,8 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this); final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this);
alertDialogBuilder alertDialogBuilder
.setTitle(getString(R.string.reservation_number) + finalApiResponse.getId()) .setTitle(finalApiResponse.getId().isEmpty() ? getString(R.string.reservation_number) : (getString(R.string.reservation_number) + finalApiResponse.getId()))
.setMessage(getString(R.string.ticket_validated) + " (" + DateUtils.formatDateTime(APIActivity.this, finalApiResponse.getExpirationDate() * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME) + ")") .setMessage(getString(R.string.ticket_validated) + (finalApiResponse.getExpirationDate() == null ? "" : " (" + DateUtils.formatDateTime(APIActivity.this, finalApiResponse.getExpirationDate() * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME) + ")"))
.setCancelable(false) .setCancelable(false)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
...@@ -339,7 +341,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -339,7 +341,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
public void run() { public void run() {
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this); final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this);
alertDialogBuilder alertDialogBuilder
.setTitle(getString(R.string.reservation_number) + apiResponse.getId()) .setTitle(apiResponse.getId().isEmpty() ? getString(R.string.reservation) : (getString(R.string.reservation_number) + apiResponse.getId()))
.setMessage(getString(R.string.ticket_maybe_falsified) + "\n" + .setMessage(getString(R.string.ticket_maybe_falsified) + "\n" +
"QRCode:\n" + "QRCode:\n" +
" id: " + qrCodeResponse.getId() + "\n" + " id: " + qrCodeResponse.getId() + "\n" +
...@@ -623,7 +625,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -623,7 +625,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
public void run() { public void run() {
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this); final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this);
alertDialogBuilder alertDialogBuilder
.setTitle(getString(R.string.reservation_number) + apiResponse.getId()) .setTitle(apiResponse.getId().isEmpty() ? getString(R.string.reservation) : (getString(R.string.reservation_number) + apiResponse.getId()))
.setMessage(getString(R.string.ticket_not_created_yet) + " (" + DateUtils.formatDateTime(APIActivity.this, apiResponse.getCreationDate() * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME) + ")") .setMessage(getString(R.string.ticket_not_created_yet) + " (" + DateUtils.formatDateTime(APIActivity.this, apiResponse.getCreationDate() * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME) + ")")
.setCancelable(false) .setCancelable(false)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
...@@ -653,7 +655,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -653,7 +655,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
public void run() { public void run() {
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this); final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this);
alertDialogBuilder alertDialogBuilder
.setTitle(getString(R.string.reservation_number) + apiResponse.getId()) .setTitle(apiResponse.getId().isEmpty() ? getString(R.string.reservation) : (getString(R.string.reservation_number) + apiResponse.getId()))
.setMessage(getString(R.string.ticket_expired) + " (" + DateUtils.formatDateTime(APIActivity.this, apiResponse.getExpirationDate() * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME) + ")") .setMessage(getString(R.string.ticket_expired) + " (" + DateUtils.formatDateTime(APIActivity.this, apiResponse.getExpirationDate() * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME) + ")")
.setCancelable(false) .setCancelable(false)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
...@@ -692,7 +694,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -692,7 +694,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
@Override @Override
public void run() { public void run() {
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this); final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(APIActivity.this);
alertDialogBuilder.setTitle(getString(R.string.reservation_number) + apiResponse.getId()).setCancelable(false); alertDialogBuilder.setTitle(apiResponse.getId().isEmpty() ? getString(R.string.reservation) : (getString(R.string.reservation_number) + apiResponse.getId())).setCancelable(false);
Map<String, Map<String, String>> data = apiResponse.getData(); Map<String, Map<String, String>> data = apiResponse.getData();
List<ArticleResponse> articleResponseList = null; List<ArticleResponse> articleResponseList = null;
List<List<Integer>> articleIdList = apiResponse.getArticleList(); List<List<Integer>> articleIdList = apiResponse.getArticleList();
...@@ -812,7 +814,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -812,7 +814,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
dialog.errorDialog(APIActivity.this, getString(R.string.reservation_number) + apiResponse.getId(), getString(R.string.api_no_data), new DialogInterface.OnClickListener() { dialog.errorDialog(APIActivity.this, apiResponse.getId().isEmpty() ? getString(R.string.reservation) : (getString(R.string.reservation_number) + apiResponse.getId()), getString(R.string.api_no_data), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
resumeReading(); resumeReading();
...@@ -877,7 +879,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -877,7 +879,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
}); });
} }
if (!(apiResponse.getArticleList().isEmpty() || apiResponse.getFoundationId() == null) || (apiResponse.getNegativeCommand() != null && apiResponse.getNegativeCommand().getCommand() != null)) if (!(apiResponse.getArticleList().isEmpty() || apiResponse.getFoundationId() == null) || (apiResponse.getNegativeCommand() != null && apiResponse.getNegativeCommand() != null))
alertDialogBuilder.setNegativeButton(apiResponse.getNegativeCommand() == null || apiResponse.getNegativeCommand().getName() == null ? getString(R.string.cancel) : apiResponse.getNegativeCommand().getName(), new DialogInterface.OnClickListener() { alertDialogBuilder.setNegativeButton(apiResponse.getNegativeCommand() == null || apiResponse.getNegativeCommand().getName() == null ? getString(R.string.cancel) : apiResponse.getNegativeCommand().getName(), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
...@@ -1000,7 +1002,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -1000,7 +1002,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
return; return;
} }
dialog.startLoading(APIActivity.this, getString(R.string.reservation_number) + id, apiCommand == null || apiCommand.getDescription() == null ? getString(R.string.api_execution) : apiCommand.getDescription()); dialog.startLoading(APIActivity.this, id.isEmpty() ? getString(R.string.reservation) : (getString(R.string.reservation_number) + id), apiCommand == null || apiCommand.getDescription() == null ? getString(R.string.api_execution) : apiCommand.getDescription());
new Thread() { new Thread() {
@Override @Override
...@@ -1042,7 +1044,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result ...@@ -1042,7 +1044,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
Log.e(LOG_TAG, "error: " + message); Log.e(LOG_TAG, "error: " + message);
dialog.errorDialog(APIActivity.this, getString(R.string.reservation_number) + id, message, new DialogInterface.OnClickListener() { dialog.errorDialog(APIActivity.this, id.isEmpty() ? getString(R.string.reservation) : (getString(R.string.reservation_number) + id), message, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
resumeReading(); resumeReading();
......
...@@ -78,6 +78,13 @@ public class FoundationsOptionsActivity extends BaseActivity { ...@@ -78,6 +78,13 @@ public class FoundationsOptionsActivity extends BaseActivity {
} }
} }
@Override
public void onResume() {
super.onResume();
config.setFoundation(-1, "");
}
@Override @Override
protected void onIdentification(final String badgeId) {} protected void onIdentification(final String badgeId) {}
......
...@@ -53,7 +53,7 @@ public class API { ...@@ -53,7 +53,7 @@ public class API {
public int interact(final String id, final String command) throws Exception { public int interact(final String id, final String command) throws Exception {
return request( return request(
id + "/" + command id + (command == null || command.isEmpty() ? "" : ("/" + command))
); );
} }
public int interact(final String id, final String command, Map<String, Object> postArgs) throws Exception { public int interact(final String id, final String command, Map<String, Object> postArgs) throws Exception {
......
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
<string name="api_not_recognized">API non reconnue</string> <string name="api_not_recognized">API non reconnue</string>
<string name="api_no_data">L\'API n\'a envoyé aucune information</string> <string name="api_no_data">L\'API n\'a envoyé aucune information</string>
<string name="api_execution">Exécution de la commande API</string> <string name="api_execution">Exécution de la commande API</string>
<string name="api_pay_caution">Attention, la commande "%s" fera payer la personne des articles affichés</string> <string name="api_pay_caution">Attention, la commande \"%s\" fera payer la personne des articles affichés</string>
<string name="key">Clé d\'application</string> <string name="key">Clé d\'application</string>
<string name="key_registration">Enregistrement d\'une clé</string> <string name="key_registration">Enregistrement d\'une clé</string>
<string name="key_explication">Pour pouvoir fonctionner, l\'application a besoin d\'être enregistrée sous un nom précis et daté (date automatiquement ajoutée si non détectée). Ceci permettra par la suite de donner des droits à cet appareil</string> <string name="key_explication">Pour pouvoir fonctionner, l\'application a besoin d\'être enregistrée sous un nom précis et daté (date automatiquement ajoutée si non détectée). Ceci permettra par la suite de donner des droits à cet appareil</string>
...@@ -210,6 +210,7 @@ ...@@ -210,6 +210,7 @@
<string name="not_understood">Non compris</string> <string name="not_understood">Non compris</string>
<string name="getting_informations_from">Récupérations des informations depuis</string> <string name="getting_informations_from">Récupérations des informations depuis</string>
<string name="already_validated">Ce ticket a déjà été validé</string> <string name="already_validated">Ce ticket a déjà été validé</string>
<string name="reservation">Réservation</string>
<string name="reservation_number">Réservation n°</string> <string name="reservation_number">Réservation n°</string>
<string name="category_name">Nom de la catégorie</string> <string name="category_name">Nom de la catégorie</string>
<string name="category_add">Ajouter une nouvelle catégorie</string> <string name="category_add">Ajouter une nouvelle catégorie</string>
......
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