update app mobile
This commit is contained in:
parent
384d9f0aba
commit
dad006937d
|
@ -9,11 +9,15 @@ 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.demoConfig.DemoConfig;
|
||||
|
||||
public class HomepageActivity extends AppCompatActivity {
|
||||
private int clickIterator = 0;
|
||||
Button bConfig;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -21,7 +25,7 @@ public class HomepageActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_homepage);
|
||||
Button bRegister = findViewById(R.id.register);
|
||||
Button bLogin = findViewById(R.id.login);
|
||||
Button bConfig = findViewById(R.id.buttonConfig);
|
||||
bConfig = findViewById(R.id.buttonConfig);
|
||||
|
||||
bRegister.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -41,6 +45,7 @@ public class HomepageActivity extends AppCompatActivity {
|
|||
launchConfActivity();
|
||||
}
|
||||
});
|
||||
bConfig.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void launchRegisterActivity(){
|
||||
|
@ -64,4 +69,15 @@ public class HomepageActivity extends AppCompatActivity {
|
|||
HomepageActivity.this.startActivity(confIntent);
|
||||
}
|
||||
|
||||
public void displayConf(View v){
|
||||
clickIterator++;
|
||||
int clickForDisplay = 6;
|
||||
if(clickIterator>=clickForDisplay){
|
||||
bConfig.setVisibility(View.VISIBLE);
|
||||
}else if(clickIterator>=3){
|
||||
int clickLeft = clickForDisplay-clickIterator;
|
||||
Toast.makeText(HomepageActivity.this, clickLeft+" click left for config", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,14 +92,19 @@ public class LoginActivity extends AppCompatActivity {
|
|||
if(jsonObject!=null){
|
||||
if(jsonObject.getInt("status")==404){
|
||||
Toast.makeText(mContext, "User Not Found", Toast.LENGTH_SHORT).show();
|
||||
progDailog.dismiss();
|
||||
} else if(jsonObject.getInt("status")==403){
|
||||
Toast.makeText(mContext, "Wrong authentication", Toast.LENGTH_SHORT).show();
|
||||
progDailog.dismiss();
|
||||
} else if(jsonObject.getInt("status")==200){
|
||||
Intent walletHomeIntent = new Intent(LoginActivity.this, HomeWalletActivity.class);
|
||||
walletHomeIntent.putExtra("USER_HASH", jsonObject.getString("user_hash"));
|
||||
walletHomeIntent.putExtra("USER_PWD",password.getText().toString());
|
||||
walletHomeIntent.putExtra("SESSION_ID",jsonObject.getString("session_id"));
|
||||
walletHomeIntent.putExtra("email",email.getText().toString());
|
||||
Boolean approved = new CheckApprovalTask().execute(jsonObject.getString("user_hash"),email.getText().toString()).get();
|
||||
walletHomeIntent.putExtra("approved", approved.toString());
|
||||
progDailog.dismiss();
|
||||
LoginActivity.this.startActivity(walletHomeIntent);
|
||||
finish();
|
||||
} else {
|
||||
|
@ -126,4 +131,16 @@ public class LoginActivity extends AppCompatActivity {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
private class CheckApprovalTask extends AsyncTask<String,Boolean,Boolean>{
|
||||
@Override
|
||||
protected Boolean doInBackground(String... strings) {
|
||||
try{
|
||||
UserApiHandler userApiHandler = new UserApiHandler();
|
||||
return userApiHandler.checkApproval(strings[0],strings[1]);
|
||||
}catch (Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,17 +72,11 @@ public class RegisterActivity extends AppCompatActivity {
|
|||
} else {
|
||||
Toast.makeText(this, "An error occured", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkInputEmpty(){
|
||||
Log.i("checkInputEmpty",name.getText().toString());
|
||||
Log.i("checkInputEmpty",firstname.getText().toString());
|
||||
Log.i("checkInputEmpty",email.getText().toString());
|
||||
Log.i("checkInputEmpty",confirmEmail.getText().toString());
|
||||
Log.i("checkInputEmpty",password.getText().toString());
|
||||
if(InputController.isEmptyEdit(name)){
|
||||
Toast.makeText(this, "You did not enter your name", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
|
@ -108,13 +102,13 @@ public class RegisterActivity extends AppCompatActivity {
|
|||
Toast.makeText(this, "You did not confirm your password", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}else {
|
||||
if (!(password.getText().toString().equals(confirmPassword.getText().toString()))) {
|
||||
Toast.makeText(this, "Password don't match confirmation password", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
} else if (!(email.getText().toString().equals(confirmEmail.getText().toString()))) {
|
||||
if (!(email.getText().toString().equals(confirmEmail.getText().toString()))) {
|
||||
Toast.makeText(this, "Email don't match confirmation email", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}else{
|
||||
} else if (!(password.getText().toString().equals(confirmPassword.getText().toString()))) {
|
||||
Toast.makeText(this, "Password don't match confirmation password", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
} else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -122,12 +116,12 @@ public class RegisterActivity extends AppCompatActivity {
|
|||
|
||||
private class UserRegisterTask extends AsyncTask<User,Void,JSONObject> {
|
||||
Context mContext;
|
||||
ProgressDialog progDailog = new ProgressDialog(RegisterActivity.this);
|
||||
private UserRegisterTask(final Context context){mContext=context;}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
ProgressDialog progDailog = new ProgressDialog(RegisterActivity.this);
|
||||
progDailog.setMessage("Register...");
|
||||
progDailog.setIndeterminate(false);
|
||||
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
|
@ -144,13 +138,17 @@ public class RegisterActivity extends AppCompatActivity {
|
|||
walletHomeIntent.putExtra("USER_PWD",password.getText().toString());
|
||||
walletHomeIntent.putExtra("SESSION_ID",jsonObject.getString("session_id"));
|
||||
walletHomeIntent.putExtra("email",email.getText().toString());
|
||||
walletHomeIntent.putExtra("approved","false");
|
||||
progDailog.dismiss();
|
||||
RegisterActivity.this.startActivity(walletHomeIntent);
|
||||
finish();
|
||||
}else{
|
||||
Toast.makeText(mContext, "AN ERROR OCCURED", Toast.LENGTH_SHORT).show();
|
||||
progDailog.dismiss();
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
progDailog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class QrCodeScannerActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void initialiseDetector(){
|
||||
Toast.makeText(getApplicationContext(), "QR code scanner started", Toast.LENGTH_SHORT).show();
|
||||
//Toast.makeText(getApplicationContext(), "QR code scanner started", Toast.LENGTH_SHORT).show();
|
||||
|
||||
barcodeDector = new BarcodeDetector.Builder(this).setBarcodeFormats(Barcode.ALL_FORMATS).build();
|
||||
cameraSource = new CameraSource.Builder(this, barcodeDector).setRequestedPreviewSize(1920,1080).setAutoFocusEnabled(true).build();
|
||||
|
@ -63,7 +63,7 @@ public class QrCodeScannerActivity extends AppCompatActivity {
|
|||
cameraSource.start(surfaceView.getHolder());
|
||||
}else{
|
||||
ActivityCompat.requestPermissions(QrCodeScannerActivity.this, new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSION);
|
||||
onResume();
|
||||
onRestart();
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.getMessage();
|
||||
|
@ -84,7 +84,7 @@ public class QrCodeScannerActivity extends AppCompatActivity {
|
|||
barcodeDector.setProcessor(new Detector.Processor<Barcode>() {
|
||||
@Override
|
||||
public void release() {
|
||||
Toast.makeText(getApplicationContext(),"Barcode scanner has been stopped",Toast.LENGTH_SHORT).show();
|
||||
//Toast.makeText(getApplicationContext(),"Barcode scanner has been stopped",Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,12 +111,14 @@ public class QrCodeScannerActivity extends AppCompatActivity {
|
|||
cameraSource.release();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume(){
|
||||
super.onResume();
|
||||
initialiseDetector();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop(); // Always call the superclass method first
|
||||
|
|
|
@ -92,7 +92,6 @@ public class SearchUser extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onPostExecute(User user) {
|
||||
try{
|
||||
progDailog.dismiss();
|
||||
if(user!=null){
|
||||
Intent displayWalletIntent = new Intent(SearchUser.this, DisplayWalletSearch.class);
|
||||
displayWalletIntent.putExtra("user_name",user.getName());
|
||||
|
@ -101,11 +100,12 @@ public class SearchUser extends AppCompatActivity {
|
|||
displayWalletIntent.putExtra("SESSION_ID",session_id);
|
||||
displayWalletIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
SearchUser.this.startActivity(displayWalletIntent);
|
||||
progDailog.dismiss();
|
||||
finish();
|
||||
}else{
|
||||
Toast.makeText(mContext,"User dosen't exist",Toast.LENGTH_SHORT).show();
|
||||
progDailog.dismiss();
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -85,10 +85,10 @@ public class ApprovePayementActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private class TransactionTask extends AsyncTask<SendingTransaction,String,String> {
|
||||
ProgressDialog progDailog = new ProgressDialog(ApprovePayementActivity.this);
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
ProgressDialog progDailog = new ProgressDialog(ApprovePayementActivity.this);
|
||||
progDailog.setMessage("Sending transaction...");
|
||||
progDailog.setIndeterminate(false);
|
||||
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
|
@ -99,8 +99,8 @@ public class ApprovePayementActivity extends AppCompatActivity {
|
|||
@Override
|
||||
protected String doInBackground(SendingTransaction... sendingTransactions) {
|
||||
try{
|
||||
|
||||
TransactionApiHandler transactionApiHandler = new TransactionApiHandler();
|
||||
progDailog.dismiss();
|
||||
return transactionApiHandler.doTransaction(sendingTransactions[0]);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -109,11 +109,11 @@ public class TransactionActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private class TransactionTask extends AsyncTask<SendingTransaction,String,String> {
|
||||
ProgressDialog progDailog = new ProgressDialog(TransactionActivity.this);
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
ProgressDialog progDailog = new ProgressDialog(TransactionActivity.this);
|
||||
progDailog.setMessage("Sending transaction...");
|
||||
progDailog.setIndeterminate(false);
|
||||
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
|
@ -125,7 +125,7 @@ public class TransactionActivity extends AppCompatActivity {
|
|||
protected String doInBackground(SendingTransaction... sendingTransactions) {
|
||||
try{
|
||||
TransactionApiHandler transactionApiHandler = new TransactionApiHandler();
|
||||
System.out.println("SEND TRANSACTION");
|
||||
progDailog.dismiss();
|
||||
return transactionApiHandler.doTransaction(sendingTransactions[0]);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -22,6 +22,7 @@ public class HomeWalletActivity extends AppCompatActivity {
|
|||
private String user_password;
|
||||
private String session_id;
|
||||
private String email;
|
||||
private Boolean approved;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -36,6 +37,8 @@ public class HomeWalletActivity extends AppCompatActivity {
|
|||
user_password = intent.getStringExtra("USER_PWD");
|
||||
session_id = intent.getStringExtra("SESSION_ID");
|
||||
email = intent.getStringExtra("email");
|
||||
approved = Boolean.parseBoolean(intent.getStringExtra("approved"));
|
||||
|
||||
|
||||
buttonCreateWallet.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -51,6 +54,9 @@ public class HomeWalletActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
if(approved){
|
||||
buttonApproveUser.setVisibility(View.INVISIBLE);
|
||||
}else{
|
||||
buttonApproveUser.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -58,11 +64,10 @@ public class HomeWalletActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void launchCreateWalletActivity() {
|
||||
try{
|
||||
Boolean approved = new CheckApprovalTask().execute(user_hash,email).get();
|
||||
|
||||
if(approved){
|
||||
Intent createWalletIntent = new Intent(HomeWalletActivity.this, CreateWalletActivity.class);
|
||||
createWalletIntent.putExtra("USER_HASH",user_hash);
|
||||
|
@ -79,7 +84,6 @@ public class HomeWalletActivity extends AppCompatActivity {
|
|||
|
||||
public void launchSelectWalletActivity() {
|
||||
try{
|
||||
Boolean approved = new CheckApprovalTask().execute(user_hash,email).get();
|
||||
if(approved){
|
||||
Intent selectWalletIntent = new Intent(HomeWalletActivity.this, SelectWalletActivity.class);
|
||||
selectWalletIntent.putExtra("USER_HASH",user_hash);
|
||||
|
@ -117,6 +121,7 @@ public class HomeWalletActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private class CheckApprovalTask extends AsyncTask<String,Boolean,Boolean>{
|
||||
ProgressDialog progDailog = new ProgressDialog(HomeWalletActivity.this);
|
||||
@Override
|
||||
|
@ -144,6 +149,7 @@ public class HomeWalletActivity extends AppCompatActivity {
|
|||
progDailog.dismiss();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private class ApproveTask extends AsyncTask<String,String,String>{
|
||||
ProgressDialog progDailog = new ProgressDialog(HomeWalletActivity.this);
|
||||
|
|
|
@ -25,13 +25,16 @@ public class SelectWalletActivity extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_select_wallet);
|
||||
|
||||
ListView listView = (ListView) findViewById(R.id.listViewWallet);
|
||||
Intent intent = getIntent();
|
||||
user_hash = intent.getStringExtra("USER_HASH");
|
||||
user_password = intent.getStringExtra("USER_PWD");
|
||||
session_id = intent.getStringExtra("SESSION_ID");
|
||||
String[] params = {user_hash};
|
||||
setupWallet();
|
||||
}
|
||||
|
||||
public void setupWallet(){
|
||||
ListView listView = (ListView) findViewById(R.id.listViewWallet);
|
||||
String[] params = {user_hash};
|
||||
try {
|
||||
userWallets = new getUserWalletTask().execute(params).get();
|
||||
} catch (Exception e){
|
||||
|
@ -92,12 +95,6 @@ public class SelectWalletActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop(); // Always call the superclass method first
|
||||
new EndSessionTask().execute(session_id);
|
||||
}
|
||||
|
||||
private class EndSessionTask extends AsyncTask<String,Void,Void> {
|
||||
@Override
|
||||
protected Void doInBackground(String... strings) {
|
||||
|
@ -110,4 +107,16 @@ public class SelectWalletActivity extends AppCompatActivity {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop(); // Always call the superclass method first
|
||||
new EndSessionTask().execute(session_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
setupWallet();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="75dp"
|
||||
android:text="Bienvenue sur Monnethic !"
|
||||
android:text="Welcome on Monnethic !"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<Button
|
||||
|
@ -43,6 +43,7 @@
|
|||
android:layout_below="@+id/welcomeText"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="51dp"
|
||||
android:onClick="displayConf"
|
||||
app:srcCompat="@drawable/newlogo" />
|
||||
|
||||
<Button
|
||||
|
|
Loading…
Reference in a new issue