network status before time
This commit is contained in:
parent
14dd29befd
commit
fa20af4440
|
@ -51,7 +51,6 @@ class ObjectivesFragment : Fragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
objectives_recyclerview.layoutManager = LinearLayoutManager(view.context)
|
||||
objectives_recyclerview.adapter = objectivesAdapter
|
||||
objectives_fake.setOnClickListener { updateGUI() }
|
||||
|
@ -208,15 +207,16 @@ class ObjectivesFragment : Fragment() {
|
|||
holder.accomplished.setTextColor(-0x3e3e3f)
|
||||
holder.verify.setOnClickListener {
|
||||
holder.verify.visibility = View.INVISIBLE
|
||||
NetworkChangeReceiver.fetch()
|
||||
SntpClient.ntpTime(object : SntpClient.Callback() {
|
||||
override fun run() {
|
||||
activity?.runOnUiThread {
|
||||
holder.verify.visibility = View.VISIBLE
|
||||
log.debug("NTP time: $time System time: ${DateUtil.now()}")
|
||||
if (!networkConnected) {
|
||||
if (!networkConnected && !objectives_fake.isChecked) {
|
||||
ToastUtils.showToastInUiThread(context, R.string.notconnected)
|
||||
} else if (success) {
|
||||
if (objective.isCompleted(time)) {
|
||||
if (objective.isCompleted(time) || objectives_fake.isChecked) {
|
||||
objective.accomplishedOn = time
|
||||
notifyDataSetChanged()
|
||||
scrollToCurrentObjective()
|
||||
|
@ -233,12 +233,13 @@ class ObjectivesFragment : Fragment() {
|
|||
}
|
||||
holder.start.setOnClickListener {
|
||||
holder.start.visibility = View.INVISIBLE
|
||||
NetworkChangeReceiver.fetch()
|
||||
SntpClient.ntpTime(object : SntpClient.Callback() {
|
||||
override fun run() {
|
||||
activity?.runOnUiThread {
|
||||
holder.start.visibility = View.VISIBLE
|
||||
log.debug("NTP time: $time System time: ${DateUtil.now()}")
|
||||
if (!networkConnected) {
|
||||
if (!networkConnected && !objectives_fake.isChecked) {
|
||||
ToastUtils.showToastInUiThread(context, R.string.notconnected)
|
||||
} else if (success) {
|
||||
objective.startedOn = time
|
||||
|
|
|
@ -57,12 +57,11 @@ class ObjectivesExamDialog : DialogFragment() {
|
|||
objectives_exam_question.setText(task.question)
|
||||
// Options
|
||||
objectives_exam_options.removeAllViews()
|
||||
for (o in task.options) {
|
||||
val option: Option = o as Option;
|
||||
val cb = option.generate(context)
|
||||
task.options.forEach {
|
||||
val cb = it.generate(context)
|
||||
if (task.answered) {
|
||||
cb.isEnabled = false
|
||||
if (option.isCorrect)
|
||||
if (it.isCorrect)
|
||||
cb.isChecked = true
|
||||
}
|
||||
objectives_exam_options.addView(cb)
|
||||
|
|
|
@ -230,7 +230,7 @@ public abstract class Objective {
|
|||
return question;
|
||||
}
|
||||
|
||||
public List getOptions() {
|
||||
public List<Objective.Option> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
|
@ -199,6 +199,11 @@ public class Objective2 extends Objective {
|
|||
.hint(new Hint(R.string.profileswitchtime_hint1))
|
||||
);
|
||||
|
||||
tasks.add(new ExamTask(R.string.other_medication_label, R.string.other_medication_text,"otherMedicationWarning")
|
||||
.option(new Option(R.string.yes, true))
|
||||
.option(new Option(R.string.no, false))
|
||||
);
|
||||
|
||||
for (Task task : tasks)
|
||||
Collections.shuffle(((ExamTask)task).options);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class NsClientReceiverDelegate {
|
|||
private final Context context;
|
||||
private final Bus bus;
|
||||
|
||||
private NetworkChangeReceiver networkChangeReceiver = new NetworkChangeReceiver();
|
||||
private NetworkChangeReceiver networkChangeReceiver = NetworkChangeReceiver.instance;
|
||||
private ChargingStateReceiver chargingStateReceiver = new ChargingStateReceiver();
|
||||
|
||||
private boolean allowedChargingState = true;
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.net.NetworkInfo;
|
|||
import android.net.wifi.SupplicantState;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -23,6 +24,17 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
|
|||
|
||||
private static EventNetworkChange lastEvent = null;
|
||||
|
||||
public static final NetworkChangeReceiver instance = new NetworkChangeReceiver();
|
||||
|
||||
// TODO: Split NSClient into network state component that can be used by several plugins and logic for plugin
|
||||
public static void fetch() {
|
||||
NetworkChangeReceiver.instance.grabNetworkStatus(MainApp.instance().getApplicationContext());
|
||||
}
|
||||
|
||||
private NetworkChangeReceiver() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
EventNetworkChange event = grabNetworkStatus(context);
|
||||
|
@ -71,7 +83,7 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
|
|||
return lastEvent != null && lastEvent.wifiConnected;
|
||||
}
|
||||
|
||||
public static boolean isConnected() {
|
||||
public static boolean isConnected() {
|
||||
return lastEvent != null && (lastEvent.wifiConnected || lastEvent.mobileConnected);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Disabled to:"
|
||||
android:text="Disabled until:"
|
||||
android:textColor="#FF5722"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -162,5 +162,8 @@
|
|||
<string name="basalhelp_diabetesteam">Your diabetes team</string>
|
||||
<string name="basalhelp_google">Google</string>
|
||||
<string name="basalhelp_facebook">Facebook</string>
|
||||
<string name="other_medication_label">Other Medication</string>
|
||||
<string name="other_medication_text">AAPS reduces BR to raise blood sugar. Drugs from the group of SGLT2 inhibitors (gliflozins) can prevent the expected increase and thus may produce a dangerous insulin deficiency (DKA).
|
||||
\nCommon brand names are: Invokana®, Forxiga®, Jardiance®, Steglatro®, Suglat®, Apleway®, Deberza®, Synjardy®, Vokanamet®, Xigduo®.\n\nI hereby confirm that I will not take such drugs when using AAPS or will deactivate the loop before using these drugs.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<string name="codeinvalid">Code invalid</string>
|
||||
<string name="objectives_exam_objective">Prove your knowledge</string>
|
||||
<string name="objectives_exam_gate">Study and answer questions correctly</string>
|
||||
<string name="answerdisabledto">Answering disabled to: %1$s</string>
|
||||
<string name="answerdisabledto">Answering disabled until: %1$s</string>
|
||||
<string name="wronganswer">Wrong answer!</string>
|
||||
<string name="unfinshed_button">Next unfinished</string>
|
||||
<string name="requestcode">Request code: %1$s</string>
|
||||
|
|
Loading…
Reference in a new issue