- Added list of accounts (seeds) in "My Accounts"

- Fixed some errors in Backup Activity
This commit is contained in:
Javier Varona 2018-01-22 22:18:15 -04:00
parent 159743b54e
commit dfc751c5f8
5 changed files with 57 additions and 8 deletions

View file

@ -34,6 +34,8 @@
</activity> </activity>
<activity android:name=".activities.CryptoCoinTransactionReceiptActivity" > <activity android:name=".activities.CryptoCoinTransactionReceiptActivity" >
</activity> </activity>
<activity android:name=".activities.BackupSeedActivity" >
</activity>
<activity android:name=".activities.SettingsActivity" <activity android:name=".activities.SettingsActivity"
android:theme="@style/AppTheme.NoActionBar" > android:theme="@style/AppTheme.NoActionBar" >
</activity> </activity>

View file

@ -1,16 +1,24 @@
package cy.agorise.crystalwallet.activities; package cy.agorise.crystalwallet.activities;
import android.app.Activity; import android.app.Activity;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.widget.TextView; import android.widget.TextView;
import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.viewmodels.AccountSeedListViewModel;
import cy.agorise.crystalwallet.views.AccountSeedListView;
/** /**
* Created by xd on 1/9/18. * Created by xd on 1/9/18.
@ -25,11 +33,25 @@ public class AccountsActivity extends AppCompatActivity {
@BindView(R.id.tvClose) @BindView(R.id.tvClose)
TextView tvClose; TextView tvClose;
@BindView(R.id.vAccountSeedList)
AccountSeedListView vAccountSeedList;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_accounts); setContentView(R.layout.activity_accounts);
ButterKnife.bind(this); ButterKnife.bind(this);
AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of(this).get(AccountSeedListViewModel.class);
LiveData<List<AccountSeed>> accountSeedData = accountSeedListViewModel.getAccountSeedList();
vAccountSeedList.setData(null);
accountSeedData.observe(this, new Observer<List<AccountSeed>>() {
@Override
public void onChanged(List<AccountSeed> accountSeeds) {
vAccountSeedList.setData(accountSeeds);
}
});
} }
@OnClick(R.id.tvSettings) @OnClick(R.id.tvSettings)

View file

@ -46,6 +46,7 @@ public class BackupSeedActivity extends AppCompatActivity {
if (seedId > -1) { if (seedId > -1) {
accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class); accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class);
accountSeedViewModel.loadSeed(seedId);
LiveData<AccountSeed> liveDataAccountSeed = accountSeedViewModel.getAccountSeed(); LiveData<AccountSeed> liveDataAccountSeed = accountSeedViewModel.getAccountSeed();
liveDataAccountSeed.observe(this, new Observer<AccountSeed>() { liveDataAccountSeed.observe(this, new Observer<AccountSeed>() {
@Override @Override
@ -60,8 +61,8 @@ public class BackupSeedActivity extends AppCompatActivity {
} }
} }
@OnClick(R.id.btnCancel) @OnClick(R.id.btnOk)
public void cancel(){ public void btnOkClick(){
this.finish(); this.finish();
} }
} }

View file

@ -1,10 +1,14 @@
package cy.agorise.crystalwallet.views; package cy.agorise.crystalwallet.views;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.activities.BackupSeedActivity;
import cy.agorise.crystalwallet.activities.SettingsActivity;
import cy.agorise.crystalwallet.models.AccountSeed; import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.models.CryptoCoinTransaction; import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
@ -14,10 +18,12 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
public class AccountSeedViewHolder extends RecyclerView.ViewHolder { public class AccountSeedViewHolder extends RecyclerView.ViewHolder {
private TextView tvAccountSeedName; private TextView tvAccountSeedName;
private Context context;
public AccountSeedViewHolder(View itemView) { public AccountSeedViewHolder(View itemView) {
super(itemView); super(itemView);
tvAccountSeedName = (TextView) itemView.findViewById(R.id.tvAccountSeedName); tvAccountSeedName = (TextView) itemView.findViewById(R.id.tvAccountSeedName);
context = itemView.getContext();
} }
public void clear(){ public void clear(){
@ -29,6 +35,15 @@ public class AccountSeedViewHolder extends RecyclerView.ViewHolder {
tvAccountSeedName.setText("loading..."); tvAccountSeedName.setText("loading...");
} else { } else {
tvAccountSeedName.setText(accountSeed.getName()); tvAccountSeedName.setText(accountSeed.getName());
tvAccountSeedName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, BackupSeedActivity.class);
intent.putExtra("SEED_ID", accountSeed.getId());
context.startActivity(intent);
}
});
} }
} }
} }

View file

@ -89,7 +89,7 @@
app:layout_constraintTop_toTopOf="@id/secondView" app:layout_constraintTop_toTopOf="@id/secondView"
app:srcCompat="@drawable/ic_add_24dp" /> app:srcCompat="@drawable/ic_add_24dp" />
<View <!--<View
android:id="@+id/thirdView" android:id="@+id/thirdView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="250dp" android:layout_height="250dp"
@ -97,6 +97,15 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/secondView" /> app:layout_constraintTop_toBottomOf="@id/secondView" />
-->
<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" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -106,10 +115,10 @@
android:text="@string/dont_have_multiple_accounts" android:text="@string/dont_have_multiple_accounts"
android:textAlignment="center" android:textAlignment="center"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@id/thirdView" app:layout_constraintBottom_toBottomOf="@id/vAccountSeedList"
app:layout_constraintEnd_toEndOf="@id/thirdView" app:layout_constraintEnd_toEndOf="@id/vAccountSeedList"
app:layout_constraintStart_toStartOf="@id/thirdView" app:layout_constraintStart_toStartOf="@id/vAccountSeedList"
app:layout_constraintTop_toTopOf="@id/thirdView" /> app:layout_constraintTop_toTopOf="@id/vAccountSeedList" />
<View <View
android:id="@+id/forthView" android:id="@+id/forthView"
@ -118,7 +127,7 @@
android:background="@color/lightGray" android:background="@color/lightGray"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/thirdView" /> app:layout_constraintTop_toBottomOf="@id/vAccountSeedList" />
<ImageView <ImageView
android:id="@+id/ivSettings" android:id="@+id/ivSettings"