danars di start

This commit is contained in:
Milos Kozak 2020-05-06 01:27:38 +02:00
parent f964011724
commit ad472beb4a
22 changed files with 169 additions and 55 deletions

View file

@ -243,6 +243,7 @@ dependencies {
wearApp project(':wear') wearApp project(':wear')
implementation project(':core') implementation project(':core')
implementation project(':danars')
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-wearable:17.0.0' implementation 'com.google.android.gms:play-services-wearable:17.0.0'

View file

@ -13,9 +13,7 @@ import info.nightscout.androidaps.plugins.pump.common.dialog.RileyLinkBLEScanAct
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRUserOptionsActivity import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRUserOptionsActivity
import info.nightscout.androidaps.plugins.pump.danaRS.activities.BLEScanActivity
import info.nightscout.androidaps.plugins.pump.danaRS.activities.EnterPinActivity import info.nightscout.androidaps.plugins.pump.danaRS.activities.EnterPinActivity
import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertActivity import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertActivity
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity
@ -26,7 +24,6 @@ import info.nightscout.androidaps.setupwizard.SetupWizardActivity
@Suppress("unused") @Suppress("unused")
abstract class ActivitiesModule { abstract class ActivitiesModule {
@ContributesAndroidInjector abstract fun contributesBLEScanActivity(): BLEScanActivity
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity @ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity
@ContributesAndroidInjector abstract fun contributeDanaRHistoryActivity(): DanaRHistoryActivity @ContributesAndroidInjector abstract fun contributeDanaRHistoryActivity(): DanaRHistoryActivity
@ContributesAndroidInjector abstract fun contributeDanaRUserOptionsActivity(): DanaRUserOptionsActivity @ContributesAndroidInjector abstract fun contributeDanaRUserOptionsActivity(): DanaRUserOptionsActivity
@ -39,7 +36,6 @@ abstract class ActivitiesModule {
@ContributesAndroidInjector abstract fun contributesLogSettingActivity(): LogSettingActivity @ContributesAndroidInjector abstract fun contributesLogSettingActivity(): LogSettingActivity
@ContributesAndroidInjector abstract fun contributeMainActivity(): MainActivity @ContributesAndroidInjector abstract fun contributeMainActivity(): MainActivity
@ContributesAndroidInjector abstract fun contributesMedtronicHistoryActivity(): MedtronicHistoryActivity @ContributesAndroidInjector abstract fun contributesMedtronicHistoryActivity(): MedtronicHistoryActivity
@ContributesAndroidInjector abstract fun contributesPairingHelperActivity(): PairingHelperActivity
@ContributesAndroidInjector abstract fun contributesPreferencesActivity(): PreferencesActivity @ContributesAndroidInjector abstract fun contributesPreferencesActivity(): PreferencesActivity
@ContributesAndroidInjector abstract fun contributesQuickWizardListActivity(): QuickWizardListActivity @ContributesAndroidInjector abstract fun contributesQuickWizardListActivity(): QuickWizardListActivity
@ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity @ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity

View file

@ -6,6 +6,7 @@ import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.core.dependencyInjection.CoreModule import info.nightscout.androidaps.core.dependencyInjection.CoreModule
import info.nightscout.androidaps.danars.dependencyInjection.DanaRSActivitiesModule
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.data.ProfileStore import info.nightscout.androidaps.data.ProfileStore
import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.data.PumpEnactResult
@ -71,7 +72,8 @@ import javax.inject.Singleton
DataClassesModule::class, DataClassesModule::class,
SMSModule::class, SMSModule::class,
UIModule::class, UIModule::class,
DanaRSCommModule::class DanaRSCommModule::class,
DanaRSActivitiesModule::class
] ]
) )
interface AppComponent : AndroidInjector<MainApp> { interface AppComponent : AndroidInjector<MainApp> {

View file

@ -217,7 +217,7 @@ class ImportExportPrefs @Inject constructor(
fun importSharedPreferences(fragment: Fragment) { fun importSharedPreferences(fragment: Fragment) {
fragment.activity?.let { fragmentAct -> fragment.activity?.let { fragmentAct ->
val callForPrefFile = fragmentAct.prepareCall(PrefsFileContract()) { val callForPrefFile = fragmentAct.registerForActivityResult(PrefsFileContract()) {
it?.let { it?.let {
importSharedPreferences(fragmentAct, it) importSharedPreferences(fragmentAct, it)
} }
@ -227,7 +227,7 @@ class ImportExportPrefs @Inject constructor(
} }
fun importSharedPreferences(activity: FragmentActivity) { fun importSharedPreferences(activity: FragmentActivity) {
val callForPrefFile = activity.prepareCall(PrefsFileContract()) { val callForPrefFile = activity.registerForActivityResult(PrefsFileContract()) {
it?.let { it?.let {
importSharedPreferences(activity, it) importSharedPreferences(activity, it)
} }

View file

@ -1,33 +0,0 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginLeft="15.67dp"
android:layout_marginRight="15.67dp" >
<TextView
android:id="@+id/ble_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/ble_address"
android:textColor="#ffffff"
android:textSize="20sp" />
<TextView
android:id="@+id/ble_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="6.5dp"
android:textColor="#FF00A0E9"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>

View file

@ -798,17 +798,11 @@
<string name="activate_profile">Activate profile</string> <string name="activate_profile">Activate profile</string>
<string name="date">Date</string> <string name="date">Date</string>
<string name="invalid">INVALID</string> <string name="invalid">INVALID</string>
<string name="waitingforpairing">Waiting for pairing on pump</string>
<string name="pairingok">Pairing OK</string>
<string name="pairingtimedout">Pairing timed out</string>
<string name="pairing">Pairing</string> <string name="pairing">Pairing</string>
<string name="key_danars_pairingkey" translatable="false">danars_pairing_key_</string> <string name="key_danars_pairingkey" translatable="false">danars_pairing_key_</string>
<string name="key_danars_v3_randompairingkey" translatable="false">danars_v3_randompairing_key_</string> <string name="key_danars_v3_randompairingkey" translatable="false">danars_v3_randompairing_key_</string>
<string name="key_danars_v3_pairingkey" translatable="false">danars_v3_pairing_key_</string> <string name="key_danars_v3_pairingkey" translatable="false">danars_v3_pairing_key_</string>
<string name="key_danars_v3_randomsynckey" translatable="false">danars_v3_randomsync_key_</string> <string name="key_danars_v3_randomsynckey" translatable="false">danars_v3_randomsync_key_</string>
<string name="key_danars_address" translatable="false">danars_address</string>
<string name="key_danars_name" translatable="false">danars_name</string>
<string name="danars_nodeviceavailable">No device found so far</string>
<string name="emptyreservoir">Empty reservoir</string> <string name="emptyreservoir">Empty reservoir</string>
<string name="bloodsugarmeasurementalert">Blood sugar measurement alert</string> <string name="bloodsugarmeasurementalert">Blood sugar measurement alert</string>
<string name="remaininsulinalert">Remaining insulin level</string> <string name="remaininsulinalert">Remaining insulin level</string>

1
danars/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

71
danars/build.gradle Normal file
View file

@ -0,0 +1,71 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
kotlinOptions {
jvmTarget = '1.8'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled(project.hasProperty('coverage'))
}
firebaseDisable {
System.setProperty("disableFirebase", "true")
ext.enableCrashlytics = false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':core')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation "androidx.activity:activity:${activityVersion}"
implementation "androidx.activity:activity-ktx:${activityVersion}"
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
//RxBus
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

View file

21
danars/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.nightscout.androidaps.danars" >
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
</manifest>

View file

@ -0,0 +1,14 @@
package info.nightscout.androidaps.danars.dependencyInjection
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.plugins.pump.danaRS.activities.BLEScanActivity
import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity
@Module
@Suppress("unused")
abstract class DanaRSActivitiesModule {
@ContributesAndroidInjector abstract fun contributesBLEScanActivity(): BLEScanActivity
@ContributesAndroidInjector abstract fun contributesPairingHelperActivity(): PairingHelperActivity
}

View file

@ -13,8 +13,8 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.BaseAdapter import android.widget.BaseAdapter
import android.widget.TextView import android.widget.TextView
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.danars.R
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck
import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange

View file

@ -17,7 +17,7 @@ import android.widget.TextView;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.android.support.DaggerDialogFragment; import dagger.android.support.DaggerDialogFragment;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.danars.R;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity; import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity;
import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess; import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess;
@ -63,7 +63,7 @@ public class PairingProgressDialog extends DaggerDialogFragment {
if (activity != null) { if (activity != null) {
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
progressBar.setProgress(100); progressBar.setProgress(100);
statusView.setText(R.string.pairingok); statusView.setText(R.string.danars_pairingok);
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
@ -84,7 +84,7 @@ public class PairingProgressDialog extends DaggerDialogFragment {
if (activity != null) { if (activity != null) {
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
progressBar.setProgress(100); progressBar.setProgress(100);
statusView.setText(R.string.pairingtimedout); statusView.setText(R.string.danars_pairingtimedout);
button.setVisibility(View.VISIBLE); button.setVisibility(View.VISIBLE);
}); });
} }
@ -140,7 +140,7 @@ public class PairingProgressDialog extends DaggerDialogFragment {
private void setViews() { private void setViews() {
progressBar.setMax(100); progressBar.setMax(100);
progressBar.setProgress(0); progressBar.setProgress(0);
statusView.setText(resourceHelper.gs(R.string.waitingforpairing)); statusView.setText(resourceHelper.gs(R.string.danars_waitingforpairing));
button.setVisibility(View.GONE); button.setVisibility(View.GONE);
button.setOnClickListener(v -> dismiss()); button.setOnClickListener(v -> dismiss());
handler.post(runnable); handler.post(runnable);

View file

@ -4,7 +4,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context=".plugins.pump.danaRS.activities.BLEScanActivity"> tools:context="info.nightscout.androidaps.plugins.pump.danaRS.activities.BLEScanActivity">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -17,7 +17,7 @@
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/pairing" android:contentDescription="@string/danars_pairing"
android:src="@drawable/ic_bluetooth_white_48dp" /> android:src="@drawable/ic_bluetooth_white_48dp" />
<TextView <TextView
@ -27,7 +27,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:text="@string/pairing" android:text="@string/danars_pairing"
android:textAlignment="center" android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:textAppearance="?android:attr/textAppearanceLarge" />

View file

@ -0,0 +1,27 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginLeft="15.67dp"
android:layout_marginRight="15.67dp">
<TextView
android:id="@+id/ble_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/ble_address"
android:textColor="#ffffff"
android:textSize="20sp" />
<TextView
android:id="@+id/ble_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="6.5dp"
android:textColor="#FF00A0E9"
android:textSize="20sp" />
</RelativeLayout>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="key_danars_address" translatable="false">danars_address</string>
<string name="key_danars_name" translatable="false">danars_name</string>
<string name="danars_pairing">Pairing</string>
<string name="danars_nodeviceavailable">No device found so far</string>
<string name="danars_pairingok">Pairing OK</string>
<string name="danars_pairingtimedout">Pairing timed out</string>
<string name="danars_waitingforpairing">Waiting for pairing on pump</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
</resources>

View file

@ -1 +1 @@
include ':app', ':wear', ':core' include ':app', ':wear', ':core', ':danars'