- Making LicenseActivity save the last version of the license accepted

This commit is contained in:
Javier Varona 2018-05-25 14:30:45 -04:00
parent a31e377d63
commit 3252062e74
5 changed files with 48 additions and 15 deletions

View file

@ -25,6 +25,7 @@ import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
import cy.agorise.crystalwallet.models.CryptoNetAccount;
import cy.agorise.crystalwallet.models.GeneralSetting;
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoCoinBalanceGenerator;
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoNetAccountGenerator;
import cy.agorise.crystalwallet.randomdatagenerators.RandomSeedGenerator;
@ -79,6 +80,8 @@ public class IntroActivity extends AppCompatActivity {
this.getApplication().registerActivityLifecycleCallbacks(CrystalSecurityMonitor.getInstance(this));
//Checks if the user has any seed created
AccountSeedListViewModel accountSeedListViewModel = ViewModelProviders.of(this).get(AccountSeedListViewModel.class);

View file

@ -1,5 +1,6 @@
package cy.agorise.crystalwallet.activities;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
@ -9,11 +10,15 @@ 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.GeneralSetting;
public class LicenseActivity extends AppCompatActivity {
@BindView(R.id.wvEULA) WebView wvEULA;
CrystalDatabase db;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -24,11 +29,29 @@ public class LicenseActivity extends AppCompatActivity {
String html = getString(R.string.licence_html);
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)
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)

View file

@ -10,6 +10,7 @@ import com.idescout.sql.SqlScoutServer;
import java.util.Locale;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.dao.CrystalDatabase;
import cy.agorise.crystalwallet.enums.CryptoNet;
import cy.agorise.crystalwallet.models.BitsharesAsset;

View file

@ -22,6 +22,7 @@ public class GeneralSetting {
public final static String SETTING_PASSWORD = "PASSWORD";
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_LAST_LICENSE_READ = "LAST_LICENSE_READ";
/**
* The id on the database

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="license_version">1</integer>
</resources>