Security mode is only used when the user try to send assets in the send assets screen
This commit is contained in:
parent
71c26c0ddf
commit
ae3ed3725d
6 changed files with 68 additions and 69 deletions
|
@ -25,6 +25,7 @@ import butterknife.ButterKnife;
|
|||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
|
||||
import cy.agorise.crystalwallet.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||
import cy.agorise.crystalwallet.util.PasswordManager;
|
||||
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
|
||||
|
@ -72,6 +73,8 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_pattern_request);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
//onResponse = null;
|
||||
|
||||
GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class);
|
||||
LiveData<List<GeneralSetting>> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList();
|
||||
|
||||
|
@ -108,7 +111,6 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
|
||||
if(onResponse != null){
|
||||
onResponse.onSuccess();
|
||||
onResponse = null;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -116,7 +118,6 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
|
||||
if(onResponse != null){
|
||||
onResponse.onSuccess();
|
||||
onResponse = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -124,7 +125,6 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
|
||||
if(onResponse != null){
|
||||
onResponse.onFailed();
|
||||
onResponse = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
public static void setOnResponse(OnResponse onResponse) {
|
||||
onResponse = onResponse;
|
||||
PatternRequestActivity.onResponse = onResponse;
|
||||
}
|
||||
|
||||
private void incorrect(){
|
||||
|
@ -249,14 +249,6 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
|
||||
return patternString;
|
||||
}
|
||||
|
||||
/*
|
||||
* Listener events for success and fail
|
||||
* */
|
||||
public interface OnResponse{
|
||||
void onSuccess();
|
||||
void onFailed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_pin_request);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
//onResponse = null;
|
||||
|
||||
/*
|
||||
* Initially the button is disabled till the user type a valid PIN
|
||||
* */
|
||||
|
@ -113,7 +115,6 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
|
||||
if(onResponse != null){
|
||||
onResponse.onSuccess();
|
||||
onResponse = null;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -121,7 +122,6 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
|
||||
if(onResponse != null){
|
||||
onResponse.onFailed();
|
||||
onResponse = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cy.agorise.crystalwallet.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.arch.lifecycle.LiveData;
|
||||
import android.arch.lifecycle.Observer;
|
||||
import android.os.Bundle;
|
||||
|
@ -11,6 +12,7 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.jaredrummler.materialspinner.MaterialSpinner;
|
||||
|
||||
|
|
|
@ -151,8 +151,11 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall
|
|||
if ((!activity.getIntent().hasExtra("ACTIVITY_TYPE")) || (!activity.getIntent().getStringExtra("ACTIVITY_TYPE").equals("PASSWORD_REQUEST"))) {
|
||||
Intent intent = null;
|
||||
if ((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals(""))) {
|
||||
|
||||
intent = new Intent(activity, PinRequestActivity.class);
|
||||
|
||||
PinRequestActivity.setOnResponse(null);
|
||||
|
||||
/*
|
||||
* Connect error and success listeners
|
||||
* */
|
||||
|
@ -162,14 +165,16 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall
|
|||
|
||||
} else if ((this.patternEncrypted != null) && (!this.patternEncrypted.equals(""))) {
|
||||
|
||||
intent = new Intent(activity, PatternRequestActivity.class);
|
||||
|
||||
PatternRequestActivity.setOnResponse(null);
|
||||
|
||||
/*
|
||||
* Connect error and success listeners
|
||||
* */
|
||||
if(onResponsePattern != null){
|
||||
PatternRequestActivity.setOnResponse(onResponsePattern);
|
||||
}
|
||||
|
||||
intent = new Intent(activity, PatternRequestActivity.class);
|
||||
}
|
||||
if (intent != null) {
|
||||
intent.putExtra("ACTIVITY_TYPE", "PASSWORD_REQUEST");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cy.agorise.crystalwallet.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.arch.lifecycle.LiveData;
|
||||
import android.arch.lifecycle.Observer;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
|
@ -8,6 +9,7 @@ import android.os.Bundle;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Editable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -27,7 +29,10 @@ import butterknife.ButterKnife;
|
|||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
|
||||
import cy.agorise.crystalwallet.dialogs.material.CrystalDialog;
|
||||
import cy.agorise.crystalwallet.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.util.ChildViewPager;
|
||||
import cy.agorise.crystalwallet.util.PasswordManager;
|
||||
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
|
||||
|
@ -199,7 +204,20 @@ public class PatternSecurityFragment extends Fragment {
|
|||
public void savePattern(String pattern){
|
||||
String patternEncripted = PasswordManager.encriptPassword(pattern);
|
||||
CrystalSecurityMonitor.getInstance(null).setPatternEncrypted(patternEncripted);
|
||||
//CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity());
|
||||
/*CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity(), new OnResponse() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
Log.i("onSuccess","onSuccess");
|
||||
Toast.makeText(getActivity(), "onSuccess", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed() {
|
||||
Log.i("onFailed","onFailed");
|
||||
Toast.makeText(getActivity(), "onFailed", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});*/
|
||||
|
||||
/*
|
||||
* Show success
|
||||
|
|
|
@ -58,8 +58,10 @@ import butterknife.OnClick;
|
|||
import butterknife.OnItemSelected;
|
||||
import butterknife.OnTextChanged;
|
||||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
|
||||
import cy.agorise.crystalwallet.dialogs.material.CrystalDialog;
|
||||
import cy.agorise.crystalwallet.dialogs.material.ToastIt;
|
||||
import cy.agorise.crystalwallet.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
|
||||
|
@ -180,53 +182,10 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
View view = inflater.inflate(R.layout.send_transaction, null);
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
|
||||
/*
|
||||
* Detet scroll changes
|
||||
* */
|
||||
/*scrollMain.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
|
||||
@Override
|
||||
public void onScrollChanged() {
|
||||
|
||||
View view = scrollMain.getChildAt(scrollMain.getChildCount() - 1);
|
||||
|
||||
int diff = (view.getBottom() - (scrollMain.getHeight() + scrollMain.getScrollY()));
|
||||
|
||||
float traslationY = btnSend.getTranslationY();
|
||||
|
||||
if(diff<=266 && diff>128){
|
||||
//btnSend.setTranslationY(0);
|
||||
//viewSend.setTranslationY(0);
|
||||
|
||||
btnSend.animate().y(880);
|
||||
viewSend.animate().y(800);
|
||||
}
|
||||
else if(diff<=128 && diff>10){
|
||||
//btnSend.setTranslationY(-130);
|
||||
//viewSend.setTranslationY(-130);
|
||||
|
||||
btnSend.animate().y(880);
|
||||
viewSend.animate().y(800);
|
||||
}
|
||||
else if(diff<=10 && diff>0){
|
||||
//btnSend.setTranslationY(-170);
|
||||
//viewSend.setTranslationY(-170);
|
||||
|
||||
btnSend.animate().y(680);
|
||||
viewSend.animate().y(600);
|
||||
}
|
||||
else if(diff==0){
|
||||
//btnSend.setTranslationY(-190);
|
||||
//viewSend.setTranslationY(-190);
|
||||
|
||||
btnSend.animate().y(680);
|
||||
viewSend.animate().y(600);
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
this.cryptoNetAccountId = getArguments().getLong("CRYPTO_NET_ACCOUNT_ID",-1);
|
||||
|
||||
final Activity activity = getActivity();
|
||||
|
||||
/*
|
||||
* Add style to the spinner android
|
||||
* */
|
||||
|
@ -253,6 +212,15 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
}
|
||||
List<CryptoCurrency> cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds);
|
||||
|
||||
/*
|
||||
* Test
|
||||
* */
|
||||
/*CryptoCurrency crypto1 = new CryptoCurrency();
|
||||
crypto1.setId(1);
|
||||
crypto1.setName("BITCOIN");
|
||||
crypto1.setPrecision(1);
|
||||
cryptoCurrencyList.add(crypto1);*/
|
||||
|
||||
assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
|
||||
spAsset.setAdapter(assetAdapter);
|
||||
}
|
||||
|
@ -652,6 +620,13 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* If exists mode scurity show it and valide events in case of success or fail
|
||||
* */
|
||||
CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity(), new OnResponse() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
/*
|
||||
* Show loading dialog
|
||||
* */
|
||||
|
@ -662,6 +637,13 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
|
||||
CryptoNetInfoRequests.getInstance().addRequest(sendRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void beginScanQrCode(){
|
||||
|
|
Loading…
Reference in a new issue