Commit 49e7daa3 authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Merge branch 'feature/foundationListActivity' into develop

parents 744986b0 424c2dd6
<?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;
<<<<<<< HEAD
=======
import android.content.DialogInterface;
import android.content.Intent;
import android.util.Log;
import com.fasterxml.jackson.databind.JsonNode;
>>>>>>> foundationListActivity
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;
/**
......@@ -27,4 +36,52 @@ public abstract class BaseActivity extends NFCActivity {
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(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,16 +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(getResources().getString(R.string.information_collection), getResources().getString(R.string.error_unexpected));
/*, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int id) {
finish();
}
<<<<<<< HEAD
runOnUiThread(new Runnable() {
@Override
......@@ -63,6 +65,10 @@ public class FoundationListActivity extends BaseActivity {
});
}
}.start();
=======
}*/
}
>>>>>>> foundationListActivity
}
@Override
......@@ -75,7 +81,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) {
......
......@@ -128,10 +128,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 +223,7 @@ public class MainActivity extends BaseActivity {
else if (!nemopaySession.isRegistered())
keyDialog();
else
startFoundationListActivity();
startFoundationListActivity(MainActivity.this);
}
});
}
......@@ -256,7 +252,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
......
......@@ -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
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