Created basic ImportBrainkeyActivity and a method to take the user to the MainActivity or ImportBrainkeyActivity depending on whether or not there is an active account after the user accepts the License.

This commit is contained in:
Severiano Jaramillo 2018-11-21 17:43:51 -06:00
parent f19556c925
commit 6b55151e3b
6 changed files with 56 additions and 9 deletions

View file

@ -30,6 +30,7 @@
</activity> </activity>
<activity android:name=".activities.MainActivity"/> <activity android:name=".activities.MainActivity"/>
<activity android:name=".activities.LicenseActivity"/> <activity android:name=".activities.LicenseActivity"/>
<activity android:name=".activities.ImportBrainkeyActivity"/>
</application> </application>
</manifest> </manifest>

View file

@ -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)
}
}

View file

@ -1,5 +1,6 @@
package cy.agorise.bitsybitshareswallet.activities package cy.agorise.bitsybitshareswallet.activities
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.preference.PreferenceManager import android.preference.PreferenceManager
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@ -7,7 +8,10 @@ import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.bitsybitshareswallet.utils.Constants
import kotlinx.android.synthetic.main.activity_license.* import kotlinx.android.synthetic.main.activity_license.*
const val CURRENT_LICENSE_VERSION = 1
class LicenseActivity : AppCompatActivity() { class LicenseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_license) setContentView(R.layout.activity_license)
@ -17,7 +21,7 @@ class LicenseActivity : AppCompatActivity() {
.getInt(Constants.KEY_LAST_AGREED_LICENSE_VERSION, 0) .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 the last agreed license version is the actual one then proceed to the following Activities
if (agreedLicenseVersion == 1) { if (agreedLicenseVersion == CURRENT_LICENSE_VERSION) {
agree() agree()
} else { } else {
wbLA.loadData(getString(R.string.licence_html), "text/html", "UTF-8") 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() { 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()
} }
} }

View file

@ -3,13 +3,12 @@ package cy.agorise.bitsybitshareswallet.utils
object Constants { object Constants {
/** /** Key used to store the number of the 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"
*/
const val KEY_LAST_AGREED_LICENSE_VERSION = "last_agreed_license_version"
/** /** Key used to store if the initial setup is already done or not */
* Key used to store the night mode setting into the shared preferences 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" const val KEY_NIGHT_MODE_ACTIVATED = "key_night_mode_activated"
} }

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Import"/>
</LinearLayout>

View file

@ -36,7 +36,7 @@
</style> </style>
<style name="Widget.PalmPay.Button.TextButton" parent="Widget.MaterialComponents.Button.TextButton"> <style name="Widget.PalmPay.Button.TextButton" parent="Widget.MaterialComponents.Button.TextButton">
<item name="android:textColor">?android:attr/colorPrimaryDark</item> <item name="android:textColor">?android:attr/colorPrimary</item>
</style> </style>
<!-- Text styles --> <!-- Text styles -->