- Making LicenseActivity save the last version of the license accepted
This commit is contained in:
parent
a31e377d63
commit
3252062e74
5 changed files with 48 additions and 15 deletions
|
@ -25,6 +25,7 @@ import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||||
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoCoinBalanceGenerator;
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoCoinBalanceGenerator;
|
||||||
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoNetAccountGenerator;
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoNetAccountGenerator;
|
||||||
import cy.agorise.crystalwallet.randomdatagenerators.RandomSeedGenerator;
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomSeedGenerator;
|
||||||
|
@ -79,10 +80,12 @@ public class IntroActivity extends AppCompatActivity {
|
||||||
this.getApplication().registerActivityLifecycleCallbacks(CrystalSecurityMonitor.getInstance(this));
|
this.getApplication().registerActivityLifecycleCallbacks(CrystalSecurityMonitor.getInstance(this));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Checks if the user has any seed created
|
//Checks if the user has any seed created
|
||||||
AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of(this).get(AccountSeedListViewModel.class);
|
AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of(this).get(AccountSeedListViewModel.class);
|
||||||
|
|
||||||
if (accountSeedListViewModel.accountSeedsCount() == 0){
|
if (accountSeedListViewModel.accountSeedsCount() == 0) {
|
||||||
//If the user doesn't have any seeds created, then
|
//If the user doesn't have any seeds created, then
|
||||||
//send the user to create/import an account
|
//send the user to create/import an account
|
||||||
//Intent intent = new Intent(this, AccountSeedsManagementActivity.class);
|
//Intent intent = new Intent(this, AccountSeedsManagementActivity.class);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cy.agorise.crystalwallet.activities;
|
package cy.agorise.crystalwallet.activities;
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -9,11 +10,15 @@ 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.dao.CrystalDatabase;
|
||||||
|
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||||
|
|
||||||
public class LicenseActivity extends AppCompatActivity {
|
public class LicenseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@BindView(R.id.wvEULA) WebView wvEULA;
|
@BindView(R.id.wvEULA) WebView wvEULA;
|
||||||
|
|
||||||
|
CrystalDatabase db;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -24,11 +29,29 @@ public class LicenseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
String html = getString(R.string.licence_html);
|
String html = getString(R.string.licence_html);
|
||||||
wvEULA.loadData(html, "text/html", "UTF-8");
|
wvEULA.loadData(html, "text/html", "UTF-8");
|
||||||
|
|
||||||
|
db = CrystalDatabase.getAppDatabase(this.getApplicationContext());
|
||||||
|
int licenseVersion = getResources().getInteger(R.integer.license_version);
|
||||||
|
GeneralSetting generalSettingLastLicenseRead = db.generalSettingDao().getSettingByName(GeneralSetting.SETTING_LAST_LICENSE_READ);
|
||||||
|
|
||||||
|
if ((generalSettingLastLicenseRead != null) && (Integer.parseInt(generalSettingLastLicenseRead.getValue()) >= licenseVersion)) {
|
||||||
|
Intent intent = new Intent(this, IntroActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.btnAgree)
|
@OnClick(R.id.btnAgree)
|
||||||
public void onAgree() {
|
public void onAgree() {
|
||||||
// TODO send user to Intro activity if no active account or to Board activity otherwise
|
CrystalDatabase db = CrystalDatabase.getAppDatabase(this.getApplicationContext());
|
||||||
|
GeneralSetting lastLicenseReadSetting = new GeneralSetting();
|
||||||
|
lastLicenseReadSetting.setName(GeneralSetting.SETTING_LAST_LICENSE_READ);
|
||||||
|
lastLicenseReadSetting.setValue(""+getResources().getInteger(R.integer.license_version));
|
||||||
|
|
||||||
|
db.generalSettingDao().deleteByName(GeneralSetting.SETTING_LAST_LICENSE_READ);
|
||||||
|
db.generalSettingDao().insertGeneralSetting(lastLicenseReadSetting);
|
||||||
|
|
||||||
|
Intent intent = new Intent(this, IntroActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.btnDisAgree)
|
@OnClick(R.id.btnDisAgree)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.idescout.sql.SqlScoutServer;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||||
import cy.agorise.crystalwallet.models.BitsharesAsset;
|
import cy.agorise.crystalwallet.models.BitsharesAsset;
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class GeneralSetting {
|
||||||
public final static String SETTING_PASSWORD = "PASSWORD";
|
public final static String SETTING_PASSWORD = "PASSWORD";
|
||||||
public final static String SETTING_PATTERN = "PATTERN";
|
public final static String SETTING_PATTERN = "PATTERN";
|
||||||
public final static String SETTING_NAME_RECEIVED_FUNDS_SOUND_PATH = "RECEIVED_FUNDS_SOUND_PATH";
|
public final static String SETTING_NAME_RECEIVED_FUNDS_SOUND_PATH = "RECEIVED_FUNDS_SOUND_PATH";
|
||||||
|
public final static String SETTING_LAST_LICENSE_READ = "LAST_LICENSE_READ";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id on the database
|
* The id on the database
|
||||||
|
|
5
app/src/main/res/values/integers.xml
Normal file
5
app/src/main/res/values/integers.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<integer name="license_version">1</integer>
|
||||||
|
|
||||||
|
</resources>
|
Loading…
Reference in a new issue