2017-10-01 01:52:34 +00:00
|
|
|
package cy.agorise.crystalwallet.activities;
|
2017-09-08 00:31:38 +00:00
|
|
|
|
2017-09-14 02:09:58 +00:00
|
|
|
import android.arch.lifecycle.ViewModelProviders;
|
2017-10-01 01:52:34 +00:00
|
|
|
import android.content.Intent;
|
2018-01-26 00:37:29 +00:00
|
|
|
import android.media.MediaPlayer;
|
2017-09-08 00:31:38 +00:00
|
|
|
import android.os.Bundle;
|
2017-09-17 00:41:10 +00:00
|
|
|
import android.support.annotation.Nullable;
|
2018-01-26 02:48:04 +00:00
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
import android.support.v4.app.FragmentTransaction;
|
2017-09-08 00:31:38 +00:00
|
|
|
import android.support.v7.app.AppCompatActivity;
|
2018-01-26 00:37:29 +00:00
|
|
|
import android.view.SurfaceHolder;
|
|
|
|
import android.view.SurfaceView;
|
2017-09-17 00:41:10 +00:00
|
|
|
import android.view.View;
|
|
|
|
import android.widget.Button;
|
2018-08-15 22:36:20 +00:00
|
|
|
import android.widget.Toast;
|
2017-09-08 00:31:38 +00:00
|
|
|
|
2017-09-17 00:41:10 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2018-01-24 23:21:34 +00:00
|
|
|
import butterknife.BindView;
|
|
|
|
import butterknife.ButterKnife;
|
|
|
|
import butterknife.OnClick;
|
2017-10-01 01:52:34 +00:00
|
|
|
import cy.agorise.crystalwallet.R;
|
2018-08-15 22:36:20 +00:00
|
|
|
import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator;
|
|
|
|
import cy.agorise.crystalwallet.application.CrystalApplication;
|
2017-09-17 00:41:10 +00:00
|
|
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
2018-08-15 22:36:20 +00:00
|
|
|
import cy.agorise.crystalwallet.dialogs.material.ToastIt;
|
|
|
|
import cy.agorise.crystalwallet.enums.CryptoNet;
|
2018-01-26 02:48:04 +00:00
|
|
|
import cy.agorise.crystalwallet.fragments.ImportAccountOptionsFragment;
|
2017-09-27 02:24:23 +00:00
|
|
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
2017-10-18 00:35:37 +00:00
|
|
|
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
2017-09-17 00:41:10 +00:00
|
|
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
2017-09-27 02:24:23 +00:00
|
|
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
2018-05-25 18:30:45 +00:00
|
|
|
import cy.agorise.crystalwallet.models.GeneralSetting;
|
2018-08-15 22:36:20 +00:00
|
|
|
import cy.agorise.crystalwallet.network.CryptoNetManager;
|
2017-10-18 00:35:37 +00:00
|
|
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoCoinBalanceGenerator;
|
2017-09-27 02:24:23 +00:00
|
|
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoNetAccountGenerator;
|
|
|
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomSeedGenerator;
|
2017-09-24 21:52:32 +00:00
|
|
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomTransactionsGenerator;
|
2018-02-01 00:42:19 +00:00
|
|
|
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
|
2017-10-01 01:52:34 +00:00
|
|
|
import cy.agorise.crystalwallet.viewmodels.AccountSeedListViewModel;
|
2017-09-14 01:06:51 +00:00
|
|
|
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
|
|
|
|
import cy.agorise.crystalwallet.views.TransactionListView;
|
|
|
|
|
2018-08-15 22:36:20 +00:00
|
|
|
public class IntroActivity extends CustomActivity {
|
2017-09-08 00:31:38 +00:00
|
|
|
|
2018-01-26 00:37:29 +00:00
|
|
|
@BindView(R.id.surface_view)
|
|
|
|
public SurfaceView mSurfaceView;
|
|
|
|
|
2018-01-24 23:21:34 +00:00
|
|
|
@BindView(R.id.btnCreateAccount)
|
|
|
|
public Button btnCreateAccount;
|
|
|
|
|
|
|
|
@BindView(R.id.btnImportAccount)
|
|
|
|
public Button btnImportAccount;
|
|
|
|
|
2017-09-08 00:31:38 +00:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_intro);
|
2018-08-15 22:36:20 +00:00
|
|
|
|
2018-01-24 23:21:34 +00:00
|
|
|
ButterKnife.bind(this);
|
2017-09-14 01:06:51 +00:00
|
|
|
|
2018-01-26 00:37:29 +00:00
|
|
|
// Appbar animation
|
|
|
|
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
|
|
|
|
@Override
|
|
|
|
public void surfaceCreated(SurfaceHolder surfaceHolder) {
|
|
|
|
//Log.d(TAG,"surfaceCreated");
|
|
|
|
MediaPlayer mediaPlayer = MediaPlayer.create(IntroActivity.this, R.raw.appbar_background);
|
|
|
|
mediaPlayer.setDisplay(mSurfaceView.getHolder());
|
|
|
|
mediaPlayer.setLooping(true);
|
|
|
|
mediaPlayer.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
|
|
|
|
//Log.d(TAG,"surfaceChanged");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
|
|
|
|
//Log.d(TAG,"surfaceDestroyed");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-05-14 01:25:03 +00:00
|
|
|
this.getApplication().registerActivityLifecycleCallbacks(CrystalSecurityMonitor.getInstance(this));
|
2018-02-01 00:42:19 +00:00
|
|
|
|
|
|
|
|
2018-05-25 18:30:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
//Checks if the user has any seed created
|
|
|
|
AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of(this).get(AccountSeedListViewModel.class);
|
|
|
|
|
|
|
|
if (accountSeedListViewModel.accountSeedsCount() == 0) {
|
|
|
|
//If the user doesn't have any seeds created, then
|
|
|
|
//send the user to create/import an account
|
|
|
|
//Intent intent = new Intent(this, AccountSeedsManagementActivity.class);
|
|
|
|
//Intent intent = new Intent(this, ImportSeedActivity.class);
|
|
|
|
//Intent intent = new Intent(this, CreateSeedActivity.class);
|
|
|
|
//startActivity(intent);
|
|
|
|
} else {
|
|
|
|
//Intent intent = new Intent(this, CreateSeedActivity.class);
|
|
|
|
Intent intent = new Intent(this, BoardActivity.class);
|
2018-08-21 00:28:46 +00:00
|
|
|
//Intent intent = new Intent(this, PocketRequestActivity.class);
|
2018-05-25 18:30:45 +00:00
|
|
|
startActivity(intent);
|
2018-07-11 17:41:00 +00:00
|
|
|
finish();
|
2018-05-25 18:30:45 +00:00
|
|
|
}
|
2017-10-01 01:52:34 +00:00
|
|
|
|
2017-09-24 21:52:32 +00:00
|
|
|
/*CrystalDatabase db = CrystalDatabase.getAppDatabase(getApplicationContext());
|
2017-09-27 02:24:23 +00:00
|
|
|
List<AccountSeed> seeds = RandomSeedGenerator.generateSeeds(2);
|
|
|
|
for(int i=0;i<seeds.size();i++) {
|
2017-10-15 02:02:55 +00:00
|
|
|
long newId = db.accountSeedDao().insertAccountSeed(seeds.get(i));
|
2017-09-27 02:24:23 +00:00
|
|
|
seeds.get(i).setId(newId);
|
|
|
|
}
|
|
|
|
List<CryptoNetAccount> accounts = RandomCryptoNetAccountGenerator.generateAccounts(5,seeds);
|
|
|
|
for(int i=0;i<accounts.size();i++) {
|
|
|
|
long newId = db.cryptoNetAccountDao().insertCryptoNetAccount(accounts.get(i))[0];
|
|
|
|
accounts.get(i).setId(newId);
|
|
|
|
}
|
2017-10-18 00:35:37 +00:00
|
|
|
List<CryptoCoinBalance> balances = RandomCryptoCoinBalanceGenerator.generateCryptoCoinBalances(accounts,5,1,20);
|
|
|
|
for(int i=0;i<balances.size();i++) {
|
|
|
|
long newId = db.cryptoCoinBalanceDao().insertCryptoCoinBalance(balances.get(i))[0];
|
|
|
|
balances.get(i).setId(newId);
|
|
|
|
}
|
2017-09-27 02:24:23 +00:00
|
|
|
List<CryptoCoinTransaction> transactions = RandomTransactionsGenerator.generateTransactions(accounts,100,1262304001,1496275201,1,999999999);
|
2017-09-24 21:52:32 +00:00
|
|
|
for(int i=0;i<transactions.size();i++) {
|
2017-09-27 02:24:23 +00:00
|
|
|
long newId = db.transactionDao().insertTransaction(transactions.get(i))[0];
|
|
|
|
transactions.get(i).setId(newId);
|
2017-09-24 21:52:32 +00:00
|
|
|
}*/
|
|
|
|
|
2017-10-01 01:52:34 +00:00
|
|
|
/*transactionListView = this.findViewById(R.id.transaction_list);
|
2017-09-14 01:06:51 +00:00
|
|
|
|
2017-09-17 00:41:10 +00:00
|
|
|
transactionListViewModel = ViewModelProviders.of(this).get(TransactionListViewModel.class);
|
2017-09-18 02:38:05 +00:00
|
|
|
LiveData<PagedList<CryptoCoinTransaction>> transactionData = transactionListViewModel.getTransactionList();
|
2017-09-24 21:52:32 +00:00
|
|
|
transactionListView.setData(null);
|
2017-09-17 00:41:10 +00:00
|
|
|
|
2017-09-18 02:38:05 +00:00
|
|
|
transactionData.observe(this, new Observer<PagedList<CryptoCoinTransaction>>() {
|
2017-09-17 00:41:10 +00:00
|
|
|
@Override
|
2017-09-18 02:38:05 +00:00
|
|
|
public void onChanged(PagedList<CryptoCoinTransaction> cryptoCoinTransactions) {
|
2017-09-17 00:41:10 +00:00
|
|
|
transactionListView.setData(cryptoCoinTransactions);
|
|
|
|
}
|
2017-10-01 01:52:34 +00:00
|
|
|
});*/
|
2017-09-08 00:31:38 +00:00
|
|
|
}
|
2018-01-24 23:21:34 +00:00
|
|
|
|
|
|
|
@OnClick(R.id.btnCreateAccount)
|
|
|
|
public void createAccount() {
|
2018-09-03 16:52:39 +00:00
|
|
|
Intent intent = new Intent(this, CreateSeedActivity.class);
|
|
|
|
startActivity(intent);
|
2018-01-24 23:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@OnClick(R.id.btnImportAccount)
|
|
|
|
public void importAccount() {
|
2018-09-03 16:52:39 +00:00
|
|
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
|
|
|
Fragment prev = getSupportFragmentManager().findFragmentByTag("importAccountOptions");
|
|
|
|
if (prev != null) {
|
|
|
|
ft.remove(prev);
|
|
|
|
}
|
|
|
|
ft.addToBackStack(null);
|
2018-01-24 23:21:34 +00:00
|
|
|
|
2018-09-03 16:52:39 +00:00
|
|
|
// Create and show the dialog.
|
|
|
|
ImportAccountOptionsFragment newFragment = ImportAccountOptionsFragment.newInstance();
|
|
|
|
newFragment.show(ft, "importAccountOptions");
|
2018-09-14 06:04:10 +00:00
|
|
|
newFragment.setIntroActivity(globalActivity); //This activity should close when import succeds
|
2018-01-24 23:21:34 +00:00
|
|
|
}
|
2017-09-08 00:31:38 +00:00
|
|
|
}
|