medtronic-0.12.0-SNAPSHOT

- Merge branch 'dev' into medtronic_andy
This commit is contained in:
Andy Rozman 2019-07-05 14:18:28 +01:00
commit 992f69daaa
222 changed files with 835 additions and 1084 deletions

View file

@ -2,19 +2,19 @@ language: android
jdk: oraclejdk8
env:
matrix:
- ANDROID_TARGET=android-23 ANDROID_ABI=x86 org.gradle.jvmargs=-XX:-OmitStackTraceInFastThrow
- ANDROID_TARGET=android-28 ANDROID_ABI=x86 org.gradle.jvmargs=-XX:-OmitStackTraceInFastThrow
android:
components:
- platform-tools
- tools
- build-tools-27.0.2
- android-23
- build-tools-28.0.3
- android-28
- extra-google-m2repository
- extra-android-m2repository
- extra-google-google_play_services
before_install:
- yes | sdkmanager "platforms;android-27"
- yes | sdkmanager "platforms;android-28"
script:
# Unit Test

View file

@ -7,22 +7,29 @@ buildscript {
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
classpath 'de.undercouch:gradle-download-task:3.4.3'
}
}
apply plugin: "com.android.application"
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: "io.fabric"
apply plugin: "jacoco-android"
apply plugin: 'io.fabric'
apply plugin: 'jacoco-android'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'de.undercouch.download'
jacoco {
toolVersion = "0.8.3"
}
ext {
supportLibraryVersion = "27.1.1"
supportLibraryVersion = "28.0.0"
ormLiteVersion = "4.46"
powermockVersion = "1.7.3"
dexmakerVersion = "1.2"
butterknifeVersion = "8.8.1"
butterknifeVersion = "10.1.0"
}
@ -97,23 +104,22 @@ tasks.matching { it instanceof Test }.all {
}
android {
compileSdkVersion 27
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
minSdkVersion 23
targetSdkVersion 28
multiDexEnabled true
versionCode 1500
// dev_version: 2.3.1-dev
version "medtronic-0.11"
version "medtronic-0.12.0-SNAPSHOT"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
buildConfigField "String", "DEV_VERSION", '"2.3.1-dev"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
buildConfigField "String", "DEV_VERSION", '"2.4-dev"'
buildConfigField "String", "DEV_DATE", '"21.6.2019"'
buildConfigField "String", "DEV_CHECKIN", '"8d9c18dd359dc671dfb1b9f75dd454e29df640f2"'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// if you change minSdkVersion to less than 11, you need to change executeTask for wear
ndk {
@ -192,8 +198,15 @@ android {
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.includeAndroidResources = true
unitTests {
returnDefaultValues = true
includeAndroidResources = true
all {
maxParallelForks = 10
forkEvery = 20
}
}
}
useLibrary "org.apache.http.legacy"
@ -208,29 +221,24 @@ allprojects {
}
}
configurations {
libs
}
dependencies {
wearApp project(':wear')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-wearable:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation("com.crashlytics.sdk.android:crashlytics:2.9.9@aar") {
transitive = true;
}
libs "MilosKozak:danars-support-lib:master@zip"
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
implementation "com.android.support:support-v13:${supportLibraryVersion}"
implementation "com.android.support:support-v4:${supportLibraryVersion}"
implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
implementation "com.android.support:recyclerview-v7:${supportLibraryVersion}"
implementation "com.android.support:gridlayout-v7:${supportLibraryVersion}"
implementation "com.android.support:design:${supportLibraryVersion}"
implementation "com.android.support:percent:${supportLibraryVersion}"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation "com.wdullaer:materialdatetimepicker:2.3.0"
implementation "com.squareup:otto:1.3.7"
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
@ -243,7 +251,7 @@ dependencies {
// Graphview cannot be upgraded
implementation "com.jjoe64:graphview:4.0.1"
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.1.1"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar")
implementation 'com.madgag.spongycastle:core:1.58.0.0'
@ -254,14 +262,13 @@ dependencies {
// excluding org.json which is provided by Android
exclude group: "org.json", module: "json"
}
implementation "com.google.code.gson:gson:2.8.2"
implementation "com.google.code.gson:gson:2.8.5"
implementation "com.google.guava:guava:24.1-jre"
implementation "net.danlew:android.joda:2.9.9.1"
implementation "uk.com.robust-it:cloning:1.9.9"
implementation 'org.mozilla:rhino:1.7.7.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.jakewharton:butterknife:${butterknifeVersion}"
annotationProcessor "com.jakewharton:butterknife-compiler:${butterknifeVersion}"
@ -277,7 +284,7 @@ dependencies {
testImplementation("com.google.truth:truth:0.39") {
exclude group: "com.google.guava", module: "guava"
}
testImplementation("org.robolectric:robolectric:3.8") {
testImplementation("org.robolectric:robolectric:4.2.1") {
exclude group: "com.google.guava", module: "guava"
}
testImplementation "org.skyscreamer:jsonassert:1.5.0"
@ -289,18 +296,23 @@ dependencies {
androidTestImplementation "org.mockito:mockito-core:2.8.47"
androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}"
androidTestImplementation "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
task unzip(type: Copy) {
def zipPath = configurations.libs.find { it.name.startsWith("danars") }
def zipFile = file(zipPath)
def outputDir = file("${buildDir}/unpacked/dist")
from zipTree(zipFile)
task downloadZipFile(type: Download) {
src 'https://github.com/MilosKozak/danars-support-lib/archive/master.zip'
dest new File(buildDir, 'danars.zip')
}
task downloadAndUnzipFile(dependsOn: downloadZipFile, type: Copy) {
from zipTree(downloadZipFile.dest)
def outputDir = file("${buildDir}/unpacked/dist")
into outputDir
}
task copyLibs(dependsOn: unzip, type: Copy) {
task copyLibs(dependsOn: downloadAndUnzipFile, type: Copy) {
def src = file("${buildDir}/unpacked/dist/danars-support-lib-master")
def target = file("src/main/jniLibs/")

View file

@ -17,10 +17,11 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="sugar.free.sightremote.HISTORY_BROADCASTS" />
<uses-permission android:name="com.dexcom.cgm.EXTERNAL_PERMISSION" />
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
@ -34,13 +35,15 @@
android:label="@string/app_name"
android:roundIcon="${appIconRound}"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:fullBackupContent="true">
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
@ -85,10 +88,8 @@
<action android:name="com.eveningoutpost.dexdrip.NS_EMULATOR"/>
<!-- Receiver from glimp -->
<action android:name="it.ct.glicemia.ACTION_GLUCOSE_MEASURED"/>
<!-- Receiver from DexcomG5 -->
<action android:name="com.dexcom.cgm.DATA"/>
<action android:name="com.dexcom.cgm.AndroidAPSEVGCallback.BROADCAST"/>
<action android:name="com.dexcom.cgm.g5.AndroidAPSEVGCallback.BROADCAST"/>
<!-- Receiver from Dexcom -->
<action android:name="com.dexcom.cgm.EXTERNAL_BROADCAST"/>
<!-- Receiver from Poctech -->
<action android:name="com.china.poctech.data"/>
<!-- Receiver from Tomato -->
@ -147,7 +148,7 @@
</receiver>
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
@ -281,7 +282,7 @@
android:name=".plugins.pump.insight.activities.InsightPairingInformationActivity"
android:label="@string/pairing_information"
android:theme="@style/AppTheme" />
<activity android:name=".activities.RequestDexcomPermissionActivity" />
<!-- Medtronic service and activities -->
<service
@ -303,6 +304,8 @@
android:theme="@style/Theme.AppCompat.NoTitle" />
<activity android:name=".plugins.pump.medtronic.dialog.MedtronicHistoryActivity" />
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
</manifest>

View file

@ -7,16 +7,16 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.PowerManager;
import android.support.annotation.Nullable;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.app.ActivityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import androidx.annotation.Nullable;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.tabs.TabLayout;
import androidx.core.app.ActivityCompat;
import androidx.viewpager.widget.ViewPager;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;

View file

@ -1,17 +1,12 @@
package info.nightscout.androidaps;
import android.app.Application;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.support.annotation.PluralsRes;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.PluralsRes;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.crashlytics.android.Crashlytics;
import com.google.firebase.analytics.FirebaseAnalytics;
@ -66,22 +61,18 @@ import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin;
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
import info.nightscout.androidaps.plugins.profile.simple.SimpleProfilePlugin;
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin;
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.source.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.source.SourceDexcomG6Plugin;
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
import info.nightscout.androidaps.plugins.source.SourceEversensePlugin;
import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin;
import info.nightscout.androidaps.plugins.source.SourceMM640gPlugin;
@ -120,7 +111,6 @@ public class MainApp extends Application {
private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver();
private static DBAccessReceiver dbAccessReciever = new DBAccessReceiver();
private LocalBroadcastManager lbm;
private BroadcastReceiver btReceiver; // used for RileyLink (Medtronic and Omnipod)
public static boolean devBranch;
public static boolean engineeringMode;
@ -154,7 +144,7 @@ public class MainApp extends Application {
File engineeringModeSemaphore = new File(extFilesDir, "engineering_mode");
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
devBranch = BuildConfig.VERSION.contains("dev");
devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(".*[a-zA-Z]+.*");
sBus = L.isEnabled(L.EVENTS) && devBranch ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY);
@ -203,8 +193,7 @@ public class MainApp extends Application {
pluginsList.add(SourceNSClientPlugin.getPlugin());
pluginsList.add(SourceMM640gPlugin.getPlugin());
pluginsList.add(SourceGlimpPlugin.getPlugin());
pluginsList.add(SourceDexcomG5Plugin.getPlugin());
pluginsList.add(SourceDexcomG6Plugin.getPlugin());
pluginsList.add(SourceDexcomPlugin.INSTANCE);
pluginsList.add(SourcePoctechPlugin.getPlugin());
pluginsList.add(SourceTomatoPlugin.getPlugin());
pluginsList.add(SourceEversensePlugin.getPlugin());
@ -462,14 +451,6 @@ public class MainApp extends Application {
return null;
}
public static boolean isEngineeringMode() {
if (!Config.APS)
return true;
return engineeringMode;
}
public static boolean isEngineeringModeOrRelease() {
if (!Config.APS)
return true;

View file

@ -2,9 +2,9 @@ package info.nightscout.androidaps.activities;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.PopupMenu;
import androidx.core.content.res.ResourcesCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.Menu;

View file

@ -40,9 +40,9 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.source.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.general.wear.WearPlugin;
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin;
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
import info.nightscout.androidaps.utils.LocaleHelper;
import info.nightscout.androidaps.utils.OKDialog;
import info.nightscout.androidaps.utils.SP;
@ -145,7 +145,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_overview);
addPreferencesFromResourceIfEnabled(SourceDexcomG5Plugin.getPlugin(), PluginType.BGSOURCE);
addPreferencesFromResourceIfEnabled(SourceDexcomPlugin.INSTANCE, PluginType.BGSOURCE);
addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginType.GENERAL);
addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginType.CONSTRAINTS);
if (Config.APS) {

View file

@ -0,0 +1,25 @@
package info.nightscout.androidaps.activities
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin
class RequestDexcomPermissionActivity : AppCompatActivity() {
private val requestCode = "AndroidAPS <3".map { it.toInt() }.sum()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(arrayOf(SourceDexcomPlugin.PERMISSION), requestCode)
} else {
finish()
}
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
finish()
}
}

View file

@ -2,9 +2,9 @@ package info.nightscout.androidaps.activities;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;

View file

@ -4,7 +4,7 @@ import android.app.Activity;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MotionEvent;

View file

@ -1,11 +1,9 @@
package info.nightscout.androidaps.data;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import javax.annotation.Nonnull;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.data;
import android.support.annotation.Nullable;
import android.support.v4.util.LongSparseArray;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,10 +1,8 @@
package info.nightscout.androidaps.data;
import android.support.annotation.Nullable;
import android.support.v4.util.LongSparseArray;
import androidx.annotation.Nullable;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.interfaces.Interval;
/**

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.data;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import info.nightscout.androidaps.interfaces.Interval;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.data;
import android.support.v4.util.LongSparseArray;
import androidx.collection.LongSparseArray;
import org.json.JSONArray;
import org.json.JSONException;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.data;
import android.support.annotation.Nullable;
import android.support.v4.util.LongSparseArray;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.data;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
import androidx.annotation.Nullable;
import androidx.collection.ArrayMap;
import org.json.JSONException;
import org.json.JSONObject;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.db;
import android.content.Context;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.CloseableIterator;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.db;
import android.graphics.Color;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.events;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import info.nightscout.androidaps.db.BgReading;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.events;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import info.nightscout.androidaps.plugins.treatments.Treatment;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.interfaces;
import android.os.SystemClock;
import android.support.v4.app.FragmentActivity;
import androidx.fragment.app.FragmentActivity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.interfaces;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import info.nightscout.androidaps.data.ProfileStore;

View file

@ -10,8 +10,8 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.v4.app.NotificationCompat;
import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import com.squareup.otto.Subscribe;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.common;
import android.support.v4.app.Fragment;
import androidx.fragment.app.Fragment;
import butterknife.Unbinder;
import info.nightscout.androidaps.MainApp;

View file

@ -3,8 +3,8 @@ package info.nightscout.androidaps.plugins.configBuilder;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.configBuilder;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.configBuilder;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.configBuilder;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.squareup.otto.Subscribe;

View file

@ -4,11 +4,11 @@ import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.LinearSmoothScroller;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.constraints.objectives.objectives;
import android.support.annotation.StringRes;
import androidx.annotation.StringRes;
import java.util.ArrayList;
import java.util.Date;

View file

@ -5,8 +5,8 @@ import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -3,8 +3,8 @@ package info.nightscout.androidaps.plugins.general.actions.dialogs;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;

View file

@ -4,8 +4,8 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -3,8 +3,8 @@ package info.nightscout.androidaps.plugins.general.actions.dialogs;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -4,7 +4,7 @@ package info.nightscout.androidaps.plugins.general.careportal;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import androidx.fragment.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -3,8 +3,8 @@ package info.nightscout.androidaps.plugins.general.careportal.Dialogs;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.format.DateFormat;

View file

@ -4,9 +4,9 @@ import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.food;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.android.apptools.OrmLiteBaseService;

View file

@ -8,9 +8,9 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;
import androidx.core.content.ContextCompat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.general.maintenance;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.appcompat.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.maintenance;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.content.FileProvider;
import androidx.core.content.FileProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.maintenance.activities;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;

View file

@ -7,8 +7,8 @@ import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import androidx.annotation.Nullable;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONObject;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONObject;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONArray;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONObject;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONArray;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONArray;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONArray;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONArray;

View file

@ -4,7 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONArray;
import org.json.JSONException;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONObject;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.data;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import org.json.JSONException;
import org.json.JSONObject;

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.receivers;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import androidx.legacy.content.WakefulBroadcastReceiver;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.overview;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.NotificationManager;
import android.arch.core.util.Function;
import androidx.arch.core.util.Function;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@ -12,14 +12,14 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.core.content.res.ResourcesCompat;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.PopupMenu;
import androidx.recyclerview.widget.RecyclerView;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
@ -103,8 +103,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress;
import info.nightscout.androidaps.plugins.source.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.source.SourceDexcomG6Plugin;
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
import info.nightscout.androidaps.plugins.source.SourceXdripPlugin;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.plugins.treatments.fragments.ProfileViewerDialog;
@ -656,8 +655,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
@Override
public void onClick(View v) {
boolean xdrip = SourceXdripPlugin.getPlugin().isEnabled(PluginType.BGSOURCE);
boolean g5 = SourceDexcomG5Plugin.getPlugin().isEnabled(PluginType.BGSOURCE);
boolean g6 = SourceDexcomG6Plugin.getPlugin().isEnabled(PluginType.BGSOURCE);
boolean dexcom = SourceDexcomPlugin.INSTANCE.isEnabled(PluginType.BGSOURCE);
String units = ProfileFunctions.getInstance().getProfileUnits();
FragmentManager manager = getFragmentManager();
@ -680,10 +678,16 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (xdrip) {
CalibrationDialog calibrationDialog = new CalibrationDialog();
calibrationDialog.show(manager, "CalibrationDialog");
} else if (g5 || g6) {
} else if (dexcom) {
try {
String packageName = SourceDexcomPlugin.INSTANCE.findDexcomPackageName();
if (packageName != null) {
Intent i = new Intent("com.dexcom.cgm.activities.MeterEntryActivity");
i.setPackage(packageName);
startActivity(i);
} else {
ToastUtils.showToastInUiThread(getActivity(), MainApp.gs(R.string.dexcom_app_not_installed));
}
} catch (ActivityNotFoundException e) {
ToastUtils.showToastInUiThread(getActivity(), MainApp.gs(R.string.g5appnotdetected));
}
@ -692,14 +696,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
case R.id.overview_cgmbutton:
if (xdrip)
openCgmApp("com.eveningoutpost.dexdrip");
else if (g5 && units.equals(Constants.MGDL))
openCgmApp("com.dexcom.cgm.region5.mgdl");
else if (g5 && units.equals(Constants.MMOL))
openCgmApp("com.dexcom.cgm.region5.mmol");
else if (g6 && units.equals(Constants.MGDL))
openCgmApp("com.dexcom.g6.region3.mgdl");
else if (g6 && units.equals(Constants.MMOL))
openCgmApp("com.dexcom.g6.region3.mmol");
else if (dexcom) {
String packageName = SourceDexcomPlugin.INSTANCE.findDexcomPackageName();
if (packageName != null) {
openCgmApp(packageName);
} else {
ToastUtils.showToastInUiThread(getActivity(), MainApp.gs(R.string.dexcom_app_not_installed));
}
}
break;
case R.id.overview_treatmentbutton:
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
@ -1092,10 +1096,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// **** Calibration & CGM buttons ****
boolean xDripIsBgSource = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginType.BGSOURCE);
boolean g5IsBgSource = MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class) != null && MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class).isEnabled(PluginType.BGSOURCE);
boolean dexcomIsSource = SourceDexcomPlugin.INSTANCE.isEnabled(PluginType.BGSOURCE);
boolean bgAvailable = DatabaseHelper.actualBg() != null;
if (calibrationButton != null) {
if ((xDripIsBgSource || g5IsBgSource) && bgAvailable && SP.getBoolean(R.string.key_show_calibration_button, true)) {
if ((xDripIsBgSource || dexcomIsSource) && bgAvailable && SP.getBoolean(R.string.key_show_calibration_button, true)) {
calibrationButton.setVisibility(View.VISIBLE);
} else {
calibrationButton.setVisibility(View.GONE);
@ -1104,7 +1108,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (cgmButton != null) {
if (xDripIsBgSource && SP.getBoolean(R.string.key_show_cgm_button, false)) {
cgmButton.setVisibility(View.VISIBLE);
} else if (g5IsBgSource && SP.getBoolean(R.string.key_show_cgm_button, false)) {
} else if (dexcomIsSource && SP.getBoolean(R.string.key_show_cgm_button, false)) {
cgmButton.setVisibility(View.VISIBLE);
} else {
cgmButton.setVisibility(View.GONE);

View file

@ -2,11 +2,11 @@ package info.nightscout.androidaps.plugins.general.overview.activities;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.fragment.app.FragmentManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -4,7 +4,7 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v4.app.DialogFragment;
import androidx.fragment.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.overview.dialogs;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
/**
* Created by adrian on 09/02/17.

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import androidx.fragment.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import androidx.fragment.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -2,8 +2,9 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import androidx.fragment.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -98,6 +99,9 @@ public class ErrorDialog extends DialogFragment implements View.OnClickListener
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);
}

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.overview.dialogs;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;

View file

@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
import android.os.Bundle;
import android.os.HandlerThread;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;

View file

@ -4,8 +4,8 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.HandlerThread;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;

View file

@ -4,8 +4,8 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;

View file

@ -3,7 +3,8 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.overview.notifications;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Intent;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugins.general.overview.notifications;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import androidx.core.content.ContextCompat;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -11,8 +11,8 @@ import android.media.AudioAttributes;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.support.v7.widget.RecyclerView;
import androidx.core.app.NotificationCompat;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import org.slf4j.Logger;
@ -69,6 +69,9 @@ public class NotificationStore {
if (usesChannels && n.soundId != null) {
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
alarm.putExtra("soundid", n.soundId);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
MainApp.instance().startForegroundService(alarm);
else
MainApp.instance().startService(alarm);
}
@ -76,6 +79,9 @@ public class NotificationStore {
if (n.soundId != null) {
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
alarm.putExtra("soundid", n.soundId);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
MainApp.instance().startForegroundService(alarm);
else
MainApp.instance().startService(alarm);
}
}

View file

@ -4,7 +4,8 @@ import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.squareup.otto.Subscribe;
@ -29,9 +30,8 @@ public class DummyService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Notification notification = PersistentNotificationPlugin.getPlugin().updateNotification();
if (notification != null)
startForeground(PersistentNotificationPlugin.ONGOING_NOTIFICATION_ID, notification);
super.onStartCommand(intent, flags, startId);
startForeground(PersistentNotificationPlugin.ONGOING_NOTIFICATION_ID, PersistentNotificationPlugin.getPlugin().updateNotification());
return START_STICKY;
}
@ -45,6 +45,11 @@ public class DummyService extends Service {
@Override
public void onCreate() {
super.onCreate();
// TODO: I guess this was moved here in order to adhere to the 5 seconds rule to call "startForeground" after a Service was called as Foreground service?
// As onCreate() is not called every time a service is started, copied to onStartCommand().
Notification notification = PersistentNotificationPlugin.getPlugin().updateNotification();
startForeground(PersistentNotificationPlugin.ONGOING_NOTIFICATION_ID, notification);
MainApp.bus().register(this);
}

View file

@ -10,17 +10,19 @@ import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.RemoteInput;
import android.support.v4.app.TaskStackBuilder;
import androidx.core.app.NotificationCompat;
import androidx.core.app.RemoteInput;
import androidx.core.app.TaskStackBuilder;
import com.squareup.otto.Subscribe;
import javax.annotation.Nonnull;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainActivity;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DatabaseHelper;
@ -37,6 +39,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
@ -49,6 +52,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter;
public class PersistentNotificationPlugin extends PluginBase {
private static PersistentNotificationPlugin plugin;
private Notification notification;
public static PersistentNotificationPlugin getPlugin() {
if (plugin == null) plugin = new PersistentNotificationPlugin(MainApp.instance());
@ -72,13 +76,14 @@ public class PersistentNotificationPlugin extends PluginBase {
/// End Android Auto
public PersistentNotificationPlugin(Context ctx) {
private PersistentNotificationPlugin(Context ctx) {
super(new PluginDescription()
.mainType(PluginType.GENERAL)
.neverVisible(true)
.pluginName(R.string.ongoingnotificaction)
.enableByDefault(true)
.alwaysEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
.alwaysEnabled(true)
.showInList(false)
.description(R.string.description_persistent_notification)
);
this.ctx = ctx;
@ -86,8 +91,8 @@ public class PersistentNotificationPlugin extends PluginBase {
@Override
protected void onStart() {
createNotificationChannel(); // make sure channels exist before triggering updates through the bus
MainApp.bus().register(this);
createNotificationChannel();
triggerNotificationUpdate();
super.onStart();
}
@ -111,19 +116,21 @@ public class PersistentNotificationPlugin extends PluginBase {
}
private void triggerNotificationUpdate() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
MainApp.instance().startForegroundService(new Intent(MainApp.instance(), DummyService.class));
else
MainApp.instance().startService(new Intent(MainApp.instance(), DummyService.class));
}
@Nonnull
Notification updateNotification() {
if (!isEnabled(PluginType.GENERAL)) {
return null;
}
String line1 = null;
String line2 = null;
String line3 = null;
NotificationCompat.CarExtender.UnreadConversation.Builder unreadConversationBuilder = null;
String line1;
if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ProfileFunctions.getInstance().isProfileValid("Notification")) {
String line1_aa;
if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() == null || !ProfileFunctions.getInstance().isProfileValid("Notificiation"))
return null;
String units = ProfileFunctions.getInstance().getProfileUnits();
@ -159,11 +166,11 @@ public class PersistentNotificationPlugin extends PluginBase {
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
String line2 = MainApp.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + MainApp.gs(R.string.cob) + ": " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "PersistentNotificationPlugin").generateCOBString();
line2 = MainApp.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + MainApp.gs(R.string.cob) + ": " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "PersistentNotificationPlugin").generateCOBString();
String line2_aa = MainApp.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U. " + MainApp.gs(R.string.cob) + ": " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "PersistentNotificationPlugin").generateCOBString() + ".";
String line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate()) + " U/h";
line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate()) + " U/h";
String line3_aa = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate()) + " U/h.";
@ -199,7 +206,7 @@ public class PersistentNotificationPlugin extends PluginBase {
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).build();
// Create the UnreadConversation
NotificationCompat.CarExtender.UnreadConversation.Builder unreadConversationBuilder =
unreadConversationBuilder =
new NotificationCompat.CarExtender.UnreadConversation.Builder(line1_aa + "\n" + line2_aa)
.setLatestTimestamp(System.currentTimeMillis())
.setReadPendingIntent(msgReadPendingIntent)
@ -208,7 +215,7 @@ public class PersistentNotificationPlugin extends PluginBase {
/// Add dot to produce a "more natural sounding result"
unreadConversationBuilder.addMessage(line3_aa);
/// End Android Auto
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, CHANNEL_ID);
builder.setOngoing(true);
@ -217,12 +224,14 @@ public class PersistentNotificationPlugin extends PluginBase {
builder.setSmallIcon(MainApp.getNotificationIcon());
Bitmap largeIcon = BitmapFactory.decodeResource(ctx.getResources(), MainApp.getIcon());
builder.setLargeIcon(largeIcon);
builder.setContentTitle(line1);
builder.setContentText(line2);
builder.setSubText(line3);
builder.setContentTitle(line1 != null ? line1 : MainApp.gs(R.string.noprofileset));
builder.setContentText(line2 != null ? line2 : MainApp.gs(R.string.noprofileset));
builder.setSubText(line3 != null ? line3 : MainApp.gs(R.string.noprofileset));
/// Android Auto
if (unreadConversationBuilder != null) {
builder.extend(new NotificationCompat.CarExtender()
.setUnreadConversation(unreadConversationBuilder.build()));
}
/// End Android Auto
@ -242,6 +251,7 @@ public class PersistentNotificationPlugin extends PluginBase {
android.app.Notification notification = builder.build();
mNotificationManager.notify(ONGOING_NOTIFICATION_ID, notification);
this.notification = notification;
return notification;
}
@ -261,6 +271,17 @@ public class PersistentNotificationPlugin extends PluginBase {
return deltastring;
}
/***
* returns the current ongoing notification.
*
* If it does not exist, return a dummy notification. This should only happen if onStart() wasn't called.
*/
public Notification getLastNotification() {
if (notification != null) return notification;
else return new Notification();
}
@Subscribe
public void onStatusEvent(final EventPreferenceChange ev) {

View file

@ -9,29 +9,21 @@ import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
import info.nightscout.androidaps.utils.SP
import org.apache.http.HttpResponse
import org.apache.http.client.methods.HttpGet
import org.apache.http.impl.client.DefaultHttpClient
import org.slf4j.LoggerFactory
import java.io.IOException
import java.io.InputStream
import java.net.URL
import java.util.concurrent.TimeUnit
// check network connection
fun isConnected(): Boolean {
val connMgr = MainApp.instance().applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
return connMgr.activeNetworkInfo?.isConnected ?: false
}
// convert inputstream to String
@Throws(IOException::class)
inline fun InputStream.findVersion(): String? {
fun findVersion(file :String?): String? {
val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex()
return bufferedReader()
.readLines()
.filter { regex.matches(it) }
.mapNotNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }
.firstOrNull()
return file?.lines()?.filter { regex.matches(it) }?.mapNotNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }?.firstOrNull()
}
private val log = LoggerFactory.getLogger(L.CORE)
@ -50,13 +42,10 @@ fun triggerCheckVersion() {
}
}
@Suppress("DEPRECATION")
private fun checkVersion() = if (isConnected()) {
Thread {
try {
val request = HttpGet("https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/build.gradle")
val response: HttpResponse = DefaultHttpClient().execute(request)
val version: String? = response.entity.content?.findVersion()
val version: String? = findVersion(URL("https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/build.gradle").readText())
compareWithCurrentVersion(version, BuildConfig.DEV_VERSION)
} catch (e: IOException) {
log.debug("Github master version check error: $e")

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.wear;
import android.app.NotificationManager;
import android.content.Context;
import android.os.HandlerThread;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import java.text.DateFormat;
import java.text.DecimalFormat;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.wear;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -17,7 +17,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;

View file

@ -5,7 +5,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import com.squareup.otto.Subscribe;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.insulin;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import info.nightscout.androidaps.utils.DecimalFormatter;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.LongSparseArray;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import com.squareup.otto.Subscribe;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
import android.content.Context;
import android.os.PowerManager;
import android.os.SystemClock;
import android.support.v4.util.LongSparseArray;
import androidx.collection.LongSparseArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
import android.content.Context;
import android.os.PowerManager;
import android.os.SystemClock;
import android.support.v4.util.LongSparseArray;
import androidx.collection.LongSparseArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.profile.local;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.profile.local;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import org.json.JSONArray;
import org.json.JSONException;

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.profile.ns;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import org.json.JSONException;
import org.json.JSONObject;

View file

@ -5,7 +5,7 @@ import android.app.Activity;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -2,10 +2,10 @@ package info.nightscout.androidaps.plugins.pump.combo;
import android.content.DialogInterface;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.appcompat.app.AlertDialog;
import org.json.JSONObject;
import org.slf4j.Logger;

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.combo;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.pump.combo.ruffyscripter;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import java.util.LinkedList;
import java.util.List;

View file

@ -7,8 +7,8 @@ import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.common.base.Joiner;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.pump.combo.ruffyscripter;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
public class WarningOrErrorCode {
@Nullable

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.commands;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import org.monkey.d.ruffy.ruffy.driver.display.MenuAttribute;
import org.monkey.d.ruffy.ruffy.driver.display.MenuType;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.commands;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import org.monkey.d.ruffy.ruffy.driver.display.MenuAttribute;
import org.monkey.d.ruffy.ruffy.driver.display.MenuType;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.LinkedList;

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.pump.danaR;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import org.json.JSONException;
import org.json.JSONObject;

Some files were not shown because too many files have changed in this diff Show more