OTGC Android v1.3.0

parent 1253c816
Pipeline #47 failed with stages
in 13 seconds
......@@ -6,3 +6,4 @@
/build
/captures
.externalNativeBuild
/iotivity-base-release/*.aar
......@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
......
......@@ -15,3 +15,7 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# Android X: https://developer.android.com/topic/libraries/support-library/androidx-rn
android.enableJetifier=true
android.useAndroidX=true
......@@ -2,29 +2,36 @@ apply plugin: 'com.android.application'
apply plugin: 'jacoco'
project.ext {
supportLibraryVersion = "27.1.1"
daggerVersion = "2.15"
butterKnifeVersion = "8.8.1"
appCompatVersion = "1.0.2"
supportLibraryVersion = "1.0.0"
constraintLayoutVersion = "1.1.3"
materialVersion = "1.1.0-alpha01"
lifecycleVersion = "2.0.0"
roomVersion = "2.0.0"
daggerVersion = "2.17"
butterKnifeVersion = "9.0.0-rc2"
rxJavaVersion = "2.1.0"
rxAndroidVersion = "2.0.1"
lifecycleVersion = "1.1.1"
timberVersion = "4.7.0"
roomVersion = "1.1.1"
swaggerParserVersion = "1.0.38"
gsonVersion = "2.8.0"
cborVersion = "3.3.0"
spongyCastleVersion = "1.58.0.0"
junitVersion = "4.12"
mockitoVersion = "1.10.19"
testRunnerVersion = "1.1.1-alpha01"
espressoVersion = "3.1.1-alpha01"
}
android {
compileSdkVersion 27
compileSdkVersion 28
defaultConfig {
applicationId "org.openconnectivity.otgc"
minSdkVersion 21
targetSdkVersion 27
targetSdkVersion 28
versionCode 13
versionName "1.2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionName "1.3.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......@@ -45,61 +52,56 @@ android {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$project.supportLibraryVersion"
implementation "com.android.support:design:$project.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$project.supportLibraryVersion"
implementation "com.android.support:support-v4:$project.supportLibraryVersion"
// Dagger core
// local modules
implementation project(':iotivity-base-release')
implementation project(':easy-setup-core')
// AndroidX: Support Library
implementation "androidx.appcompat:appcompat:$project.appCompatVersion"
implementation "androidx.recyclerview:recyclerview:$project.supportLibraryVersion"
implementation "androidx.recyclerview:recyclerview-selection:$project.supportLibraryVersion"
implementation "androidx.cardview:cardview:$project.supportLibraryVersion"
implementation "androidx.legacy:legacy-support-v4:$project.supportLibraryVersion"
// AndroidX: ConstraintLayout
implementation "androidx.constraintlayout:constraintlayout:$project.constraintLayoutVersion"
// Material Components
implementation "com.google.android.material:material:$project.materialVersion"
// AndroidX: Lifecycle
implementation "androidx.lifecycle:lifecycle-runtime:$project.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-extensions:$project.lifecycleVersion"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$project.lifecycleVersion"
// AndroidX: Room
implementation "androidx.room:room-runtime:$project.roomVersion"
implementation "androidx.room:room-rxjava2:$project.roomVersion"
annotationProcessor "androidx.room:room-compiler:$project.roomVersion"
// Dagger
implementation "com.google.dagger:dagger:$project.daggerVersion"
annotationProcessor "com.google.dagger:dagger-compiler:$project.daggerVersion"
// Dagger Android
implementation "com.google.dagger:dagger-android:$project.daggerVersion"
implementation "com.google.dagger:dagger-android-support:$project.daggerVersion"
annotationProcessor "com.google.dagger:dagger-android-processor:$project.daggerVersion"
// ButterKnife
implementation "com.jakewharton:butterknife:$project.butterKnifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$project.butterKnifeVersion"
// ReactiveX
implementation "io.reactivex.rxjava2:rxjava:$project.rxJavaVersion"
implementation "io.reactivex.rxjava2:rxandroid:$project.rxAndroidVersion"
// Timber
implementation "com.jakewharton.timber:timber:$project.timberVersion"
// Lifecycle
implementation "android.arch.lifecycle:runtime:$project.lifecycleVersion"
implementation "android.arch.lifecycle:extensions:$project.lifecycleVersion"
annotationProcessor "android.arch.lifecycle:compiler:$project.lifecycleVersion"
// Swagger
implementation "io.swagger:swagger-parser:$project.swaggerParserVersion"
// Room
implementation "android.arch.persistence.room:runtime:$project.roomVersion"
implementation "android.arch.persistence.room:rxjava2:$project.roomVersion"
annotationProcessor "android.arch.persistence.room:compiler:$project.roomVersion"
// Gson
implementation "com.google.code.gson:gson:$project.gsonVersion"
// CBOR
implementation "com.upokecenter:cbor:$project.cborVersion"
// Bouncy Castle Provider
// Spongy Castle
implementation "com.madgag.spongycastle:core:$project.spongyCastleVersion"
implementation "com.madgag.spongycastle:prov:$project.spongyCastleVersion"
implementation "com.madgag.spongycastle:bcpkix-jdk15on:$project.spongyCastleVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':iotivity-base-release')
implementation project(':easy-setup-core')
// JUnit
testImplementation "junit:junit:$project.junitVersion"
// Mockito
testImplementation "org.mockito:mockito-core:$project.mockitoVersion"
// AndroidX: Test
androidTestImplementation "androidx.test:runner:$project.testRunnerVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$project.espressoVersion"
}
......@@ -22,7 +22,7 @@
package org.openconnectivity.otgc.accesscontrol.data.repository;
import android.support.test.InstrumentationRegistry;
import androidx.test.InstrumentationRegistry;
import org.iotivity.base.AceSubjectType;
import org.iotivity.base.OcException;
......
......@@ -22,10 +22,10 @@
package org.openconnectivity.otgc.common.data.persistence;
import android.arch.persistence.room.EmptyResultSetException;
import android.arch.persistence.room.Room;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.room.EmptyResultSetException;
import androidx.room.Room;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
......
......@@ -22,8 +22,8 @@
package org.openconnectivity.otgc.common.data.repository;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
......
......@@ -22,8 +22,8 @@
package org.openconnectivity.otgc.common.data.repository;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.iotivity.base.OcException;
import org.junit.Before;
......
......@@ -22,8 +22,8 @@
package org.openconnectivity.otgc.common.data.repository;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
......
......@@ -69,6 +69,11 @@
android:name=".client.presentation.view.GenericClientActivity"
android:configChanges="orientation|screenSize"
android:parentActivityName=".devicelist.presentation.view.DeviceListActivity" />
<activity
android:name=".linkedroles.presentation.view.LinkedRolesActivity"
android:label="@string/linked_roles_title"
android:configChanges="orientation|screenSize"
android:parentActivityName=".devicelist.presentation.view.DeviceListActivity" />
<activity
android:name=".logviewer.presentation.view.LogViewerActivity"
android:configChanges="orientation|screenSize"
......
......@@ -23,7 +23,7 @@
package org.openconnectivity.otgc.about.presentation.view;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.TextView;
import org.openconnectivity.otgc.BuildConfig;
......
......@@ -40,7 +40,7 @@ public class RetrieveVerticalResourcesUseCase {
public Single<List<String>> execute(String deviceId) {
return iotivityRepository.getDeviceCoapIpv6Host(deviceId)
.flatMap(iotivityRepository::findResource)
.flatMap(iotivityRepository::findResources)
.map(ocResources -> {
List<String> verticalResources = new ArrayList<>();
for (OcResource ocResource : ocResources) {
......
......@@ -22,17 +22,17 @@
package org.openconnectivity.otgc.accesscontrol.presentation.view;
import android.arch.lifecycle.ViewModelProvider;
import android.arch.lifecycle.ViewModelProviders;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import androidx.annotation.NonNull;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.ProgressBar;
......
......@@ -23,9 +23,9 @@
package org.openconnectivity.otgc.accesscontrol.presentation.view;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.util.SortedList;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.SortedList;
import androidx.recyclerview.widget.RecyclerView;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
......
......@@ -22,14 +22,14 @@
package org.openconnectivity.otgc.accesscontrol.presentation.view;
import android.arch.lifecycle.ViewModelProvider;
import android.arch.lifecycle.ViewModelProviders;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.SparseBooleanArray;
import android.view.MenuItem;
import android.view.View;
......
......@@ -22,9 +22,9 @@
package org.openconnectivity.otgc.accesscontrol.presentation.viewmodel;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import org.iotivity.base.OicSecAce;
import org.openconnectivity.otgc.accesscontrol.domain.usecase.DeleteAclUseCase;
......
......@@ -22,15 +22,13 @@
package org.openconnectivity.otgc.accesscontrol.presentation.viewmodel;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import org.openconnectivity.otgc.accesscontrol.domain.usecase.CreateAclUseCase;
import org.openconnectivity.otgc.accesscontrol.domain.usecase.RetrieveVerticalResourcesUseCase;
import org.openconnectivity.otgc.accesscontrol.domain.usecase.UpdateAclUseCase;
import org.openconnectivity.otgc.client.domain.model.SerializableResource;
import org.openconnectivity.otgc.client.domain.usecase.GetResourcesUseCase;
import org.openconnectivity.otgc.common.presentation.viewmodel.ViewModelError;
import org.openconnectivity.otgc.common.presentation.viewmodel.ViewModelErrorType;
import org.openconnectivity.otgc.common.domain.rx.SchedulersFacade;
......
......@@ -32,10 +32,14 @@ import org.iotivity.base.OcException;
import org.iotivity.base.OcHeaderOption;
import org.iotivity.base.OcRepresentation;
import org.iotivity.base.OcResource;
import org.iotivity.base.OicSecResr;
import org.iotivity.base.QualityOfService;
import org.openconnectivity.otgc.common.constant.OcfResourceType;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -103,6 +107,26 @@ public class ResourceRepository {
emitter.onComplete();
});
}
public List<OicSecResr> getVerticalResources(List<OcResource> ocResources) {
List<OicSecResr> resources = new ArrayList<>();
for (OcResource resource : ocResources) {
for (String resourceType : resource.getResourceTypes()) {
if (OcfResourceType.isVerticalResourceType(resourceType)) {
OicSecResr res = new OicSecResr();
res.setHref(resource.getUri());
List<String> types = resource.getResourceTypes();
res.setTypes(types);
res.setTypeLen(types.size());
List<String> interfaces = resource.getResourceInterfaces();
res.setInterfaces(interfaces);
res.setInterfaceLen(interfaces.size());
resources.add(res);
}
}
}
return resources;
}
}
......@@ -22,7 +22,7 @@
package org.openconnectivity.otgc.client.domain.model;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import org.iotivity.base.OcResource;
......
......@@ -23,7 +23,7 @@
package org.openconnectivity.otgc.client.domain.usecase;
import android.os.Build;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import org.json.JSONArray;
import org.json.JSONException;
......
......@@ -23,8 +23,8 @@
package org.openconnectivity.otgc.client.presentation.view;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......
......@@ -21,20 +21,20 @@
*/
package org.openconnectivity.otgc.client.presentation.view;
import android.arch.lifecycle.ViewModelProvider;
import android.arch.lifecycle.ViewModelProviders;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.appcompat.widget.Toolbar;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
......
......@@ -22,12 +22,12 @@
package org.openconnectivity.otgc.client.presentation.view;
import android.arch.lifecycle.ViewModelProvider;
import android.arch.lifecycle.ViewModelProviders;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.core.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......
......@@ -22,22 +22,23 @@
package org.openconnectivity.otgc.client.presentation.view;
import android.arch.lifecycle.ViewModelProvider;
import android.arch.lifecycle.ViewModelProviders;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.core.content.ContextCompat;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.GridLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
......@@ -53,6 +54,7 @@ import org.openconnectivity.otgc.di.Injectable;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -211,6 +213,41 @@ public class ResourceFragment extends Fragment implements Injectable {
} else {
((TextView) mViews.get(entry.getKey())).setText(numberFormat.format(entry.getValue()));
}
} else if (entry.getValue() instanceof String) {
if (isViewEnabled(response.getResourceInterfaces())) {
((EditText) mViews.get(entry.getKey())).setText(entry.getValue().toString());
} else {
((TextView) mViews.get(entry.getKey())).setText(entry.getValue().toString());
}
} else if (entry.getValue() instanceof String[]) {
List<String> list = Arrays.asList((String[]) entry.getValue());
ArrayAdapter<String> dataAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
((Spinner) mViews.get(entry.getKey())).setAdapter(dataAdapter);
} else if (entry.getValue() instanceof int[]) {
LinearLayout layout = ((LinearLayout)mViews.get(entry.getKey()));
NumberFormat numberFormat = NumberFormat.getInstance();
int i = 0;
for (int value : (int[])entry.getValue()) {
if (isViewEnabled(response.getResourceInterfaces())) {
((EditText)layout.getChildAt(i)).setText(numberFormat.format(value));
} else {
((TextView)layout.getChildAt(i)).setText(numberFormat.format(value));
}
i++;
}
} else if (entry.getValue() instanceof double[]) {
LinearLayout layout = ((LinearLayout)mViews.get(entry.getKey()));
NumberFormat numberFormat = new DecimalFormat("0.0");
int i = 0;
for (double value : (double[])entry.getValue()) {
if (isViewEnabled(response.getResourceInterfaces())) {
((EditText)layout.getChildAt(i)).setText(numberFormat.format(value));
} else {
((TextView)layout.getChildAt(i)).setText(numberFormat.format(value));
}
i++;
}