This commit is contained in:
GME 2019-06-14 15:46:45 +02:00
parent 259df4c00b
commit 32f5d4c99b
15 changed files with 371 additions and 271 deletions

View file

@ -35,6 +35,7 @@ import monnethic.mobile.restApi.TransactionApiHandler;
import monnethic.mobile.transaction.TransactionAdapter; import monnethic.mobile.transaction.TransactionAdapter;
public class HistoryActivity extends AppCompatActivity { public class HistoryActivity extends AppCompatActivity {
private ArrayList<Transaction> receivedT;
private String wallet_hash; private String wallet_hash;
private String user_hash; private String user_hash;
private String user_password; private String user_password;
@ -65,18 +66,39 @@ public class HistoryActivity extends AppCompatActivity {
user_password = intent.getStringExtra("USER_PWD"); user_password = intent.getStringExtra("USER_PWD");
session_id = intent.getStringExtra("SESSION_ID"); session_id = intent.getStringExtra("SESSION_ID");
wallet_hash = intent.getStringExtra("WALLET_HASH"); wallet_hash = intent.getStringExtra("WALLET_HASH");
receivedT = (ArrayList<Transaction>) intent.getSerializableExtra("data");
} }
private void initView(){ private void initView(){
inputSize = findViewById(R.id.inputSize); inputSize = findViewById(R.id.inputSize);
listView = findViewById(R.id.listViewTransactions);
inputSize.setText(String.valueOf(10)); inputSize.setText(String.valueOf(10));
dateInit(); dateInit();
buttonInit(); buttonInit();
switchInit(); switchInit();
spinnerInit(); spinnerInit();
listViewHandler("0"); initListView();
} }
private void initListView(){
TransactionAdapter adapter = new TransactionAdapter(HistoryActivity.this,receivedT,wallet_hash);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Transaction t = (Transaction) listView.getItemAtPosition(i);
Intent transactionDetailsIntent = new Intent(HistoryActivity.this, HistoryDetailsActivity.class);
transactionDetailsIntent.putExtra("USER_HASH",user_hash);
transactionDetailsIntent.putExtra("USER_PWD",user_password);
transactionDetailsIntent.putExtra("SESSION_ID",session_id);
transactionDetailsIntent.putExtra("WALLET_HASH",wallet_hash);
transactionDetailsIntent.putExtra("TRANSACTION",t);
HistoryActivity.this.startActivity(transactionDetailsIntent);
}
});
}
public void dateInit(){ public void dateInit(){
DatePickerDialog.OnDateSetListener fromDatePicker = new DatePickerDialog.OnDateSetListener() { DatePickerDialog.OnDateSetListener fromDatePicker = new DatePickerDialog.OnDateSetListener() {
@Override @Override

View file

@ -121,14 +121,6 @@ public class LoginActivity extends AppCompatActivity {
walletHomeIntent.putExtra("email",email.getText().toString()); walletHomeIntent.putExtra("email",email.getText().toString());
Boolean approved = new CheckApprovalTask().execute(jsonObject.getString("user_hash"),email.getText().toString()).get(); Boolean approved = new CheckApprovalTask().execute(jsonObject.getString("user_hash"),email.getText().toString()).get();
walletHomeIntent.putExtra("approved", approved.toString()); walletHomeIntent.putExtra("approved", approved.toString());
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
email.setEnabled(true);
password.setEnabled(true);
buttonCancel.setEnabled(true);
buttonOk.setEnabled(true);
LoginActivity.this.startActivity(walletHomeIntent); LoginActivity.this.startActivity(walletHomeIntent);
finish(); finish();
} else { } else {

View file

@ -149,7 +149,10 @@ public class RegisterActivity extends AppCompatActivity {
walletHomeIntent.putExtra("SESSION_ID",jsonObject.getString("session_id")); walletHomeIntent.putExtra("SESSION_ID",jsonObject.getString("session_id"));
walletHomeIntent.putExtra("email",email.getText().toString()); walletHomeIntent.putExtra("email",email.getText().toString());
walletHomeIntent.putExtra("approved","false"); walletHomeIntent.putExtra("approved","false");
RegisterActivity.this.startActivity(walletHomeIntent);
finish();
}else{
Toast.makeText(mContext, "AN ERROR OCCURED", Toast.LENGTH_SHORT).show();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE); progress.setVisibility(View.GONE);
name.setEnabled(true); name.setEnabled(true);
@ -161,16 +164,20 @@ public class RegisterActivity extends AppCompatActivity {
confirmPassword.setEnabled(true); confirmPassword.setEnabled(true);
buttonCancel.setEnabled(true); buttonCancel.setEnabled(true);
buttonOk.setEnabled(true); buttonOk.setEnabled(true);
RegisterActivity.this.startActivity(walletHomeIntent);
finish();
}else{
Toast.makeText(mContext, "AN ERROR OCCURED", Toast.LENGTH_SHORT).show();
} }
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
name.setEnabled(true);
firstname.setEnabled(true);
email.setEnabled(true);
confirmEmail.setEnabled(true);
phone.setEnabled(true);
password.setEnabled(true);
confirmPassword.setEnabled(true);
buttonCancel.setEnabled(true);
buttonOk.setEnabled(true);
} }
} }

View file

@ -24,6 +24,7 @@ public class TransactionApiHandler {
map.put("transaction_amount",sendingTransaction.getTransaction_amount()); map.put("transaction_amount",sendingTransaction.getTransaction_amount());
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);
System.out.println("TRANSACTION: "+response);
JSONObject jsonObject = new JSONObject(response); JSONObject jsonObject = new JSONObject(response);
return jsonObject.getString("response"); return jsonObject.getString("response");
}catch (Exception e){ }catch (Exception e){

View file

@ -45,40 +45,6 @@ public class DisplayWalletSearch extends AppCompatActivity {
}); });
} }
/*
private class SearchWalletTask extends AsyncTask<String,String,ArrayList<Wallet>> {
ProgressDialog progDailog = new ProgressDialog(DisplayWalletSearch.this);
@Override
protected void onPreExecute() {
super.onPreExecute();
progDailog.setMessage("Searching user wallets...");
progDailog.setIndeterminate(false);
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progDailog.setCancelable(true);
progDailog.show();
}
@Override
protected void onPostExecute(ArrayList<Wallet> listWallet) {
progDailog.dismiss();
}
@Override
protected ArrayList<Wallet> doInBackground(String... strings) {
ArrayList<Wallet> walletsList = new ArrayList<>();
try{
WalletApiHandler walletApiHandler = new WalletApiHandler();
walletsList = walletApiHandler.getUserWallets(strings);
}catch (Exception e){
e.printStackTrace();
}
return walletsList;
}
}
*/
@Override @Override
protected void onStop() { protected void onStop() {
super.onStop(); // Always call the superclass method first super.onStop(); // Always call the superclass method first

View file

@ -112,19 +112,10 @@ public class SearchUser extends AppCompatActivity {
for(Wallet w : wallets){ for(Wallet w : wallets){
displayWallets.add(new DisplayWallet(u_dest_n,u_dest_fn,w.getWallet_hash(),w.getType())); displayWallets.add(new DisplayWallet(u_dest_n,u_dest_fn,w.getWallet_hash(),w.getType()));
} }
Intent displayWalletIntent = new Intent(SearchUser.this, DisplayWalletSearch.class); Intent displayWalletIntent = new Intent(SearchUser.this, DisplayWalletSearch.class);
displayWalletIntent.putExtra("data",displayWallets); displayWalletIntent.putExtra("data",displayWallets);
displayWalletIntent.putExtra("SESSION_ID",session_id); displayWalletIntent.putExtra("SESSION_ID",session_id);
displayWalletIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); displayWalletIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
emailAddress.setEnabled(true);
phoneNumber.setEnabled(true);
buttonCancel.setEnabled(true);
buttonOk.setEnabled(true);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
SearchUser.this.startActivity(displayWalletIntent); SearchUser.this.startActivity(displayWalletIntent);
finish(); finish();
}else{ }else{

View file

@ -310,17 +310,6 @@ public class SettingsActivity extends AppCompatActivity {
@Override @Override
protected void onPostExecute(String v) { protected void onPostExecute(String v) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
currentPassword.setEnabled(true);
newPassword.setEnabled(true);
confirmedNewPassword.setEnabled(true);
buttonCancel.setEnabled(true);
buttonConfirm.setEnabled(true);
enableChangePassword.setEnabled(true);
enableChangePassword.setChecked(false);
if(Boolean.parseBoolean(v)){ if(Boolean.parseBoolean(v)){
Toast.makeText(SettingsActivity.this,"Password updated",Toast.LENGTH_SHORT).show(); Toast.makeText(SettingsActivity.this,"Password updated",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(); Intent intent = new Intent();
@ -329,9 +318,18 @@ public class SettingsActivity extends AppCompatActivity {
finish(); finish();
}else{ }else{
Toast.makeText(SettingsActivity.this,"An error occured",Toast.LENGTH_SHORT).show(); Toast.makeText(SettingsActivity.this,"An error occured",Toast.LENGTH_SHORT).show();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
currentPassword.setEnabled(true);
newPassword.setEnabled(true);
confirmedNewPassword.setEnabled(true);
buttonCancel.setEnabled(true);
buttonConfirm.setEnabled(true);
enableChangePassword.setEnabled(true);
enableChangePassword.setChecked(false);
} }
} }
} }
@ -369,17 +367,6 @@ public class SettingsActivity extends AppCompatActivity {
@Override @Override
protected void onPostExecute(String v) { protected void onPostExecute(String v) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
walletToDelete.setEnabled(true);
walletToTransfer.setEnabled(true);
confirmWalletToDelete.setEnabled(true);
buttonCancel.setEnabled(true);
buttonConfirm.setEnabled(true);
enableDeleteWallet.setEnabled(true);
enableDeleteWallet.setChecked(false);
if(Boolean.parseBoolean(v)){ if(Boolean.parseBoolean(v)){
Toast.makeText(SettingsActivity.this,"Wallet has been deleted",Toast.LENGTH_SHORT).show(); Toast.makeText(SettingsActivity.this,"Wallet has been deleted",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(); Intent intent = new Intent();
@ -388,6 +375,16 @@ public class SettingsActivity extends AppCompatActivity {
finish(); finish();
}else{ }else{
Toast.makeText(SettingsActivity.this,"An error occured",Toast.LENGTH_SHORT).show(); Toast.makeText(SettingsActivity.this,"An error occured",Toast.LENGTH_SHORT).show();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
walletToDelete.setEnabled(true);
walletToTransfer.setEnabled(true);
confirmWalletToDelete.setEnabled(true);
buttonCancel.setEnabled(true);
buttonConfirm.setEnabled(true);
enableDeleteWallet.setEnabled(true);
enableDeleteWallet.setChecked(false);
} }
} }
@ -433,33 +430,32 @@ public class SettingsActivity extends AppCompatActivity {
@Override @Override
protected void onPostExecute(String v) { protected void onPostExecute(String v) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
currentPassword.setEnabled(true);
newPassword.setEnabled(true);
confirmedNewPassword.setEnabled(true);
buttonCancel.setEnabled(true);
buttonConfirm.setEnabled(true);
enableChangePassword.setEnabled(true);
enableChangePassword.setChecked(false);
walletToDelete.setEnabled(true);
walletToTransfer.setEnabled(true);
confirmWalletToDelete.setEnabled(true);
buttonCancel.setEnabled(true);
buttonConfirm.setEnabled(true);
enableDeleteWallet.setEnabled(true);
enableDeleteWallet.setChecked(false);
if(Boolean.parseBoolean(v)){ if(Boolean.parseBoolean(v)){
Toast.makeText(SettingsActivity.this,"Password updated & Wallet deleted",Toast.LENGTH_SHORT).show(); Toast.makeText(SettingsActivity.this,"Password updated & Wallet deleted",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra("new_password",user_password); intent.putExtra("new_password",newPassword.getText().toString());
setResult(1,intent); setResult(1,intent);
finish(); finish();
}else{ }else{
Toast.makeText(SettingsActivity.this,"An error occured",Toast.LENGTH_SHORT).show(); Toast.makeText(SettingsActivity.this,"An error occured",Toast.LENGTH_SHORT).show();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
currentPassword.setEnabled(true);
newPassword.setEnabled(true);
confirmedNewPassword.setEnabled(true);
buttonCancel.setEnabled(true);
buttonConfirm.setEnabled(true);
enableChangePassword.setEnabled(true);
enableChangePassword.setChecked(false);
walletToDelete.setEnabled(true);
walletToTransfer.setEnabled(true);
confirmWalletToDelete.setEnabled(true);
buttonCancel.setEnabled(true);
buttonConfirm.setEnabled(true);
enableDeleteWallet.setEnabled(true);
enableDeleteWallet.setChecked(false);
} }
} }

View file

@ -97,10 +97,6 @@ public class ApprovePayementActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(ApprovePayementActivity.this, "Couldn't get transaction id", Toast.LENGTH_SHORT).show(); Toast.makeText(ApprovePayementActivity.this, "Couldn't get transaction id", Toast.LENGTH_SHORT).show();
} }
buttonCancel.setEnabled(true);
buttonVal.setEnabled(true);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
finish(); finish();
} }

View file

@ -83,9 +83,8 @@ public class TransactionActivity extends AppCompatActivity {
} else { } else {
String wallet_dest = addressDestination.getText().toString(); String wallet_dest = addressDestination.getText().toString();
String amount = amountEditText.getText().toString(); String amount = amountEditText.getText().toString();
SendingTransaction sendingTransaction = new SendingTransaction(user_hash,user_password,wallet_hash,wallet_dest,amount,"gonette");
try { try {
new TransactionTask().execute(sendingTransaction); new TransactionTask().execute(new SendingTransaction(user_hash,user_password,wallet_hash,wallet_dest,amount,"gonette"));
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -128,6 +127,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("TRANSACTION: "+sendingTransactions[0].toString());
return transactionApiHandler.doTransaction(sendingTransactions[0]); return transactionApiHandler.doTransaction(sendingTransactions[0]);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
@ -142,13 +142,6 @@ public class TransactionActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(TransactionActivity.this, "Couldn't get transaction id", Toast.LENGTH_SHORT).show(); Toast.makeText(TransactionActivity.this, "Couldn't get transaction id", Toast.LENGTH_SHORT).show();
} }
buttonCancel.setEnabled(true);
buttonOk.setEnabled(true);
buttonSearch.setEnabled(true);
amountEditText.setEnabled(true);
addressDestination.setEnabled(true);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
finish(); finish();
} }
} }

View file

@ -5,13 +5,20 @@ 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;
import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.example.monnthic.monnethicmobile.R; import com.example.monnthic.monnethicmobile.R;
import java.util.ArrayList;
import monnethic.mobile.database.Transaction;
import monnethic.mobile.history.HistoryActivity; import monnethic.mobile.history.HistoryActivity;
import monnethic.mobile.restApi.Config;
import monnethic.mobile.restApi.SessionApiHandler; import monnethic.mobile.restApi.SessionApiHandler;
import monnethic.mobile.restApi.TransactionApiHandler;
import monnethic.mobile.restApi.WalletApiHandler; import monnethic.mobile.restApi.WalletApiHandler;
import monnethic.mobile.settings.SettingsActivity; import monnethic.mobile.settings.SettingsActivity;
import monnethic.mobile.transaction.MakePayementActivity; import monnethic.mobile.transaction.MakePayementActivity;
@ -23,6 +30,10 @@ public class UserAccountActivity extends AppCompatActivity {
private String user_hash; private String user_hash;
private String user_password; private String user_password;
private String session_id; private String session_id;
private Button buttonPayement;
private Button buttonReceive;
private Button buttonRefresh;
private Button buttonHistory;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -30,11 +41,11 @@ public class UserAccountActivity extends AppCompatActivity {
setContentView(R.layout.activity_user_account); setContentView(R.layout.activity_user_account);
balance = findViewById(R.id.balanceView); balance = findViewById(R.id.balanceView);
TextView walletHashView = findViewById(R.id.walletHash); TextView walletHashView = findViewById(R.id.walletHash);
Button buttonPayement = findViewById(R.id.buttonPayement); buttonPayement = findViewById(R.id.buttonPayement);
Button buttonReceive = findViewById(R.id.buttonReceive); buttonReceive = findViewById(R.id.buttonReceive);
Button buttonRefresh = findViewById(R.id.buttonRefreshBalance); buttonRefresh = findViewById(R.id.buttonRefreshBalance);
Button buttonHistory = findViewById(R.id.goToHistory); buttonHistory = findViewById(R.id.goToHistory);
Intent intent = getIntent(); Intent intent = getIntent();
user_hash = intent.getStringExtra("USER_HASH"); user_hash = intent.getStringExtra("USER_HASH");
@ -94,16 +105,10 @@ public class UserAccountActivity extends AppCompatActivity {
} }
public void history(){ public void history(){
Intent historyIntent = new Intent(UserAccountActivity.this, HistoryActivity.class); new GetUserHistoryTask().execute();
historyIntent.putExtra("USER_HASH",user_hash);
historyIntent.putExtra("USER_PWD",user_password);
historyIntent.putExtra("WALLET_HASH",wallet_hash);
historyIntent.putExtra("SESSION_ID",session_id);
UserAccountActivity.this.startActivity(historyIntent);
} }
public class GetUserBalanceTask extends AsyncTask<String,String,Double> public class GetUserBalanceTask extends AsyncTask<String,String,Double> {
{
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
@ -135,6 +140,57 @@ public class UserAccountActivity extends AppCompatActivity {
} }
} }
public class GetUserHistoryTask extends AsyncTask<String,Void,ArrayList<Transaction>>{
RelativeLayout progress = findViewById(R.id.progressLayout);
@Override
protected void onPreExecute() {
super.onPreExecute();
buttonPayement.setEnabled(false);
buttonReceive.setEnabled(false);
buttonRefresh.setEnabled(false);
buttonHistory.setEnabled(false);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.VISIBLE);
}
@Override
protected void onPostExecute(ArrayList<Transaction> transactions) {
Intent historyIntent = new Intent(UserAccountActivity.this, HistoryActivity.class);
historyIntent.putExtra("USER_HASH",user_hash);
historyIntent.putExtra("USER_PWD",user_password);
historyIntent.putExtra("WALLET_HASH",wallet_hash);
historyIntent.putExtra("SESSION_ID",session_id);
historyIntent.putExtra("data",transactions);
UserAccountActivity.this.startActivity(historyIntent);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
buttonPayement.setEnabled(true);
buttonReceive.setEnabled(true);
buttonRefresh.setEnabled(true);
buttonHistory.setEnabled(true);
}
@Override
protected ArrayList<Transaction> doInBackground(String... strings) {
ArrayList<Transaction> transactionsList = new ArrayList<>();
try{
TransactionApiHandler transactionApiHandler = new TransactionApiHandler();
transactionsList = transactionApiHandler.getTransactions("0",Config.TRANSACTION_LATEST,wallet_hash,null,null,null);
System.out.println("RECEIVED_T "+transactionsList.toString());
}catch (Exception e){
e.printStackTrace();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
buttonPayement.setEnabled(true);
buttonReceive.setEnabled(true);
buttonRefresh.setEnabled(true);
buttonHistory.setEnabled(true);
}
return transactionsList;
}
}
@Override @Override
protected void onStop() { protected void onStop() {
super.onStop(); // Always call the superclass method first super.onStop(); // Always call the superclass method first

View file

@ -89,18 +89,10 @@ public class CreateWalletActivity extends AppCompatActivity {
accountIntent.putExtra("WALLET_HASH",w.getWallet_hash()); accountIntent.putExtra("WALLET_HASH",w.getWallet_hash());
accountIntent.putExtra("WALLET_BALANCE",String.valueOf(w.getBalance())); accountIntent.putExtra("WALLET_BALANCE",String.valueOf(w.getBalance()));
accountIntent.putExtra("WALLET_TYPE",w.getType()); accountIntent.putExtra("WALLET_TYPE",w.getType());
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE);
buttonValidate.setEnabled(true);
buttonCancel.setEnabled(true);
wallet_type.setEnabled(true);
CreateWalletActivity.this.startActivity(accountIntent); CreateWalletActivity.this.startActivity(accountIntent);
finish(); finish();
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE); progress.setVisibility(View.GONE);
buttonValidate.setEnabled(true); buttonValidate.setEnabled(true);

View file

@ -49,6 +49,7 @@ public class HomeWalletActivity extends AppCompatActivity {
Intent intent = getIntent(); Intent intent = getIntent();
user_hash = intent.getStringExtra("USER_HASH"); user_hash = intent.getStringExtra("USER_HASH");
user_password = intent.getStringExtra("USER_PWD"); user_password = intent.getStringExtra("USER_PWD");
System.out.println("USER_PWD: "+user_password);
session_id = intent.getStringExtra("SESSION_ID"); session_id = intent.getStringExtra("SESSION_ID");
email = intent.getStringExtra("email"); email = intent.getStringExtra("email");
approved = Boolean.parseBoolean(intent.getStringExtra("approved")); approved = Boolean.parseBoolean(intent.getStringExtra("approved"));
@ -132,12 +133,9 @@ public class HomeWalletActivity extends AppCompatActivity {
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){ protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
System.out.println("HERE"); user_password = data.getStringExtra("new_password");
if(requestCode==1){
user_password = data.getStringExtra("new_password");
}
System.out.println("NEW_PWD "+user_password);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
System.out.println("USER_PWD: "+user_password);
buttonCreateWallet.setEnabled(true); buttonCreateWallet.setEnabled(true);
buttonSelectWallet.setEnabled(true); buttonSelectWallet.setEnabled(true);
buttonSettings.setEnabled(true); buttonSettings.setEnabled(true);
@ -199,6 +197,7 @@ public class HomeWalletActivity extends AppCompatActivity {
selectWalletIntent.putExtra("USER_PWD",user_password); selectWalletIntent.putExtra("USER_PWD",user_password);
selectWalletIntent.putExtra("SESSION_ID",session_id); selectWalletIntent.putExtra("SESSION_ID",session_id);
selectWalletIntent.putExtra("data",listWallet); selectWalletIntent.putExtra("data",listWallet);
HomeWalletActivity.this.startActivity(selectWalletIntent);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE); progress.setVisibility(View.GONE);
@ -206,8 +205,6 @@ public class HomeWalletActivity extends AppCompatActivity {
buttonSelectWallet.setEnabled(true); buttonSelectWallet.setEnabled(true);
buttonSettings.setEnabled(true); buttonSettings.setEnabled(true);
buttonApproveUser.setEnabled(true); buttonApproveUser.setEnabled(true);
HomeWalletActivity.this.startActivity(selectWalletIntent);
}else { }else {
Toast.makeText(HomeWalletActivity.this,"You don't have wallets",Toast.LENGTH_SHORT).show(); Toast.makeText(HomeWalletActivity.this,"You don't have wallets",Toast.LENGTH_SHORT).show();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
@ -258,6 +255,7 @@ public class HomeWalletActivity extends AppCompatActivity {
settingsIntent.putExtra("USER_PWD",user_password); settingsIntent.putExtra("USER_PWD",user_password);
settingsIntent.putExtra("SESSION_ID",session_id); settingsIntent.putExtra("SESSION_ID",session_id);
settingsIntent.putExtra("data",listWallet); settingsIntent.putExtra("data",listWallet);
HomeWalletActivity.this.startActivityForResult(settingsIntent,1);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
progress.setVisibility(View.GONE); progress.setVisibility(View.GONE);
@ -265,8 +263,6 @@ public class HomeWalletActivity extends AppCompatActivity {
buttonSelectWallet.setEnabled(true); buttonSelectWallet.setEnabled(true);
buttonSettings.setEnabled(true); buttonSettings.setEnabled(true);
buttonApproveUser.setEnabled(true); buttonApproveUser.setEnabled(true);
HomeWalletActivity.this.startActivityForResult(settingsIntent,1);
} }
} }
private class ApproveTask extends AsyncTask<String,String,String>{ private class ApproveTask extends AsyncTask<String,String,String>{

View file

@ -19,16 +19,17 @@ public class SelectWalletActivity extends AppCompatActivity {
private String user_hash; private String user_hash;
private String user_password; private String user_password;
private String session_id; private String session_id;
private ListView listView;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_wallet); setContentView(R.layout.activity_select_wallet);
Intent intent = getIntent(); Intent intent = getIntent();
user_hash = intent.getStringExtra("USER_HASH"); user_hash = intent.getStringExtra("USER_HASH");
user_password = intent.getStringExtra("USER_PWD"); user_password = intent.getStringExtra("USER_PWD");
session_id = intent.getStringExtra("SESSION_ID"); session_id = intent.getStringExtra("SESSION_ID");
listView = (ListView) findViewById(R.id.listViewWallet);
try{ try{
userWallets = (ArrayList<Wallet>) intent.getSerializableExtra("data"); userWallets = (ArrayList<Wallet>) intent.getSerializableExtra("data");
}catch (Exception e){ }catch (Exception e){
@ -52,6 +53,10 @@ public class SelectWalletActivity extends AppCompatActivity {
}); });
} }
private void updateWalletList(){
new getUserWalletTask().execute(user_hash);
}
public void launchAcountActivity(Wallet w) { public void launchAcountActivity(Wallet w) {
Intent accountIntent = new Intent(SelectWalletActivity.this, UserAccountActivity.class); Intent accountIntent = new Intent(SelectWalletActivity.this, UserAccountActivity.class);
accountIntent.putExtra("USER_HASH",user_hash); accountIntent.putExtra("USER_HASH",user_hash);
@ -63,6 +68,36 @@ public class SelectWalletActivity extends AppCompatActivity {
SelectWalletActivity.this.startActivity(accountIntent); SelectWalletActivity.this.startActivity(accountIntent);
} }
//AsyncTask to get user wallets
private class getUserWalletTask extends AsyncTask<String,ArrayList<Wallet>,ArrayList<Wallet>> {
@Override
protected ArrayList<Wallet> doInBackground(String... params) {
ArrayList<Wallet> walletsList = new ArrayList<>();
try{
WalletApiHandler walletApiHandler = new WalletApiHandler();
walletsList = walletApiHandler.getUserWallets(params);
}catch (Exception e){
e.printStackTrace();
}
return walletsList;
}
@Override
protected void onPostExecute(ArrayList<Wallet> listWallet) {
if(listWallet!=null && !listWallet.isEmpty()){
WalletAdapter adapter = new WalletAdapter(SelectWalletActivity.this,listWallet);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Wallet w = (Wallet) listView.getItemAtPosition(i);
launchAcountActivity(w);
}
});
}
}
}
private class EndSessionTask extends AsyncTask<String,Void,Void> { private class EndSessionTask extends AsyncTask<String,Void,Void> {
@Override @Override
protected Void doInBackground(String... strings) { protected Void doInBackground(String... strings) {
@ -76,6 +111,7 @@ public class SelectWalletActivity extends AppCompatActivity {
} }
} }
@Override @Override
protected void onStop() { protected void onStop() {
super.onStop(); // Always call the superclass method first super.onStop(); // Always call the superclass method first
@ -85,6 +121,6 @@ public class SelectWalletActivity extends AppCompatActivity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
setupWallet(); updateWalletList();
} }
} }

View file

@ -37,136 +37,150 @@
android:textColor="@android:color/black" /> android:textColor="@android:color/black" />
</RelativeLayout> </RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:fillViewport="true">
<LinearLayout <LinearLayout
android:id="@+id/l1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginTop="90dp"
android:background="@android:color/darker_gray"
android:orientation="vertical"> android:orientation="vertical">
<Switch <LinearLayout
android:id="@+id/switchChangePassword" android:id="@+id/l1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Password : "
android:textSize="18sp"
android:textStyle="bold" />
<EditText
android:id="@+id/currentPwd"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_alignParentStart="true"
android:ems="10" android:layout_alignParentTop="true"
android:hint="Current Password" android:layout_marginStart="0dp"
android:inputType="textPassword" /> android:layout_marginTop="90dp"
android:background="@android:color/darker_gray"
android:orientation="vertical">
<EditText <Switch
android:id="@+id/newPwd1" android:id="@+id/switchChangePassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Password : "
android:textSize="18sp"
android:textStyle="bold" />
<EditText
android:id="@+id/currentPwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:ems="10"
android:hint="Current Password"
android:inputType="textPassword" />
<EditText
android:id="@+id/newPwd1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:ems="10"
android:hint="New Password"
android:inputType="textPassword" />
<EditText
android:id="@+id/newPwd2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:ems="10"
android:hint="Confirm New Password"
android:inputType="textPassword" />
</LinearLayout>
<LinearLayout
android:id="@+id/l2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_below="@+id/l1"
android:ems="10" android:layout_alignParentStart="true"
android:hint="New Password" android:layout_marginStart="0dp"
android:inputType="textPassword" /> android:layout_marginTop="20dp"
android:background="@android:color/darker_gray"
android:orientation="vertical">
<EditText <Switch
android:id="@+id/newPwd2" android:id="@+id/switchDeleteWallet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete Wallet : "
android:textColor="@android:color/holo_red_light"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Wallet to delete :"
android:textSize="18sp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinnerWalletToDelete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp" />
<EditText
android:id="@+id/editTextConfirmDeleteWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:ems="10"
android:hint="Confirm wallet to delete"
android:inputType="textPersonName"
android:textColor="@android:color/holo_red_light" />
<TextView
android:id="@+id/textView17"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Wallet to transfer fund :"
android:textSize="18sp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinnerWalletToMoveFund"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_below="@+id/l2"
android:ems="10" android:layout_alignParentStart="true"
android:hint="Confirm New Password" android:layout_marginStart="0dp"
android:inputType="textPassword" /> android:layout_marginTop="25dp"
</LinearLayout> android:orientation="horizontal">
<Button
<LinearLayout android:id="@+id/buttonCancelSettings"
android:id="@+id/l2" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:layout_below="@+id/l1" android:text="Cancel" />
android:layout_alignParentStart="true"
android:layout_marginStart="0dp" <Button
android:layout_marginTop="20dp" android:id="@+id/buttonConfirmSettings"
android:background="@android:color/darker_gray" android:layout_width="wrap_content"
android:orientation="vertical"> android:layout_height="wrap_content"
android:layout_weight="1"
<Switch android:text="Confirm" />
android:id="@+id/switchDeleteWallet" </LinearLayout>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete Wallet : "
android:textColor="@android:color/holo_red_light"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Wallet to delete :"
android:textSize="18sp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinnerWalletToDelete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp" />
<EditText
android:id="@+id/editTextConfirmDeleteWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:ems="10"
android:hint="Confirm wallet to delete"
android:inputType="textPersonName"
android:textColor="@android:color/holo_red_light" />
<TextView
android:id="@+id/textView17"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Wallet to transfer fund :"
android:textSize="18sp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinnerWalletToMoveFund"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/l2"
android:layout_alignParentStart="true"
android:layout_marginStart="0dp"
android:layout_marginTop="25dp"
android:orientation="horizontal">
<Button
android:id="@+id/buttonCancelSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel" />
<Button
android:id="@+id/buttonConfirmSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Confirm" />
</LinearLayout> </LinearLayout>
</ScrollView>
</RelativeLayout> </RelativeLayout>

View file

@ -1,14 +1,56 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <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:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_height="wrap_content"> android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/progressLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:background="@color/gray_transparent"
android:elevation="1dp"
android:gravity="center"
android:visibility="gone">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:indeterminate="true"
android:max="100"
android:visibility="visible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="2dp"
android:layout_toEndOf="@+id/progressBar"
android:text="Please wait, Collecting history..."
android:textSize="18dp"
android:textColor="@android:color/black" />
</RelativeLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:layout_marginTop="50dp"
android:layout_marginBottom="50dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -61,7 +103,7 @@
android:inputType="none" android:inputType="none"
android:textAlignment="center" android:textAlignment="center"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -100,4 +142,4 @@
android:text="History" /> android:text="History" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </android.support.constraint.ConstraintLayout>