diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt index f491aaf14b..d11ee90f70 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt @@ -14,6 +14,7 @@ import com.google.common.primitives.Ints.min import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.NoSplashAppCompatActivity +import info.nightscout.androidaps.databinding.ActivitySmscommunicatorOtpBinding import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword @@ -21,7 +22,6 @@ import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePas import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.OKDialog -import kotlinx.android.synthetic.main.activity_smscommunicator_otp.* import net.glxn.qrgen.android.QRCode import javax.inject.Inject @@ -32,23 +32,27 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { @Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin @Inject lateinit var otp: OneTimePassword + private lateinit var binding: ActivitySmscommunicatorOtpBinding + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) - setContentView(R.layout.activity_smscommunicator_otp) - smscommunicator_otp_verify_edit.addTextChangedListener(object : TextWatcher { + binding = ActivitySmscommunicatorOtpBinding.inflate(layoutInflater) + setContentView(binding.root) + + binding.otpVerifyEdit.addTextChangedListener(object : TextWatcher { override fun afterTextChanged(s: Editable) { val checkResult = otp.checkOTP(s.toString()) - smscommunicator_otp_verify_label.text = when (checkResult) { + binding.otpVerifyLabel.text = when (checkResult) { OneTimePasswordValidationResult.OK -> "OK" OneTimePasswordValidationResult.ERROR_WRONG_LENGTH -> "INVALID SIZE!" OneTimePasswordValidationResult.ERROR_WRONG_PIN -> "WRONG PIN" OneTimePasswordValidationResult.ERROR_WRONG_OTP -> "WRONG OTP" } - smscommunicator_otp_verify_label.setTextColor(when (checkResult) { + binding.otpVerifyLabel.setTextColor(when (checkResult) { OneTimePasswordValidationResult.OK -> Color.GREEN OneTimePasswordValidationResult.ERROR_WRONG_LENGTH -> Color.YELLOW OneTimePasswordValidationResult.ERROR_WRONG_PIN -> Color.RED @@ -61,7 +65,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {} }) - actions_smscommunicator_otp_reset.setOnClickListener { + binding.otpReset.setOnClickListener { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.smscommunicator_otp_reset_title), resourceHelper.gs(R.string.smscommunicator_otp_reset_prompt), @@ -72,7 +76,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { }) } - smscommunicator_otp_provisioning.setOnLongClickListener { + binding.otpProvisioning.setOnLongClickListener { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.smscommunicator_otp_export_title), resourceHelper.gs(R.string.smscommunicator_otp_export_prompt), @@ -104,12 +108,12 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { if (provURI != null) { val myBitmap = QRCode.from(provURI).withErrorCorrection(ErrorCorrectionLevel.H).withSize(dim, dim).bitmap() - smscommunicator_otp_provisioning.setImageBitmap(myBitmap) - smscommunicator_otp_provisioning.visibility = View.VISIBLE + binding.otpProvisioning.setImageBitmap(myBitmap) + binding.otpProvisioning.visibility = View.VISIBLE } else { - smscommunicator_otp_provisioning.visibility = View.GONE + binding.otpProvisioning.visibility = View.GONE } - smscommunicator_otp_verify_edit.text = smscommunicator_otp_verify_edit.text + binding.otpVerifyEdit.text = binding.otpVerifyEdit.text } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_smscommunicator_otp.xml b/app/src/main/res/layout/activity_smscommunicator_otp.xml index 91e9fef298..cfa5865277 100644 --- a/app/src/main/res/layout/activity_smscommunicator_otp.xml +++ b/app/src/main/res/layout/activity_smscommunicator_otp.xml @@ -9,7 +9,7 @@ android:layout_height="fill_parent"> @@ -32,7 +32,7 @@ android:text="@string/smscommunicator_otp_step2_provisioning_header" />