update
This commit is contained in:
parent
6c47bf8458
commit
9dcf437fa6
|
@ -26,7 +26,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
email = findViewById(R.id.editTextEmail);
|
email = findViewById(R.id.editTextEmail);
|
||||||
password = findViewById(R.id.editTextPassword);
|
password = findViewById(R.id.editTextPassword);
|
||||||
Button buttonCancel = findViewById(R.id.buttonCancel);
|
Button buttonCancel = findViewById(R.id.buttonCancel);
|
||||||
Button buttonOk = findViewById(R.id.buttonOk);
|
Button buttonOk = findViewById(R.id.buttonOkLogin);
|
||||||
|
|
||||||
buttonCancel.setOnClickListener(new View.OnClickListener() {
|
buttonCancel.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,6 +37,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
buttonOk.setOnClickListener(new View.OnClickListener() {
|
buttonOk.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
System.out.println("CLICKED");
|
||||||
validateInput();
|
validateInput();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class Config {
|
||||||
static public String USER_GET = BASE_URL_USER+"get";
|
static public String USER_GET = BASE_URL_USER+"get";
|
||||||
|
|
||||||
//TRANSACTION
|
//TRANSACTION
|
||||||
|
static public String TRANSACTION_SEND = BASE_URL_TRANSACTION+"send";
|
||||||
static public String TRANSACTION_GET = BASE_URL_TRANSACTION+"get";
|
static public String TRANSACTION_GET = BASE_URL_TRANSACTION+"get";
|
||||||
static public String TRANSACTION_LATEST = BASE_URL_TRANSACTION+"getLatest";
|
static public String TRANSACTION_LATEST = BASE_URL_TRANSACTION+"getLatest";
|
||||||
static public String TRANSACTION_ALL = BASE_URL_TRANSACTION+"getAll";
|
static public String TRANSACTION_ALL = BASE_URL_TRANSACTION+"getAll";
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package monnethic.mobile.restApi;
|
package monnethic.mobile.restApi;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -63,7 +64,11 @@ public class HttpCallHandler {
|
||||||
DataOutputStream os = new DataOutputStream(urlConnection.getOutputStream());
|
DataOutputStream os = new DataOutputStream(urlConnection.getOutputStream());
|
||||||
os.writeBytes(jsonParam.toString());
|
os.writeBytes(jsonParam.toString());
|
||||||
|
|
||||||
|
Log.i("HttpCallHandler",jsonParam.toString());
|
||||||
|
|
||||||
|
|
||||||
int statusCode = urlConnection.getResponseCode();
|
int statusCode = urlConnection.getResponseCode();
|
||||||
|
Log.i("HttpCallHandler",String.valueOf(statusCode));
|
||||||
if(statusCode != 200){
|
if(statusCode != 200){
|
||||||
JSONObject jsonReturn = new JSONObject();
|
JSONObject jsonReturn = new JSONObject();
|
||||||
if(statusCode == 404){
|
if(statusCode == 404){
|
||||||
|
@ -84,8 +89,11 @@ public class HttpCallHandler {
|
||||||
while ((line = bufferedReader.readLine())!=null){
|
while ((line = bufferedReader.readLine())!=null){
|
||||||
stringBuilder.append(line);
|
stringBuilder.append(line);
|
||||||
}
|
}
|
||||||
stringBuilder.append("{\"status\":"+200+"}");
|
|
||||||
returnValue = stringBuilder.toString();
|
//stringBuilder.append("{\"status\":"+200+"}");
|
||||||
|
JSONObject json = new JSONObject(stringBuilder.toString());
|
||||||
|
json.put("status",200);
|
||||||
|
returnValue = json.toString();
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package monnethic.mobile.restApi;
|
package monnethic.mobile.restApi;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -13,8 +15,9 @@ public class TransactionApiHandler {
|
||||||
public String doTransaction(SendingTransaction sendingTransaction){
|
public String doTransaction(SendingTransaction sendingTransaction){
|
||||||
HttpCallHandler httpCallHandler = new HttpCallHandler();
|
HttpCallHandler httpCallHandler = new HttpCallHandler();
|
||||||
try{
|
try{
|
||||||
String url = Config.TRANSACTION_SENT;
|
String url = Config.TRANSACTION_SEND;
|
||||||
Map<String,String> map = new HashMap<>();
|
Map<String,String> map = new HashMap<>();
|
||||||
|
Log.i("TransactionApiHandler",sendingTransaction.toString());
|
||||||
map.put("source_user_hash",sendingTransaction.getSource_user_hash());
|
map.put("source_user_hash",sendingTransaction.getSource_user_hash());
|
||||||
map.put("source_user_pwd",sendingTransaction.getSource_user_pwd());
|
map.put("source_user_pwd",sendingTransaction.getSource_user_pwd());
|
||||||
map.put("transaction_from",sendingTransaction.getTransaction_from());
|
map.put("transaction_from",sendingTransaction.getTransaction_from());
|
||||||
|
@ -23,7 +26,8 @@ public class TransactionApiHandler {
|
||||||
map.put("transaction_unit",sendingTransaction.getTransaction_unit());
|
map.put("transaction_unit",sendingTransaction.getTransaction_unit());
|
||||||
String response = httpCallHandler.postHttp(new URL(url),map);
|
String response = httpCallHandler.postHttp(new URL(url),map);
|
||||||
JSONObject jsonObject = new JSONObject(response);
|
JSONObject jsonObject = new JSONObject(response);
|
||||||
return jsonObject.getString("message");
|
Log.i("TransactionApiHandler",jsonObject.toString());
|
||||||
|
return jsonObject.getString("response");
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.json.JSONObject;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import monnethic.mobile.database.User;
|
import monnethic.mobile.database.User;
|
||||||
|
|
||||||
|
@ -49,16 +50,19 @@ public class UserApiHandler {
|
||||||
|
|
||||||
String responseCall = httpCallHandler.postHttp(new URL(url), map);
|
String responseCall = httpCallHandler.postHttp(new URL(url), map);
|
||||||
JSONObject jsonObject = new JSONObject(responseCall);
|
JSONObject jsonObject = new JSONObject(responseCall);
|
||||||
u.setUser_hash(jsonObject.getString("user_hash"));
|
if(jsonObject.getInt("status")!=200){
|
||||||
|
return jsonObject;
|
||||||
|
} else {
|
||||||
|
System.out.println("OUT OUT OUT / "+jsonObject.toString());
|
||||||
|
u.setUser_hash(jsonObject.getString("user_hash"));
|
||||||
|
JSONObject jsonReturn = new JSONObject();
|
||||||
|
jsonReturn.put("status",200);
|
||||||
|
jsonReturn.put("user_hash",u.getUser_hash());
|
||||||
|
//jsonReturn.put("session_id",jsonObject.getString("session_id")); //TODO
|
||||||
|
jsonReturn.put("session_id",0);
|
||||||
|
|
||||||
|
return jsonReturn;
|
||||||
JSONObject jsonReturn = new JSONObject();
|
}
|
||||||
jsonReturn.put("status",jsonObject.getString("status"));
|
|
||||||
jsonReturn.put("user_hash",u.getUser_hash());
|
|
||||||
//jsonReturn.put("session_id",jsonObject.getString("session_id")); //TODO
|
|
||||||
jsonReturn.put("session_id",jsonObject.getString("0"));
|
|
||||||
|
|
||||||
return jsonReturn;
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package monnethic.mobile.transaction;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -30,6 +31,12 @@ public class MakePayementActivity extends AppCompatActivity {
|
||||||
session_id = intent.getStringExtra("SESSION_ID");
|
session_id = intent.getStringExtra("SESSION_ID");
|
||||||
wallet_hash = intent.getStringExtra("WALLET_HASH");
|
wallet_hash = intent.getStringExtra("WALLET_HASH");
|
||||||
|
|
||||||
|
|
||||||
|
Log.i("UserAccountActivity", "user_hash : "+user_hash);
|
||||||
|
Log.i("UserAccountActivity", "user_password : "+user_password);
|
||||||
|
Log.i("UserAccountActivity", "session_id : "+session_id);
|
||||||
|
Log.i("UserAccountActivity", "wallet_hash : "+wallet_hash);
|
||||||
|
|
||||||
initViews();
|
initViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +49,7 @@ public class MakePayementActivity extends AppCompatActivity {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Intent payementIntent = new Intent(MakePayementActivity.this, QrCodeScannerActivity.class);
|
Intent payementIntent = new Intent(MakePayementActivity.this, QrCodeScannerActivity.class);
|
||||||
payementIntent.putExtra("USER_HASH",user_hash);
|
payementIntent.putExtra("USER_HASH",user_hash);
|
||||||
payementIntent.putExtra("USER_PDW",user_password);
|
payementIntent.putExtra("USER_PWD",user_password);
|
||||||
payementIntent.putExtra("WALLET_HASH",wallet_hash);
|
payementIntent.putExtra("WALLET_HASH",wallet_hash);
|
||||||
payementIntent.putExtra("SESSION_ID",session_id);
|
payementIntent.putExtra("SESSION_ID",session_id);
|
||||||
MakePayementActivity.this.startActivity(payementIntent);
|
MakePayementActivity.this.startActivity(payementIntent);
|
||||||
|
@ -54,7 +61,7 @@ public class MakePayementActivity extends AppCompatActivity {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Intent payementIntent = new Intent(MakePayementActivity.this, TransactionActivity.class);
|
Intent payementIntent = new Intent(MakePayementActivity.this, TransactionActivity.class);
|
||||||
payementIntent.putExtra("USER_HASH",user_hash);
|
payementIntent.putExtra("USER_HASH",user_hash);
|
||||||
payementIntent.putExtra("USER_PDW",user_password);
|
payementIntent.putExtra("USER_PWD",user_password);
|
||||||
payementIntent.putExtra("WALLET_HASH",wallet_hash);
|
payementIntent.putExtra("WALLET_HASH",wallet_hash);
|
||||||
payementIntent.putExtra("SESSION_ID",session_id);
|
payementIntent.putExtra("SESSION_ID",session_id);
|
||||||
MakePayementActivity.this.startActivity(payementIntent);
|
MakePayementActivity.this.startActivity(payementIntent);
|
||||||
|
|
|
@ -68,4 +68,16 @@ public class SendingTransaction {
|
||||||
public void setTransaction_unit(String transaction_unit) {
|
public void setTransaction_unit(String transaction_unit) {
|
||||||
this.transaction_unit = transaction_unit;
|
this.transaction_unit = transaction_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SendingTransaction{" +
|
||||||
|
"source_user_hash='" + source_user_hash + '\'' +
|
||||||
|
", source_user_pwd='" + source_user_pwd + '\'' +
|
||||||
|
", transaction_from='" + transaction_from + '\'' +
|
||||||
|
", transaction_to='" + transaction_to + '\'' +
|
||||||
|
", transaction_amount='" + transaction_amount + '\'' +
|
||||||
|
", transaction_unit='" + transaction_unit + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,12 @@ import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
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.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.example.monnthic.monnethicmobile.R;
|
import com.example.monnthic.monnethicmobile.R;
|
||||||
import com.j256.ormlite.stmt.query.In;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
|
|
||||||
import monnethic.mobile.homepage.InputController;
|
import monnethic.mobile.homepage.InputController;
|
||||||
import monnethic.mobile.restApi.TransactionApiHandler;
|
import monnethic.mobile.restApi.TransactionApiHandler;
|
||||||
|
@ -40,6 +37,11 @@ public class TransactionActivity extends AppCompatActivity {
|
||||||
session_id = intent.getStringExtra("SESSION_ID");
|
session_id = intent.getStringExtra("SESSION_ID");
|
||||||
wallet_hash = intent.getStringExtra("WALLET_HASH");
|
wallet_hash = intent.getStringExtra("WALLET_HASH");
|
||||||
|
|
||||||
|
Log.i("UserAccountActivity", "user_hash : "+user_hash);
|
||||||
|
Log.i("UserAccountActivity", "user_password : "+user_password);
|
||||||
|
Log.i("UserAccountActivity", "session_id : "+session_id);
|
||||||
|
Log.i("UserAccountActivity", "wallet_hash : "+wallet_hash);
|
||||||
|
|
||||||
buttonCancel.setOnClickListener(new View.OnClickListener() {
|
buttonCancel.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -61,8 +63,14 @@ public class TransactionActivity extends AppCompatActivity {
|
||||||
} else if(InputController.isEmptyEdit(amountEditText)) {
|
} else if(InputController.isEmptyEdit(amountEditText)) {
|
||||||
Toast.makeText(this, "No amount", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "No amount", Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
|
System.out.println("HERE");
|
||||||
String wallet_dest = addressDestination.getText().toString();
|
String wallet_dest = addressDestination.getText().toString();
|
||||||
|
System.out.println("wallet_dest : "+wallet_dest);
|
||||||
String amount = amountEditText.getText().toString();
|
String amount = amountEditText.getText().toString();
|
||||||
|
System.out.println("amount : "+amount);
|
||||||
|
System.out.println("user_hash : "+user_hash);
|
||||||
|
System.out.println("user_password : "+user_password);
|
||||||
|
System.out.println("wallet_hash : "+wallet_hash);
|
||||||
SendingTransaction sendingTransaction = new SendingTransaction(user_hash,user_password,wallet_hash,wallet_dest,amount,"gonette");
|
SendingTransaction sendingTransaction = new SendingTransaction(user_hash,user_password,wallet_hash,wallet_dest,amount,"gonette");
|
||||||
try {
|
try {
|
||||||
String transaction_hash = new TransactionTask().execute(sendingTransaction).get();
|
String transaction_hash = new TransactionTask().execute(sendingTransaction).get();
|
||||||
|
@ -71,10 +79,10 @@ public class TransactionActivity extends AppCompatActivity {
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, "couldn't get transaction id", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "couldn't get transaction id", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
finish();
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +98,7 @@ public class TransactionActivity extends AppCompatActivity {
|
||||||
protected String doInBackground(SendingTransaction... sendingTransactions) {
|
protected String doInBackground(SendingTransaction... sendingTransactions) {
|
||||||
try{
|
try{
|
||||||
TransactionApiHandler transactionApiHandler = new TransactionApiHandler();
|
TransactionApiHandler transactionApiHandler = new TransactionApiHandler();
|
||||||
|
System.out.println("SEND TRANSACTION");
|
||||||
return transactionApiHandler.doTransaction(sendingTransactions[0]);
|
return transactionApiHandler.doTransaction(sendingTransactions[0]);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class UserAccountActivity extends AppCompatActivity {
|
||||||
public void sendPayement(){
|
public void sendPayement(){
|
||||||
Intent payementIntent = new Intent(UserAccountActivity.this, MakePayementActivity.class);
|
Intent payementIntent = new Intent(UserAccountActivity.this, MakePayementActivity.class);
|
||||||
payementIntent.putExtra("USER_HASH",user_hash);
|
payementIntent.putExtra("USER_HASH",user_hash);
|
||||||
payementIntent.putExtra("USER_PDW",user_password);
|
payementIntent.putExtra("USER_PWD",user_password);
|
||||||
payementIntent.putExtra("WALLET_HASH",wallet_hash);
|
payementIntent.putExtra("WALLET_HASH",wallet_hash);
|
||||||
payementIntent.putExtra("SESSION_ID",session_id);
|
payementIntent.putExtra("SESSION_ID",session_id);
|
||||||
UserAccountActivity.this.startActivity(payementIntent);
|
UserAccountActivity.this.startActivity(payementIntent);
|
||||||
|
@ -102,7 +102,7 @@ public class UserAccountActivity extends AppCompatActivity {
|
||||||
public void receivePayement(){
|
public void receivePayement(){
|
||||||
Intent receivePayementIntent = new Intent(UserAccountActivity.this, ReceivePayementActivity.class);
|
Intent receivePayementIntent = new Intent(UserAccountActivity.this, ReceivePayementActivity.class);
|
||||||
receivePayementIntent.putExtra("USER_HASH",user_hash);
|
receivePayementIntent.putExtra("USER_HASH",user_hash);
|
||||||
receivePayementIntent.putExtra("USER_PDW",user_password);
|
receivePayementIntent.putExtra("USER_PWD",user_password);
|
||||||
receivePayementIntent.putExtra("WALLET_HASH",wallet_hash);
|
receivePayementIntent.putExtra("WALLET_HASH",wallet_hash);
|
||||||
receivePayementIntent.putExtra("SESSION_ID",session_id);
|
receivePayementIntent.putExtra("SESSION_ID",session_id);
|
||||||
UserAccountActivity.this.startActivity(receivePayementIntent);
|
UserAccountActivity.this.startActivity(receivePayementIntent);
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
android:text="Cancel" />
|
android:text="Cancel" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/buttonOk"
|
android:id="@+id/buttonOkLogin"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignTop="@+id/buttonCancel"
|
android:layout_alignTop="@+id/buttonCancel"
|
||||||
|
|
Loading…
Reference in a new issue