diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1c61fb1..9f6fed7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -30,6 +30,7 @@ + \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ImportBrainkeyActivity.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ImportBrainkeyActivity.kt new file mode 100644 index 0000000..b2a2b4b --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ImportBrainkeyActivity.kt @@ -0,0 +1,12 @@ +package cy.agorise.bitsybitshareswallet.activities + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import cy.agorise.bitsybitshareswallet.R + +class ImportBrainkeyActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_import_brainkey) + } +} \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/LicenseActivity.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/LicenseActivity.kt index af9f8d4..6dcfbc4 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/LicenseActivity.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/LicenseActivity.kt @@ -1,5 +1,6 @@ package cy.agorise.bitsybitshareswallet.activities +import android.content.Intent import android.os.Bundle import android.preference.PreferenceManager import androidx.appcompat.app.AppCompatActivity @@ -7,7 +8,10 @@ import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.utils.Constants import kotlinx.android.synthetic.main.activity_license.* +const val CURRENT_LICENSE_VERSION = 1 + class LicenseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_license) @@ -17,7 +21,7 @@ class LicenseActivity : AppCompatActivity() { .getInt(Constants.KEY_LAST_AGREED_LICENSE_VERSION, 0) // If the last agreed license version is the actual one then proceed to the following Activities - if (agreedLicenseVersion == 1) { + if (agreedLicenseVersion == CURRENT_LICENSE_VERSION) { agree() } else { wbLA.loadData(getString(R.string.licence_html), "text/html", "UTF-8") @@ -28,7 +32,25 @@ class LicenseActivity : AppCompatActivity() { } } + /** + * This function stores the version of the current accepted license version into the Shared Preferences and + * sends the user to either import/create account if there is no active account or to the MainActivity otherwise + */ private fun agree() { + PreferenceManager.getDefaultSharedPreferences(this).edit() + .putInt(Constants.KEY_LAST_AGREED_LICENSE_VERSION, CURRENT_LICENSE_VERSION).apply() + val intent : Intent? + + val initialSetupDone = PreferenceManager.getDefaultSharedPreferences(this) + .getBoolean(Constants.KEY_INITIAL_SETUP_DONE, false) + + intent = if (initialSetupDone) + Intent(this, MainActivity::class.java) + else + Intent(this, ImportBrainkeyActivity::class.java) + + startActivity(intent) + finish() } } \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt index 0e9524d..c8ed782 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt @@ -3,13 +3,12 @@ package cy.agorise.bitsybitshareswallet.utils object Constants { - /** - * Key used to store the number of the last agreed License version - */ - const val KEY_LAST_AGREED_LICENSE_VERSION = "last_agreed_license_version" + /** Key used to store the number of the last agreed License version */ + const val KEY_LAST_AGREED_LICENSE_VERSION = "key_last_agreed_license_version" - /** - * Key used to store the night mode setting into the shared preferences - */ + /** Key used to store if the initial setup is already done or not */ + const val KEY_INITIAL_SETUP_DONE = "key_initial_setup_done" + + /** Key used to store the night mode setting into the shared preferences */ const val KEY_NIGHT_MODE_ACTIVATED = "key_night_mode_activated" } diff --git a/app/src/main/res/layout/activity_import_brainkey.xml b/app/src/main/res/layout/activity_import_brainkey.xml new file mode 100644 index 0000000..183b943 --- /dev/null +++ b/app/src/main/res/layout/activity_import_brainkey.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index cb43b60..298bc0a 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -36,7 +36,7 @@