From 9527c3b758009109fd7d3181a30a15bbdfae4e4a Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 25 Jan 2018 20:48:04 -0600 Subject: [PATCH] Created ImportAccountOptionsFragment that shows up when the user wants to ImportAccount --- .../activities/IntroActivity.java | 12 +++ .../ImportAccountOptionsFragment.java | 72 ++++++++++++++++++ .../fragment_import_account_options.xml | 69 ++++++++++++++++++ app/src/main/res/layout/import_seed.xml | 73 +++++-------------- app/src/main/res/values/strings.xml | 3 + 5 files changed, 174 insertions(+), 55 deletions(-) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/fragments/ImportAccountOptionsFragment.java create mode 100644 app/src/main/res/layout/fragment_import_account_options.xml 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 f7057ae..fca4558 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java @@ -10,6 +10,8 @@ import android.content.Intent; import android.media.MediaPlayer; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AppCompatActivity; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -23,6 +25,7 @@ import butterknife.ButterKnife; import butterknife.OnClick; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.dao.CrystalDatabase; +import cy.agorise.crystalwallet.fragments.ImportAccountOptionsFragment; import cy.agorise.crystalwallet.models.AccountSeed; import cy.agorise.crystalwallet.models.CryptoCoinBalance; import cy.agorise.crystalwallet.models.CryptoCoinTransaction; @@ -139,6 +142,15 @@ public class IntroActivity extends AppCompatActivity { @OnClick(R.id.btnImportAccount) public void importAccount() { + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + Fragment prev = getSupportFragmentManager().findFragmentByTag("importAccountOptions"); + if (prev != null) { + ft.remove(prev); + } + ft.addToBackStack(null); + // Create and show the dialog. + ImportAccountOptionsFragment newFragment = ImportAccountOptionsFragment.newInstance(); + newFragment.show(ft, "importAccountOptions"); } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/ImportAccountOptionsFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/ImportAccountOptionsFragment.java new file mode 100644 index 0000000..d676d4c --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/ImportAccountOptionsFragment.java @@ -0,0 +1,72 @@ +package cy.agorise.crystalwallet.fragments; + +import android.app.Dialog; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.DialogFragment; +import android.support.v4.app.Fragment; +import android.support.v7.app.AlertDialog; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.widget.Button; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; +import cy.agorise.crystalwallet.R; + +/** + * Created by xd on 1/25/18. + * Shows a dialog where the user can select how to import his/her existing account + */ + +public class ImportAccountOptionsFragment extends DialogFragment { + + @BindView(R.id.btnCancel) + Button btnClose; + + public ImportAccountOptionsFragment() { + // Required empty public constructor + } + + public static ImportAccountOptionsFragment newInstance() { + ImportAccountOptionsFragment fragment = new ImportAccountOptionsFragment(); + Bundle args = new Bundle(); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + + LayoutInflater inflater = getActivity().getLayoutInflater(); + View view = inflater.inflate(R.layout.fragment_import_account_options, null); + ButterKnife.bind(this, view); + + return builder.setView(view).create(); + } + + @Override + public void onResume() { + super.onResume(); + + // Force dialog fragment to use the full width of the screen + Window dialogWindow = getDialog().getWindow(); + assert dialogWindow != null; + dialogWindow.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + } + + @OnClick(R.id.btnCancel) + public void cancel() { + dismiss(); + } +} diff --git a/app/src/main/res/layout/fragment_import_account_options.xml b/app/src/main/res/layout/fragment_import_account_options.xml new file mode 100644 index 0000000..3a461c2 --- /dev/null +++ b/app/src/main/res/layout/fragment_import_account_options.xml @@ -0,0 +1,69 @@ + + + + + +