Merge branch 'dev' into batteryopt
This commit is contained in:
commit
4831eb9193
|
@ -11,13 +11,13 @@ import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
public class AgreementActivity extends Activity {
|
public class AgreementActivity extends NoSplashActivity {
|
||||||
boolean IUnderstand;
|
boolean IUnderstand;
|
||||||
CheckBox agreeCheckBox;
|
CheckBox agreeCheckBox;
|
||||||
Button saveButton;
|
Button saveButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_agreement);
|
setContentView(R.layout.activity_agreement);
|
||||||
IUnderstand = SP.getBoolean(R.string.key_i_understand, false);
|
IUnderstand = SP.getBoolean(R.string.key_i_understand, false);
|
||||||
|
|
|
@ -45,7 +45,7 @@ import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
|
||||||
public class HistoryBrowseActivity extends AppCompatActivity {
|
public class HistoryBrowseActivity extends NoSplashActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(HistoryBrowseActivity.class);
|
private static Logger log = LoggerFactory.getLogger(HistoryBrowseActivity.class);
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_historybrowse);
|
setContentView(R.layout.activity_historybrowse);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package info.nightscout.androidaps.activities
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.os.Bundle
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
|
||||||
|
open class NoSplashActivity : Activity() {
|
||||||
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
setTheme(R.style.AppTheme_NoActionBar)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
}
|
|
@ -56,6 +56,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
setTheme(R.style.AppTheme_NoActionBar);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
myPreferenceFragment = new MyPreferenceFragment();
|
myPreferenceFragment = new MyPreferenceFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
|
|
@ -52,7 +52,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
|
|
||||||
public class TDDStatsActivity extends Activity {
|
public class TDDStatsActivity extends NoSplashActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(TDDStatsActivity.class);
|
private static Logger log = LoggerFactory.getLogger(TDDStatsActivity.class);
|
||||||
|
|
||||||
TextView statusView, statsMessage, totalBaseBasal2;
|
TextView statusView, statsMessage, totalBaseBasal2;
|
||||||
|
@ -99,7 +99,7 @@ public class TDDStatsActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.danar_statsactivity);
|
setContentView(R.layout.danar_statsactivity);
|
||||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.aps.openAPSAMA;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -97,7 +98,7 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
|
||||||
currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
|
currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
|
||||||
try {
|
try {
|
||||||
JSONArray iobArray = new JSONArray(determineBasalAdapterAMAJS.getIobDataParam());
|
JSONArray iobArray = new JSONArray(determineBasalAdapterAMAJS.getIobDataParam());
|
||||||
iobDataView.setText(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0)));
|
iobDataView.setText(TextUtils.concat(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n", JSONFormatter.format(iobArray.getString(0))));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
iobDataView.setText("JSONException");
|
iobDataView.setText("JSONException");
|
||||||
|
|
|
@ -2,6 +2,8 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -94,26 +96,26 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
|
||||||
}
|
}
|
||||||
DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS = plugin.lastDetermineBasalAdapterSMBJS;
|
DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS = plugin.lastDetermineBasalAdapterSMBJS;
|
||||||
if (determineBasalAdapterSMBJS != null) {
|
if (determineBasalAdapterSMBJS != null) {
|
||||||
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getGlucoseStatusParam()).toString().trim());
|
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getGlucoseStatusParam()));
|
||||||
currentTempView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getCurrentTempParam()).toString().trim());
|
currentTempView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getCurrentTempParam()));
|
||||||
try {
|
try {
|
||||||
JSONArray iobArray = new JSONArray(determineBasalAdapterSMBJS.getIobDataParam());
|
JSONArray iobArray = new JSONArray(determineBasalAdapterSMBJS.getIobDataParam());
|
||||||
iobDataView.setText((String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0))).trim());
|
iobDataView.setText(TextUtils.concat(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n", JSONFormatter.format(iobArray.getString(0))));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
iobDataView.setText("JSONException see log for details");
|
iobDataView.setText("JSONException see log for details");
|
||||||
}
|
}
|
||||||
profileView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getProfileParam()).toString().trim());
|
profileView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getProfileParam()));
|
||||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getMealDataParam()).toString().trim());
|
mealDataView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getMealDataParam()));
|
||||||
scriptdebugView.setText(determineBasalAdapterSMBJS.getScriptDebug().trim());
|
scriptdebugView.setText(determineBasalAdapterSMBJS.getScriptDebug());
|
||||||
if (lastAPSResult != null && lastAPSResult.inputConstraints != null)
|
if (lastAPSResult != null && lastAPSResult.inputConstraints != null)
|
||||||
constraintsView.setText(lastAPSResult.inputConstraints.getReasons().trim());
|
constraintsView.setText(lastAPSResult.inputConstraints.getReasons());
|
||||||
}
|
}
|
||||||
if (plugin.lastAPSRun != 0) {
|
if (plugin.lastAPSRun != 0) {
|
||||||
lastRunView.setText(DateUtil.dateAndTimeFullString(plugin.lastAPSRun));
|
lastRunView.setText(DateUtil.dateAndTimeFullString(plugin.lastAPSRun));
|
||||||
}
|
}
|
||||||
if (plugin.lastAutosensResult != null) {
|
if (plugin.lastAutosensResult != null) {
|
||||||
autosensDataView.setText(JSONFormatter.format(plugin.lastAutosensResult.json()).toString().trim());
|
autosensDataView.setText(JSONFormatter.format(plugin.lastAutosensResult.json()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.services.AlarmSoundService;
|
|
||||||
|
|
||||||
public class ErrorDialog extends DialogFragment implements View.OnClickListener {
|
|
||||||
private static Logger log = LoggerFactory.getLogger(ErrorDialog.class);
|
|
||||||
Button muteButton;
|
|
||||||
Button okButton;
|
|
||||||
TextView statusView;
|
|
||||||
ErrorHelperActivity helperActivity;
|
|
||||||
|
|
||||||
static String status;
|
|
||||||
static String title;
|
|
||||||
static int soundId;
|
|
||||||
|
|
||||||
public ErrorDialog() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(String status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSound(int soundId) {
|
|
||||||
this.soundId = soundId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHelperActivity(ErrorHelperActivity activity) {
|
|
||||||
this.helperActivity = activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
getDialog().setTitle(title);
|
|
||||||
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);
|
|
||||||
statusView = (TextView) view.findViewById(R.id.overview_error_status);
|
|
||||||
muteButton.setOnClickListener(this);
|
|
||||||
okButton.setOnClickListener(this);
|
|
||||||
setCancelable(false);
|
|
||||||
|
|
||||||
startAlarm();
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (getDialog() != null)
|
|
||||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
statusView.setText(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dismiss() {
|
|
||||||
super.dismissAllowingStateLoss();
|
|
||||||
if (helperActivity != null) {
|
|
||||||
helperActivity.finish();
|
|
||||||
}
|
|
||||||
stopAlarm();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.overview_error_mute:
|
|
||||||
log.debug("Error dialog mute button pressed");
|
|
||||||
stopAlarm();
|
|
||||||
break;
|
|
||||||
case R.id.overview_error_ok:
|
|
||||||
log.debug("Error dialog ok button pressed");
|
|
||||||
dismiss();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startAlarm() {
|
|
||||||
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
|
|
||||||
alarm.putExtra("soundid", soundId);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
|
||||||
MainApp.instance().startForegroundService(alarm);
|
|
||||||
else
|
|
||||||
MainApp.instance().startService(alarm);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopAlarm() {
|
|
||||||
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
|
|
||||||
MainApp.instance().stopService(alarm);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.overview.dialogs
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.services.AlarmSoundService
|
||||||
|
import kotlinx.android.synthetic.main.overview_error_dialog.*
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
|
class ErrorDialog : DialogFragment() {
|
||||||
|
private val log = LoggerFactory.getLogger(ErrorDialog::class.java)
|
||||||
|
|
||||||
|
var helperActivity: ErrorHelperActivity? = null
|
||||||
|
var status: String = ""
|
||||||
|
var title: String = ""
|
||||||
|
var sound: Int = 0
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
dialog.setTitle(title)
|
||||||
|
isCancelable = false
|
||||||
|
|
||||||
|
savedInstanceState?.let { bundle ->
|
||||||
|
bundle.getString("status")?.let { status = it }
|
||||||
|
bundle.getString("title")?.let { title = it }
|
||||||
|
sound = bundle.getInt("sound", R.raw.error)
|
||||||
|
}
|
||||||
|
return inflater.inflate(R.layout.overview_error_dialog, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
overview_error_ok.setOnClickListener {
|
||||||
|
log.debug("Error dialog ok button pressed")
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
overview_error_mute.setOnClickListener {
|
||||||
|
log.debug("Error dialog mute button pressed")
|
||||||
|
stopAlarm()
|
||||||
|
}
|
||||||
|
startAlarm()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSaveInstanceState(bundle: Bundle) {
|
||||||
|
super.onSaveInstanceState(bundle)
|
||||||
|
bundle.putString("status", status)
|
||||||
|
bundle.putString("title", title)
|
||||||
|
bundle.putInt("sound", sound)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
dialog?.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
|
overview_error_status.text = status
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dismiss() {
|
||||||
|
super.dismissAllowingStateLoss()
|
||||||
|
helperActivity?.finish()
|
||||||
|
stopAlarm()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startAlarm() {
|
||||||
|
if (sound != 0) {
|
||||||
|
val alarm = Intent(MainApp.instance().applicationContext, AlarmSoundService::class.java)
|
||||||
|
alarm.putExtra("soundid", sound)
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
MainApp.instance().startForegroundService(alarm)
|
||||||
|
} else {
|
||||||
|
MainApp.instance().startService(alarm)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun stopAlarm() =
|
||||||
|
MainApp.instance().stopService(Intent(MainApp.instance().applicationContext, AlarmSoundService::class.java))
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
|
|
||||||
public class ErrorHelperActivity extends AppCompatActivity {
|
|
||||||
public ErrorHelperActivity() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
ErrorDialog errorDialog = new ErrorDialog();
|
|
||||||
errorDialog.setHelperActivity(this);
|
|
||||||
errorDialog.setStatus(getIntent().getStringExtra("status"));
|
|
||||||
errorDialog.setSound(getIntent().getIntExtra("soundid", 0));
|
|
||||||
errorDialog.setTitle(getIntent().getStringExtra("title"));
|
|
||||||
errorDialog.show(this.getSupportFragmentManager(), "Error");
|
|
||||||
|
|
||||||
if (SP.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
|
|
||||||
NSUpload.uploadError(getIntent().getStringExtra("status"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.overview.dialogs
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
|
import info.nightscout.androidaps.utils.SP
|
||||||
|
|
||||||
|
class ErrorHelperActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
val errorDialog = ErrorDialog()
|
||||||
|
errorDialog.helperActivity = this
|
||||||
|
errorDialog.status = intent.getStringExtra("status")
|
||||||
|
errorDialog.sound = intent.getIntExtra("soundid", R.raw.error)
|
||||||
|
errorDialog.title = intent.getStringExtra("title")
|
||||||
|
errorDialog.show(supportFragmentManager, "Error")
|
||||||
|
|
||||||
|
if (SP.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
|
||||||
|
NSUpload.uploadError(intent.getStringExtra("status"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,13 +7,14 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.media.AudioAttributes;
|
import android.media.AudioManager;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -66,7 +67,7 @@ public class NotificationStore {
|
||||||
|
|
||||||
if (SP.getBoolean(MainApp.gs(R.string.key_raise_notifications_as_android_notifications), false) && !(n instanceof NotificationWithAction)) {
|
if (SP.getBoolean(MainApp.gs(R.string.key_raise_notifications_as_android_notifications), false) && !(n instanceof NotificationWithAction)) {
|
||||||
raiseSystemNotification(n);
|
raiseSystemNotification(n);
|
||||||
if (usesChannels && n.soundId != null) {
|
if (usesChannels && n.soundId != null && n.soundId != 0) {
|
||||||
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
|
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
|
||||||
alarm.putExtra("soundid", n.soundId);
|
alarm.putExtra("soundid", n.soundId);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
|
@ -76,7 +77,7 @@ public class NotificationStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (n.soundId != null) {
|
if (n.soundId != null && n.soundId != 0) {
|
||||||
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
|
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
|
||||||
alarm.putExtra("soundid", n.soundId);
|
alarm.putExtra("soundid", n.soundId);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
|
@ -146,7 +147,7 @@ public class NotificationStore {
|
||||||
if (n.level == Notification.URGENT) {
|
if (n.level == Notification.URGENT) {
|
||||||
notificationBuilder.setVibrate(new long[]{1000, 1000, 1000, 1000})
|
notificationBuilder.setVibrate(new long[]{1000, 1000, 1000, 1000})
|
||||||
.setContentTitle(MainApp.gs(R.string.urgent_alarm))
|
.setContentTitle(MainApp.gs(R.string.urgent_alarm))
|
||||||
.setSound(sound, AudioAttributes.USAGE_ALARM);
|
.setSound(sound, AudioManager.STREAM_ALARM);
|
||||||
} else {
|
} else {
|
||||||
notificationBuilder.setVibrate(new long[]{0, 100, 50, 100, 50})
|
notificationBuilder.setVibrate(new long[]{0, 100, 50, 100, 50})
|
||||||
.setContentTitle(MainApp.gs(R.string.info))
|
.setContentTitle(MainApp.gs(R.string.info))
|
||||||
|
|
|
@ -1529,6 +1529,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
ServiceTaskExecutor.startTask(new WakeAndTuneTask());
|
ServiceTaskExecutor.startTask(new WakeAndTuneTask());
|
||||||
} else {
|
} else {
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
|
i.putExtra("soundid", R.raw.boluserror);
|
||||||
i.putExtra("status", MainApp.gs(R.string.medtronic_error_operation_not_possible_no_configuration));
|
i.putExtra("status", MainApp.gs(R.string.medtronic_error_operation_not_possible_no_configuration));
|
||||||
i.putExtra("title", MainApp.gs(R.string.combo_warning));
|
i.putExtra("title", MainApp.gs(R.string.combo_warning));
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
|
@ -38,6 +38,8 @@ public class AlarmSoundService extends Service {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
if (L.isEnabled(L.CORE))
|
if (L.isEnabled(L.CORE))
|
||||||
log.debug("onCreate");
|
log.debug("onCreate");
|
||||||
|
Notification notification = PersistentNotificationPlugin.getPlugin().getLastNotification();
|
||||||
|
startForeground(PersistentNotificationPlugin.ONGOING_NOTIFICATION_ID, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
@ -51,28 +53,22 @@ public class AlarmSoundService extends Service {
|
||||||
resourceId = intent.getIntExtra("soundid", R.raw.error);
|
resourceId = intent.getIntExtra("soundid", R.raw.error);
|
||||||
|
|
||||||
player = new MediaPlayer();
|
player = new MediaPlayer();
|
||||||
|
try {
|
||||||
AssetFileDescriptor afd = MainApp.sResources.openRawResourceFd(resourceId);
|
AssetFileDescriptor afd = MainApp.sResources.openRawResourceFd(resourceId);
|
||||||
if (afd == null)
|
if (afd == null)
|
||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
try {
|
|
||||||
player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
|
player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
|
||||||
afd.close();
|
afd.close();
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
player.setLooping(true); // Set looping
|
player.setLooping(true); // Set looping
|
||||||
AudioManager manager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager manager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
|
||||||
if (manager == null || !manager.isMusicActive()) {
|
if (manager == null || !manager.isMusicActive()) {
|
||||||
player.setVolume(100, 100);
|
player.setVolume(100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.start();
|
player.start();
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.utils;
|
package info.nightscout.androidaps.utils;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
|
||||||
|
@ -18,14 +19,23 @@ public class JSONFormatter {
|
||||||
private static Logger log = LoggerFactory.getLogger(JSONFormatter.class);
|
private static Logger log = LoggerFactory.getLogger(JSONFormatter.class);
|
||||||
|
|
||||||
public static Spanned format(final String jsonString) {
|
public static Spanned format(final String jsonString) {
|
||||||
final JsonVisitor visitor = new JsonVisitor(4, ' ');
|
final JsonVisitor visitor = new JsonVisitor(1, '\t');
|
||||||
try {
|
try {
|
||||||
if (jsonString.equals("undefined"))
|
if (jsonString.equals("undefined"))
|
||||||
return Html.fromHtml("undefined");
|
return Html.fromHtml("undefined");
|
||||||
else if (jsonString.getBytes()[0] == '[')
|
else if (jsonString.getBytes()[0] == '[')
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
return Html.fromHtml(visitor.visit(new JSONArray(jsonString), 0), Html.FROM_HTML_MODE_COMPACT);
|
||||||
|
} else {
|
||||||
return Html.fromHtml(visitor.visit(new JSONArray(jsonString), 0));
|
return Html.fromHtml(visitor.visit(new JSONArray(jsonString), 0));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
return Html.fromHtml(visitor.visit(new JSONObject(jsonString), 0), Html.FROM_HTML_MODE_COMPACT);
|
||||||
|
} else {
|
||||||
return Html.fromHtml(visitor.visit(new JSONObject(jsonString), 0));
|
return Html.fromHtml(visitor.visit(new JSONObject(jsonString), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
return Html.fromHtml("");
|
return Html.fromHtml("");
|
||||||
|
@ -33,7 +43,7 @@ public class JSONFormatter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spanned format(final JSONObject object) {
|
public static Spanned format(final JSONObject object) {
|
||||||
final JsonVisitor visitor = new JsonVisitor(4, ' ');
|
final JsonVisitor visitor = new JsonVisitor(1, '\t');
|
||||||
try {
|
try {
|
||||||
return Html.fromHtml(visitor.visit(object, 0));
|
return Html.fromHtml(visitor.visit(object, 0));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -58,7 +68,7 @@ public class JSONFormatter {
|
||||||
} else {
|
} else {
|
||||||
ret += write("[", indent);
|
ret += write("[", indent);
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
ret += visit(array.get(i), indent + 1);
|
ret += visit(array.get(i), indent);
|
||||||
}
|
}
|
||||||
ret += write("]", indent);
|
ret += write("]", indent);
|
||||||
}
|
}
|
||||||
|
@ -73,8 +83,8 @@ public class JSONFormatter {
|
||||||
final Iterator<String> keys = obj.keys();
|
final Iterator<String> keys = obj.keys();
|
||||||
while (keys.hasNext()) {
|
while (keys.hasNext()) {
|
||||||
final String key = keys.next();
|
final String key = keys.next();
|
||||||
ret += write("<b>" + key + "</b>: ", indent + 1);
|
ret += write("<b>" + key + "</b>: ", indent);
|
||||||
ret += visit(obj.get(key), 0);
|
ret += visit(obj.get(key), indent + 1);
|
||||||
ret += "<br>";
|
ret += "<br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +96,7 @@ public class JSONFormatter {
|
||||||
if (object instanceof JSONArray) {
|
if (object instanceof JSONArray) {
|
||||||
ret += visit((JSONArray) object, indent);
|
ret += visit((JSONArray) object, indent);
|
||||||
} else if (object instanceof JSONObject) {
|
} else if (object instanceof JSONObject) {
|
||||||
ret += visit((JSONObject) object, indent);
|
ret += "<br>" + visit((JSONObject) object, indent);
|
||||||
} else {
|
} else {
|
||||||
if (object instanceof String) {
|
if (object instanceof String) {
|
||||||
ret += write("\"" + ((String) object).replace("<", "<").replace(">", ">") + "\"", indent);
|
ret += write("\"" + ((String) object).replace("<", "<").replace(">", ">") + "\"", indent);
|
||||||
|
|
Loading…
Reference in a new issue