Merge pull request #673 from jotomo/bolus-error-dialog-sound

Bolus error dialog / sound
This commit is contained in:
Milos Kozak 2018-02-08 21:07:21 +01:00 committed by GitHub
commit 5c7c430ee4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 6 deletions

View file

@ -19,6 +19,7 @@ import info.nightscout.androidaps.Services.AlarmSoundService;
public class ErrorDialog extends DialogFragment implements View.OnClickListener { public class ErrorDialog extends DialogFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(ErrorDialog.class); private static Logger log = LoggerFactory.getLogger(ErrorDialog.class);
Button muteButton;
Button okButton; Button okButton;
TextView statusView; TextView statusView;
ErrorHelperActivity helperActivity; ErrorHelperActivity helperActivity;
@ -52,14 +53,14 @@ public class ErrorDialog extends DialogFragment implements View.OnClickListener
Bundle savedInstanceState) { Bundle savedInstanceState) {
getDialog().setTitle(title); getDialog().setTitle(title);
View view = inflater.inflate(R.layout.overview_error_dialog, container, false); View view = inflater.inflate(R.layout.overview_error_dialog, container, false);
muteButton = (Button) view.findViewById(R.id.overview_error_mute);
okButton = (Button) view.findViewById(R.id.overview_error_ok); okButton = (Button) view.findViewById(R.id.overview_error_ok);
statusView = (TextView) view.findViewById(R.id.overview_error_status); statusView = (TextView) view.findViewById(R.id.overview_error_status);
muteButton.setOnClickListener(this);
okButton.setOnClickListener(this); okButton.setOnClickListener(this);
setCancelable(false); setCancelable(false);
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class); startAlarm();
alarm.putExtra("soundid", soundId);
MainApp.instance().startService(alarm);
return view; return view;
} }
@ -77,13 +78,16 @@ public class ErrorDialog extends DialogFragment implements View.OnClickListener
if (helperActivity != null) { if (helperActivity != null) {
helperActivity.finish(); helperActivity.finish();
} }
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class); stopAlarm();
MainApp.instance().stopService(alarm);
} }
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.overview_error_mute:
log.debug("Error dialog mute button pressed");
stopAlarm();
break;
case R.id.overview_error_ok: case R.id.overview_error_ok:
log.debug("Error dialog ok button pressed"); log.debug("Error dialog ok button pressed");
dismiss(); dismiss();
@ -91,4 +95,14 @@ public class ErrorDialog extends DialogFragment implements View.OnClickListener
} }
} }
private void startAlarm() {
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
alarm.putExtra("soundid", soundId);
MainApp.instance().startService(alarm);
}
private void stopAlarm() {
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
MainApp.instance().stopService(alarm);
}
} }

View file

@ -13,12 +13,20 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" /> android:layout_gravity="center_horizontal" />
<Button
android:id="@+id/overview_error_mute"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:text="@string/mute" />
<Button <Button
android:id="@+id/overview_error_ok" android:id="@+id/overview_error_ok"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp" android:layout_marginTop="5dp"
android:text="@string/ok" /> android:text="@string/ok" />
</LinearLayout> </LinearLayout>

Binary file not shown.

View file

@ -928,5 +928,6 @@
<string name="enablesmbwithhightemptarget">Enable SMB with high temp targets</string> <string name="enablesmbwithhightemptarget">Enable SMB with high temp targets</string>
<string name="enablesmbwithhightemptarget_summary">Enable SMB when there is high temp target active (exercise)</string> <string name="enablesmbwithhightemptarget_summary">Enable SMB when there is high temp target active (exercise)</string>
<string name="let_temp_basal_run">Let current temp basal run</string> <string name="let_temp_basal_run">Let current temp basal run</string>
<string name="mute">Mute</string>
</resources> </resources>