Commit 0cc60596 authored by Nastuzzi Samy's avatar Nastuzzi Samy

Merge branch 'release/v0.12.3' into develop

parents b14efd35 39210485
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.utc.simde.jessy"
android:versionCode="45"
android:versionName="0.12.2">
android:versionCode="46"
android:versionName="0.12.3">
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.INTERNET" />
......
......@@ -82,6 +82,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
alertDialogBuilder
.setTitle(R.string.getting_informations_from)
.setView(popupView)
.setCancelable(false)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
......@@ -91,16 +92,32 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
Map<String, String> apiInfo = config.getApi(inputApi.getText().toString());
if (apiInfo == null) {
Log.e(LOG_TAG, getString(R.string.api_not_recognized));
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.e(LOG_TAG, getString(R.string.api_not_recognized));
dialog.infoDialog(APIActivity.this, getString(R.string.badge_read), getString(R.string.api_not_recognized));
dialog.infoDialog(APIActivity.this, getString(R.string.badge_read), getString(R.string.api_not_recognized));
}
});
} else
handleAPI(buttonTag.isChecked() ? inputInfo.getText().toString().toUpperCase() : inputInfo.getText().toString(), apiInfo, null, null, buttonTag.isChecked());
}
}).start();
}
})
.setCancelable(true);
.setNeutralButton(R.string.api_assign, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
new Thread(new Runnable() {
@Override
public void run() {
Map<String, String> apiInfo = config.getApi(inputApi.getText().toString());
}
}).start();
}
})
.setNegativeButton(R.string.cancel, null);
dialog.createDialog(alertDialogBuilder, inputInfo);
......@@ -864,7 +881,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (apiResponse.getPositiveCommand() != null && apiResponse.getPositiveCommand().getCommand() != null)
startCommand(api, apiResponse.getId(), apiResponse.getPositiveCommand(), gingerResponse);
startCommand(api, apiResponse.getId(), apiResponse.getUsername(), apiResponse.getPositiveCommand(), gingerResponse);
else
resumeReading();
}
......@@ -883,7 +900,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
alertDialogBuilder.setNegativeButton(apiResponse.getNegativeCommand() == null || apiResponse.getNegativeCommand().getName() == null ? getString(R.string.cancel) : apiResponse.getNegativeCommand().getName(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
startCommand(api, apiResponse.getId(), apiResponse.getNegativeCommand(), gingerResponse);
startCommand(api, apiResponse.getId(), apiResponse.getUsername(), apiResponse.getNegativeCommand(), gingerResponse);
}
});
else if (apiResponse.getPositiveCommand() != null && apiResponse.getPositiveCommand().getCommand() != null) // Si le bouton ok est déjà défini et qu'on ne défini pas le bouton négatif, alors il s'agira du simple bouton ok
......@@ -898,7 +915,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
alertDialogBuilder.setNeutralButton(apiResponse.getNeutralCommand().getName() == null ? getString(R.string.more) : apiResponse.getNeutralCommand().getName(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
startCommand(api, apiResponse.getId(), apiResponse.getNeutralCommand(), gingerResponse);
startCommand(api, apiResponse.getId(), apiResponse.getUsername(), apiResponse.getNeutralCommand(), gingerResponse);
}
});
......@@ -944,13 +961,16 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
if (apiResponse.getPositiveCommand().getArguments() == null)
apiCommand.setArguments(new HashMap<String, String>(){{
put("paid", "true");
put("paid", "1");
}});
else
apiCommand.setArguments(apiResponse.getPositiveCommand().getArguments());
if (apiResponse.getPositiveCommand().getUseUsername() != null)
apiCommand.setUseUsername(apiResponse.getPositiveCommand().getUseUsername());
}
startCommand(api, apiResponse.getId(), apiCommand, gingerResponse);
startCommand(api, apiResponse.getId(), apiResponse.getUsername(), apiCommand, gingerResponse);
}
});
} catch (final Exception e) {
......@@ -995,7 +1015,7 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
}.start();
}
protected void startCommand(final API api, final String id, final APICommand apiCommand, final GingerResponse gingerResponse) {
protected void startCommand(final API api, final String id, final String username, final APICommand apiCommand, final GingerResponse gingerResponse) {
if (apiCommand == null) {
resumeReading();
......@@ -1009,9 +1029,9 @@ public class APIActivity extends BaseActivity implements ZXingScannerView.Result
public void run() {
try {
if (apiCommand.getArguments() == null)
api.interact(id, apiCommand.getCommand());
api.interact(apiCommand.getUseUsername() == null || apiCommand.getUseUsername() == false ? id : ("user/" + username), apiCommand.getCommand());
else
api.interact(id, apiCommand.getCommand(), mapArgs(apiCommand.getArguments()));
api.interact(apiCommand.getUseUsername() == null || apiCommand.getUseUsername() == false ? id : ("user/" + username), apiCommand.getCommand(), mapArgs(apiCommand.getArguments()));
Thread.sleep(100);
final APIResponse apiResponse = new ObjectMapper().readValue(api.getRequest().getResponse(), APIResponse.class);
......
......@@ -100,7 +100,7 @@ public abstract class BaseActivity extends InternetActivity {
protected void hasRights(final String title, final String[] rightList, final Runnable runnablePos) { hasRights(title, rightList, false, runnablePos);}
protected void hasRights(final String title, final String[] rightList, final boolean needToBeSuper, final Runnable runnablePos) {
hasRights(title, rightList, false, runnablePos, new Runnable() {
hasRights(title, rightList, needToBeSuper, runnablePos, new Runnable() {
@Override
public void run() {
dialog.errorDialog(BaseActivity.this, title, nemopaySession.forbidden(rightList, needToBeSuper));
......
......@@ -204,7 +204,7 @@ public class FoundationsOptionsActivity extends BaseActivity {
}
protected void keyEditDialog() {
hasRights(getString(R.string.key_registration), new String[]{}, new Runnable(){
hasRights(getString(R.string.key_registration), new String[]{}, true, new Runnable(){
@Override
public void run() {
final View keyView = getLayoutInflater().inflate(R.layout.dialog_key_set, null);
......
......@@ -16,14 +16,18 @@ public class APICommand {
protected String name;
protected String description;
protected Map<String, String> arguments;
// Si on souhaite utiliser le username plutôt que l'id pour la command
protected Boolean useUsername;
public String getCommand() { return command; }
public String getName() { return name; }
public String getDescription() { return description; }
public Map<String, String> getArguments() { return arguments; }
public Boolean getUseUsername() { return useUsername; }
public void setCommand(String command) { this.command = command; }
public void setName(String name) { this.name = name; }
public void setDescription(String description) { this.description = description; }
public void setArguments(Map<String, String> arguments) { this.arguments = arguments; }
public void setUseUsername(Boolean useUsername) { this.useUsername = useUsername; }
}
......@@ -51,14 +51,14 @@ public class API {
public HTTPRequest getRequest() { return this.request; }
public int interact(final String id, final String command) throws Exception {
public int interact(final String before, final String command) throws Exception {
return request(
id + (command == null || command.isEmpty() ? "" : ("/" + command))
before + (before == null || before.isEmpty() || 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 before, final String command, Map<String, Object> postArgs) throws Exception {
return request(
id + "/" + command,
before + (before == null || before.isEmpty() || command == null || command.isEmpty() ? "" : "/") + command,
postArgs
);
}
......
......@@ -4,11 +4,11 @@
<item>Mode annulation</item>
<item>Modifier les articles, catégories/claviers de caisse</item>
<item>Modifier les points de vente</item>
<item>Lire un QR Code</item>
<item>Communiquer avec une API</item>
<item>Gestion des cartes/cotisations</item>
<item>Modifier la clé Nemopay</item>
<item>Modifier la clé Ginger</item>
<item>Modifier une clé API</item>
<item>Modifier une API</item>
<item>Rechercher une mise à jour</item>
<item>Crédits</item>
</string-array>
......
......@@ -123,6 +123,7 @@
<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_pay_caution">Attention, la commande \"%s\" fera payer la personne des articles affichés</string>
<string name="api_assign">Assigner cette API</string>
<string name="key">Clé d\'application</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>
......
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