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

Sell with Botto with card

Optimization
Card maangement during QR Code reading
parent a8782689
......@@ -43,7 +43,7 @@
<activity android:name="fr.utc.simde.jessy.SellActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity android:name="fr.utc.simde.jessy.SellByQRCodeActivity"
<activity android:name="fr.utc.simde.jessy.SellByBottomatikActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity android:name="fr.utc.simde.jessy.EditActivity"
......
......@@ -23,6 +23,7 @@ import android.util.Log;
import android.widget.TextView;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.util.ArrayList;
......@@ -31,6 +32,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import fr.utc.simde.jessy.responses.BottomatikResponse;
import fr.utc.simde.jessy.tools.Bottomatik;
import fr.utc.simde.jessy.tools.CASConnexion;
import fr.utc.simde.jessy.tools.Config;
......@@ -250,8 +252,11 @@ public abstract class BaseActivity extends InternetActivity {
startArticleGroupActivity(activity, new Intent(activity, SellActivity.class));
}
public void startSellByQRCodeActivity(final Activity activity) {
startActivity(new Intent(activity, SellByQRCodeActivity.class));
public void startSellBottomatikActivity(final Activity activity) {
if (activity instanceof SellByBottomatikActivity)
finish();
startActivity(new Intent(activity, SellByBottomatikActivity.class));
}
public void startEditActivity(final Activity activity) {
......@@ -520,6 +525,8 @@ public abstract class BaseActivity extends InternetActivity {
});
else
throw new Exception("");
return;
} catch (Exception e1) {
runOnUiThread(new Runnable() {
@Override
......@@ -558,6 +565,9 @@ public abstract class BaseActivity extends InternetActivity {
}
protected void setNemopayKey(final String key) {
if (key.equals(""))
return;
dialog.startLoading(BaseActivity.this, getString(R.string.nemopay_connection), getString(R.string.nemopay_authentification));
new Thread() {
......@@ -600,6 +610,9 @@ public abstract class BaseActivity extends InternetActivity {
}
protected void setGingerKey(final String key) {
if (key.equals(""))
return;
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("key_ginger", key);
editor.apply();
......@@ -607,6 +620,17 @@ public abstract class BaseActivity extends InternetActivity {
ginger.setKey(key);
}
protected void setBottomatikKey(final String key) {
if (key.equals(""))
return;
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("key_bottomatik", key);
editor.apply();
bottomatik.setKey(key);
}
protected boolean haveStoragePermission() {
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
......
......@@ -136,8 +136,10 @@ public class FoundationsOptionsActivity extends BaseActivity {
else if (isOption(position,7))
keyGingerDialog();
else if (isOption(position,8))
checkUpdate();
keyBottomotikDialog();
else if (isOption(position,9))
checkUpdate();
else if (isOption(position,10))
creditDialog();
else
configDialog();
......@@ -197,6 +199,30 @@ public class FoundationsOptionsActivity extends BaseActivity {
});
}
protected void keyBottomotikDialog() {
hasRights(getString(R.string.bottomatik), new String[]{}, new Runnable(){
@Override
public void run() {
final View keyView = getLayoutInflater().inflate(R.layout.dialog_key_force, null);
final EditText keyInput = keyView.findViewById(R.id.input_key);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(FoundationsOptionsActivity.this);
alertDialogBuilder
.setTitle(getString(R.string.key_registration) + " " + getString(R.string.bottomatik))
.setView(keyView)
.setCancelable(false)
.setPositiveButton(R.string.register, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int id) {
if (!keyInput.getText().toString().equals(""))
setBottomatikKey(keyInput.getText().toString());
}
})
.setNegativeButton(R.string.cancel, null);
dialog.createDialog(alertDialogBuilder, keyInput);
}
});
}
protected void creditDialog() {
dialog.infoDialog(FoundationsOptionsActivity.this, getString(R.string.credit), getString(R.string.author));
......
......@@ -62,13 +62,9 @@ public class MainActivity extends BaseActivity {
casConnexion = new CASConnexion(nemopaySession);
config = new Config(sharedPreferences);
String key = sharedPreferences.getString("key", "");
if (!key.equals(""))
setNemopayKey(key);
key = sharedPreferences.getString("key_ginger", "");
if (!key.equals(""))
setGingerKey(key);
setNemopayKey(sharedPreferences.getString("key", ""));
setGingerKey(sharedPreferences.getString("key_ginger", ""));
setBottomatikKey(sharedPreferences.getString("key_bottomatik", ""));
appImg = findViewById(R.id.img_payutc);
appNameText = findViewById(R.id.text_app_name);
......
......@@ -43,7 +43,12 @@ public class QRCodeReaderActivity extends BaseActivity implements ZXingScannerVi
public void onIdentification(final String badgeId) {
this.scannerView.stopCamera();
handleResult(new Result(badgeId, null, null, BarcodeFormat.DATA_MATRIX));
dialog.infoDialog(QRCodeReaderActivity.this, "Badge", badgeId, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
resumeReading();
}
});
}
@Override
......
......@@ -37,7 +37,7 @@ public class SellActivity extends ArticleGroupActivity {
panierText.setOnLongClickListener(new TextView.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
startSellByQRCodeActivity(SellActivity.this);
startSellBottomatikActivity(SellActivity.this);
return false;
}
......
package fr.utc.simde.jessy.responses;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.List;
......@@ -17,7 +18,7 @@ public class BottomatikResponse {
protected int fun_id;
protected long expires_at;
protected long creation_date;
protected List<String> articles;
protected List<Integer> articles;
public String getId() { return this.id; }
public String getUsername() { return this.username; }
......@@ -25,12 +26,5 @@ public class BottomatikResponse {
public int getFoundationId() { return this.fun_id; }
public long getExpiresAt() { return this.expires_at; }
public long getCreatedAt() { return this.creation_date; }
public List<Integer> getArticleList() {
List<Integer> articleList = new ArrayList<Integer>();
for (String article : this.articles)
articleList.add(Integer.parseInt(article));
return articleList;
}
public List<Integer> getArticleList() { return this.articles; }
}
......@@ -64,7 +64,7 @@ public class Bottomatik {
public int getTransactionFromUsername(final String username) throws Exception {
return request(
username
"user/" + username
);
}
......@@ -73,12 +73,11 @@ public class Bottomatik {
this.request = new HTTPRequest(url + request);
int responseCode;
this.request.setGet(new HashMap<String, String>(){{ put("app_key", key); }});
if (postArgs.size() == 0) {
this.request.setGet(new HashMap<String, String>(){{ put("app_key", key); }});
responseCode = this.request.get();
}
else {
postArgs.put("key", key);
this.request.setPost(postArgs);
responseCode = this.request.post();
}
......
......@@ -9,6 +9,7 @@
<item>Gestion des cartes/cotisations</item>
<item>Modifier la clé Nemopay</item>
<item>Modifier la clé Ginger</item>
<item>Modifier la clé Bottomatik</item>
<item>Rechercher une mise à jour</item>
<item>Crédits</item>
</string-array>
......
......@@ -3,6 +3,7 @@
<string name="payutc">PayUTC</string>
<string name="nemopay">Nemopay</string>
<string name="ginger">Ginger</string>
<string name="bottomatik">Bottomatik</string>
<string name="hello">Pour se connecter, clique sur\n le bouton ou scanne ton badge</string>
<string name="ok">Ok</string>
<string name="yes">Oui</string>
......@@ -172,12 +173,14 @@
<string name="qrcode_reading">Lecture d\'un QR Code</string>
<string name="article_name">Nom de l\'article</string>
<string name="bottomatik_get_transaction">Récupération de la transaction auprès de Bottomatik</string>
<string name="bottomatik_already_validated">La commande a déjà été servie</string>
<string name="can_not_sell_other_foundation">Il n\'est pas possible de vendre des produits d\'une autre fondation</string>
<string name="transaction_realized">Paiement effectué</string>
<string name="transaction_in_validation">Transaction en cours de validation</string>
<string name="transaction_validated">Transaction validée</string>
<string name="transaction_in_cancelation">Transaction en cours d\'annulation</string>
<string name="transaction_refunded">Remboursement réalisé</string>
<string name="transaction_no">Aucune commande récente n\'a été réalisée</string>
<string name="print_mode">Mode d\'affichage</string>
<string name="filters">Filtres d\'affichage</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