Add a Security section to the Settings screen, with a Security Lock option where the user can see the currently selected Security Lock option. When it is tapped a dialog appears where the user can select his desired Security Lock (PIN/Pattern/None).
This commit is contained in:
parent
19c50a0b6e
commit
084a90d515
6 changed files with 158 additions and 85 deletions
|
@ -14,12 +14,14 @@ import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.callbacks.onDismiss
|
import com.afollestad.materialdialogs.callbacks.onDismiss
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
import com.afollestad.materialdialogs.list.customListAdapter
|
import com.afollestad.materialdialogs.list.customListAdapter
|
||||||
|
import com.afollestad.materialdialogs.list.listItems
|
||||||
import cy.agorise.bitsybitshareswallet.BuildConfig
|
import cy.agorise.bitsybitshareswallet.BuildConfig
|
||||||
import cy.agorise.bitsybitshareswallet.R
|
import cy.agorise.bitsybitshareswallet.R
|
||||||
import cy.agorise.bitsybitshareswallet.adapters.FullNodesAdapter
|
import cy.agorise.bitsybitshareswallet.adapters.FullNodesAdapter
|
||||||
import cy.agorise.bitsybitshareswallet.repositories.AuthorityRepository
|
import cy.agorise.bitsybitshareswallet.repositories.AuthorityRepository
|
||||||
import cy.agorise.bitsybitshareswallet.utils.Constants
|
import cy.agorise.bitsybitshareswallet.utils.Constants
|
||||||
import cy.agorise.bitsybitshareswallet.utils.CryptoUtils
|
import cy.agorise.bitsybitshareswallet.utils.CryptoUtils
|
||||||
|
import cy.agorise.bitsybitshareswallet.utils.toast
|
||||||
import cy.agorise.graphenej.BrainKey
|
import cy.agorise.graphenej.BrainKey
|
||||||
import cy.agorise.graphenej.api.android.NetworkService
|
import cy.agorise.graphenej.api.android.NetworkService
|
||||||
import cy.agorise.graphenej.api.android.RxBus
|
import cy.agorise.graphenej.api.android.RxBus
|
||||||
|
@ -97,6 +99,19 @@ class SettingsFragment : Fragment(), ServiceConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtain the current Security Lock Option selected and display it in the screen
|
||||||
|
val securityLockSelected = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getInt(Constants.KEY_SECURITY_LOCK_SELECTED, 0)
|
||||||
|
// Security Lock Options
|
||||||
|
// 0 -> PIN
|
||||||
|
// 1 -> Pattern
|
||||||
|
// 2 -> None
|
||||||
|
|
||||||
|
tvSecurityLockSelected.text = resources.getStringArray(R.array.security_lock_options)[securityLockSelected]
|
||||||
|
|
||||||
|
tvSecurityLock.setOnClickListener { v -> showChooseSecurityLockDialog(v) }
|
||||||
|
tvSecurityLockSelected.setOnClickListener { v -> showChooseSecurityLockDialog(v) }
|
||||||
|
|
||||||
// Connect to the RxBus, which receives events from the NetworkService
|
// Connect to the RxBus, which receives events from the NetworkService
|
||||||
mDisposables.add(
|
mDisposables.add(
|
||||||
RxBus.getBusInstance()
|
RxBus.getBusInstance()
|
||||||
|
@ -195,6 +210,18 @@ class SettingsFragment : Fragment(), ServiceConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows a dialog so the user can select its desired Security Lock option.
|
||||||
|
*/
|
||||||
|
private fun showChooseSecurityLockDialog(view: View) {
|
||||||
|
MaterialDialog(view.context).show {
|
||||||
|
title(R.string.title__security_dialog)
|
||||||
|
listItems(R.array.security_lock_options) {dialog, index, text ->
|
||||||
|
dialog.context.toast("$text selected!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains the brainKey from the authorities db table for the current user account and if it is not null it passes
|
* Obtains the brainKey from the authorities db table for the current user account and if it is not null it passes
|
||||||
* the brainKey to a method to show it in a nice MaterialDialog
|
* the brainKey to a method to show it in a nice MaterialDialog
|
||||||
|
|
|
@ -101,4 +101,7 @@ object Constants {
|
||||||
|
|
||||||
/** Name of the external storage folder used to save files like PDF and CSV exports and Backups **/
|
/** Name of the external storage folder used to save files like PDF and CSV exports and Backups **/
|
||||||
const val EXTERNAL_STORAGE_FOLDER = "BiTSy"
|
const val EXTERNAL_STORAGE_FOLDER = "BiTSy"
|
||||||
|
|
||||||
|
/** Key used to store the user's selected Security Lock option */
|
||||||
|
const val KEY_SECURITY_LOCK_SELECTED = "key_security_lock_selected"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:layout_weight="1"
|
||||||
tools:context=".fragments.SettingsFragment">
|
tools:context=".fragments.SettingsFragment">
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -61,6 +56,32 @@
|
||||||
android:textAppearance="@style/TextAppearance.Bitsy.Body1"
|
android:textAppearance="@style/TextAppearance.Bitsy.Body1"
|
||||||
android:drawableEnd="@drawable/ic_disconnected"/>
|
android:drawableEnd="@drawable/ic_disconnected"/>
|
||||||
|
|
||||||
|
<!-- Security -->
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_different_section"
|
||||||
|
android:text="@string/title__security"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvSecurityLock"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_different_topic"
|
||||||
|
android:text="@string/text__security_lock"
|
||||||
|
android:textAppearance="@style/TextAppearance.Bitsy.Body1"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvSecurityLockSelected"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
tools:text="PIN"
|
||||||
|
android:textSize="16sp"/>
|
||||||
|
|
||||||
<!-- Backup -->
|
<!-- Backup -->
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -108,5 +129,3 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -137,4 +137,12 @@
|
||||||
<string name="msg__bugs_or_ideas">Telegram: https://t.me/Agorise\nKeybase: https://keybase.io/team/Agorise</string>
|
<string name="msg__bugs_or_ideas">Telegram: https://t.me/Agorise\nKeybase: https://keybase.io/team/Agorise</string>
|
||||||
<string name="title__bitshares_nodes_dialog">Bloque: %1$s</string>
|
<string name="title__bitshares_nodes_dialog">Bloque: %1$s</string>
|
||||||
|
|
||||||
|
<!-- Security Settings -->
|
||||||
|
<string name="title__security">Seguridad</string>
|
||||||
|
<string name="text__security_lock">Bloqueo de Seguridad</string>
|
||||||
|
<string name="title__security_dialog">Choose Security Lock</string>
|
||||||
|
<string name="text__pin">PIN</string>
|
||||||
|
<string name="text__pattern">Patrón</string>
|
||||||
|
<string name="text__none">Ninguno</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<!-- Options used to populate the Export Options Dialog in the Transactions Screen -->
|
||||||
<string-array name="export_options">
|
<string-array name="export_options">
|
||||||
<item>@string/text__pdf</item>
|
<item>@string/text__pdf</item>
|
||||||
<item>@string/text__csv</item>
|
<item>@string/text__csv</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Options used to populate the Security Lock Options Dialog in the Settings Screen -->
|
||||||
|
<string-array name="security_lock_options">
|
||||||
|
<item>@string/text__pin</item>
|
||||||
|
<item>@string/text__pattern</item>
|
||||||
|
<item>@string/text__none</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
|
@ -138,4 +138,12 @@
|
||||||
<string name="msg__bugs_or_ideas">Telegram: https://t.me/Agorise\nKeybase: https://keybase.io/team/Agorise</string>
|
<string name="msg__bugs_or_ideas">Telegram: https://t.me/Agorise\nKeybase: https://keybase.io/team/Agorise</string>
|
||||||
<string name="title__bitshares_nodes_dialog">Block: %1$s</string>
|
<string name="title__bitshares_nodes_dialog">Block: %1$s</string>
|
||||||
|
|
||||||
|
<!-- Security Settings -->
|
||||||
|
<string name="title__security">Security</string>
|
||||||
|
<string name="text__security_lock">Security Lock</string>
|
||||||
|
<string name="title__security_dialog">Choose Security Lock</string>
|
||||||
|
<string name="text__pin">PIN</string>
|
||||||
|
<string name="text__pattern">Pattern</string>
|
||||||
|
<string name="text__none">None</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue