Merge branch 'todo/clean' into develop
This commit is contained in:
commit
65951331ab
Binary file not shown.
|
@ -5,27 +5,33 @@
|
||||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||||
<option name="myNullables">
|
<option name="myNullables">
|
||||||
<value>
|
<value>
|
||||||
<list size="5">
|
<list size="7">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
<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="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||||
|
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||||
|
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
<option name="myNotNulls">
|
<option name="myNotNulls">
|
||||||
<value>
|
<value>
|
||||||
<list size="4">
|
<list size="6">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
<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="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="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||||
|
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
<option name="id" value="Android" />
|
<option name="id" value="Android" />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,12 +1,12 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 26
|
compileSdkVersion 27
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.example.monnthic.monnthicmobile"
|
applicationId 'com.monnethic.appmobile'
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 26
|
targetSdkVersion 27
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
@ -21,38 +21,23 @@ android {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
packagingOptions {
|
buildToolsVersion '28.0.3'
|
||||||
exclude 'META-INF/INDEX.LIST'
|
productFlavors {
|
||||||
exclude 'META-INF/DEPENDENCIES'
|
|
||||||
exclude 'META-INF/io.netty.versions.properties'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||||
implementation 'com.android.support:design:26.1.0'
|
|
||||||
implementation 'com.android.support:multidex:1.0.3'
|
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
|
||||||
//implementation 'org.glassfish:javax.json:1.0.4'
|
|
||||||
implementation 'com.google.code.gson:gson:2.8.5'
|
|
||||||
implementation ('org.hyperledger.fabric-sdk-java:fabric-sdk-java:1.0.0'){
|
|
||||||
//exclude group:'org.glassfish', module:'javax.json'
|
|
||||||
exclude group:'log4j', module:'log4j'
|
|
||||||
exclude group:'org.jacoco', module:"jacoco-maven-plugin"
|
|
||||||
}
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||||
androidTestImplementation 'com.android.support.test:rules:1.0.1'
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'com.android.support:support-annotations:26.1.0'
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
|
implementation 'com.google.code.gson:gson:2.8.5'
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
|
||||||
})
|
|
||||||
implementation 'com.j256.ormlite:ormlite-core:5.1'
|
|
||||||
implementation 'com.j256.ormlite:ormlite-jdbc:5.1'
|
|
||||||
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.5'
|
|
||||||
implementation 'com.google.zxing:core:3.2.1'
|
implementation 'com.google.zxing:core:3.2.1'
|
||||||
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
|
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
|
||||||
implementation 'com.google.android.gms:play-services-vision:11.8.0'
|
implementation 'com.google.android.gms:play-services-vision:17.0.2'
|
||||||
implementation group: 'com.madgag.spongycastle', name: 'core', version: '1.54.0.0'
|
implementation 'com.j256.ormlite:ormlite-core:5.1'
|
||||||
|
implementation 'com.j256.ormlite:ormlite-jdbc:5.1'
|
||||||
|
implementation 'org.postgresql:postgresql:42.2.5'
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,19 +5,9 @@ import android.support.test.InstrumentationRegistry;
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
import com.example.monnthic.monnethicmobile.R;
|
||||||
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
|
|
||||||
import javax.json.Json;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.json.JsonReader;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
package monnethic.mobile.test.blockchain;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.test.InstrumentationRegistry;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.sdk.ProposalResponse;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import monnethic.mobile.blockchain.client.CAClientWrapper;
|
|
||||||
import monnethic.mobile.blockchain.client.ChannelClientWrapper;
|
|
||||||
import monnethic.mobile.blockchain.client.FabriClientWrapper;
|
|
||||||
import monnethic.mobile.blockchain.network.Config;
|
|
||||||
import monnethic.mobile.blockchain.participant.UserContext;
|
|
||||||
import monnethic.mobile.test.blockchain.Utility.UtilTest;
|
|
||||||
|
|
||||||
|
|
||||||
public class TestQuery {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestAEnrollAdmin() throws Exception {
|
|
||||||
try{
|
|
||||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
String caUrl = Config.CA_ORG1_URL;
|
|
||||||
CAClientWrapper caClientWrapper = new CAClientWrapper(caUrl,null,null,null);
|
|
||||||
UserContext adminContext = new UserContext();
|
|
||||||
adminContext.setName(Config.ADMIN);
|
|
||||||
adminContext.setAffiliation(Config.ORG1);
|
|
||||||
adminContext.setMspId(Config.ORG1_MSP);
|
|
||||||
caClientWrapper.setAdminContext(adminContext);
|
|
||||||
adminContext = caClientWrapper.enrollAdmin(appContext,Config.ADMIN,Config.ADMIN_PASSWORD,Config.ORG1);
|
|
||||||
Logger.getLogger(TestQuery.class.getName()).log(Level.INFO, "adminContext Enrollement : "+adminContext.getEnrollment().toString());
|
|
||||||
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
@Test
|
|
||||||
public void TestAQueryChainCode() throws Exception {
|
|
||||||
// Test query for user a on blockchain
|
|
||||||
try{
|
|
||||||
String query = "query";
|
|
||||||
String[] args1 = {"a"};
|
|
||||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
|
|
||||||
String caUrl = Config.CA_ORG1_URL;
|
|
||||||
CAClientWrapper caClientWrapper = new CAClientWrapper(caUrl,null,null,null);
|
|
||||||
|
|
||||||
UserContext adminContext = new UserContext();
|
|
||||||
adminContext.setName(Config.ADMIN);
|
|
||||||
adminContext.setAffiliation(Config.ORG1);
|
|
||||||
adminContext.setMspId(Config.ORG1_MSP);
|
|
||||||
|
|
||||||
caClientWrapper.setAdminContext(adminContext);
|
|
||||||
adminContext = caClientWrapper.enrollAdmin(appContext,Config.ADMIN,Config.ADMIN_PASSWORD,Config.ORG1);
|
|
||||||
|
|
||||||
FabriClientWrapper fabriClientWrapper = new FabriClientWrapper(adminContext);
|
|
||||||
ChannelClientWrapper channelClientWrapper = fabriClientWrapper.createChannelClient(Config.CHANNEL_NAME);
|
|
||||||
|
|
||||||
Logger.getLogger(TestQuery.class.getName()).log(Level.INFO, "Querying for USER A ...");
|
|
||||||
|
|
||||||
Collection<ProposalResponse> responsesQuery = channelClientWrapper.queryByChainCode(Config.CHAINCODE_NAME,query,args1);
|
|
||||||
|
|
||||||
for(ProposalResponse pres : responsesQuery){
|
|
||||||
String stringResponse = new String(pres.getChaincodeActionResponsePayload());
|
|
||||||
Logger.getLogger(TestQuery.class.getName()).log(Level.INFO, stringResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
@Test
|
|
||||||
public void TestBQuery() throws Exception {
|
|
||||||
try{
|
|
||||||
UserContext userContext = new UserContext();
|
|
||||||
userContext.setName(Config.ADMIN);
|
|
||||||
userContext.setAffiliation(Config.ORG1);
|
|
||||||
userContext.setMspId(Config.ORG1_MSP);
|
|
||||||
|
|
||||||
FabriClientWrapper client = new FabriClientWrapper(userContext);
|
|
||||||
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
package monnethic.mobile.test.blockchain.Utility;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.test.InstrumentationRegistry;
|
|
||||||
|
|
||||||
import org.junit.FixMethodOrder;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runners.MethodSorters;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
|
|
||||||
import monnethic.mobile.blockchain.participant.UserContext;
|
|
||||||
import monnethic.mobile.blockchain.utility.Util;
|
|
||||||
|
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
|
||||||
public class UtilTest {
|
|
||||||
/*
|
|
||||||
@Test
|
|
||||||
public void readEmptyUserContext() throws Exception {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAreadNonUserContext() throws Exception {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
UserContext uc = Util.readUserContext(appContext,"tata","abdel");
|
|
||||||
if(uc!=null){
|
|
||||||
Logger.getLogger(UtilTest.class.getName()).log(Level.INFO, "UserContext is : "+uc.toString());
|
|
||||||
}else{
|
|
||||||
Logger.getLogger(UtilTest.class.getName()).log(Level.INFO, "UserContext doesn't exist");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBwriteUserContext() throws Exception {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
UserContext user = new UserContext();
|
|
||||||
user.setName("abdel");
|
|
||||||
user.setAffiliation("toto");
|
|
||||||
user.setEnrollment(null);
|
|
||||||
user.setMspId("test");
|
|
||||||
|
|
||||||
Util.writeUserContext(appContext, user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreadUserContext() throws Exception {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
UserContext uc = Util.readUserContext(appContext,"toto","abdel");
|
|
||||||
Logger.getLogger(UtilTest.class.getName()).log(Level.INFO, "UserContext is : "+uc.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,11 +4,10 @@
|
||||||
|
|
||||||
<!-- To auto-complete the email text field in the login form with Useruser's emails -->
|
<!-- To auto-complete the email text field in the login form with Useruser's emails -->
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||||
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
@ -31,7 +30,6 @@
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="monnethic.mobile.homepage.RegisterActivity" />
|
<activity android:name="monnethic.mobile.homepage.RegisterActivity" />
|
||||||
<activity android:name="monnethic.mobile.homepage.LoginActivity" />
|
<activity android:name="monnethic.mobile.homepage.LoginActivity" />
|
||||||
<activity android:name="monnethic.mobile.wallet.WalletActivity" />
|
|
||||||
<activity android:name="monnethic.mobile.user.UserAccountActivity" />
|
<activity android:name="monnethic.mobile.user.UserAccountActivity" />
|
||||||
<activity android:name="monnethic.mobile.demo.DemoActivity" />
|
<activity android:name="monnethic.mobile.demo.DemoActivity" />
|
||||||
<activity android:name="monnethic.mobile.wallet.WalletPresenterActivity" />
|
<activity android:name="monnethic.mobile.wallet.WalletPresenterActivity" />
|
||||||
|
|
|
@ -1,149 +0,0 @@
|
||||||
package monnethic.mobile.blockchain.client;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.sdk.Enrollment;
|
|
||||||
import org.hyperledger.fabric.sdk.exception.CryptoException;
|
|
||||||
import org.hyperledger.fabric.sdk.security.CryptoSuite;
|
|
||||||
import org.hyperledger.fabric_ca.sdk.HFCAClient;
|
|
||||||
import org.hyperledger.fabric_ca.sdk.RegistrationRequest;
|
|
||||||
import org.hyperledger.fabric.sdk.exception.InvalidArgumentException;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import monnethic.mobile.blockchain.participant.UserContext;
|
|
||||||
import monnethic.mobile.blockchain.utility.Util;
|
|
||||||
|
|
||||||
public class CAClientWrapper {
|
|
||||||
|
|
||||||
private String caUrl;
|
|
||||||
private HFCAClient hfcaClient;
|
|
||||||
private Properties properties;
|
|
||||||
private String org;
|
|
||||||
private String mspId;
|
|
||||||
private UserContext adminContext;
|
|
||||||
|
|
||||||
public UserContext getAdminContext() {
|
|
||||||
return adminContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdminContext(UserContext adminContext){
|
|
||||||
this.adminContext=adminContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public CAClientWrapper(String caUrl, Properties properties, String org, String mspId) throws MalformedURLException, IllegalAccessException, InstantiationException, ClassNotFoundException, CryptoException, InvalidArgumentException, NoSuchMethodException, InvocationTargetException {
|
|
||||||
this.caUrl=caUrl;
|
|
||||||
this.properties=properties;
|
|
||||||
this.org=org;
|
|
||||||
this.mspId=mspId;
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init() throws MalformedURLException, IllegalAccessException, InstantiationException, ClassNotFoundException, CryptoException, InvalidArgumentException, NoSuchMethodException, InvocationTargetException {
|
|
||||||
CryptoSuite cryptoSuite = CryptoSuite.Factory.getCryptoSuite();
|
|
||||||
hfcaClient = HFCAClient.createNewInstance(caUrl,properties);
|
|
||||||
hfcaClient.setCryptoSuite(cryptoSuite);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HFCAClient getHfcaClient(){
|
|
||||||
return hfcaClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
public CAClientWrapper(String url, String org){
|
|
||||||
this.org=org;
|
|
||||||
init(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(String url){
|
|
||||||
try{
|
|
||||||
this.hfcaClient = HFCAClient.createNewInstance(url,null);
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//Method to enroll admin and save his info
|
|
||||||
public UserContext enrollAdmin(Context context, String name, String secret, String org) throws Exception {
|
|
||||||
UserContext adminContext;
|
|
||||||
adminContext = Util.readUserContext(context,org,name);
|
|
||||||
if(adminContext!=null){
|
|
||||||
Logger.getLogger(CAClientWrapper.class.getName()).log(Level.WARNING, "Admin already enrolled, skip");
|
|
||||||
return adminContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
Enrollment enrollment = hfcaClient.enroll(name,secret);
|
|
||||||
Logger.getLogger(CAClientWrapper.class.getName()).log(Level.INFO, "Admin enrolled");
|
|
||||||
|
|
||||||
//adminContext = new UserContext();
|
|
||||||
//adminContext.setName(name);
|
|
||||||
//adminContext.setAffiliation(org);
|
|
||||||
//adminContext.setMspId(mspId);
|
|
||||||
adminContext.setEnrollment(enrollment);
|
|
||||||
|
|
||||||
Util.writeUserContext(context,adminContext);
|
|
||||||
return adminContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Method to register and enroll user
|
|
||||||
public void regiserUser(Context context, String userName, String registrarAdmin) throws Exception{
|
|
||||||
UserContext userContext;
|
|
||||||
userContext = Util.readUserContext(context,org,userName);
|
|
||||||
if(userContext!=null){
|
|
||||||
Logger.getLogger(CAClientWrapper.class.getName()).log(Level.WARNING, "User already registered");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RegistrationRequest registrationRequest = new RegistrationRequest(userName,org);
|
|
||||||
UserContext registrarContext = Util.readUserContext(context,org,registrarAdmin);
|
|
||||||
if(registrarAdmin==null){
|
|
||||||
Logger.getLogger(CAClientWrapper.class.getName()).log(Level.SEVERE, "Registar not enrolled");
|
|
||||||
throw new Exception("registrar context not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
String enrollSecret = hfcaClient.register(registrationRequest, registrarContext);
|
|
||||||
|
|
||||||
Enrollment enrollment = hfcaClient.enroll(userName,enrollSecret);
|
|
||||||
|
|
||||||
userContext = new UserContext();
|
|
||||||
userContext.setMspId(mspId);
|
|
||||||
userContext.setAffiliation(org); //TODO GET MSPID IN ORGANIZATIONS, ORGNAME
|
|
||||||
userContext.setEnrollment(enrollment);
|
|
||||||
userContext.setName(userName);
|
|
||||||
|
|
||||||
Util.writeUserContext(context,userContext);
|
|
||||||
Logger.getLogger(CAClientWrapper.class.getName()).log(Level.INFO, "User has been successfully registered");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Method to get userContext
|
|
||||||
public static UserContext getUserContext(Context context, String userName, String org){
|
|
||||||
UserContext userContext;
|
|
||||||
userContext = Util.readUserContext(context,org,userName);
|
|
||||||
if(userContext!=null){
|
|
||||||
return userContext;
|
|
||||||
}
|
|
||||||
Logger.getLogger(CAClientWrapper.class.getName()).log(Level.SEVERE, "User context not found : "+userName+" - "+org);
|
|
||||||
return userContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Method to enroll user.
|
|
||||||
public UserContext enrollUser(Context context, String userName, String enrollSecret, String org) throws Exception {
|
|
||||||
Enrollment enrollment = hfcaClient.enroll(userName,enrollSecret);
|
|
||||||
|
|
||||||
UserContext userContext = new UserContext();
|
|
||||||
userContext.setMspId(mspId);
|
|
||||||
userContext.setAffiliation(this.org);
|
|
||||||
userContext.setEnrollment(enrollment);
|
|
||||||
userContext.setName(userName);
|
|
||||||
|
|
||||||
Util.writeUserContext(context, userContext);
|
|
||||||
Logger.getLogger(CAClientWrapper.class.getName()).log(Level.INFO, "UserName - "+userName+" enrolled");
|
|
||||||
return userContext;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package monnethic.mobile.blockchain.client;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.sdk.ChaincodeID;
|
|
||||||
import org.hyperledger.fabric.sdk.Channel;
|
|
||||||
import org.hyperledger.fabric.sdk.ProposalResponse;
|
|
||||||
import org.hyperledger.fabric.sdk.QueryByChaincodeRequest;
|
|
||||||
import org.hyperledger.fabric.sdk.exception.InvalidArgumentException;
|
|
||||||
import org.hyperledger.fabric.sdk.exception.ProposalException;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class ChannelClientWrapper {
|
|
||||||
FabriClientWrapper fabriClientWrapper;
|
|
||||||
Channel channel;
|
|
||||||
String name;
|
|
||||||
|
|
||||||
public Channel getChannel() {
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FabriClientWrapper getFabriClientWrapper() {
|
|
||||||
return fabriClientWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChannelClientWrapper(String name, Channel channel, FabriClientWrapper fabriClientWrapper){
|
|
||||||
this.name=name;
|
|
||||||
this.channel=channel;
|
|
||||||
this.fabriClientWrapper=fabriClientWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<ProposalResponse> queryByChainCode(String chaincodeName, String functionName, String[] args) throws InvalidArgumentException, ProposalException {
|
|
||||||
Logger.getLogger(ChannelClientWrapper.class.getName()).log(Level.INFO, "Querying "+chaincodeName+" with "+functionName);
|
|
||||||
|
|
||||||
QueryByChaincodeRequest request = fabriClientWrapper.getHfClient().newQueryProposalRequest();
|
|
||||||
ChaincodeID chaincodeId = ChaincodeID.newBuilder().setName(chaincodeName).build();
|
|
||||||
request.setChaincodeID(chaincodeId);
|
|
||||||
request.setFcn(functionName);
|
|
||||||
|
|
||||||
if(args != null){
|
|
||||||
request.setArgs(args);
|
|
||||||
}
|
|
||||||
Collection<ProposalResponse> response = channel.queryByChaincode(request);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package monnethic.mobile.blockchain.client;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.sdk.Channel;
|
|
||||||
import org.hyperledger.fabric.sdk.HFClient;
|
|
||||||
import org.hyperledger.fabric.sdk.exception.CryptoException;
|
|
||||||
import org.hyperledger.fabric.sdk.exception.InvalidArgumentException;
|
|
||||||
import org.hyperledger.fabric.sdk.security.CryptoSuite;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
import monnethic.mobile.blockchain.participant.UserContext;
|
|
||||||
|
|
||||||
public class FabriClientWrapper {
|
|
||||||
private HFClient hfClient;
|
|
||||||
|
|
||||||
public HFClient getHfClient() {
|
|
||||||
return hfClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FabriClientWrapper(UserContext userContext) throws CryptoException, InvalidArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
|
|
||||||
CryptoSuite cryptoSuite = CryptoSuite.Factory.getCryptoSuite();
|
|
||||||
hfClient = HFClient.createNewInstance();
|
|
||||||
hfClient.setCryptoSuite(cryptoSuite);
|
|
||||||
hfClient.setUserContext(userContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChannelClientWrapper createChannelClient(String name) throws InvalidArgumentException {
|
|
||||||
Channel channel = hfClient.newChannel(name);
|
|
||||||
ChannelClientWrapper client = new ChannelClientWrapper(name, channel, this);
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package monnethic.mobile.blockchain.network;
|
|
||||||
|
|
||||||
public class Config {
|
|
||||||
//TODO SET STATIC FINAL VAR FOR NETWORK CONFIG, REPLACE LOADCONFIGINFO
|
|
||||||
public static final String ORG1_MSP = "Org1MSP";
|
|
||||||
|
|
||||||
public static final String ORG1 = "org1";
|
|
||||||
|
|
||||||
public static final String ADMIN = "AdminOrg1";
|
|
||||||
|
|
||||||
public static final String ADMIN_PASSWORD = "AdminOrg1Pwd";
|
|
||||||
|
|
||||||
public static final String CA_ORG1_URL = "http://vps577432.ovh.net:7054";
|
|
||||||
|
|
||||||
public static final String ORDERER_URL = "vps577432.ovh.net:7050";
|
|
||||||
|
|
||||||
public static final String ORDERER_NAME = "orderer.example.com";
|
|
||||||
|
|
||||||
public static final String CHANNEL_NAME = "mychannel";
|
|
||||||
|
|
||||||
public static final String CHAINCODE_NAME = "mycc";
|
|
||||||
|
|
||||||
public static final String ORG1_PEER_0 = "peer0.org1.example.com";
|
|
||||||
|
|
||||||
public static final String ORG1_PEER_0_URL = "vps577432.ovh.net:7051";
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
package monnethic.mobile.blockchain.network;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
|
||||||
|
|
||||||
//import org.hyperledger.fabric.sdk.NetworkConfig;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.logging.XMLFormatter;
|
|
||||||
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
|
|
||||||
public class LoadConfigInfo {
|
|
||||||
private static final Integer lock = 0;
|
|
||||||
private static JSONObject jsonObject;
|
|
||||||
|
|
||||||
//Generate JSONObject from configFile
|
|
||||||
private LoadConfigInfo(Context context) {
|
|
||||||
|
|
||||||
InputStream is = context.getResources().openRawResource(R.raw.config);
|
|
||||||
Writer writer = new StringWriter();
|
|
||||||
char[] buffer = new char[1024];
|
|
||||||
try {
|
|
||||||
Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
|
||||||
int n;
|
|
||||||
while ((n = reader.read(buffer)) != -1) {
|
|
||||||
writer.write(buffer, 0, n);
|
|
||||||
}
|
|
||||||
} catch (Exception e){
|
|
||||||
e.getMessage();
|
|
||||||
} finally {
|
|
||||||
try{
|
|
||||||
if(is!=null) {
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String jsonString = writer.toString();
|
|
||||||
try{
|
|
||||||
jsonObject = new JSONObject(jsonString);
|
|
||||||
}catch (Exception e){
|
|
||||||
e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void getInstanceFile(Context context){
|
|
||||||
try{
|
|
||||||
synchronized (lock){
|
|
||||||
if(jsonObject == null){
|
|
||||||
new LoadConfigInfo(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO GET ORGANIZATION INFOS
|
|
||||||
public static String getOrgInfo(Context context, String org) {
|
|
||||||
getInstanceFile(context);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//TODO GET ORGANIZATION NAME
|
|
||||||
public static String getOrgName(Context context){
|
|
||||||
getInstanceFile(context);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO GET MSPID IN ORG NAME
|
|
||||||
public static String getMspId(Context context,String orgName){
|
|
||||||
getInstanceFile(context);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
package monnethic.mobile.blockchain.participant;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.sdk.Enrollment;
|
|
||||||
import org.hyperledger.fabric.sdk.User;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class UserContext implements User, Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
protected String name;
|
|
||||||
protected Set<String> roles;
|
|
||||||
protected String account;
|
|
||||||
protected String affiliation;
|
|
||||||
protected Enrollment enrollment;
|
|
||||||
protected String mspId;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name){
|
|
||||||
this.name=name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<String> getRoles() {
|
|
||||||
return roles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRoles(Set<String> roles){
|
|
||||||
this.roles=roles;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAccount() {
|
|
||||||
return account;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccount(String account){
|
|
||||||
this.account=account;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAffiliation() {
|
|
||||||
return affiliation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAffiliation(String affiliation){
|
|
||||||
this.affiliation=affiliation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Enrollment getEnrollment() {
|
|
||||||
return enrollment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnrollment(Enrollment enrollment){
|
|
||||||
this.enrollment=enrollment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMspId() {
|
|
||||||
return mspId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMspId(String mspId){
|
|
||||||
this.mspId=mspId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,105 +0,0 @@
|
||||||
package monnethic.mobile.blockchain.utility;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import monnethic.mobile.blockchain.participant.UserContext;
|
|
||||||
|
|
||||||
public class Util {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
public Util(Context context){
|
|
||||||
this.context=context;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Method which write user info into a directory
|
|
||||||
public static void writeUserContext(Context context, UserContext userContext){
|
|
||||||
ObjectOutputStream out = null;
|
|
||||||
FileOutputStream fileOutputStream = null;
|
|
||||||
try{
|
|
||||||
String filename = userContext.getName()+".context";
|
|
||||||
String dirPath = context.getFilesDir()+"userInfos/"+userContext.getAffiliation();
|
|
||||||
String pathFile = dirPath+"/"+filename;
|
|
||||||
Logger.getLogger(Util.class.getName()).log(Level.INFO, "pathFile is : "+pathFile);
|
|
||||||
File dir = new File(dirPath);
|
|
||||||
if(!dir.exists()){
|
|
||||||
Boolean res = dir.mkdirs();
|
|
||||||
if(res){
|
|
||||||
Logger.getLogger(Util.class.getName()).log(Level.INFO, "RESPONSE IS TRUE");
|
|
||||||
}else{
|
|
||||||
Logger.getLogger(Util.class.getName()).log(Level.SEVERE, "RESPONSE IS FALSE");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File file = new File(pathFile);
|
|
||||||
fileOutputStream = new FileOutputStream(file);
|
|
||||||
out = new ObjectOutputStream(fileOutputStream);
|
|
||||||
Logger.getLogger(Util.class.getName()).log(Level.INFO, "out is : "+out);
|
|
||||||
out.writeObject(userContext);
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (out != null){
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
try{
|
|
||||||
if(fileOutputStream != null){
|
|
||||||
fileOutputStream.close();
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Method to read user in file
|
|
||||||
public static UserContext readUserContext(Context context, String affiliation, String username){
|
|
||||||
UserContext userContext = null;
|
|
||||||
FileInputStream fileInputStream = null;
|
|
||||||
ObjectInputStream in = null;
|
|
||||||
|
|
||||||
try{
|
|
||||||
String filename = username+".context";
|
|
||||||
String dirPath = context.getFilesDir()+"userInfos/"+affiliation;
|
|
||||||
String pathFile = dirPath+"/"+filename;
|
|
||||||
|
|
||||||
File file = new File(pathFile);
|
|
||||||
|
|
||||||
if(file.exists()){
|
|
||||||
fileInputStream = new FileInputStream(pathFile);
|
|
||||||
in = new ObjectInputStream(fileInputStream);
|
|
||||||
userContext = (UserContext) in.readObject();
|
|
||||||
}
|
|
||||||
} catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if(in != null){
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if(fileInputStream!=null){
|
|
||||||
fileInputStream.close();
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return userContext;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package monnethic.mobile.database;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import monnethic.mobile.transaction.Transaction;
|
|
||||||
import monnethic.mobile.user.User;
|
|
||||||
|
|
||||||
import com.j256.ormlite.dao.Dao;
|
|
||||||
import com.j256.ormlite.dao.DaoManager;
|
|
||||||
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
|
||||||
import com.j256.ormlite.support.ConnectionSource;
|
|
||||||
|
|
||||||
public class DatabaseHelper {
|
|
||||||
private static final String DATABASE_NAME = "monnethic";
|
|
||||||
private static final String DATABASE_USER = "";
|
|
||||||
private static final String DATABASE_PWD = "";
|
|
||||||
private final static String DATABASE_URL = "jdbc:postgresql:///"+DATABASE_NAME;
|
|
||||||
|
|
||||||
|
|
||||||
public ConnectionSource setupDatabaseConnection(){
|
|
||||||
try{
|
|
||||||
return new JdbcConnectionSource(DATABASE_URL, DATABASE_USER, DATABASE_PWD);
|
|
||||||
}catch (Exception e){
|
|
||||||
System.out.print("\n"+e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
public void insertTransaction(Transaction tx){
|
|
||||||
try{
|
|
||||||
//Dao<Transaction, Integer> dao = getDao(Transaction.class);
|
|
||||||
//dao.create(tx);
|
|
||||||
} catch(Exception exception){
|
|
||||||
Log.e("DATABASE","Can't insert Transaction into Database", exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package monnethic.mobile.database;
|
|
||||||
|
|
||||||
import com.j256.ormlite.field.DatabaseField;
|
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
|
||||||
|
|
||||||
@DatabaseTable(tableName = "T_TEST")
|
|
||||||
public class DatabaseTest {
|
|
||||||
private static final String NAME_FIELD_NAME = "name";
|
|
||||||
private static final String ID_FIELD_NAME = "id";
|
|
||||||
|
|
||||||
@DatabaseField(columnName = ID_FIELD_NAME, id = true)
|
|
||||||
private int id;
|
|
||||||
@DatabaseField(columnName = NAME_FIELD_NAME, canBeNull = false)
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public DatabaseTest(int id, String name) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseTest() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
86
app/src/main/java/monnethic/mobile/database/Transaction.java
Normal file
86
app/src/main/java/monnethic/mobile/database/Transaction.java
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
package monnethic.mobile.database;
|
||||||
|
|
||||||
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class Transaction {
|
||||||
|
private int transactionId;
|
||||||
|
private long transactionDate;
|
||||||
|
private String transactionFrom;
|
||||||
|
private String transactionTo;
|
||||||
|
private String transactionHash;
|
||||||
|
private Double transactionAmount;
|
||||||
|
private String transactionUnit;
|
||||||
|
|
||||||
|
//Constructors
|
||||||
|
public Transaction(String transactionFrom, String transactionTo, String transactionHash, Double transactionAmount, String transactionUnit) {
|
||||||
|
this.transactionFrom = transactionFrom;
|
||||||
|
this.transactionTo = transactionTo;
|
||||||
|
this.transactionHash = transactionHash;
|
||||||
|
this.transactionAmount = transactionAmount;
|
||||||
|
this.transactionUnit = transactionUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Transaction(int transactionId, long transactionDate, String transactionFrom, String transactionTo, String transactionHash, Double transactionAmount, String transactionUnit) {
|
||||||
|
this.transactionId = transactionId;
|
||||||
|
this.transactionDate = transactionDate;
|
||||||
|
this.transactionFrom = transactionFrom;
|
||||||
|
this.transactionTo = transactionTo;
|
||||||
|
this.transactionHash = transactionHash;
|
||||||
|
this.transactionAmount = transactionAmount;
|
||||||
|
this.transactionUnit = transactionUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Getters and Setters
|
||||||
|
public int getTransactionId() {
|
||||||
|
return transactionId;
|
||||||
|
}
|
||||||
|
public void setTransactionId(int transactionId) {
|
||||||
|
this.transactionId = transactionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTransactionDate() {
|
||||||
|
return transactionDate;
|
||||||
|
}
|
||||||
|
public void setTransactionDate(long transactionDate) {
|
||||||
|
this.transactionDate = transactionDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTransactionFrom() {
|
||||||
|
return transactionFrom;
|
||||||
|
}
|
||||||
|
public void setTransactionFrom(String transactionFrom) {
|
||||||
|
this.transactionFrom = transactionFrom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTransactionTo() {
|
||||||
|
return transactionTo;
|
||||||
|
}
|
||||||
|
public void setTransactionTo(String transactionTo) {
|
||||||
|
this.transactionTo = transactionTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTransactionHash() {
|
||||||
|
return transactionHash;
|
||||||
|
}
|
||||||
|
public void setTransactionHash(String transactionHash) {
|
||||||
|
this.transactionHash = transactionHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getTransactionAmount() {
|
||||||
|
return transactionAmount;
|
||||||
|
}
|
||||||
|
public void setTransactionAmount(Double transactionAmount) {
|
||||||
|
this.transactionAmount = transactionAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTransactionUnit() {
|
||||||
|
return transactionUnit;
|
||||||
|
}
|
||||||
|
public void setTransactionUnit(String transactionUnit) {
|
||||||
|
this.transactionUnit = transactionUnit;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package monnethic.mobile.user;
|
package monnethic.mobile.database;
|
||||||
|
|
||||||
import com.j256.ormlite.field.DatabaseField;
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
@ -8,32 +8,20 @@ import java.util.Date;
|
||||||
* Created by Guillaume on 15/04/2018.
|
* Created by Guillaume on 15/04/2018.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//Class User which represent an User for api rest
|
||||||
//Class User which represent an User in the postgresDB
|
|
||||||
@DatabaseTable(tableName = "T_USER")
|
|
||||||
public class User {
|
public class User {
|
||||||
@DatabaseField(canBeNull = false)
|
private int userId;
|
||||||
private String name;
|
private String name;
|
||||||
@DatabaseField(canBeNull = false)
|
|
||||||
private String firstname;
|
private String firstname;
|
||||||
@DatabaseField(id = true)
|
|
||||||
private String email;
|
private String email;
|
||||||
@DatabaseField(canBeNull = false)
|
|
||||||
private String password;
|
private String password;
|
||||||
@DatabaseField(canBeNull = false)
|
|
||||||
private long creation_date;
|
private long creation_date;
|
||||||
@DatabaseField(canBeNull = false)
|
|
||||||
private long modification_date;
|
private long modification_date;
|
||||||
@DatabaseField(canBeNull = false)
|
|
||||||
private boolean verified;
|
private boolean verified;
|
||||||
@DatabaseField(canBeNull = false)
|
|
||||||
private boolean approved;
|
private boolean approved;
|
||||||
|
private String user_hash;
|
||||||
|
|
||||||
//Constructors
|
//Constructors
|
||||||
//Default constructor for ORMLite
|
|
||||||
public User() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public User(String name, String firstname, String email, String password) {
|
public User(String name, String firstname, String email, String password) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.firstname = firstname;
|
this.firstname = firstname;
|
||||||
|
@ -41,9 +29,11 @@ public class User {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(String name, String firstname, String email, String password, long creation_date, long modification_date, boolean verified, boolean approved) {
|
public User(int userId, String name, String firstname, String user_hash, String email, String password, long creation_date, long modification_date, boolean verified, boolean approved) {
|
||||||
|
this.userId=userId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.firstname = firstname;
|
this.firstname = firstname;
|
||||||
|
this.user_hash = user_hash;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.creation_date = creation_date;
|
this.creation_date = creation_date;
|
||||||
|
@ -54,10 +44,12 @@ public class User {
|
||||||
|
|
||||||
|
|
||||||
//Getters and Setters
|
//Getters and Setters
|
||||||
|
public int getUserId(){return userId;}
|
||||||
|
public void setUserId(int userId){this.userId=userId;}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
@ -65,15 +57,16 @@ public class User {
|
||||||
public String getFirstname() {
|
public String getFirstname() {
|
||||||
return firstname;
|
return firstname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirstname(String firstname) {
|
public void setFirstname(String firstname) {
|
||||||
this.firstname = firstname;
|
this.firstname = firstname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUser_hash(){return user_hash;}
|
||||||
|
public void setUser_hash(String user_hash){this.user_hash=user_hash;}
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmail(String email) {
|
public void setEmail(String email) {
|
||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +74,6 @@ public class User {
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPassword(String password) {
|
public void setPassword(String password) {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +81,6 @@ public class User {
|
||||||
public long getCreation_date() {
|
public long getCreation_date() {
|
||||||
return creation_date;
|
return creation_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreation_date(long creation_date) {
|
public void setCreation_date(long creation_date) {
|
||||||
this.creation_date = creation_date;
|
this.creation_date = creation_date;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +88,6 @@ public class User {
|
||||||
public long getModification_date() {
|
public long getModification_date() {
|
||||||
return modification_date;
|
return modification_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModification_date(long modification_date) {
|
public void setModification_date(long modification_date) {
|
||||||
this.modification_date = modification_date;
|
this.modification_date = modification_date;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +95,6 @@ public class User {
|
||||||
public boolean isVerified() {
|
public boolean isVerified() {
|
||||||
return verified;
|
return verified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVerified(boolean verified) {
|
public void setVerified(boolean verified) {
|
||||||
this.verified = verified;
|
this.verified = verified;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +102,6 @@ public class User {
|
||||||
public boolean isApproved() {
|
public boolean isApproved() {
|
||||||
return approved;
|
return approved;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setApproved(boolean approved) {
|
public void setApproved(boolean approved) {
|
||||||
this.approved = approved;
|
this.approved = approved;
|
||||||
}
|
}
|
|
@ -1,48 +0,0 @@
|
||||||
package monnethic.mobile.demo;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
|
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
|
||||||
|
|
||||||
import monnethic.mobile.wallet.WalletPresenterActivity;
|
|
||||||
|
|
||||||
public class DemoActivity extends AppCompatActivity {
|
|
||||||
private static final String WALLET_A = "0x5421c79d465a288c28e10aa43f9b7dff1b313c8e";
|
|
||||||
private static final String WALLET_B = "";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_demo_wallet);
|
|
||||||
Button bWalletA = findViewById(R.id.walletA);
|
|
||||||
Button bWalletB = findViewById(R.id.walletB);
|
|
||||||
|
|
||||||
bWalletA.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
launchWalletPresenterActivity(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bWalletB.setOnClickListener(new View.OnClickListener() {
|
|
||||||
public void onClick(View view) {
|
|
||||||
launchWalletPresenterActivity(1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void launchWalletPresenterActivity(int idWallet) {
|
|
||||||
if (idWallet == 0) {
|
|
||||||
Intent demoWalletIntent = new Intent(DemoActivity.this, WalletPresenterActivity.class);
|
|
||||||
demoWalletIntent.putExtra("WALLET_ADDRESS",WALLET_A);
|
|
||||||
DemoActivity.this.startActivity(demoWalletIntent);
|
|
||||||
} else {
|
|
||||||
Intent demoWalletIntent = new Intent(DemoActivity.this, WalletPresenterActivity.class);
|
|
||||||
demoWalletIntent.putExtra("WALLET_ADDRESS","WALLET B");
|
|
||||||
DemoActivity.this.startActivity(demoWalletIntent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,8 +8,6 @@ import android.widget.Button;
|
||||||
|
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
import com.example.monnthic.monnethicmobile.R;
|
||||||
|
|
||||||
import monnethic.mobile.demo.DemoActivity;
|
|
||||||
|
|
||||||
public class HomepageActivity extends AppCompatActivity {
|
public class HomepageActivity extends AppCompatActivity {
|
||||||
//TODO MOVE TO LOGIN ACTIVITY
|
//TODO MOVE TO LOGIN ACTIVITY
|
||||||
private static final String[] DUMMY_CREDENTIALS = new String[]{
|
private static final String[] DUMMY_CREDENTIALS = new String[]{
|
||||||
|
@ -22,7 +20,6 @@ public class HomepageActivity extends AppCompatActivity {
|
||||||
setContentView(R.layout.activity_homepage);
|
setContentView(R.layout.activity_homepage);
|
||||||
Button bRegister = findViewById(R.id.register);
|
Button bRegister = findViewById(R.id.register);
|
||||||
Button bLogin = findViewById(R.id.login);
|
Button bLogin = findViewById(R.id.login);
|
||||||
Button bDemo = findViewById(R.id.demo);
|
|
||||||
|
|
||||||
bRegister.setOnClickListener(new View.OnClickListener() {
|
bRegister.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,11 +33,6 @@ public class HomepageActivity extends AppCompatActivity {
|
||||||
launchLoginActivity();
|
launchLoginActivity();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bDemo.setOnClickListener(new View.OnClickListener(){
|
|
||||||
public void onClick(View view){
|
|
||||||
launchDemoActivity();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void launchRegisterActivity(){
|
public void launchRegisterActivity(){
|
||||||
|
@ -51,8 +43,5 @@ public class HomepageActivity extends AppCompatActivity {
|
||||||
Intent loginIntent = new Intent(HomepageActivity.this, LoginActivity.class);
|
Intent loginIntent = new Intent(HomepageActivity.this, LoginActivity.class);
|
||||||
HomepageActivity.this.startActivity(loginIntent);
|
HomepageActivity.this.startActivity(loginIntent);
|
||||||
}
|
}
|
||||||
public void launchDemoActivity(){
|
|
||||||
Intent demoIntent = new Intent(HomepageActivity.this, DemoActivity.class);
|
|
||||||
HomepageActivity.this.startActivity(demoIntent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
import com.example.monnthic.monnethicmobile.R;
|
||||||
|
|
||||||
import monnethic.mobile.wallet.WalletActivity;
|
import monnethic.mobile.user.UserAccountActivity;
|
||||||
|
|
||||||
public class LoginActivity extends AppCompatActivity {
|
public class LoginActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
public void launchWalletActivity(int ldapId){
|
public void launchWalletActivity(int ldapId){
|
||||||
//LAUNCH APP WALLET WITH ID USER
|
//LAUNCH APP WALLET WITH ID USER
|
||||||
Intent walletIntent = new Intent(LoginActivity.this, WalletActivity.class);
|
Intent accountIntent = new Intent(LoginActivity.this, UserAccountActivity.class);
|
||||||
walletIntent.putExtra("idUser", ldapId);
|
accountIntent.putExtra("idUser", ldapId);
|
||||||
LoginActivity.this.startActivity(walletIntent);
|
LoginActivity.this.startActivity(accountIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
import com.example.monnthic.monnethicmobile.R;
|
||||||
|
|
||||||
import monnethic.mobile.user.User;
|
import monnethic.mobile.database.User;
|
||||||
import monnethic.mobile.wallet.WalletActivity;
|
import monnethic.mobile.user.UserAccountActivity;
|
||||||
|
|
||||||
public class RegisterActivity extends AppCompatActivity {
|
public class RegisterActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@ -78,14 +78,14 @@ public class RegisterActivity extends AppCompatActivity {
|
||||||
Toast.makeText(this, "User already have an account, please log in", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "User already have an account, please log in", Toast.LENGTH_SHORT).show();
|
||||||
}else {
|
}else {
|
||||||
Toast.makeText(this, "INSERT", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "INSERT", Toast.LENGTH_SHORT).show();
|
||||||
launchWalletActivity(1);
|
launchUserActivity(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO LAUNCH WALLET ACTIVITY
|
//TODO LAUNCH WALLET ACTIVITY
|
||||||
private void launchWalletActivity(int ldapId){
|
private void launchUserActivity(int ldapId){
|
||||||
//LAUNCH APP WALLET WITH ID USER
|
//LAUNCH APP WALLET WITH ID USER
|
||||||
Intent walletIntent = new Intent(RegisterActivity.this, WalletActivity.class);
|
Intent walletIntent = new Intent(RegisterActivity.this, UserAccountActivity.class);
|
||||||
walletIntent.putExtra("idUser", ldapId);
|
walletIntent.putExtra("idUser", ldapId);
|
||||||
RegisterActivity.this.startActivity(walletIntent);
|
RegisterActivity.this.startActivity(walletIntent);
|
||||||
finish();
|
finish();
|
||||||
|
|
5
app/src/main/java/monnethic/mobile/restApi/Config.java
Normal file
5
app/src/main/java/monnethic/mobile/restApi/Config.java
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package monnethic.mobile.restApi;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
static public String URL_BALANCE = "http://10.0.2.2:8083/balance?name=";
|
||||||
|
}
|
|
@ -1,106 +0,0 @@
|
||||||
package monnethic.mobile.transaction;
|
|
||||||
|
|
||||||
import com.j256.ormlite.field.DatabaseField;
|
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@DatabaseTable(tableName = "T_TRANSACTION")
|
|
||||||
public class Transaction {
|
|
||||||
@DatabaseField(columnName = "transactionId", generatedId = true, unique = true)
|
|
||||||
private int id;
|
|
||||||
@DatabaseField(columnName = "transactionDate")
|
|
||||||
private Date transactionDate;
|
|
||||||
@DatabaseField(columnName = "transactionDSrcAddress")
|
|
||||||
private String sourceAddress;
|
|
||||||
@DatabaseField(columnName = "transactionDestAddress")
|
|
||||||
private String destAddress;
|
|
||||||
@DatabaseField(columnName = "transactionHash")
|
|
||||||
private String transactionHash;
|
|
||||||
@DatabaseField(columnName = "transactionBlockNumber")
|
|
||||||
private String blockNumber;
|
|
||||||
@DatabaseField(columnName = "transactionAmout")
|
|
||||||
private BigInteger amount;
|
|
||||||
@DatabaseField(columnName = "transactionUnit")
|
|
||||||
private String unit;
|
|
||||||
|
|
||||||
public Transaction() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Transaction(Date transactionDate, String sourceAddress, String destAddress, String transactionHash, String blockNumber, BigInteger amount, String unit) {
|
|
||||||
super();
|
|
||||||
this.transactionDate = transactionDate;
|
|
||||||
this.sourceAddress = sourceAddress;
|
|
||||||
this.destAddress = destAddress;
|
|
||||||
this.transactionHash = transactionHash;
|
|
||||||
this.blockNumber = blockNumber;
|
|
||||||
this.amount = amount;
|
|
||||||
this.unit = unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSourceAddress() {
|
|
||||||
return sourceAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSourceAddress(String sourceAddress) {
|
|
||||||
this.sourceAddress = sourceAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDestAddress() {
|
|
||||||
return destAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDestAddress(String destAddress) {
|
|
||||||
this.destAddress = destAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTransactionHash() {
|
|
||||||
return transactionHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTransactionHash(String transactionHash) {
|
|
||||||
this.transactionHash = transactionHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigInteger getAmount() {
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAmount(BigInteger amount) {
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getTransactionDate() {
|
|
||||||
return transactionDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTransactionDate(Date transactionDate) {
|
|
||||||
this.transactionDate = transactionDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUnit() {
|
|
||||||
return unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnit(String unit) {
|
|
||||||
this.unit = unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBlockNumber() {
|
|
||||||
return blockNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBlockNumber(String blockNumber) {
|
|
||||||
this.blockNumber = blockNumber;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
package monnethic.mobile.user;
|
package monnethic.mobile.user;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -10,23 +11,34 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
import com.example.monnthic.monnethicmobile.R;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import monnethic.mobile.restApi.Config;
|
||||||
import monnethic.mobile.transaction.MakePayementActivity;
|
import monnethic.mobile.transaction.MakePayementActivity;
|
||||||
import monnethic.mobile.transaction.ReceivePayementActivity;
|
import monnethic.mobile.transaction.ReceivePayementActivity;
|
||||||
|
|
||||||
public class UserAccountActivity extends AppCompatActivity {
|
public class UserAccountActivity extends AppCompatActivity {
|
||||||
private TextView solde;
|
|
||||||
|
private TextView balance;
|
||||||
|
private String strUrl = Config.URL_BALANCE+"b";
|
||||||
|
private String result;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_user_account);
|
setContentView(R.layout.activity_user_account);
|
||||||
|
|
||||||
solde = findViewById(R.id.viewSolde);
|
balance = findViewById(R.id.balanceView);
|
||||||
Button buttonPayement = findViewById(R.id.buttonPayement);
|
Button buttonPayement = findViewById(R.id.buttonPayement);
|
||||||
Button buttonReceive = findViewById(R.id.buttonReceive);
|
Button buttonReceive = findViewById(R.id.buttonReceive);
|
||||||
Button buttonSettings = findViewById(R.id.buttonSettings);
|
Button buttonSettings = findViewById(R.id.buttonSettings);
|
||||||
|
Button buttonRefresh = findViewById(R.id.buttonRefreshBalance);
|
||||||
|
|
||||||
|
|
||||||
//refreshSolde();
|
|
||||||
buttonPayement.setOnClickListener(new View.OnClickListener() {
|
buttonPayement.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -45,13 +57,21 @@ public class UserAccountActivity extends AppCompatActivity {
|
||||||
settings();
|
settings();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
buttonRefresh.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
refreshBalance("b");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
new GetUserBalanceTask().execute(strUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPayement(){
|
public void sendPayement(){
|
||||||
Intent payementIntent = new Intent(UserAccountActivity.this, MakePayementActivity.class);
|
Intent payementIntent = new Intent(UserAccountActivity.this, MakePayementActivity.class);
|
||||||
UserAccountActivity.this.startActivity(payementIntent);
|
UserAccountActivity.this.startActivity(payementIntent);
|
||||||
}
|
}
|
||||||
public void receivePayement(){
|
public void receivePayement(){
|
||||||
|
|
||||||
Intent receivePayementIntent = new Intent(UserAccountActivity.this, ReceivePayementActivity.class);
|
Intent receivePayementIntent = new Intent(UserAccountActivity.this, ReceivePayementActivity.class);
|
||||||
UserAccountActivity.this.startActivity(receivePayementIntent);
|
UserAccountActivity.this.startActivity(receivePayementIntent);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +79,66 @@ public class UserAccountActivity extends AppCompatActivity {
|
||||||
Toast.makeText(this, "Coming soon", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Coming soon", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshSolde(){
|
public void refreshBalance(String userHash){
|
||||||
solde.setText("0.00");
|
String url = Config.URL_BALANCE+userHash;
|
||||||
|
new GetUserBalanceTask().execute(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBalance(String value){
|
||||||
|
balance.setText(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class GetUserBalanceTask extends AsyncTask<String,String,String>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
super.onPreExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(String s) {
|
||||||
|
balance.setText(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String doInBackground(String... params) {
|
||||||
|
System.out.println(params[0]);
|
||||||
|
InputStream inputStream = null;
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
try{
|
||||||
|
URL url = new URL(params[0]);
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
int response = conn.getResponseCode();
|
||||||
|
if(response != 200){
|
||||||
|
return "Error response";
|
||||||
|
}
|
||||||
|
|
||||||
|
inputStream = conn.getInputStream();
|
||||||
|
if(inputStream == null){
|
||||||
|
return "Error inputStream";
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while ((line = reader.readLine())!=null){
|
||||||
|
buffer.append(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
String value = new String(buffer);
|
||||||
|
|
||||||
|
System.out.println("result is "+value);
|
||||||
|
result = value;
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
System.out.println("Exception : "+e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
package monnethic.mobile.user;
|
|
||||||
|
|
||||||
import com.j256.ormlite.dao.Dao;
|
|
||||||
import com.j256.ormlite.dao.DaoManager;
|
|
||||||
import com.j256.ormlite.stmt.PreparedQuery;
|
|
||||||
import com.j256.ormlite.stmt.QueryBuilder;
|
|
||||||
import com.j256.ormlite.stmt.UpdateBuilder;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import monnethic.mobile.database.DatabaseHelper;
|
|
||||||
|
|
||||||
//Class to communicate with database with ORMLite
|
|
||||||
public class UserDao {
|
|
||||||
private DatabaseHelper dbh = new DatabaseHelper();
|
|
||||||
private Dao<User, String> userDao;
|
|
||||||
|
|
||||||
public Dao createUserDaoConnection(){
|
|
||||||
try {
|
|
||||||
return DaoManager.createDao(dbh.setupDatabaseConnection(),User.class);
|
|
||||||
}catch (Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addUser(User user)throws Exception {
|
|
||||||
userDao = createUserDaoConnection();
|
|
||||||
userDao.create(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkApprovedUser(String email) throws Exception {
|
|
||||||
userDao = createUserDaoConnection();
|
|
||||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
|
||||||
queryBuilder.where().eq("email",email);
|
|
||||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
|
||||||
User user = userDao.queryForFirst(preparedQuery);
|
|
||||||
return user.isApproved();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkVerifiedUser(String email) throws Exception {
|
|
||||||
userDao = createUserDaoConnection();
|
|
||||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
|
||||||
queryBuilder.where().eq("email",email);
|
|
||||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
|
||||||
User user = userDao.queryForFirst(preparedQuery);
|
|
||||||
return user.isVerified();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean updateUserPassword(String email, String password) throws Exception {
|
|
||||||
userDao = createUserDaoConnection();
|
|
||||||
UpdateBuilder<User, String> updateBuilder = userDao.updateBuilder();
|
|
||||||
updateBuilder.updateColumnValue("password",password);
|
|
||||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
|
||||||
updateBuilder.updateColumnValue("modification_date",timestamp.getTime());
|
|
||||||
updateBuilder.where().eq("email",email);
|
|
||||||
updateBuilder.update();
|
|
||||||
|
|
||||||
if(checkUserPassword(email, password)){
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean verifyUserExist(String email) throws Exception {
|
|
||||||
userDao = createUserDaoConnection();
|
|
||||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
|
||||||
queryBuilder.where().eq("email",email);
|
|
||||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
|
||||||
User user = userDao.queryForFirst(preparedQuery);
|
|
||||||
|
|
||||||
if(user==null){
|
|
||||||
return false;
|
|
||||||
}else{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkUserPassword(String email, String password) throws Exception {
|
|
||||||
User user = getUser(email);
|
|
||||||
if(password.equals(user.getPassword())){
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public User getUser(String email) throws Exception {
|
|
||||||
if(!verifyUserExist(email)){
|
|
||||||
return null;
|
|
||||||
}else{
|
|
||||||
userDao = createUserDaoConnection();
|
|
||||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
|
||||||
queryBuilder.where().eq("email",email);
|
|
||||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
|
||||||
return userDao.queryForFirst(preparedQuery);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void approveUser (String email) throws Exception{
|
|
||||||
userDao = createUserDaoConnection();
|
|
||||||
UpdateBuilder<User, String> updateBuilder = userDao.updateBuilder();
|
|
||||||
updateBuilder.updateColumnValue("approved",true);
|
|
||||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
|
||||||
updateBuilder.updateColumnValue("modification_date",timestamp.getTime());
|
|
||||||
updateBuilder.where().eq("email",email);
|
|
||||||
updateBuilder.update();
|
|
||||||
}
|
|
||||||
public void verifyUser (String email) throws Exception{
|
|
||||||
userDao = createUserDaoConnection();
|
|
||||||
UpdateBuilder<User, String> updateBuilder = userDao.updateBuilder();
|
|
||||||
updateBuilder.updateColumnValue("verified",true);
|
|
||||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
|
||||||
updateBuilder.updateColumnValue("modification_date",timestamp.getTime());
|
|
||||||
updateBuilder.where().eq("email",email);
|
|
||||||
updateBuilder.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
package monnethic.mobile.wallet;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
|
||||||
|
|
||||||
import monnethic.mobile.user.UserAccountActivity;
|
|
||||||
|
|
||||||
public class WalletActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_wallet);
|
|
||||||
|
|
||||||
Button buttonCreate = findViewById(R.id.buttonCreateWallet);
|
|
||||||
Button buttonRestore = findViewById(R.id.buttonRestoreWallet);
|
|
||||||
Button buttonSkip = findViewById(R.id.buttonSkip);
|
|
||||||
|
|
||||||
buttonCreate.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
createWallet();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
buttonRestore.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
restoreWallet();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
buttonSkip.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
skip();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public void skip(){
|
|
||||||
Intent userIntent = new Intent(WalletActivity.this, UserAccountActivity.class);
|
|
||||||
WalletActivity.this.startActivity(userIntent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
public void createWallet(){
|
|
||||||
Toast.makeText(this, "Coming soon", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
public void restoreWallet(){
|
|
||||||
Toast.makeText(this, "Coming soon", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<android.support.constraint.ConstraintLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/walletA"
|
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:text="WALLET A"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/walletB"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintVertical_bias="0.782" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/walletB"
|
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="192dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:text="WALLET B"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/presenter_Demo"
|
|
||||||
android:layout_width="137dp"
|
|
||||||
android:layout_height="23dp"
|
|
||||||
android:layout_marginBottom="68dp"
|
|
||||||
android:layout_marginEnd="120dp"
|
|
||||||
android:text="WALLET FOR DEMO"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/walletA"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
|
|
@ -43,7 +43,7 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:text="version v0.1"
|
android:text="version v0.1"
|
||||||
android:textAlignment="center" />
|
android:textAlignment="center" />
|
||||||
|
<!--
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/demo"
|
android:id="@+id/demo"
|
||||||
android:layout_width="200dp"
|
android:layout_width="200dp"
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
android:layout_below="@+id/register"
|
android:layout_below="@+id/register"
|
||||||
android:layout_marginTop="53dp"
|
android:layout_marginTop="53dp"
|
||||||
android:text="DEMO" />
|
android:text="DEMO" />
|
||||||
|
-->
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="230dp"
|
android:layout_width="230dp"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:orientation="vertical" android:layout_width="match_parent"
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
@ -28,12 +27,12 @@
|
||||||
android:id="@+id/editTextPassword"
|
android:id="@+id/editTextPassword"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignStart="@+id/editTextEmail"
|
|
||||||
android:layout_below="@+id/editTextEmail"
|
android:layout_below="@+id/editTextEmail"
|
||||||
|
android:layout_alignStart="@+id/editTextEmail"
|
||||||
android:layout_marginTop="69dp"
|
android:layout_marginTop="69dp"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:hint="Password"
|
android:hint="Password"
|
||||||
android:inputType="textPersonName" />
|
android:inputType="textPassword" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/forgetPassword"
|
android:id="@+id/forgetPassword"
|
||||||
|
|
|
@ -8,14 +8,17 @@
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/buttonScanQr"
|
android:id="@+id/buttonScanQr"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="141dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="148dp"
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginStart="148dp"
|
android:layout_marginBottom="160dp"
|
||||||
android:text="SCAN QR CODE"
|
android:text="SCAN QR CODE"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.502"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.905" />
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
<android.support.constraint.ConstraintLayout
|
<android.support.constraint.ConstraintLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/buttonSettings"
|
android:id="@+id/buttonSettings"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="45dp"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:text="Settings" />
|
android:text="Settings" />
|
||||||
|
@ -25,32 +25,61 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/buttonSettings"
|
android:layout_below="@+id/buttonSettings"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="13dp"
|
||||||
android:text="User account" />
|
android:text="User account" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/viewSolde"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/textView4"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="48dp" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/buttonPayement"
|
android:id="@+id/buttonPayement"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="150dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="45dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_marginBottom="202dp"
|
||||||
android:text="Payement" />
|
android:text="Payement" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/buttonReceive"
|
android:id="@+id/buttonReceive"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="150dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="45dp"
|
||||||
android:layout_below="@+id/buttonPayement"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="38dp"
|
android:layout_marginBottom="142dp"
|
||||||
android:text="Receive" />
|
android:text="Receive" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonRefreshBalance"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="82dp"
|
||||||
|
android:text="Refresh" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/balanceView"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:layout_below="@+id/textView4"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginStart="119dp"
|
||||||
|
android:layout_marginTop="156dp"
|
||||||
|
android:layout_marginEnd="113dp"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="30sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView6"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="204dp"
|
||||||
|
android:text="BALANCE"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical" android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="119dp"
|
|
||||||
android:text="Generate or Restore wallet" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/versionApp"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:text="version v0.1" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/buttonCreateWallet"
|
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/textView2"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="83dp"
|
|
||||||
android:text="Create Wallet" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/buttonRestoreWallet"
|
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignStart="@+id/buttonCreateWallet"
|
|
||||||
android:layout_below="@+id/buttonCreateWallet"
|
|
||||||
android:layout_marginTop="54dp"
|
|
||||||
android:text="RESTORE WALLET" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/buttonSkip"
|
|
||||||
android:layout_width="50dp"
|
|
||||||
android:layout_height="35dp"
|
|
||||||
android:layout_alignStart="@+id/buttonRestoreWallet"
|
|
||||||
android:layout_below="@+id/buttonRestoreWallet"
|
|
||||||
android:text="SKIP"
|
|
||||||
android:textSize="8sp" />
|
|
||||||
</RelativeLayout>
|
|
|
@ -1,5 +1,5 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Monnéthic Mobile</string>
|
<string name="app_name">Monnethic Mobile</string>
|
||||||
<string name="title_activity_login">Sign in</string>
|
<string name="title_activity_login">Sign in</string>
|
||||||
|
|
||||||
<!-- Strings related to login -->
|
<!-- Strings related to login -->
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
package monnethic.mobile.test.blockchain;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import org.junit.FixMethodOrder;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runners.MethodSorters;
|
|
||||||
|
|
||||||
import monnethic.mobile.blockchain.client.CAClientWrapper;
|
|
||||||
import monnethic.mobile.blockchain.network.Config;
|
|
||||||
import monnethic.mobile.blockchain.participant.UserContext;
|
|
||||||
|
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
|
||||||
public class TestQuery {
|
|
||||||
@Test
|
|
||||||
void TestAQueryChainCode(){
|
|
||||||
try{
|
|
||||||
//context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
|
|
||||||
String caUrl = Config.CA_ORG1_URL;
|
|
||||||
CAClientWrapper caClientWrapper = new CAClientWrapper(caUrl,null,null,null);
|
|
||||||
|
|
||||||
UserContext adminContext = new UserContext();
|
|
||||||
adminContext.setName(Config.ADMIN);
|
|
||||||
adminContext.setAffiliation(Config.ORG1);
|
|
||||||
adminContext.setMspId(Config.ORG1_MSP);
|
|
||||||
|
|
||||||
caClientWrapper.setAdminContext(adminContext);
|
|
||||||
//adminContext = caClientWrapper.enrollAdmin(appContext);
|
|
||||||
} catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package monnethic.mobile.test.database;
|
|
||||||
|
|
||||||
import com.j256.ormlite.dao.Dao;
|
|
||||||
import com.j256.ormlite.dao.DaoManager;
|
|
||||||
import org.junit.Test;
|
|
||||||
import monnethic.mobile.database.DatabaseHelper;
|
|
||||||
import monnethic.mobile.database.DatabaseTest;
|
|
||||||
|
|
||||||
|
|
||||||
//Testing class for postgresql connection
|
|
||||||
public class DatabaseHelperTest {
|
|
||||||
private DatabaseHelper dbh = new DatabaseHelper();
|
|
||||||
|
|
||||||
//Test connection by getting existing data in T_TEST
|
|
||||||
@Test
|
|
||||||
public void TestConnection(){
|
|
||||||
Dao<DatabaseTest, Integer> testDao;
|
|
||||||
try{
|
|
||||||
testDao = DaoManager.createDao(dbh.setupDatabaseConnection(),DatabaseTest.class);
|
|
||||||
DatabaseTest dbt = testDao.queryForId(1);
|
|
||||||
assert dbt != null;
|
|
||||||
assert "thomas".equals(dbt.getName());
|
|
||||||
}catch (Exception e){
|
|
||||||
System.out.println("\n"+e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,151 +0,0 @@
|
||||||
package monnethic.mobile.test.user;
|
|
||||||
|
|
||||||
import com.j256.ormlite.dao.Dao;
|
|
||||||
import com.j256.ormlite.table.TableUtils;
|
|
||||||
|
|
||||||
import org.junit.FixMethodOrder;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runners.MethodSorters;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import monnethic.mobile.user.User;
|
|
||||||
import monnethic.mobile.user.UserDao;
|
|
||||||
|
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
|
||||||
public class UserDaoTest {
|
|
||||||
private UserDao udao = new UserDao();
|
|
||||||
private final String USER_EMAIL = "thomas.marshal@gmail.com";
|
|
||||||
private final String USER_PASSWORD = "avcde";
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestACreateTable(){
|
|
||||||
try{
|
|
||||||
Dao<User, String> userDao;
|
|
||||||
userDao = udao.createUserDaoConnection();
|
|
||||||
TableUtils.createTable(userDao);
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestBInsertUser(){
|
|
||||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
|
||||||
User user = new User("marshal","thomas",USER_EMAIL,USER_PASSWORD,timestamp.getTime(),timestamp.getTime(),false,false);
|
|
||||||
try{
|
|
||||||
udao.addUser(user);
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestCGetGeneratedUser(){
|
|
||||||
try{
|
|
||||||
User uTest = udao.getUser(USER_EMAIL);
|
|
||||||
if(uTest==null){
|
|
||||||
System.out.println("User don't Exist");
|
|
||||||
}else {
|
|
||||||
System.out.println(uTest.getEmail());
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestDCheckApprovedUser(){
|
|
||||||
try{
|
|
||||||
boolean response = udao.checkApprovedUser(USER_EMAIL);
|
|
||||||
if(response){
|
|
||||||
System.out.println("Approved");
|
|
||||||
}else{
|
|
||||||
System.out.println("Not Approved");
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestECheckVerifiedUser(){
|
|
||||||
try{
|
|
||||||
boolean response = udao.checkVerifiedUser(USER_EMAIL);
|
|
||||||
if(response){
|
|
||||||
System.out.println("Verified");
|
|
||||||
}else{
|
|
||||||
System.out.println("Not Verified");
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestFCheckUserPassword(){
|
|
||||||
try{
|
|
||||||
boolean response = udao.checkUserPassword(USER_EMAIL,USER_PASSWORD);
|
|
||||||
if(response){
|
|
||||||
System.out.println("Password OK");
|
|
||||||
}else{
|
|
||||||
System.out.println("Password Failed");
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestGUpdateUserPassword(){
|
|
||||||
String newPassword = "newPassword";
|
|
||||||
try{
|
|
||||||
boolean response = udao.updateUserPassword(USER_EMAIL,newPassword);
|
|
||||||
if(response){
|
|
||||||
System.out.println("Password Changed");
|
|
||||||
}else{
|
|
||||||
System.out.println("Password Update Failed");
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestHApproveVerifyUser(){
|
|
||||||
try{
|
|
||||||
udao.approveUser(USER_EMAIL);
|
|
||||||
udao.verifyUser(USER_EMAIL);
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestICheckApprovedUser(){
|
|
||||||
try{
|
|
||||||
boolean response = udao.checkApprovedUser(USER_EMAIL);
|
|
||||||
if(response){
|
|
||||||
System.out.println("Approved");
|
|
||||||
}else{
|
|
||||||
System.out.println("Not Approved");
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void TestJCheckVerifiedUser(){
|
|
||||||
try{
|
|
||||||
boolean response = udao.checkVerifiedUser(USER_EMAIL);
|
|
||||||
if(response){
|
|
||||||
System.out.println("Verified");
|
|
||||||
}else{
|
|
||||||
System.out.println("Not Verified");
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue