From 9d973b995e4d6459e77e281b4cf6d825dc22e69b Mon Sep 17 00:00:00 2001 From: dtvv Date: Fri, 14 Sep 2018 01:04:10 -0500 Subject: [PATCH] =?UTF-8?q?-When=20you=20import=20the=20backup=20account?= =?UTF-8?q?=20and=20it=20runs=20successfully,=20it=20should=20to=20take=20?= =?UTF-8?q?you=20to=20the=20main=20window=20and=20not=20on=20the=20login?= =?UTF-8?q?=20one=20-When=20you=20import=20the=20backup=20account=20and=20?= =?UTF-8?q?it=20runs=20successfully,=20it=20should=20close=20the=20intro?= =?UTF-8?q?=20window=20-When=20the=20user=20is=20restoring=20the=20backup?= =?UTF-8?q?=20it=20has=20to=20show=20loading=20dialog=20-Remove=20Backup?= =?UTF-8?q?=20restored!=20Text=20when=20finishing=20importing=20backup=20-?= =?UTF-8?q?Create=20class=20CrystalLoading=20extend=C3=AD=20from=20Crystal?= =?UTF-8?q?Dialog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activities/IntroActivity.java | 1 + .../ImportAccountOptionsFragment.java | 61 +++++++++++++++++-- app/src/main/res/values/strings.xml | 2 + 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java index 50968fa..f0e00d3 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java @@ -158,5 +158,6 @@ public class IntroActivity extends CustomActivity { // Create and show the dialog. ImportAccountOptionsFragment newFragment = ImportAccountOptionsFragment.newInstance(); newFragment.show(ft, "importAccountOptions"); + newFragment.setIntroActivity(globalActivity); //This activity should close when import succeds } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/ImportAccountOptionsFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/ImportAccountOptionsFragment.java index ca278d5..6d3fe60 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/ImportAccountOptionsFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/ImportAccountOptionsFragment.java @@ -1,12 +1,15 @@ package cy.agorise.crystalwallet.fragments; +import android.app.Activity; import android.app.Dialog; +import android.arch.lifecycle.ViewModelProviders; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; +import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; @@ -22,12 +25,16 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.activities.BoardActivity; import cy.agorise.crystalwallet.activities.ImportSeedActivity; 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.FileServiceRequests; import cy.agorise.crystalwallet.requestmanagers.ImportBackupRequest; import cy.agorise.crystalwallet.util.UriTranslator; +import cy.agorise.crystalwallet.viewmodels.AccountSeedListViewModel; import static android.app.Activity.RESULT_OK; @@ -45,6 +52,21 @@ public class ImportAccountOptionsFragment extends DialogFragment { @BindView(R.id.btnImportBackup) Button btnImportBackup; + + /* + Dialog for loading + */ + private CrystalDialog crystalDialog; + + /* + * Contains the activity to close in case import succed + * */ + private Activity introActivity; + + + + + public ImportAccountOptionsFragment() { // Required empty public constructor } @@ -141,14 +163,30 @@ public class ImportAccountOptionsFragment extends DialogFragment { @Override public void run() { 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); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + //Checks if the user has any seed created + AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of((FragmentActivity) getContext()).get(AccountSeedListViewModel.class); + + if(introActivity!=null){ + introActivity.finish(); + } + + Intent intent = new Intent(getContext(), BoardActivity.class); startActivity(intent); + dismiss(); + + /* + * Hide the loading dialog + * */ + crystalDialog.dismiss(); + } else if (importBackupRequest.getStatus() == ImportBackupRequest.StatusCode.FAILED) { + + /* + * Hide the loading dialog + * */ + crystalDialog.dismiss(); + Toast toast = Toast.makeText( getContext(), "An error ocurred while restoring the backup!", Toast.LENGTH_LONG); toast.show(); @@ -159,6 +197,14 @@ public class ImportAccountOptionsFragment extends DialogFragment { }); 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", @@ -173,4 +219,9 @@ public class ImportAccountOptionsFragment extends DialogFragment { } } + + + public void setIntroActivity(Activity introActivity) { + this.introActivity = introActivity; + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0e4e2be..e2aabac 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -279,6 +279,8 @@ head_block_number e_receipt + Creating backup from file + SmartcoinsWallet {\"id\":1,\"method\":\"call\",\"params\":[1,\"login\",[\"\",\"\"]]} {\"id\":7,\"method\":\"call\",\"params\":[1,\"get_limit_orders\",[\"1.3.0\",\"1.3.120\",1]]}