- 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 android:name=".activities.CryptoCoinTransactionReceiptActivity" >
</activity>
<activity android:name=".activities.BackupSeedActivity" >
</activity>
<activity android:name=".activities.SettingsActivity"
android:theme="@style/AppTheme.NoActionBar" >
</activity>

View file

@ -1,16 +1,24 @@
package cy.agorise.crystalwallet.activities;
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.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
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.
@ -25,11 +33,25 @@ public class AccountsActivity extends AppCompatActivity {
@BindView(R.id.tvClose)
TextView tvClose;
@BindView(R.id.vAccountSeedList)
AccountSeedListView vAccountSeedList;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_accounts);
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)

View file

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

View file

@ -1,10 +1,14 @@
package cy.agorise.crystalwallet.views;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
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.CryptoCoinTransaction;
@ -14,10 +18,12 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
public class AccountSeedViewHolder extends RecyclerView.ViewHolder {
private TextView tvAccountSeedName;
private Context context;
public AccountSeedViewHolder(View itemView) {
super(itemView);
tvAccountSeedName = (TextView) itemView.findViewById(R.id.tvAccountSeedName);
context = itemView.getContext();
}
public void clear(){
@ -29,6 +35,15 @@ public class AccountSeedViewHolder extends RecyclerView.ViewHolder {
tvAccountSeedName.setText("loading...");
} else {
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:srcCompat="@drawable/ic_add_24dp" />
<View
<!--<View
android:id="@+id/thirdView"
android:layout_width="match_parent"
android:layout_height="250dp"
@ -97,6 +97,15 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
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
android:layout_width="match_parent"
@ -106,10 +115,10 @@
android:text="@string/dont_have_multiple_accounts"
android:textAlignment="center"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@id/thirdView"
app:layout_constraintEnd_toEndOf="@id/thirdView"
app:layout_constraintStart_toStartOf="@id/thirdView"
app:layout_constraintTop_toTopOf="@id/thirdView" />
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"
@ -118,7 +127,7 @@
android:background="@color/lightGray"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/thirdView" />
app:layout_constraintTop_toBottomOf="@id/vAccountSeedList" />
<ImageView
android:id="@+id/ivSettings"