add rice to objective bypass code
This commit is contained in:
parent
91ebc11d9b
commit
64a2b45866
4 changed files with 18 additions and 1 deletions
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Obje
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
|
import info.nightscout.androidaps.utils.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import kotlinx.android.synthetic.main.objectives_fragment.*
|
import kotlinx.android.synthetic.main.objectives_fragment.*
|
||||||
|
@ -219,6 +220,11 @@ class ObjectivesFragment : Fragment() {
|
||||||
scrollToCurrentObjective()
|
scrollToCurrentObjective()
|
||||||
}
|
}
|
||||||
if (objective.hasSpecialInput && !objective.isAccomplished && objective.isStarted) {
|
if (objective.hasSpecialInput && !objective.isAccomplished && objective.isStarted) {
|
||||||
|
// generate random request code if none exists
|
||||||
|
val request = SP.getString(R.string.key_objectives_request_code, String.format("%1$05d", (Math.random() * 99999).toInt()))
|
||||||
|
SP.putString(R.string.key_objectives_request_code, request)
|
||||||
|
holder.requestCode.text = MainApp.gs(R.string.requestcode, request)
|
||||||
|
holder.requestCode.visibility = View.VISIBLE
|
||||||
holder.enterButton.visibility = View.VISIBLE
|
holder.enterButton.visibility = View.VISIBLE
|
||||||
holder.input.visibility = View.VISIBLE
|
holder.input.visibility = View.VISIBLE
|
||||||
holder.inputHint.visibility = View.VISIBLE
|
holder.inputHint.visibility = View.VISIBLE
|
||||||
|
@ -231,6 +237,7 @@ class ObjectivesFragment : Fragment() {
|
||||||
holder.enterButton.visibility = View.GONE
|
holder.enterButton.visibility = View.GONE
|
||||||
holder.input.visibility = View.GONE
|
holder.input.visibility = View.GONE
|
||||||
holder.inputHint.visibility = View.GONE
|
holder.inputHint.visibility = View.GONE
|
||||||
|
holder.requestCode.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +258,7 @@ class ObjectivesFragment : Fragment() {
|
||||||
val inputHint: TextView = itemView.findViewById(R.id.objective_inputhint)
|
val inputHint: TextView = itemView.findViewById(R.id.objective_inputhint)
|
||||||
val input: EditText = itemView.findViewById(R.id.objective_input)
|
val input: EditText = itemView.findViewById(R.id.objective_input)
|
||||||
val enterButton: Button = itemView.findViewById(R.id.objective_enterbutton)
|
val enterButton: Button = itemView.findViewById(R.id.objective_enterbutton)
|
||||||
|
val requestCode: TextView = itemView.findViewById(R.id.objective_requestcode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,9 +102,10 @@ object ObjectivesPlugin : PluginBase(PluginDescription()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun completeObjectives(activity: Activity, request: String) {
|
fun completeObjectives(activity: Activity, request: String) {
|
||||||
|
val requestCode = SP.getString(R.string.key_objectives_request_code, "")
|
||||||
var url = SP.getString(R.string.key_nsclientinternal_url, "").toLowerCase()
|
var url = SP.getString(R.string.key_nsclientinternal_url, "").toLowerCase()
|
||||||
if (!url.endsWith("\"")) url = "$url/"
|
if (!url.endsWith("\"")) url = "$url/"
|
||||||
val hashNS = Hashing.sha1().hashString(url + BuildConfig.APPLICATION_ID, Charsets.UTF_8).toString()
|
val hashNS = Hashing.sha1().hashString(url + BuildConfig.APPLICATION_ID + "/" + requestCode, Charsets.UTF_8).toString()
|
||||||
if (request.equals(hashNS.substring(0, 10), ignoreCase = true)) {
|
if (request.equals(hashNS.substring(0, 10), ignoreCase = true)) {
|
||||||
SP.putLong("Objectives_" + "openloop" + "_started", DateUtil.now())
|
SP.putLong("Objectives_" + "openloop" + "_started", DateUtil.now())
|
||||||
SP.putLong("Objectives_" + "openloop" + "_accomplished", DateUtil.now())
|
SP.putLong("Objectives_" + "openloop" + "_accomplished", DateUtil.now())
|
||||||
|
|
|
@ -80,6 +80,12 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/enter_code_obtained_from_developers_to_bypass_the_rest_of_objectives" />
|
android:text="@string/enter_code_obtained_from_developers_to_bypass_the_rest_of_objectives" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/objective_requestcode"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Request code: XXXXX" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
|
@ -1635,6 +1635,8 @@
|
||||||
<string name="wronganswer">Wrong answer!</string>
|
<string name="wronganswer">Wrong answer!</string>
|
||||||
<string name="unfinshed_button">Next unfinished</string>
|
<string name="unfinshed_button">Next unfinished</string>
|
||||||
<string name="close">Close</string>
|
<string name="close">Close</string>
|
||||||
|
<string name="key_objectives_request_code" translatable="false">objectives_request_code</string>
|
||||||
|
<string name="requestcode">Request code: %1$s</string>
|
||||||
|
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d day</item>
|
<item quantity="one">%1$d day</item>
|
||||||
|
|
Loading…
Reference in a new issue