Add copy button in the fragment_general_crypto_net_account_settings.xml screen
This commit is contained in:
parent
53066696ce
commit
62e205ccfe
2 changed files with 43 additions and 0 deletions
|
@ -1,6 +1,10 @@
|
||||||
package cy.agorise.crystalwallet.fragments;
|
package cy.agorise.crystalwallet.fragments;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.arch.lifecycle.LiveData;
|
import android.arch.lifecycle.LiveData;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -8,11 +12,13 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
|
@ -30,9 +36,15 @@ public class GeneralCryptoNetAccountSettingsFragment extends Fragment {
|
||||||
@BindView(R.id.tvMnemonic)
|
@BindView(R.id.tvMnemonic)
|
||||||
TextView tvMnemonic;
|
TextView tvMnemonic;
|
||||||
|
|
||||||
|
@BindView(R.id.btnCopy)
|
||||||
|
Button btnCopy;
|
||||||
|
|
||||||
CryptoNetAccount cryptoNetAccount;
|
CryptoNetAccount cryptoNetAccount;
|
||||||
AccountSeed accountSeed;
|
AccountSeed accountSeed;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GeneralCryptoNetAccountSettingsFragment() {
|
public GeneralCryptoNetAccountSettingsFragment() {
|
||||||
|
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
|
@ -83,4 +95,24 @@ public class GeneralCryptoNetAccountSettingsFragment extends Fragment {
|
||||||
tvMnemonic.setText(this.accountSeed.getMasterSeed());
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,17 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnCopy"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/linearlayout1"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:text="@string/window_seed_copy"
|
||||||
|
android:textColor="#0099ff"
|
||||||
|
android:background="?android:attr/selectableItemBackground"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue