reset password procedure
This commit is contained in:
parent
4b6d4d287c
commit
72a309a055
6 changed files with 72 additions and 5 deletions
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver
|
||||||
import info.nightscout.androidaps.utils.ActivityMonitor
|
import info.nightscout.androidaps.utils.ActivityMonitor
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.locale.LocaleHelper.update
|
import info.nightscout.androidaps.utils.locale.LocaleHelper.update
|
||||||
|
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxkotlin.plusAssign
|
import io.reactivex.rxkotlin.plusAssign
|
||||||
|
@ -56,6 +57,7 @@ class MainApp : DaggerApplication() {
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var staticInjector: StaticInjector// TODO avoid , here fake only to initialize
|
@Inject lateinit var staticInjector: StaticInjector// TODO avoid , here fake only to initialize
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
@Inject lateinit var passwordCheck: PasswordCheck
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
@ -87,6 +89,7 @@ class MainApp : DaggerApplication() {
|
||||||
keepAliveManager.setAlarm(this)
|
keepAliveManager.setAlarm(this)
|
||||||
doMigrations()
|
doMigrations()
|
||||||
uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps)
|
uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps)
|
||||||
|
passwordCheck.passwordResetCheck(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doMigrations() {
|
private fun doMigrations() {
|
||||||
|
|
|
@ -109,5 +109,6 @@ class VirtualPumpFragment : DaggerFragment() {
|
||||||
|
|
||||||
binding.type.text = pumpType?.description
|
binding.type.text = pumpType?.description
|
||||||
binding.typeDef.text = pumpType?.getFullDescription(resourceHelper.gs(R.string.virtualpump_pump_def), pumpType.hasExtendedBasals(), resourceHelper)
|
binding.typeDef.text = pumpType?.getFullDescription(resourceHelper.gs(R.string.virtualpump_pump_def), pumpType.hasExtendedBasals(), resourceHelper)
|
||||||
|
binding.serialNumber.text = virtualPumpPlugin.serialNumber()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,6 +234,51 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Pump Serial -->
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dip"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:background="@color/list_delimiter" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:text="@string/serialnumber"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/serial_number"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Pump Type -->
|
<!-- Pump Type -->
|
||||||
<View
|
<View
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -279,7 +324,7 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Pump Type -->
|
<!-- Pump Definition -->
|
||||||
<View
|
<View
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="2dip"
|
android:layout_height="2dip"
|
||||||
|
|
|
@ -8,10 +8,13 @@ import android.widget.EditText
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import info.nightscout.androidaps.core.R
|
import info.nightscout.androidaps.core.R
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
|
||||||
import info.nightscout.androidaps.utils.CryptoUtil
|
import info.nightscout.androidaps.utils.CryptoUtil
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.AlertDialogHelper
|
import info.nightscout.androidaps.utils.alertDialogs.AlertDialogHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -20,8 +23,10 @@ const val AUTOFILL_HINT_NEW_PASSWORD = "newPassword"
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class PasswordCheck @Inject constructor(
|
class PasswordCheck @Inject constructor(
|
||||||
val sp: SP,
|
private val sp: SP,
|
||||||
private val cryptoUtil: CryptoUtil
|
private val cryptoUtil: CryptoUtil,
|
||||||
|
private val fileListProvider: PrefFileListProvider,
|
||||||
|
private val activePlugin: ActivePlugin
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,4 +164,18 @@ class PasswordCheck @Inject constructor(
|
||||||
|
|
||||||
alertDialogBuilder.create().show()
|
alertDialogBuilder.create().show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for existing PasswordReset file and
|
||||||
|
* reset password to SN of active pump if file exists
|
||||||
|
*/
|
||||||
|
fun passwordResetCheck(context: Context) {
|
||||||
|
val passwordReset = File(fileListProvider.ensureExtraDirExists(), "PasswordReset")
|
||||||
|
if (passwordReset.exists()) {
|
||||||
|
val sn = activePlugin.activePump.serialNumber()
|
||||||
|
sp.putString(R.string.key_master_password, cryptoUtil.hashPassword(sn))
|
||||||
|
passwordReset.delete()
|
||||||
|
ToastUtils.okToast(context, context.getString(R.string.password_set))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,6 @@
|
||||||
<string name="extended_bolus">Extended bolus</string>
|
<string name="extended_bolus">Extended bolus</string>
|
||||||
<string name="pump_time_updated">Pump time updated</string>
|
<string name="pump_time_updated">Pump time updated</string>
|
||||||
<string name="exit">Exit</string>
|
<string name="exit">Exit</string>
|
||||||
<string name="serial_number">Serial number</string>
|
|
||||||
<string name="removerecord">Remove record</string>
|
<string name="removerecord">Remove record</string>
|
||||||
<string name="loopisdisabled">Loop is disabled</string>
|
<string name="loopisdisabled">Loop is disabled</string>
|
||||||
<string name="alarm">Alarm</string>
|
<string name="alarm">Alarm</string>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:text="@string/serial_number" />
|
android:text="@string/serialnumber" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/serial_number"
|
android:id="@+id/serial_number"
|
||||||
|
|
Loading…
Reference in a new issue