Fixes from henrry code
This commit is contained in:
parent
9a1dc0548d
commit
10cc88c8d3
6 changed files with 108 additions and 102 deletions
|
@ -26,6 +26,7 @@ import butterknife.OnTextChanged;
|
|||
import cy.agorise.crystalwallet.R;
|
||||
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
|
||||
//import cy.agorise.crystalwallet.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||
import cy.agorise.crystalwallet.util.PasswordManager;
|
||||
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
|
||||
|
@ -43,7 +44,7 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
/*
|
||||
* External listener for success or fail
|
||||
* */
|
||||
//private static OnResponse onResponse;
|
||||
private static OnResponse onResponse;
|
||||
|
||||
/*
|
||||
* Contains the bad tries
|
||||
|
@ -143,9 +144,9 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
});
|
||||
}
|
||||
|
||||
/*public static void setOnResponse(OnResponse onResponse) {
|
||||
public static void setOnResponse(OnResponse onResponse) {
|
||||
PatternRequestActivity.onResponse = onResponse;
|
||||
}*/
|
||||
}
|
||||
|
||||
private void incorrect(){
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import cy.agorise.crystalwallet.dialogs.material.DialogMaterial;
|
|||
import cy.agorise.crystalwallet.dialogs.material.NegativeResponse;
|
||||
import cy.agorise.crystalwallet.dialogs.material.PositiveResponse;
|
||||
import cy.agorise.crystalwallet.dialogs.material.QuestionDialog;
|
||||
//import cy.agorise.crystalwallet.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||
import cy.agorise.crystalwallet.util.PasswordManager;
|
||||
|
@ -47,19 +47,19 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
TextView txtBadtry;
|
||||
|
||||
/*
|
||||
* Contains the bad tries
|
||||
* */
|
||||
* Contains the bad tries
|
||||
* */
|
||||
private int tries = 0;
|
||||
|
||||
/*
|
||||
* Seconds counter
|
||||
* */
|
||||
* Seconds counter
|
||||
* */
|
||||
private int seconds = 15;
|
||||
|
||||
/*
|
||||
* External listener for success or fail
|
||||
* */
|
||||
//private static OnResponse onResponse;
|
||||
private static OnResponse onResponse;
|
||||
|
||||
|
||||
|
||||
|
@ -80,8 +80,8 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
//onResponse = null;
|
||||
|
||||
/*
|
||||
* Initially the button is disabled till the user type a valid PIN
|
||||
* */
|
||||
* Initially the button is disabled till the user type a valid PIN
|
||||
* */
|
||||
btnOK.setEnabled(false);
|
||||
|
||||
GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class);
|
||||
|
@ -113,23 +113,23 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
if (CrystalSecurityMonitor.getInstance(null).is2ndFactorSet()) {
|
||||
CrystalSecurityMonitor.getInstance(null).call2ndFactor(this);
|
||||
|
||||
/*if(onResponse != null){
|
||||
if(onResponse != null){
|
||||
onResponse.onSuccess();
|
||||
}*/
|
||||
}
|
||||
|
||||
} else {
|
||||
this.finish();
|
||||
|
||||
/*if(onResponse != null){
|
||||
if(onResponse != null){
|
||||
onResponse.onFailed();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
/*
|
||||
* One more bad try
|
||||
* */
|
||||
* One more bad try
|
||||
* */
|
||||
++tries;
|
||||
|
||||
final Activity activity = this;
|
||||
|
@ -137,8 +137,8 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
etPassword.setTextColor(Color.RED);
|
||||
|
||||
/*
|
||||
* User can not go more up to 5 bad tries
|
||||
* */
|
||||
* User can not go more up to 5 bad tries
|
||||
* */
|
||||
if(tries==4){
|
||||
tries = 0;
|
||||
|
||||
|
@ -193,8 +193,8 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
/*
|
||||
* Set in red the rext and reset the password after a period of time
|
||||
* */
|
||||
* Set in red the rext and reset the password after a period of time
|
||||
* */
|
||||
final Timer t = new Timer();
|
||||
//Set the schedule function and rate
|
||||
t.scheduleAtFixedRate(new TimerTask() {
|
||||
|
@ -213,17 +213,17 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
},
|
||||
//Set how long before to start calling the TimerTask (in milliseconds)
|
||||
//Set how long before to start calling the TimerTask (in milliseconds)
|
||||
500,
|
||||
//Set the amount of time between each execution (in milliseconds)
|
||||
//Set the amount of time between each execution (in milliseconds)
|
||||
500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*public static void setOnResponse(OnResponse onResponse) {
|
||||
public static void setOnResponse(OnResponse onResponse) {
|
||||
PinRequestActivity.onResponse = onResponse;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@OnTextChanged(value = R.id.etPassword,
|
||||
|
@ -231,8 +231,8 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
void afterPasswordChanged(Editable editable) {
|
||||
|
||||
/*
|
||||
* If it is valid length enable button
|
||||
* */
|
||||
* If it is valid length enable button
|
||||
* */
|
||||
if(etPassword.getText().length()>=6){
|
||||
btnOK.setEnabled(true);
|
||||
}
|
||||
|
@ -240,6 +240,4 @@ public class PinRequestActivity extends AppCompatActivity {
|
|||
btnOK.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@ import cy.agorise.crystalwallet.activities.PatternRequestActivity;
|
|||
import cy.agorise.crystalwallet.activities.PinRequestActivity;
|
||||
import cy.agorise.crystalwallet.activities.PocketRequestActivity;
|
||||
import cy.agorise.crystalwallet.fragments.PatternSecurityFragment;
|
||||
//import cy.agorise.crystalwallet.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||
import cy.agorise.crystalwallet.notifiers.CrystalWalletNotifier;
|
||||
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
|
||||
|
@ -131,7 +131,7 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall
|
|||
public void onActivityStarted(Activity activity) {
|
||||
if (numStarted == 0) {
|
||||
if (!actualSecurity().equals("")){
|
||||
callPasswordRequest(activity);
|
||||
callPasswordRequest(activity,null);
|
||||
}
|
||||
}
|
||||
numStarted++;
|
||||
|
@ -142,39 +142,39 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall
|
|||
numStarted--;
|
||||
if (numStarted == 0) {
|
||||
if (!actualSecurity().equals("")){
|
||||
callPasswordRequest(activity);
|
||||
callPasswordRequest(activity,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void callPasswordRequest(Activity activity){
|
||||
public void callPasswordRequest(Activity activity, final OnResponse onResponsePattern){
|
||||
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);
|
||||
PinRequestActivity.setOnResponse(null);
|
||||
|
||||
/*
|
||||
* Connect error and success listeners
|
||||
* */
|
||||
/*if(onResponsePattern != null){
|
||||
* Connect error and success listeners
|
||||
* */
|
||||
if(onResponsePattern != null){
|
||||
PinRequestActivity.setOnResponse(onResponsePattern);
|
||||
}*/
|
||||
}
|
||||
|
||||
} else if ((this.patternEncrypted != null) && (!this.patternEncrypted.equals(""))) {
|
||||
|
||||
intent = new Intent(activity, PatternRequestActivity.class);
|
||||
|
||||
//PatternRequestActivity.setOnResponse(null);
|
||||
PatternRequestActivity.setOnResponse(null);
|
||||
|
||||
/*
|
||||
* Connect error and success listeners
|
||||
* */
|
||||
/*if(onResponsePattern != null){
|
||||
if(onResponsePattern != null){
|
||||
PatternRequestActivity.setOnResponse(onResponsePattern);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if (intent != null) {
|
||||
intent.putExtra("ACTIVITY_TYPE", "PASSWORD_REQUEST");
|
||||
|
@ -220,7 +220,4 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall
|
|||
public void onActivityDestroyed(Activity activity) {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ 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.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.util.ChildViewPager;
|
||||
|
@ -52,8 +52,8 @@ public class PatternSecurityFragment extends Fragment {
|
|||
TextView tvPatternText;
|
||||
|
||||
/*
|
||||
* Contains the ChildViewPager to block the viewpager when the user is using the pattern control
|
||||
* */
|
||||
* Contains the ChildViewPager to block the viewpager when the user is using the pattern control
|
||||
* */
|
||||
private ChildViewPager childViewPager;
|
||||
|
||||
private PatternLockViewListener actualPatternListener;
|
||||
|
@ -174,8 +174,8 @@ public class PatternSecurityFragment extends Fragment {
|
|||
private void resetPattern(){
|
||||
|
||||
/*
|
||||
* Show error
|
||||
* */
|
||||
* Show error
|
||||
* */
|
||||
tvPatternText.setText(getActivity().getResources().getString(R.string.Incorrect_pattern));
|
||||
tvPatternText.setTextColor(Color.RED);
|
||||
final Timer t = new Timer();
|
||||
|
@ -227,20 +227,20 @@ public class PatternSecurityFragment extends Fragment {
|
|||
final Timer t_ = new Timer();
|
||||
t_.scheduleAtFixedRate(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
t_.cancel();
|
||||
showNewPatternUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
t_.cancel();
|
||||
showNewPatternUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
//Set how long before to start calling the TimerTask (in milliseconds)
|
||||
1000,
|
||||
//Set the amount of time between each execution (in milliseconds)
|
||||
|
|
|
@ -152,6 +152,16 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
|
|||
}
|
||||
List<CryptoCurrency> cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds);
|
||||
|
||||
/*
|
||||
* Test
|
||||
* */
|
||||
CryptoCurrency crypto1 = new CryptoCurrency();
|
||||
crypto1.setId(1);
|
||||
crypto1.setName("BITCOIN");
|
||||
crypto1.setPrecision(1);
|
||||
cryptoCurrencyList.add(crypto1);
|
||||
|
||||
|
||||
CryptoCurrencyAdapter assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
|
||||
spAsset.setAdapter(assetAdapter);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ 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.interfaces.OnResponse;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
|
||||
|
@ -134,8 +134,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
View viewCamera;
|
||||
|
||||
/*
|
||||
* Flag to control when the camera is visible and when is hide
|
||||
* */
|
||||
* Flag to control when the camera is visible and when is hide
|
||||
* */
|
||||
private boolean cameraVisible = true;
|
||||
|
||||
Button btnScanQrCode;
|
||||
|
@ -196,9 +196,9 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
this.cryptoNetAccount = db.cryptoNetAccountDao().getById(this.cryptoNetAccountId);
|
||||
|
||||
/*
|
||||
* this is only for graphene accounts.
|
||||
*
|
||||
**/
|
||||
* this is only for graphene accounts.
|
||||
*
|
||||
**/
|
||||
this.grapheneAccount = new GrapheneAccount(this.cryptoNetAccount);
|
||||
this.grapheneAccount.loadInfo(db.grapheneAccountInfoDao().getByAccountId(this.cryptoNetAccountId));
|
||||
|
||||
|
@ -213,8 +213,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
List<CryptoCurrency> cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds);
|
||||
|
||||
/*
|
||||
* Test
|
||||
* */
|
||||
* Test
|
||||
* */
|
||||
/*CryptoCurrency crypto1 = new CryptoCurrency();
|
||||
crypto1.setId(1);
|
||||
crypto1.setName("BITCOIN");
|
||||
|
@ -234,8 +234,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
CryptoNetAccountAdapter fromSpinnerAdapter = new CryptoNetAccountAdapter(this.getContext(), android.R.layout.simple_spinner_item, cryptoNetAccounts);
|
||||
|
||||
/*
|
||||
* If only one account block the control
|
||||
* */
|
||||
* If only one account block the control
|
||||
* */
|
||||
if(cryptoNetAccounts.size()==1){
|
||||
spFrom.setEnabled(false);
|
||||
}
|
||||
|
@ -244,8 +244,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
//spFrom.setSelection(0);
|
||||
|
||||
/*
|
||||
* Custom material spinner implementation
|
||||
* */
|
||||
* Custom material spinner implementation
|
||||
* */
|
||||
spFrom.setItems(cryptoNetAccounts);
|
||||
//spFrom.setSelectedIndex(0);
|
||||
spFrom.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<CryptoNetAccount>() {
|
||||
|
@ -275,8 +275,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
// Your Permission granted already .Do next code
|
||||
|
||||
/*
|
||||
* Init the camera
|
||||
* */
|
||||
* Init the camera
|
||||
* */
|
||||
try {
|
||||
beginScanQrCode();
|
||||
}catch(Exception e){
|
||||
|
@ -312,8 +312,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
Toast.makeText(getActivity(), getActivity().getString(R.string.permission_denied_camera), Toast.LENGTH_LONG).show();
|
||||
|
||||
/*
|
||||
* Disable the button of the camera visibility
|
||||
* */
|
||||
* Disable the button of the camera visibility
|
||||
* */
|
||||
disableVisibilityCamera();
|
||||
|
||||
} else {
|
||||
|
@ -458,8 +458,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
mScannerView.stopCamera();
|
||||
|
||||
/*
|
||||
* Hide the camera or show it
|
||||
* */
|
||||
* Hide the camera or show it
|
||||
* */
|
||||
if(cameraVisible){
|
||||
hideCamera();
|
||||
}
|
||||
|
@ -490,31 +490,31 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
cameraVisible = true;
|
||||
|
||||
/*
|
||||
* Star the camera again
|
||||
* */
|
||||
* Star the camera again
|
||||
* */
|
||||
beginScanQrCode();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hide the camera and show the black background
|
||||
* */
|
||||
* Hide the camera and show the black background
|
||||
* */
|
||||
private void hideCamera(){
|
||||
|
||||
/*
|
||||
* Change visibilities of views
|
||||
* */
|
||||
* Change visibilities of views
|
||||
* */
|
||||
viewCamera.setVisibility(View.VISIBLE);
|
||||
mScannerView.setVisibility(View.INVISIBLE);
|
||||
|
||||
/*
|
||||
* Change icon
|
||||
* */
|
||||
* Change icon
|
||||
* */
|
||||
btnCloseCamera.setImageDrawable(getResources().getDrawable(R.drawable.ok));
|
||||
|
||||
/*
|
||||
* Reset variable
|
||||
* */
|
||||
* Reset variable
|
||||
* */
|
||||
cameraVisible = false;
|
||||
}
|
||||
|
||||
|
@ -595,12 +595,12 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
Long amount = (long)Math.floor(amountFromEditText*Math.round(Math.pow(10,((CryptoCurrency)spAsset.getSelectedItem()).getPrecision())));
|
||||
|
||||
final ValidateBitsharesSendRequest sendRequest = new ValidateBitsharesSendRequest(
|
||||
this.getContext(),
|
||||
grapheneAccountSelected,
|
||||
this.etTo.getText().toString(),
|
||||
amount,
|
||||
((CryptoCurrency)spAsset.getSelectedItem()).getName(),
|
||||
etMemo.getText().toString()
|
||||
this.getContext(),
|
||||
grapheneAccountSelected,
|
||||
this.etTo.getText().toString(),
|
||||
amount,
|
||||
((CryptoCurrency)spAsset.getSelectedItem()).getName(),
|
||||
etMemo.getText().toString()
|
||||
);
|
||||
|
||||
sendRequest.setListener(new CryptoNetInfoRequestListener() {
|
||||
|
@ -621,16 +621,16 @@ 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() {
|
||||
* 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
|
||||
* */
|
||||
/* crystalDialog = new CrystalDialog((Activity) getContext());
|
||||
crystalDialog = new CrystalDialog((Activity) getContext());
|
||||
crystalDialog.setText("Sending");
|
||||
crystalDialog.progress();
|
||||
crystalDialog.show();
|
||||
|
@ -642,7 +642,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
public void onFailed() {
|
||||
|
||||
}
|
||||
});*/
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -743,4 +743,4 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue