Commit 7e7a5385 authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Merge branch 'release/0.2.3'

parents 23d50386 6c747d2e
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
......@@ -27,17 +24,7 @@
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "fr.utc.simde.payutc"
minSdkVersion 21
......
package fr.utc.simde.payutc;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import com.fasterxml.jackson.databind.JsonNode;
import fr.utc.simde.payutc.tools.CASConnexion;
import fr.utc.simde.payutc.tools.Dialog;
import fr.utc.simde.payutc.tools.HTTPRequest;
import fr.utc.simde.payutc.tools.NemopaySession;
/**
......@@ -21,10 +26,58 @@ public abstract class BaseActivity extends NFCActivity {
casConnexion.disconnect();
}
protected void unregister(Activity activity) {
protected void unregister(final Activity activity) {
nemopaySession.unregister();
disconnect();
dialog.errorDialog(activity, getString(R.string.key_registration), getString(R.string.key_remove_temp));
}
protected void startFoundationListActivity(final Activity activity) {
dialog.startLoading(activity, getString(R.string.information_collection), getString(R.string.foundation_list_collecting));
new Thread() {
@Override
public void run() {
try {
nemopaySession.getFoundations();
Thread.sleep(100);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
}
runOnUiThread(new Runnable() {
@Override
public void run() {
HTTPRequest request = nemopaySession.getRequest();
try {
if (request.getResponseCode() != 200)
throw new Exception("Malformed JSON");
JsonNode foundationList = request.getJsonResponse();
String response = request.getResponse();
if (!request.isJsonResponse() || !foundationList.isArray())
throw new Exception("JSON unexpected");
for (final JsonNode foundation : foundationList) {
if (!foundation.has("name") || !foundation.has("fun_id"))
throw new Exception("Unexpected JSON");
}
getIntent().getSerializableExtra("MyClass");
Intent intent = new Intent(activity, FoundationListActivity.class);
intent.putExtra("foundationList", response);
dialog.stopLoading();
activity.startActivity(intent);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
dialog.errorDialog(activity, getString(R.string.information_collection), getString(R.string.foundation_error_get_list));
}
}
});
}
}.start();
}
}
package fr.utc.simde.payutc;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
......@@ -28,41 +29,17 @@ public class FoundationListActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_foundation_list);
dialog.startLoading(FoundationListActivity.this, getString(R.string.nemopay_connection), getString(R.string.nemopay_authentification));
new Thread() {
@Override
public void run() {
try {
nemopaySession.getFoundations();
Thread.sleep(100);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
try {
setFoundationList(new ObjectMapper().readTree(getIntent().getExtras().getString("foundationList")));
} catch (Exception e) {
Log.wtf(LOG_TAG, "error: " + e.getMessage());
dialog.errorDialog(this, getResources().getString(R.string.information_collection), getResources().getString(R.string.error_unexpected), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int id) {
finish();
}
runOnUiThread(new Runnable() {
@Override
public void run() {
HTTPRequest request = nemopaySession.getRequest();
dialog.stopLoading();
try {
if (request.getResponseCode() != 200)
throw new Exception("Malformed JSON");
JsonNode foundationList = request.getJsonResponse();
if (!request.isJsonResponse() || !foundationList.isArray())
throw new Exception("JSON unexpected");
setFoundationList(foundationList);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
dialog.errorDialog(FoundationListActivity.this, getString(R.string.information_collection), getString(R.string.foundation_error_get_list));
}
}
});
}
}.start();
});
}
}
@Override
......@@ -75,7 +52,7 @@ public class FoundationListActivity extends BaseActivity {
disconnect();
}
protected void setFoundationList(JsonNode foundationList) throws Exception {
protected void setFoundationList(final JsonNode foundationList) throws Exception {
LinearLayout linearLayout = findViewById(R.id.foundationList);
for (final JsonNode foundation : foundationList) {
......
......@@ -3,7 +3,6 @@ package fr.utc.simde.payutc;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AlertDialog;
import android.os.Bundle;
......@@ -77,7 +76,7 @@ public class MainActivity extends BaseActivity {
}
@Override
protected void unregister(Activity activity) {
protected void unregister(final Activity activity) {
super.unregister(activity);
((TextView) findViewById(R.id.text_app_registered)).setText(R.string.app_not_registred);
......@@ -128,10 +127,6 @@ public class MainActivity extends BaseActivity {
}.start();
}
protected void startFoundationListActivity() {
MainActivity.this.startActivity(new Intent(MainActivity.this, FoundationListActivity.class));
}
protected void connectWithCAS(final String username, final String password) throws InterruptedException {
dialog.startLoading(MainActivity.this, getString(R.string.cas_connection), getString(R.string.cas_in_url));
new Thread() {
......@@ -227,7 +222,7 @@ public class MainActivity extends BaseActivity {
else if (!nemopaySession.isRegistered())
keyDialog();
else
startFoundationListActivity();
startFoundationListActivity(MainActivity.this);
}
});
}
......@@ -256,7 +251,7 @@ public class MainActivity extends BaseActivity {
try {
if (nemopaySession.isConnected())
startFoundationListActivity();
startFoundationListActivity(MainActivity.this);
else if (nemopaySession.getRequest().getResponseCode() == 400)
dialog.errorDialog(MainActivity.this, getString(R.string.badge_dialog), getString(R.string.badge_pin_error_not_recognized));
else
......
......@@ -3,11 +3,10 @@ package fr.utc.simde.payutc.tools;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.text.method.LinkMovementMethod;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import fr.utc.simde.payutc.R;
......@@ -74,13 +73,14 @@ public class Dialog {
}
}
public void errorDialog(final Activity activity, final String title, final String message) {
public void errorDialog(final Activity activity, final String title, final String message) { errorDialog(activity, title, message, null); }
public void errorDialog(final Activity activity, final String title, final String message, final DialogInterface.OnClickListener onClickListener) {
this.alertDialogBuilder = new AlertDialog.Builder(activity);
this.alertDialogBuilder
.setTitle(title)
.setMessage(message)
.setCancelable(true)
.setNegativeButton(R.string.ok, null);
.setNegativeButton(R.string.ok, onClickListener);
createDialog();
}
......
......@@ -21,6 +21,9 @@
<string name="no_pin">Pas de PIN</string>
<string name="pin_required">Code PIN requis !</string>
<string name="username_and_password_required">Login CAS et mot de passe requis !</string>
<string name="error_unexpected">Une erreur improbable a eu lieu</string>
<string name="nfc_not_available">NFC non disponible</string>
<string name="nfc_not_enabled">NFC non activé</string>
<string name="nfc_availability">L\'application nécessite que le NFC soit disponible sur le téléphone pour que celle-ci fonctionne correctement. Elle ne pourra donc être utilisée sur ce téléphone.</string>
......
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
#Mon Oct 23 19:30:32 CEST 2017
#Fri Oct 27 13:27:57 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Supports Markdown
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