Commit cbf4be9a authored by Nastuzzi Samy's avatar Nastuzzi Samy

API can now ask to pay

Print all articles to pay
Print a text to prevent a future paiement
parent 3cb1c8ce
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
......
......@@ -4,9 +4,9 @@ android {
signingConfigs {
config {
keyAlias 'jessy'
keyPassword 'kVg6ikc+(lTkre8//m%f1'
storeFile file('/root/jessy.jks')
storePassword 'kVg6ikc+(lTkre8//m%f1'
keyPassword 'payutc'
storeFile file('D:/cloud/Git/jessy/app/simde.jks')
storePassword 'simde-utc'
}
}
compileSdkVersion 26
......@@ -22,9 +22,11 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile '/root'
signingConfig signingConfigs.config
}
debug {
proguardFile '/root'
signingConfig signingConfigs.config
}
}
packagingOptions {
......
......@@ -46,7 +46,7 @@
<activity android:name="fr.utc.simde.jessy.EditActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity android:name="fr.utc.simde.jessy.QRCodeReaderActivity"
<activity android:name="fr.utc.simde.jessy.APIActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
</application>
......
......@@ -29,6 +29,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import fr.utc.simde.jessy.responses.APIResponse;
import fr.utc.simde.jessy.tools.CASConnexion;
import fr.utc.simde.jessy.tools.Config;
import fr.utc.simde.jessy.tools.Dialog;
......@@ -565,12 +566,12 @@ public abstract class BaseActivity extends InternetActivity {
});
}
protected void startQRCodeReaderActivity(final Activity activity) {
protected void startAPIActivity(final Activity activity) {
if (!nemopaySession.isConnected())
restartApp(activity);
if (haveCameraPermission())
startActivity(new Intent(activity, QRCodeReaderActivity.class));
startActivity(new Intent(activity, APIActivity.class));
else
dialog.errorDialog(BaseActivity.this, getString(R.string.qrcode), getString(R.string.need_camera_permission));
}
......
......@@ -125,7 +125,7 @@ public class FoundationsOptionsActivity extends BaseActivity {
else if (isOption(position, 2))
editDialog();
else if (isOption(position, 3))
startQRCodeReaderActivity(FoundationsOptionsActivity.this);
startAPIActivity(FoundationsOptionsActivity.this);
else if (isOption(position, 4))
startCardManagementActivity(FoundationsOptionsActivity.this);
else if (isOption(position, 5))
......
......@@ -503,9 +503,8 @@ public class MainActivity extends BaseActivity {
}
protected void optionDialog() {
final View keyView = getLayoutInflater().inflate(R.layout.dialog_key_set, null);
final View keyView = getLayoutInflater().inflate(R.layout.dialog_key_edit, null);
final EditText keyInput = keyView.findViewById(R.id.input_key);
keyView.findViewById(R.id.input_name).setVisibility(View.GONE);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
alertDialogBuilder
......
......@@ -45,7 +45,7 @@ public class SellActivity extends ArticleGroupActivity {
panierText.setOnLongClickListener(new TextView.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
startQRCodeReaderActivity(SellActivity.this);
startAPIActivity(SellActivity.this);
return false;
}
......
package fr.utc.simde.jessy.responses;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.Map;
/**
* Created by Samy on 10/11/2017.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class APICommand {
// Informations nécessaires
protected String command;
// Informations complémentaires
protected String name;
protected String description;
protected Map<String, String> arguments;
public String getCommand() { return command; }
public String getName() { return name; }
public String getDescription() { return description; }
public Map<String, String> getArguments() { return arguments; }
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; }
}
......@@ -2,32 +2,13 @@ package fr.utc.simde.jessy.responses;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Created by Samy on 10/11/2017.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class APIResponse {
@JsonIgnoreProperties(ignoreUnknown = true)
public class APICommand {
// Informations nécessaires
protected String command;
// Informations complémentaires
protected String name;
protected String description;
protected Map<String, String> arguments;
public String getCommand() { return command; }
public String getName() { return name; }
public String getDescription() { return description; }
public Map<String, String> getArguments() { return arguments; }
}
// Informations nécessaires
protected String id;
protected String username;
// Informations complémentaires
......@@ -36,6 +17,9 @@ public class APIResponse {
// Affiche soit un message, soit une liste de données rangée par catégorie
protected String message;
protected Map<String, Map<String, String>> data;
// Fais payer la personne les articles donnés correspondant à la fondation (il est nécessaire que la personne possède les droits de ventes dessus) => Implique que la première commande fera payer les articles affichés (uniquelment le message peut-être affiché) protected List<List<String>> articles;
protected List<List<String>> articles;
protected Integer foundationId;
// Permet d'exécuter des commandes suites à l'affichage (rien d'obligatoire mais button Ok par défaut)
protected APICommand neutralCommand;
protected APICommand negativeCommand;
......@@ -48,6 +32,22 @@ public class APIResponse {
public Long getCreationDate() { return this.creationDate; }
public Long getExpirationDate() { return this.expirationDate; }
public void removeExpirationDate() { this.expirationDate = null; }
public List<List<String>> getArticles() { return this.articles; }
public List<List<Integer>> getArticleList() {
List<List<Integer>> articleList = new ArrayList<List<Integer>>();
if (this.articles == null)
return articleList;
for (final List<String> article : this.articles)
articleList.add(new ArrayList<Integer>() {{
add(Integer.parseInt(article.get(0)));
add(Integer.parseInt(article.get(1)));
}});
return articleList;
}
public Integer getFoundationId() { return this.foundationId; }
public APICommand getNeutralCommand() { return neutralCommand; }
public APICommand getNegativeCommand() { return negativeCommand; }
public APICommand getPositiveCommand() { return positiveCommand; }
......
......@@ -253,7 +253,7 @@ public class NemopaySession {
if (!isConnected())
throw new Exception(this.notLogged);
if (this.foundationId == -1)
if (foundationId == -1)
throw new Exception("No foundation set");
return request(
......@@ -349,7 +349,8 @@ public class NemopaySession {
);
}
public int getArticles() throws Exception {
public int getArticles() throws Exception { return getArticles(this.foundationId); }
public int getArticles(final Integer foundationId) throws Exception {
if (!isConnected())
throw new Exception(this.notLogged);
......
......@@ -74,6 +74,7 @@
<string name="price">Prix</string>
<string name="seance">Séance</string>
<string name="print">Affichage</string>
<string name="pay">Payer</string>
<string name="author">&lt;/&gt; avec ♥ par Samy NASTUZZI</string>
<string name="error_unexpected">Une erreur improbable a eu lieu</string>
......@@ -115,11 +116,13 @@
<string name="nemopay_information">Informations de la part de Nemopay</string>
<string name="ginger_registering">Enregistrement de l\'application</string>
<string name="ginger_error_registering">Clé Ginger incorrecte</string>
<string name="no_api">Aucune API configurée</string>
<string name="api_name">Nom d\'application</string>
<string name="api_url">Url de l\'application</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_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="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