- Once again, the list of accounts in the profiles settings are really account seeds

- When an account seed is pressed, the seeds settings show the mnemonic words and a new tab for the coin settings
- The coin settings allow the user to activate a coin account like bitcoin
This commit is contained in:
Javier Varona 2018-10-31 22:19:15 -04:00
parent 6c0d936b67
commit 5965528abe
15 changed files with 913 additions and 16 deletions

View file

@ -40,6 +40,10 @@
</activity>
<activity android:name=".activities.AccountSeedsManagementActivity" >
</activity>
<activity android:name=".activities.AccountSeedSettingsActivity"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan">
</activity>
<activity android:name=".activities.ImportSeedActivity" >
</activity>
<activity android:name=".activities.SendTransactionActivity" >

View file

@ -0,0 +1,134 @@
package cy.agorise.crystalwallet.activities;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.fragments.BitsharesSettingsFragment;
import cy.agorise.crystalwallet.fragments.GeneralAccountSeedCoinSettingsFragment;
import cy.agorise.crystalwallet.fragments.GeneralAccountSeedFragment;
import cy.agorise.crystalwallet.fragments.GeneralCryptoNetAccountSettingsFragment;
import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.models.CryptoNetAccount;
import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel;
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountViewModel;
/**
* Created by henry varona on 10/29/18.
*
*/
public class AccountSeedSettingsActivity extends AppCompatActivity{
@BindView(R.id.ivGoBack)
public ImageView ivGoBack;
@BindView(R.id.pager)
public ViewPager mPager;
public SettingsPagerAdapter settingsPagerAdapter;
@BindView(R.id.tvBuildVersion)
public TextView tvBuildVersion;
@BindView(R.id.tabs)
public TabLayout tabs;
private AccountSeed accountSeed;
@BindView(R.id.ivAppBarAnimation)
ImageView ivAppBarAnimation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_seed_activity_settings);
ButterKnife.bind(this);
final AccountSeedSettingsActivity thisActivity = this;
long accountSeedId = getIntent().getLongExtra("SEED_ID",-1);
if (accountSeedId > -1) {
AccountSeedViewModel accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class);
accountSeedViewModel.loadSeed(accountSeedId);
LiveData<AccountSeed> accountSeedLiveData = accountSeedViewModel.getAccountSeed();
accountSeedLiveData.observe(this, new Observer<AccountSeed>() {
@Override
public void onChanged(@Nullable AccountSeed accountSeed) {
thisActivity.accountSeed = accountSeed;
settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(settingsPagerAdapter);
TabLayout tabLayout = findViewById(R.id.tabs);
mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mPager));
}
});
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Sets AppBar animation
Glide.with(this)
.load(R.drawable.appbar_background)
.apply(new RequestOptions().centerCrop())
.into(ivAppBarAnimation);
} else {
this.finish();
}
}
private class SettingsPagerAdapter extends FragmentStatePagerAdapter {
SettingsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position){
case 0:
return GeneralAccountSeedFragment.newInstance(accountSeed.getId());
case 1:
return GeneralAccountSeedCoinSettingsFragment.newInstance(accountSeed.getId());
}
return null;
}
@Override
public int getCount() {
int tabCount = 2;
return tabCount;
}
}
@OnClick(R.id.ivGoBack)
public void goBack(){
onBackPressed();
}
}

View file

@ -57,8 +57,11 @@ public class AccountsActivity extends AppCompatActivity {
@BindView(R.id.tvClose)
TextView tvClose;
@BindView(R.id.vAccountList)
CryptoNetAccountListView vAccountList;
//@BindView(R.id.vAccountList)
//CryptoNetAccountListView vAccountList;
@BindView(R.id.vAccountSeedList)
AccountSeedListView vAccountSeedList;
@BindView(R.id.user_img)
CircleImageView userImg;
@ -88,14 +91,17 @@ public class AccountsActivity extends AppCompatActivity {
} );
CryptoNetAccountListViewModel crytpoNetAccountListViewModel = ViewModelProviders.of(this).get(CryptoNetAccountListViewModel.class);
LiveData<List<CryptoNetAccount>> accountData = crytpoNetAccountListViewModel.getCryptoNetAccounts();
vAccountList.setData(null);
AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of(this).get(AccountSeedListViewModel.class);
LiveData<List<AccountSeed>> accountSeedLD = accountSeedListViewModel.getAccountSeedList();
accountData.observe(this, new Observer<List<CryptoNetAccount>>() {
//CryptoNetAccountListViewModel crytpoNetAccountListViewModel = ViewModelProviders.of(this).get(CryptoNetAccountListViewModel.class);
//LiveData<List<CryptoNetAccount>> accountData = crytpoNetAccountListViewModel.getCryptoNetAccounts();
vAccountSeedList.setData(null);
accountSeedLD.observe(this, new Observer<List<AccountSeed>>() {
@Override
public void onChanged(List<CryptoNetAccount> cryptoNetAccounts) {
vAccountList.setData(cryptoNetAccounts);
public void onChanged(List<AccountSeed> accountsSeeds) {
vAccountSeedList.setData(accountsSeeds);
}
});

View file

@ -27,6 +27,7 @@ import butterknife.OnClick;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.fragments.BackupsSettingsFragment;
import cy.agorise.crystalwallet.fragments.BitsharesSettingsFragment;
import cy.agorise.crystalwallet.fragments.CryptoNetAccountActivationSettingsFragment;
import cy.agorise.crystalwallet.fragments.GeneralCryptoNetAccountSettingsFragment;
import cy.agorise.crystalwallet.fragments.GeneralSettingsFragment;
import cy.agorise.crystalwallet.fragments.SecuritySettingsFragment;

View file

@ -0,0 +1,127 @@
package cy.agorise.crystalwallet.fragments;
import android.app.Activity;
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;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.thekhaeng.pushdownanim.PushDownAnim;
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;
import cy.agorise.crystalwallet.models.CryptoNetAccount;
/**
* Created by xd on 12/28/17.
*/
public class CryptoNetAccountActivationSettingsFragment extends Fragment {
@BindView(R.id.tvMnemonic)
TextView tvMnemonic;
@BindView(R.id.btnCopy)
Button btnCopy;
CryptoNetAccount cryptoNetAccount;
AccountSeed accountSeed;
public CryptoNetAccountActivationSettingsFragment() {
if (getArguments() != null) {
long cryptoNetAcountId = getArguments().getLong("CRYPTO_NET_ACCOUNT_ID", -1);
if (cryptoNetAcountId > -1) {
this.cryptoNetAccount = CrystalDatabase.getAppDatabase(getContext()).cryptoNetAccountDao().getById(cryptoNetAcountId);
this.accountSeed = CrystalDatabase.getAppDatabase(getContext()).accountSeedDao().findById(this.cryptoNetAccount.getSeedId());
}
}
// Required empty public constructor
}
public static CryptoNetAccountActivationSettingsFragment newInstance(long cryptoNetAccountId) {
CryptoNetAccountActivationSettingsFragment fragment = new CryptoNetAccountActivationSettingsFragment();
Bundle args = new Bundle();
args.putLong("CRYPTO_NET_ACCOUNT_ID", cryptoNetAccountId);
fragment.setArguments(args);
if (cryptoNetAccountId > -1){
fragment.cryptoNetAccount = CrystalDatabase.getAppDatabase(fragment.getContext()).cryptoNetAccountDao().getById(cryptoNetAccountId);
fragment.accountSeed = CrystalDatabase.getAppDatabase(fragment.getContext()).accountSeedDao().findById(fragment.cryptoNetAccount.getSeedId());
}
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_general_crypto_net_account_settings, container, false);
ButterKnife.bind(this, v);
/*
* Integration of library with button efects
* */
PushDownAnim.setPushDownAnimTo(btnCopy)
.setOnClickListener( new View.OnClickListener(){
@Override
public void onClick( View view ){
btnCopyClick();
}
} );
initAlreadyLtm();
return v;
}
public void initAlreadyLtm(){
if (this.cryptoNetAccount != null) {
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();
}
}

View file

@ -0,0 +1,116 @@
package cy.agorise.crystalwallet.fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.dao.CrystalDatabase;
import cy.agorise.crystalwallet.enums.CryptoNet;
import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.models.CryptoNetSelection;
import cy.agorise.crystalwallet.requestmanagers.CreateBitcoinAccountRequest;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
import cy.agorise.crystalwallet.views.CryptoNetSelectionListAdapter;
/**
* Created by xd on 12/28/17.
*/
public class GeneralAccountSeedCoinSettingsFragment extends Fragment implements CryptoNetSelectionListAdapter.CryptoNetSelectionListener {
@BindView(R.id.rvCoinSelection)
RecyclerView rvCoinSelection;
AccountSeed accountSeed;
ArrayList<CryptoNetSelection> cryptoNetSelectionList;
public GeneralAccountSeedCoinSettingsFragment() {
if (getArguments() != null) {
long accountSeedId = getArguments().getLong("SEED_ID", -1);
if (accountSeedId > -1) {
this.accountSeed = CrystalDatabase.getAppDatabase(getContext()).accountSeedDao().findById(accountSeedId);
}
}
cryptoNetSelectionList = new ArrayList<CryptoNetSelection>();
CryptoNetSelection nextCryptoNetSelection;
for (CryptoNet nextCryptoNet : CryptoNet.values()){
if ((nextCryptoNet != CryptoNet.UNKNOWN) && (nextCryptoNet != CryptoNet.BITCOIN_TEST)) {
nextCryptoNetSelection = new CryptoNetSelection(nextCryptoNet, false);
cryptoNetSelectionList.add(nextCryptoNetSelection);
}
}
// Required empty public constructor
}
public static GeneralAccountSeedCoinSettingsFragment newInstance(long accountSeedId) {
GeneralAccountSeedCoinSettingsFragment fragment = new GeneralAccountSeedCoinSettingsFragment();
Bundle args = new Bundle();
args.putLong("SEED_ID", accountSeedId);
fragment.setArguments(args);
if (accountSeedId > -1){
fragment.accountSeed = CrystalDatabase.getAppDatabase(fragment.getContext()).accountSeedDao().findById(accountSeedId);
}
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_general_account_seed_coin_settings, container, false);
ButterKnife.bind(this, v);
CryptoNetSelectionListAdapter cryptoNetSelectionListAdapter = new CryptoNetSelectionListAdapter(this.cryptoNetSelectionList);
cryptoNetSelectionListAdapter.addListener(this);
rvCoinSelection.setAdapter(cryptoNetSelectionListAdapter);
LinearLayoutManager llm = new LinearLayoutManager(this.getContext());
llm.setOrientation(LinearLayoutManager.VERTICAL);
rvCoinSelection.setLayoutManager(llm);
return v;
}
@Override
public void onCryptoNetSelectionChecked(CryptoNetSelection source) {
//Toast.makeText(this.getContext(),"the coin "+source.getCryptoNet().name()+" was "+(source.getSelected()?"selected":"unselected"),Toast.LENGTH_LONG).show();
final CreateBitcoinAccountRequest request = new CreateBitcoinAccountRequest(this.accountSeed,this.getContext(),source.getCryptoNet());
request.setListener(new CryptoNetInfoRequestListener() {
@Override
public void onCarryOut() {
if (request.getStatus() == CreateBitcoinAccountRequest.StatusCode.SUCCEEDED){
Toast.makeText(getContext(),"The account was successfully created",Toast.LENGTH_LONG);
} else {
Toast.makeText(getContext(),"There was an error enabling the account",Toast.LENGTH_LONG);
}
}
});
CryptoNetInfoRequests.getInstance().addRequest(request);
}
}

View file

@ -0,0 +1,122 @@
package cy.agorise.crystalwallet.fragments;
import android.app.Activity;
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;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.thekhaeng.pushdownanim.PushDownAnim;
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;
import cy.agorise.crystalwallet.models.CryptoNetAccount;
/**
* Created by xd on 12/28/17.
*/
public class GeneralAccountSeedFragment extends Fragment {
@BindView(R.id.tvMnemonic)
TextView tvMnemonic;
@BindView(R.id.btnCopy)
Button btnCopy;
AccountSeed accountSeed;
public GeneralAccountSeedFragment() {
if (getArguments() != null) {
long accountSeedId = getArguments().getLong("SEED_ID", -1);
if (accountSeedId > -1) {
this.accountSeed = CrystalDatabase.getAppDatabase(getContext()).accountSeedDao().findById(accountSeedId);
}
}
// Required empty public constructor
}
public static GeneralAccountSeedFragment newInstance(long accountSeedId) {
GeneralAccountSeedFragment fragment = new GeneralAccountSeedFragment();
Bundle args = new Bundle();
args.putLong("SEED_ID", accountSeedId);
fragment.setArguments(args);
if (accountSeedId > -1){
fragment.accountSeed = CrystalDatabase.getAppDatabase(fragment.getContext()).accountSeedDao().findById(accountSeedId);
}
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_general_crypto_net_account_settings, container, false);
ButterKnife.bind(this, v);
/*
* Integration of library with button efects
* */
PushDownAnim.setPushDownAnimTo(btnCopy)
.setOnClickListener( new View.OnClickListener(){
@Override
public void onClick( View view ){
btnCopyClick();
}
} );
initAlreadyLtm();
return v;
}
public void initAlreadyLtm(){
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();
}
}

View file

@ -0,0 +1,45 @@
package cy.agorise.crystalwallet.models;
import android.support.annotation.NonNull;
import android.support.v7.util.DiffUtil;
import cy.agorise.crystalwallet.enums.CryptoNet;
public class CryptoNetSelection {
CryptoNet cryptoNet;
Boolean selected;
public CryptoNetSelection(CryptoNet cryptoNet, Boolean selected) {
this.cryptoNet = cryptoNet;
this.selected = selected;
}
public CryptoNet getCryptoNet() {
return cryptoNet;
}
public void setCryptoNet(CryptoNet cryptoNet) {
this.cryptoNet = cryptoNet;
}
public Boolean getSelected() {
return selected;
}
public void setSelected(Boolean selected) {
this.selected = selected;
}
public static final DiffUtil.ItemCallback<CryptoNetSelection> DIFF_CALLBACK = new DiffUtil.ItemCallback<CryptoNetSelection>() {
@Override
public boolean areItemsTheSame(
@NonNull CryptoNetSelection oldCryptoNetSelection, @NonNull CryptoNetSelection newCryptoNetSelection) {
return oldCryptoNetSelection.getCryptoNet() == newCryptoNetSelection.getCryptoNet();
}
@Override
public boolean areContentsTheSame(
@NonNull CryptoNetSelection oldCryptoNetSelection, @NonNull CryptoNetSelection newCryptoNetSelection) {
return oldCryptoNetSelection.equals(newCryptoNetSelection);
}
};
}

View file

@ -7,6 +7,7 @@ import android.view.View;
import android.widget.TextView;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.activities.AccountSeedSettingsActivity;
import cy.agorise.crystalwallet.activities.BackupSeedActivity;
import cy.agorise.crystalwallet.activities.SettingsActivity;
import cy.agorise.crystalwallet.models.AccountSeed;
@ -39,7 +40,7 @@ public class AccountSeedViewHolder extends RecyclerView.ViewHolder {
tvAccountSeedName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, BackupSeedActivity.class);
Intent intent = new Intent(context, AccountSeedSettingsActivity.class);
intent.putExtra("SEED_ID", accountSeed.getId());
context.startActivity(intent);
}

View file

@ -0,0 +1,91 @@
package cy.agorise.crystalwallet.views;
import android.support.annotation.NonNull;
import android.support.v7.recyclerview.extensions.ListAdapter;
import android.support.v7.util.DiffUtil;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.Toast;
import org.tukaani.xz.check.Check;
import java.util.ArrayList;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
import cy.agorise.crystalwallet.models.CryptoNetSelection;
/**
* Created by Henry Varona on 10/30/2018.
*
*/
public class CryptoNetSelectionListAdapter extends ListAdapter<CryptoNetSelection, CryptoNetSelectionViewHolder> {
private ArrayList<CryptoNetSelection> cryptoNetSelections = new ArrayList<CryptoNetSelection>();
private ArrayList<CryptoNetSelectionListener> listeners = new ArrayList<>();
public CryptoNetSelectionListAdapter(ArrayList<CryptoNetSelection> cryptoNetSelections) {
super(CryptoNetSelection.DIFF_CALLBACK);
this.cryptoNetSelections = cryptoNetSelections;
}
public CryptoNetSelection findCryptoNetSelectionByName(String name){
for(CryptoNetSelection nextCryptoNetSelection : this.cryptoNetSelections){
if (nextCryptoNetSelection.getCryptoNet().getLabel().equals(name)){
return nextCryptoNetSelection;
}
}
return null;
}
@NonNull
@Override
public CryptoNetSelectionViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.crypto_net_selection_item,parent,false);
final CheckBox cbCryptoNetSelected = v.findViewById(R.id.cbCryptoNetSelected);
final TextView tvCryptoNetName = v.findViewById(R.id.tvCryptoNetName);
cbCryptoNetSelected.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
CryptoNetSelection cryptoNetSelection = findCryptoNetSelectionByName(tvCryptoNetName.getText().toString());
cryptoNetSelection.setSelected(b);
_fireOnChecked(cryptoNetSelection);
}
});
return new CryptoNetSelectionViewHolder(v);
}
@Override
public int getItemCount() {
return cryptoNetSelections.size();
}
@Override
public void onBindViewHolder(@NonNull CryptoNetSelectionViewHolder holder, int position) {
holder.bindTo(cryptoNetSelections.get(position));
}
public void addListener(CryptoNetSelectionListener listener){
this.listeners.add(listener);
}
public void _fireOnChecked(CryptoNetSelection selection){
for(CryptoNetSelectionListener listener:this.listeners){
listener.onCryptoNetSelectionChecked(selection);
}
}
public interface CryptoNetSelectionListener{
public void onCryptoNetSelectionChecked(CryptoNetSelection source);
}
}

View file

@ -0,0 +1,64 @@
package cy.agorise.crystalwallet.views;
import android.arch.lifecycle.LifecycleOwner;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.Observer;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.dao.CrystalDatabase;
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
import cy.agorise.crystalwallet.models.CryptoCurrency;
import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence;
import cy.agorise.crystalwallet.models.CryptoNetSelection;
import cy.agorise.crystalwallet.models.GeneralSetting;
/**
* Created by Henry Varona on 10/30/2018.
*
*/
public class CryptoNetSelectionViewHolder extends RecyclerView.ViewHolder {
/*
* the view holding the crypto coin name
*/
private TextView cryptoNetName;
private CheckBox cryptoNetCheckBox;
private Context context;
public CryptoNetSelectionViewHolder(View itemView) {
super(itemView);
//TODO: use ButterKnife to load this
cryptoNetName = (TextView) itemView.findViewById(R.id.tvCryptoNetName);
cryptoNetCheckBox = (CheckBox) itemView.findViewById(R.id.cbCryptoNetSelected);
this.context = itemView.getContext();
}
/*
* Clears the information in this element view
*/
public void clear(){
cryptoNetName.setText("");
cryptoNetCheckBox.setSelected(false);
}
/*
* Binds this view with the data of an element of the list
*/
public void bindTo(final CryptoNetSelection cryptoNetSelection) {
if (cryptoNetSelection == null){
this.clear();
} else {
cryptoNetName.setText(cryptoNetSelection.getCryptoNet().getLabel());
cryptoNetCheckBox.setSelected(cryptoNetSelection.getSelected());
}
}
}

View file

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.AccountSeedSettingsActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="@color/colorPrimary"
app:theme="@style/AppTheme.AppBarOverlay">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ivAppBarAnimation"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryTransparent"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/transparent"
android:layout_marginTop="8dp"
app:popupTheme="@style/AppTheme.PopupOverlay">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ivGoBack"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="8dp"
app:srcCompat="@drawable/ic_arrow_back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/go_back_arrow" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="Account Seed Settings"
android:textColor="@color/semiTransparentWhite"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/ivGoBack"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/ivInfo"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="24dp"
app:srcCompat="@drawable/ic_info_outline"
android:contentDescription="@string/info_icon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<android.support.design.widget.TabItem
android:id="@+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/general" />
<android.support.design.widget.TabItem
android:id="@+id/tabItem1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Coins" />
</android.support.design.widget.TabLayout>
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottomStatusBar"/>
<cy.agorise.crystalwallet.util.BottomStatusBar
android:id="@+id/bottomStatusBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>

View file

@ -101,7 +101,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/secondView" />
-->
<cy.agorise.crystalwallet.views.CryptoNetAccountListView
<cy.agorise.crystalwallet.views.AccountSeedListView
android:id="@+id/vAccountSeedList"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/secondView" />
<!--<cy.agorise.crystalwallet.views.CryptoNetAccountListView
android:id="@+id/vAccountList"
android:layout_width="match_parent"
android:layout_height="250dp"
@ -109,7 +117,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/secondView" />
-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -119,10 +127,10 @@
android:textAlignment="center"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/vAccountList"
app:layout_constraintEnd_toEndOf="@id/vAccountList"
app:layout_constraintStart_toStartOf="@id/vAccountList"
app:layout_constraintTop_toTopOf="@id/vAccountList" />
app:layout_constraintBottom_toBottomOf="@id/vAccountSeedList"
app:layout_constraintEnd_toEndOf="@id/vAccountSeedList"
app:layout_constraintStart_toStartOf="@id/vAccountSeedList"
app:layout_constraintTop_toTopOf="@id/vAccountSeedList" />
<View
android:id="@+id/forthView"
@ -131,7 +139,7 @@
android:background="@color/lightGray"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vAccountList" />
app:layout_constraintTop_toBottomOf="@id/vAccountSeedList" />
<ImageView
android:id="@+id/ivSettings"

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<CheckBox
android:id="@+id/cbCryptoNetSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tvCryptoNetName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/cbCryptoNetSelected"
android:ems="10"
android:text="unknown coin" />
</RelativeLayout>
</LinearLayout>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="25dp"
android:background="@color/white"
android:paddingRight="25dp"
android:paddingTop="@dimen/activity_vertical_margin">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvCoinSelection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="20dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>