From 62e205ccfe57164824d9e229eb88e304441e1c34 Mon Sep 17 00:00:00 2001 From: dtvv Date: Fri, 5 Oct 2018 02:47:06 -0500 Subject: [PATCH] Add copy button in the fragment_general_crypto_net_account_settings.xml screen --- ...neralCryptoNetAccountSettingsFragment.java | 32 +++++++++++++++++++ ...nt_general_crypto_net_account_settings.xml | 11 +++++++ 2 files changed, 43 insertions(+) diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/GeneralCryptoNetAccountSettingsFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/GeneralCryptoNetAccountSettingsFragment.java index 2c182a9..d51e3e5 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/GeneralCryptoNetAccountSettingsFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/GeneralCryptoNetAccountSettingsFragment.java @@ -1,6 +1,10 @@ package cy.agorise.crystalwallet.fragments; +import android.app.Activity; import android.arch.lifecycle.LiveData; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; @@ -8,11 +12,13 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; +import android.widget.Toast; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; +import butterknife.OnClick; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.models.AccountSeed; @@ -30,9 +36,15 @@ public class GeneralCryptoNetAccountSettingsFragment extends Fragment { @BindView(R.id.tvMnemonic) TextView tvMnemonic; + @BindView(R.id.btnCopy) + Button btnCopy; + CryptoNetAccount cryptoNetAccount; AccountSeed accountSeed; + + + public GeneralCryptoNetAccountSettingsFragment() { if (getArguments() != null) { @@ -83,4 +95,24 @@ public class GeneralCryptoNetAccountSettingsFragment extends Fragment { tvMnemonic.setText(this.accountSeed.getMasterSeed()); } } + + /* + * Clic on button copy to clipboard + * */ + @OnClick(R.id.btnCopy) + public void btnCopyClick(){ + + /* + * Save to clipboard the brainkey chain + * */ + final Activity activity = getActivity(); + ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText(tvMnemonic.getText(), tvMnemonic.getText().toString()); + clipboard.setPrimaryClip(clip); + + /* + * Success message + * */ + Toast.makeText(activity,getResources().getString(R.string.window_seed_toast_clipboard), Toast.LENGTH_SHORT).show(); + } } diff --git a/app/src/main/res/layout/fragment_general_crypto_net_account_settings.xml b/app/src/main/res/layout/fragment_general_crypto_net_account_settings.xml index 744547f..fde0910 100644 --- a/app/src/main/res/layout/fragment_general_crypto_net_account_settings.xml +++ b/app/src/main/res/layout/fragment_general_crypto_net_account_settings.xml @@ -51,6 +51,17 @@ +