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,112 +1,131 @@
|
||||||
<?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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1">
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingStart="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingEnd="@dimen/activity_horizontal_margin"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<!-- General -->
|
||||||
|
|
||||||
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
android:text="@string/title__general"
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:textAppearance="@style/TextAppearance.Bitsy.Subtitle1"
|
||||||
android:paddingStart="@dimen/activity_horizontal_margin"
|
android:textStyle="bold"/>
|
||||||
android:paddingEnd="@dimen/activity_horizontal_margin"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<!-- General -->
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/switchAutoClose"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_different_topic"
|
||||||
|
app:switchPadding="12dp"
|
||||||
|
android:text="@string/msg__close_timer"
|
||||||
|
android:textAppearance="@style/TextAppearance.Bitsy.Body1"
|
||||||
|
android:textColor="?android:textColorPrimary"/>
|
||||||
|
|
||||||
<TextView
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/switchNightMode"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:text="@string/title__general"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="@style/TextAppearance.Bitsy.Subtitle1"
|
android:layout_marginTop="@dimen/spacing_same_topic"
|
||||||
android:textStyle="bold"/>
|
android:text="@string/msg__night_mode"
|
||||||
|
android:textAppearance="@style/TextAppearance.Bitsy.Body1"
|
||||||
|
android:textColor="?android:textColorPrimary"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<TextView
|
||||||
android:id="@+id/switchAutoClose"
|
android:id="@+id/tvNetworkStatus"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/spacing_different_topic"
|
android:layout_marginTop="@dimen/spacing_same_topic"
|
||||||
app:switchPadding="12dp"
|
android:layout_marginEnd="2dp"
|
||||||
android:text="@string/msg__close_timer"
|
android:text="@string/text__view_network_status"
|
||||||
android:textAppearance="@style/TextAppearance.Bitsy.Body1"
|
android:gravity="center_vertical"
|
||||||
android:textColor="?android:textColorPrimary"/>
|
android:textAppearance="@style/TextAppearance.Bitsy.Body1"
|
||||||
|
android:drawableEnd="@drawable/ic_disconnected"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<!-- Security -->
|
||||||
android:id="@+id/switchNightMode"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_same_topic"
|
|
||||||
android:text="@string/msg__night_mode"
|
|
||||||
android:textAppearance="@style/TextAppearance.Bitsy.Body1"
|
|
||||||
android:textColor="?android:textColorPrimary"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvNetworkStatus"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginTop="@dimen/spacing_different_section"
|
||||||
android:layout_marginTop="@dimen/spacing_same_topic"
|
android:text="@string/title__security"
|
||||||
android:layout_marginEnd="2dp"
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||||
android:text="@string/text__view_network_status"
|
android:textStyle="bold"/>
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:textAppearance="@style/TextAppearance.Bitsy.Body1"
|
|
||||||
android:drawableEnd="@drawable/ic_disconnected"/>
|
|
||||||
|
|
||||||
<!-- Backup -->
|
<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
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/tvSecurityLockSelected"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="@dimen/spacing_different_section"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/title__backup"
|
android:paddingTop="4dp"
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
tools:text="PIN"
|
||||||
android:textStyle="bold"/>
|
android:textSize="16sp"/>
|
||||||
|
|
||||||
<TextView
|
<!-- Backup -->
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_different_topic"
|
|
||||||
android:text="@string/msg__brainkey_description"
|
|
||||||
android:textAppearance="@style/TextAppearance.Bitsy.Body1"/>
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<TextView
|
||||||
android:id="@+id/btnViewBrainKey"
|
android:layout_width="match_parent"
|
||||||
style="@style/Widget.Bitsy.Button"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_marginTop="@dimen/spacing_different_section"
|
||||||
android:layout_height="wrap_content"
|
android:text="@string/title__backup"
|
||||||
android:layout_marginTop="@dimen/spacing_same_topic"
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||||
android:text="@string/button__view_and_copy"/>
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
<!-- Bugs or Ideas -->
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_different_topic"
|
||||||
|
android:text="@string/msg__brainkey_description"
|
||||||
|
android:textAppearance="@style/TextAppearance.Bitsy.Body1"/>
|
||||||
|
|
||||||
<TextView
|
<com.google.android.material.button.MaterialButton
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/btnViewBrainKey"
|
||||||
android:layout_height="wrap_content"
|
style="@style/Widget.Bitsy.Button"
|
||||||
android:layout_marginTop="@dimen/spacing_different_section"
|
android:layout_width="wrap_content"
|
||||||
android:text="@string/title__bugs_or_ideas"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
android:layout_marginTop="@dimen/spacing_same_topic"
|
||||||
android:textStyle="bold"/>
|
android:text="@string/button__view_and_copy"/>
|
||||||
|
|
||||||
<TextView
|
<!-- Bugs or Ideas -->
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_same_topic"
|
|
||||||
android:autoLink="all"
|
|
||||||
android:lineSpacingExtra="8dp"
|
|
||||||
android:text="@string/msg__bugs_or_ideas"
|
|
||||||
android:textAppearance="@style/TextAppearance.Bitsy.Body1"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_different_section"
|
||||||
|
android:text="@string/title__bugs_or_ideas"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
</ScrollView>
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_same_topic"
|
||||||
|
android:autoLink="all"
|
||||||
|
android:lineSpacingExtra="8dp"
|
||||||
|
android:text="@string/msg__bugs_or_ideas"
|
||||||
|
android:textAppearance="@style/TextAppearance.Bitsy.Body1"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
|
@ -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