-When you import the backup account and it runs successfully, it should to take you to the main window and not on the login one

-When you import the backup account and it runs successfully, it should close the intro window
-When the user is restoring the backup it has to show loading dialog
-Remove Backup restored! Text when finishing importing backup
-Create class CrystalLoading extendí from CrystalDialog
This commit is contained in:
dtvv 2018-09-14 01:04:10 -05:00
parent 8e00c08d6a
commit 9d973b995e
3 changed files with 59 additions and 5 deletions

View file

@ -158,5 +158,6 @@ public class IntroActivity extends CustomActivity {
// Create and show the dialog. // Create and show the dialog.
ImportAccountOptionsFragment newFragment = ImportAccountOptionsFragment.newInstance(); ImportAccountOptionsFragment newFragment = ImportAccountOptionsFragment.newInstance();
newFragment.show(ft, "importAccountOptions"); newFragment.show(ft, "importAccountOptions");
newFragment.setIntroActivity(globalActivity); //This activity should close when import succeds
} }
} }

View file

@ -1,12 +1,15 @@
package cy.agorise.crystalwallet.fragments; package cy.agorise.crystalwallet.fragments;
import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.arch.lifecycle.ViewModelProviders;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -22,12 +25,16 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.activities.BoardActivity;
import cy.agorise.crystalwallet.activities.ImportSeedActivity; import cy.agorise.crystalwallet.activities.ImportSeedActivity;
import cy.agorise.crystalwallet.activities.IntroActivity; import cy.agorise.crystalwallet.activities.IntroActivity;
import cy.agorise.crystalwallet.dialogs.material.CrystalDialog;
import cy.agorise.crystalwallet.dialogs.material.DialogMaterial;
import cy.agorise.crystalwallet.requestmanagers.FileServiceRequestListener; import cy.agorise.crystalwallet.requestmanagers.FileServiceRequestListener;
import cy.agorise.crystalwallet.requestmanagers.FileServiceRequests; import cy.agorise.crystalwallet.requestmanagers.FileServiceRequests;
import cy.agorise.crystalwallet.requestmanagers.ImportBackupRequest; import cy.agorise.crystalwallet.requestmanagers.ImportBackupRequest;
import cy.agorise.crystalwallet.util.UriTranslator; import cy.agorise.crystalwallet.util.UriTranslator;
import cy.agorise.crystalwallet.viewmodels.AccountSeedListViewModel;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
@ -45,6 +52,21 @@ public class ImportAccountOptionsFragment extends DialogFragment {
@BindView(R.id.btnImportBackup) @BindView(R.id.btnImportBackup)
Button btnImportBackup; Button btnImportBackup;
/*
Dialog for loading
*/
private CrystalDialog crystalDialog;
/*
* Contains the activity to close in case import succed
* */
private Activity introActivity;
public ImportAccountOptionsFragment() { public ImportAccountOptionsFragment() {
// Required empty public constructor // Required empty public constructor
} }
@ -141,14 +163,30 @@ public class ImportAccountOptionsFragment extends DialogFragment {
@Override @Override
public void run() { public void run() {
if (importBackupRequest.getStatus() == ImportBackupRequest.StatusCode.SUCCEEDED) { if (importBackupRequest.getStatus() == ImportBackupRequest.StatusCode.SUCCEEDED) {
Toast toast = Toast.makeText(
getContext(), "Backup restored!", Toast.LENGTH_LONG);
toast.show();
Intent intent = new Intent(getContext(), IntroActivity.class); //Checks if the user has any seed created
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of((FragmentActivity) getContext()).get(AccountSeedListViewModel.class);
if(introActivity!=null){
introActivity.finish();
}
Intent intent = new Intent(getContext(), BoardActivity.class);
startActivity(intent); startActivity(intent);
dismiss();
/*
* Hide the loading dialog
* */
crystalDialog.dismiss();
} else if (importBackupRequest.getStatus() == ImportBackupRequest.StatusCode.FAILED) { } else if (importBackupRequest.getStatus() == ImportBackupRequest.StatusCode.FAILED) {
/*
* Hide the loading dialog
* */
crystalDialog.dismiss();
Toast toast = Toast.makeText( Toast toast = Toast.makeText(
getContext(), "An error ocurred while restoring the backup!", Toast.LENGTH_LONG); getContext(), "An error ocurred while restoring the backup!", Toast.LENGTH_LONG);
toast.show(); toast.show();
@ -159,6 +197,14 @@ public class ImportAccountOptionsFragment extends DialogFragment {
}); });
FileServiceRequests.getInstance().addRequest(importBackupRequest); FileServiceRequests.getInstance().addRequest(importBackupRequest);
/*
* Show loading dialog
* */
crystalDialog = new CrystalDialog((Activity) getContext());
crystalDialog.setText(getContext().getString(R.string.Creating_backup_from_file));
crystalDialog.progress();
crystalDialog.show();
} }
}) })
.setNegativeButton("Cancel", .setNegativeButton("Cancel",
@ -173,4 +219,9 @@ public class ImportAccountOptionsFragment extends DialogFragment {
} }
} }
public void setIntroActivity(Activity introActivity) {
this.introActivity = introActivity;
}
} }

View file

@ -279,6 +279,8 @@
<string name="head_block_number">head_block_number</string> <string name="head_block_number">head_block_number</string>
<string name="e_receipt">e_receipt</string> <string name="e_receipt">e_receipt</string>
<string name="Creating_backup_from_file">Creating backup from file</string>
<string name="folder_name">SmartcoinsWallet</string> <string name="folder_name">SmartcoinsWallet</string>
<string name="login_api">{\"id\":1,\"method\":\"call\",\"params\":[1,\"login\",[\"\",\"\"]]}</string> <string name="login_api">{\"id\":1,\"method\":\"call\",\"params\":[1,\"login\",[\"\",\"\"]]}</string>
<string name="exchange_rate_params">{\"id\":7,\"method\":\"call\",\"params\":[1,\"get_limit_orders\",[\"1.3.0\",\"1.3.120\",1]]} <string name="exchange_rate_params">{\"id\":7,\"method\":\"call\",\"params\":[1,\"get_limit_orders\",[\"1.3.0\",\"1.3.120\",1]]}