Move OTP settings to preferences
This commit is contained in:
parent
4d88786fb6
commit
a12762f034
12 changed files with 93 additions and 226 deletions
|
@ -265,6 +265,13 @@
|
||||||
android:label="@string/pairing_information"
|
android:label="@string/pairing_information"
|
||||||
android:theme="@style/AppTheme" />
|
android:theme="@style/AppTheme" />
|
||||||
<activity android:name=".activities.RequestDexcomPermissionActivity" />
|
<activity android:name=".activities.RequestDexcomPermissionActivity" />
|
||||||
|
<activity android:name=".plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="info.nightscout.androidaps.plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<!-- Medtronic service and activities -->
|
<!-- Medtronic service and activities -->
|
||||||
<service
|
<service
|
||||||
|
|
|
@ -7,6 +7,7 @@ import info.nightscout.androidaps.activities.*
|
||||||
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity
|
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity
|
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity
|
||||||
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
|
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
|
||||||
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RileyLinkBLEScanActivity
|
import info.nightscout.androidaps.plugins.pump.common.dialog.RileyLinkBLEScanActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity
|
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity
|
||||||
|
@ -43,6 +44,7 @@ abstract class ActivitiesModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesRileyLinkBLEScanActivity(): RileyLinkBLEScanActivity
|
@ContributesAndroidInjector abstract fun contributesRileyLinkBLEScanActivity(): RileyLinkBLEScanActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesSetupWizardActivity(): SetupWizardActivity
|
@ContributesAndroidInjector abstract fun contributesSetupWizardActivity(): SetupWizardActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesSingleFragmentActivity(): SingleFragmentActivity
|
@ContributesAndroidInjector abstract fun contributesSingleFragmentActivity(): SingleFragmentActivity
|
||||||
|
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorOtpActivity(): SmsCommunicatorOtpActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity
|
@ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity
|
@ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
|
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
|
||||||
|
|
|
@ -27,8 +27,6 @@ import info.nightscout.androidaps.plugins.general.nsclient.NSClientFragment
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment
|
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorFragment
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorFragment
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.fragments.SmsCommunicatorLogFragment
|
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.fragments.SmsCommunicatorOtpFragment
|
|
||||||
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolFragment
|
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolFragment
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinFragment
|
import info.nightscout.androidaps.plugins.insulin.InsulinFragment
|
||||||
import info.nightscout.androidaps.plugins.profile.local.LocalProfileFragment
|
import info.nightscout.androidaps.plugins.profile.local.LocalProfileFragment
|
||||||
|
@ -77,8 +75,6 @@ abstract class FragmentsModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment
|
@ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesNSClientFragment(): NSClientFragment
|
@ContributesAndroidInjector abstract fun contributesNSClientFragment(): NSClientFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorFragment(): SmsCommunicatorFragment
|
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorFragment(): SmsCommunicatorFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorLogFragment(): SmsCommunicatorLogFragment
|
|
||||||
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorOtpFragment(): SmsCommunicatorOtpFragment
|
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment
|
@ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesTreatmentsFragment(): TreatmentsFragment
|
@ContributesAndroidInjector abstract fun contributesTreatmentsFragment(): TreatmentsFragment
|
||||||
|
|
|
@ -4,78 +4,75 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.fragment.app.FragmentTransaction
|
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.fragments.SmsCommunicatorLogFragment
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.events.EventSmsCommunicatorUpdateGui
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.fragments.SmsCommunicatorOtpFragment
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.OneTimePassword
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import kotlinx.android.synthetic.main.smscommunicator_fragment.*
|
import kotlinx.android.synthetic.main.smscommunicator_fragment.*
|
||||||
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
class SmsCommunicatorFragment : DaggerFragment() {
|
class SmsCommunicatorFragment : DaggerFragment() {
|
||||||
|
@Inject lateinit var fabricPrivacy : FabricPrivacy
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
|
||||||
@Inject lateinit var otp: OneTimePassword
|
|
||||||
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
||||||
|
|
||||||
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?): View? {
|
savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.smscommunicator_fragment, container, false)
|
return inflater.inflate(R.layout.smscommunicator_fragment, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
smscomunicator_tab_log.setOnClickListener {
|
|
||||||
setFragment(SmsCommunicatorLogFragment())
|
|
||||||
setBackgroundColorOnSelected(it)
|
|
||||||
}
|
|
||||||
smscomunicator_tab_otp.setOnClickListener {
|
|
||||||
setFragment(SmsCommunicatorOtpFragment())
|
|
||||||
setBackgroundColorOnSelected(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
setFragment(SmsCommunicatorLogFragment())
|
|
||||||
setBackgroundColorOnSelected(smscomunicator_tab_log)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
disposable += rxBus
|
||||||
|
.toObservable(EventSmsCommunicatorUpdateGui::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ updateGui() }) { fabricPrivacy.logException(it) }
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
disposable.clear()
|
||||||
|
}
|
||||||
|
|
||||||
fun updateGui() {
|
fun updateGui() {
|
||||||
if (otp.isEnabled()) {
|
class CustomComparator : Comparator<Sms> {
|
||||||
smscomunicator_tab_otp.visibility = View.VISIBLE
|
override fun compare(object1: Sms, object2: Sms): Int {
|
||||||
} else {
|
return (object1.date - object2.date).toInt()
|
||||||
if (smscomunicator_tab_otp.visibility != View.GONE) {
|
|
||||||
setFragment(SmsCommunicatorLogFragment())
|
|
||||||
setBackgroundColorOnSelected(smscomunicator_tab_log)
|
|
||||||
smscomunicator_tab_otp.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
Collections.sort(smsCommunicatorPlugin.messages, CustomComparator())
|
||||||
|
val messagesToShow = 40
|
||||||
|
val start = max(0, smsCommunicatorPlugin.messages.size - messagesToShow)
|
||||||
|
var logText = ""
|
||||||
|
for (x in start until smsCommunicatorPlugin.messages.size) {
|
||||||
|
val sms = smsCommunicatorPlugin.messages[x]
|
||||||
|
when {
|
||||||
|
sms.ignored -> {
|
||||||
|
logText += DateUtil.timeString(sms.date) + " <<< " + "░ " + sms.phoneNumber + " <b>" + sms.text + "</b><br>"
|
||||||
|
}
|
||||||
|
|
||||||
private fun setFragment(selectedFragment: Fragment) {
|
sms.received -> {
|
||||||
val ft = childFragmentManager.beginTransaction()
|
logText += DateUtil.timeString(sms.date) + " <<< " + (if (sms.processed) "● " else "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>"
|
||||||
ft.replace(R.id.smscomunicator_fragment_container, selectedFragment)
|
}
|
||||||
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
|
||||||
ft.addToBackStack(null)
|
|
||||||
ft.commit()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setBackgroundColorOnSelected(selected: View) {
|
sms.sent -> {
|
||||||
smscomunicator_tab_log.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground))
|
logText += DateUtil.timeString(sms.date) + " >>> " + (if (sms.processed) "● " else "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>"
|
||||||
smscomunicator_tab_otp.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground))
|
}
|
||||||
selected.setBackgroundColor(resourceHelper.gc(R.color.tabBgColorSelected))
|
}
|
||||||
|
}
|
||||||
|
smscommunicator_log?.text = HtmlHelper.fromHtml(logText)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,17 +1,14 @@
|
||||||
package info.nightscout.androidaps.plugins.general.smsCommunicator.fragments
|
package info.nightscout.androidaps.plugins.general.smsCommunicator.activities
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import com.google.common.primitives.Ints.min
|
import com.google.common.primitives.Ints.min
|
||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.DaggerActivity
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||||
|
@ -21,27 +18,23 @@ import info.nightscout.androidaps.utils.OneTimePassword
|
||||||
import info.nightscout.androidaps.utils.OneTimePasswordValidationResult
|
import info.nightscout.androidaps.utils.OneTimePasswordValidationResult
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import kotlinx.android.synthetic.main.smscommunicator_fragment_otp.*
|
import kotlinx.android.synthetic.main.activity_smscommunicator_otp.*
|
||||||
import net.glxn.qrgen.android.QRCode
|
import net.glxn.qrgen.android.QRCode
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SmsCommunicatorOtpFragment : DaggerFragment() {
|
class SmsCommunicatorOtpActivity : DaggerActivity() {
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
||||||
@Inject lateinit var otp: OneTimePassword
|
@Inject lateinit var otp: OneTimePassword
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
savedInstanceState: Bundle?): View? {
|
super.onCreate(savedInstanceState)
|
||||||
return inflater.inflate(R.layout.smscommunicator_fragment_otp, container, false)
|
setContentView(R.layout.activity_smscommunicator_otp)
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
smscommunicator_otp_verify_edit.addTextChangedListener(object : TextWatcher {
|
smscommunicator_otp_verify_edit.addTextChangedListener(object : TextWatcher {
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable) {
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
val checkResult = otp.checkOTP(s.toString())
|
val checkResult = otp.checkOTP(s.toString())
|
||||||
|
|
||||||
|
@ -65,26 +58,21 @@ class SmsCommunicatorOtpFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
actions_smscommunicator_otp_reset.setOnClickListener {
|
actions_smscommunicator_otp_reset.setOnClickListener {
|
||||||
if (this.activity != null) {
|
OKDialog.showConfirmation(this,
|
||||||
OKDialog.showConfirmation(this.activity!!,
|
resourceHelper.gs(R.string.smscommunicator_otp_reset_title),
|
||||||
resourceHelper.gs(R.string.smscommunicator_otp_reset_title),
|
resourceHelper.gs(R.string.smscommunicator_otp_reset_prompt),
|
||||||
resourceHelper.gs(R.string.smscommunicator_otp_reset_prompt),
|
Runnable {
|
||||||
Runnable {
|
otp.ensureKey(true)
|
||||||
otp.ensureKey(true)
|
updateGui()
|
||||||
updateGui()
|
ToastUtils.showToastInUiThread(this, R.string.smscommunicator_otp_reset_successful)
|
||||||
ToastUtils.showToastInUiThread(this.context, R.string.smscommunicator_otp_reset_successful)
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
|
@ -1,80 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.smsCommunicator.fragments
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import dagger.android.support.DaggerFragment
|
|
||||||
import info.nightscout.androidaps.R
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.Sms
|
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.events.EventSmsCommunicatorUpdateGui
|
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
|
||||||
import kotlinx.android.synthetic.main.smscommunicator_fragment_log.*
|
|
||||||
import java.util.*
|
|
||||||
import javax.inject.Inject
|
|
||||||
import kotlin.math.max
|
|
||||||
|
|
||||||
class SmsCommunicatorLogFragment : DaggerFragment() {
|
|
||||||
@Inject lateinit var fabricPrivacy : FabricPrivacy
|
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
|
||||||
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?): View? {
|
|
||||||
return inflater.inflate(R.layout.smscommunicator_fragment_log, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
disposable += rxBus
|
|
||||||
.toObservable(EventSmsCommunicatorUpdateGui::class.java)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe({ updateGui() }) { fabricPrivacy.logException(it) }
|
|
||||||
updateGui()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
override fun onPause() {
|
|
||||||
super.onPause()
|
|
||||||
disposable.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateGui() {
|
|
||||||
class CustomComparator : Comparator<Sms> {
|
|
||||||
override fun compare(object1: Sms, object2: Sms): Int {
|
|
||||||
return (object1.date - object2.date).toInt()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Collections.sort(smsCommunicatorPlugin.messages, CustomComparator())
|
|
||||||
val messagesToShow = 40
|
|
||||||
val start = max(0, smsCommunicatorPlugin.messages.size - messagesToShow)
|
|
||||||
var logText = ""
|
|
||||||
for (x in start until smsCommunicatorPlugin.messages.size) {
|
|
||||||
val sms = smsCommunicatorPlugin.messages[x]
|
|
||||||
when {
|
|
||||||
sms.ignored -> {
|
|
||||||
logText += DateUtil.timeString(sms.date) + " <<< " + "░ " + sms.phoneNumber + " <b>" + sms.text + "</b><br>"
|
|
||||||
}
|
|
||||||
|
|
||||||
sms.received -> {
|
|
||||||
logText += DateUtil.timeString(sms.date) + " <<< " + (if (sms.processed) "● " else "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>"
|
|
||||||
}
|
|
||||||
|
|
||||||
sms.sent -> {
|
|
||||||
logText += DateUtil.timeString(sms.date) + " >>> " + (if (sms.processed) "● " else "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
smscommunicator_log?.text = HtmlHelper.fromHtml(logText)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -40,7 +40,7 @@ class OneTimePassword @Inject constructor(
|
||||||
* If OTP Authenticator support is enabled by user
|
* If OTP Authenticator support is enabled by user
|
||||||
*/
|
*/
|
||||||
fun isEnabled(): Boolean {
|
fun isEnabled(): Boolean {
|
||||||
return sp.getBoolean(R.string.key_smscommunicator_otp_enabled, false);
|
return sp.getBoolean(R.string.key_smscommunicator_otp_enabled, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".plugins.general.smsCommunicator.fragments.SmsCommunicatorOtpFragment">
|
tools:context=".plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
|
@ -4,48 +4,15 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".plugins.general.smsCommunicator.SmsCommunicatorFragment">
|
tools:context=".plugins.general.smsCommunicator.SmsCommunicatorFragment">
|
||||||
|
|
||||||
<LinearLayout
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="fill_parent">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<com.google.android.flexbox.FlexboxLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/smscommunicator_log"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:background="@color/defaultbackground"
|
android:layout_height="fill_parent"
|
||||||
app:alignContent="stretch"
|
android:text=""/>
|
||||||
app:alignItems="stretch"
|
</ScrollView>
|
||||||
app:flexDirection="row"
|
|
||||||
app:flexWrap="wrap"
|
|
||||||
app:justifyContent="center">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/smscomunicator_tab_log"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical|center_horizontal"
|
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:text="@string/smscomunicator_tab_log_label" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/smscomunicator_tab_otp"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical|center_horizontal"
|
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:text="@string/smscomunicator_tab_otp_label" />
|
|
||||||
|
|
||||||
</com.google.android.flexbox.FlexboxLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/smscomunicator_fragment_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context=".plugins.general.smsCommunicator.fragments.SmsCommunicatorLogFragment">
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/smscommunicator_log"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:text="" />
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
|
@ -1720,8 +1720,7 @@
|
||||||
<string name="smscommunicator_otp_name">User name for Authenticator</string>
|
<string name="smscommunicator_otp_name">User name for Authenticator</string>
|
||||||
<string name="smscommunicator_otp_name_summary">User name displayed along with generated OTP on Authenticator App</string>
|
<string name="smscommunicator_otp_name_summary">User name displayed along with generated OTP on Authenticator App</string>
|
||||||
|
|
||||||
<string name="smscomunicator_tab_log_label">Operations Log</string>
|
<string name="smscomunicator_tab_otp_label">Authenticator setup</string>
|
||||||
<string name="smscomunicator_tab_otp_label">Authenticator</string>
|
|
||||||
|
|
||||||
<string name="smscommunicator_otp_verify_label">OTP to check:</string>
|
<string name="smscommunicator_otp_verify_label">OTP to check:</string>
|
||||||
<string name="smscommunicator_otp_reset_btn">Reset Authenticators</string>
|
<string name="smscommunicator_otp_reset_btn">Reset Authenticators</string>
|
||||||
|
@ -1734,7 +1733,7 @@
|
||||||
<string name="smscommunicator_otp_step3_test_header">3. Test One-Time-Password</string>
|
<string name="smscommunicator_otp_step3_test_header">3. Test One-Time-Password</string>
|
||||||
<string name="smscommunicator_otp_reset_header">Reset Authenticators</string>
|
<string name="smscommunicator_otp_reset_header">Reset Authenticators</string>
|
||||||
|
|
||||||
<string name="smscommunicator_otp_install_info">On each follower phone install Authenticator app that support RFC 6238 TOTP tokens. Popular free apps are:\n • Google Authenticator\n • LastPass Authenticator\n • FreeOTP Authenticator</string>
|
<string name="smscommunicator_otp_install_info">On each follower phone install Authenticator app that support RFC 6238 TOTP tokens. Popular free apps are:\n • Authy\n • Google Authenticator\n • LastPass Authenticator\n • FreeOTP Authenticator</string>
|
||||||
<string name="smscommunicator_otp_provisioning_warning">DO NOT SHARE this code online!\nUse it only to setup Authenticator App on follower phones.</string>
|
<string name="smscommunicator_otp_provisioning_warning">DO NOT SHARE this code online!\nUse it only to setup Authenticator App on follower phones.</string>
|
||||||
<string name="smscommunicator_otp_reset_warning">By reseting authenticator you make all already provisioned authenticators invalid. You will need to set up them again!</string>
|
<string name="smscommunicator_otp_reset_warning">By reseting authenticator you make all already provisioned authenticators invalid. You will need to set up them again!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -32,15 +32,25 @@
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:key="@string/key_smscommunicator_otp_enabled"
|
android:key="@string/key_smscommunicator_otp_enabled"
|
||||||
android:summary="@string/smscommunicator_otp_enabled_summary"
|
android:summary="@string/smscommunicator_otp_enabled_summary"
|
||||||
android:title="@string/smscommunicator_otp_enabled" />
|
android:title="@string/smscommunicator_otp_enabled"
|
||||||
|
app:isPreferenceVisible="false" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:dependency="@string/key_smscommunicator_remotecommandsallowed"
|
||||||
|
android:key="otpsetup"
|
||||||
|
android:title="@string/smscomunicator_tab_otp_label">
|
||||||
|
<intent android:action="info.nightscout.androidaps.plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity" />
|
||||||
|
</Preference>
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:dependency="@string/key_smscommunicator_remotecommandsallowed"
|
||||||
android:key="@string/key_smscommunicator_otp_password"
|
android:key="@string/key_smscommunicator_otp_password"
|
||||||
android:summary="@string/smscommunicator_otp_pin_summary"
|
android:summary="@string/smscommunicator_otp_pin_summary"
|
||||||
android:title="@string/smscommunicator_otp_pin"
|
android:title="@string/smscommunicator_otp_pin"
|
||||||
validate:testType="pinStrength" />
|
validate:testType="pinStrength" />
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:dependency="@string/key_smscommunicator_remotecommandsallowed"
|
||||||
android:key="@string/key_smscommunicator_otp_name"
|
android:key="@string/key_smscommunicator_otp_name"
|
||||||
android:summary="@string/smscommunicator_otp_name_summary"
|
android:summary="@string/smscommunicator_otp_name_summary"
|
||||||
android:title="@string/smscommunicator_otp_name"
|
android:title="@string/smscommunicator_otp_name"
|
||||||
|
|
Loading…
Reference in a new issue