Skip to content

Commit 9a9d0d0

Browse files
ThetaVのクライアントモードに対応した。
1 parent 7855ce7 commit 9a9d0d0

30 files changed

Lines changed: 657 additions & 89 deletions

dConnectDevicePlugin/dConnectDeviceTheta/app/build.gradle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ android {
1717

1818
defaultConfig {
1919
applicationId "org.deviceconnect.android.deviceplugin.theta"
20-
minSdkVersion 14
20+
minSdkVersion 16
2121
targetSdkVersion 26
2222
versionCode 7
2323
versionName getVersionName()
@@ -31,7 +31,16 @@ android {
3131
keyPassword = project.properties.keyPassword
3232
}
3333
}
34-
34+
lintOptions {
35+
checkReleaseBuilds false
36+
// Or, if you prefer, you can continue to check for errors in release builds,
37+
// but continue the build even when errors are found:
38+
abortOnError false
39+
}
40+
compileOptions {
41+
sourceCompatibility JavaVersion.VERSION_1_8
42+
targetCompatibility JavaVersion.VERSION_1_8
43+
}
3544
buildTypes {
3645
release {
3746
minifyEnabled false
@@ -63,4 +72,5 @@ dependencies {
6372
implementation fileTree(include: '*.jar', dir: 'libs')
6473
implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.5.1'
6574
implementation 'com.squareup.okhttp:okhttp:2.5.0'
75+
implementation 'com.burgstaller:okhttp-digest:1.16'
6676
}

dConnectDevicePlugin/dConnectDeviceTheta/app/src/main/java/org/deviceconnect/android/deviceplugin/theta/ThetaDeviceApplication.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88

99
import android.app.Application;
1010
import android.content.Context;
11+
import android.os.Build;
1112
import android.support.v4.util.LruCache;
1213

1314
import org.deviceconnect.android.deviceplugin.theta.core.SphericalViewApi;
15+
import org.deviceconnect.android.deviceplugin.theta.core.ThetaDeviceDetectionFromAccessPoint;
16+
import org.deviceconnect.android.deviceplugin.theta.core.ThetaDeviceDetectionFromLAN;
1417
import org.deviceconnect.android.deviceplugin.theta.core.ThetaDeviceManager;
1518
import org.deviceconnect.android.deviceplugin.theta.core.sensor.AbstractHeadTracker;
1619
import org.deviceconnect.android.deviceplugin.theta.core.sensor.DefaultHeadTracker;
@@ -78,6 +81,11 @@ public void onCreate() {
7881

7982
Context context = getApplicationContext();
8083
mDeviceMgr = new ThetaDeviceManager(context);
84+
mDeviceMgr.addDeviceDetection(new ThetaDeviceDetectionFromAccessPoint());
85+
// 16以上でNsdManagerが使用できるので追加する
86+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
87+
mDeviceMgr.addDeviceDetection(new ThetaDeviceDetectionFromLAN());
88+
}
8189
mHeadTracker = new HeadTrackerWrapper(new DefaultHeadTracker(context));
8290
mSphericalViewApi = new SphericalViewApi(context);
8391
}

dConnectDevicePlugin/dConnectDeviceTheta/app/src/main/java/org/deviceconnect/android/deviceplugin/theta/ThetaDeviceService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public void onCreate() {
8787
mDeviceMgr = app.getDeviceManager();
8888
mDeviceMgr.registerDeviceEventListener(this);
8989
mDeviceMgr.checkConnectedDevice();
90+
mDeviceMgr.startDeviceDetection();
9091
mClient = new ThetaDeviceClient(mDeviceMgr);
9192
mFileMgr = new FileManager(this);
9293

@@ -103,6 +104,7 @@ public void onCreate() {
103104
@Override
104105
public void onDestroy() {
105106
unregisterReceiver(mWifiReceiver);
107+
mDeviceMgr.dispose();
106108
mDeviceMgr.unregisterDeviceEventListener(this);
107109
try {
108110
PtpipInitiator.close();

dConnectDevicePlugin/dConnectDeviceTheta/app/src/main/java/org/deviceconnect/android/deviceplugin/theta/activity/ThetaDeviceSettingsActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ protected void onRestoreInstanceState(final Bundle savedInstanceState) {
7373
protected void onResume() {
7474
super.onResume();
7575
getDeviceManager().checkConnectedDevice();
76+
getDeviceManager().startDeviceDetection();
7677
}
7778

7879
@Override

dConnectDevicePlugin/dConnectDeviceTheta/app/src/main/java/org/deviceconnect/android/deviceplugin/theta/core/AbstractThetaDevice.java

100644100755
File mode changed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.deviceconnect.android.deviceplugin.theta.core;
2+
3+
import java.util.ArrayList;
4+
import java.util.Iterator;
5+
import java.util.List;
6+
7+
abstract class AbstractThetaDeviceDetection implements ThetaDeviceDetection {
8+
9+
private final List<DetectionListener> mDetectionListeners = new ArrayList<>();
10+
11+
@Override
12+
public void registerListener(final DetectionListener listener) {
13+
synchronized (mDetectionListeners) {
14+
for (DetectionListener cache : mDetectionListeners) {
15+
if (cache == listener) {
16+
return;
17+
}
18+
}
19+
mDetectionListeners.add(listener);
20+
}
21+
}
22+
23+
@Override
24+
public void unregisterListener(final DetectionListener listener) {
25+
synchronized (mDetectionListeners) {
26+
for (Iterator<DetectionListener> it = mDetectionListeners.iterator(); it.hasNext(); ) {
27+
DetectionListener cache = it.next();
28+
if (cache == listener) {
29+
it.remove();
30+
return;
31+
}
32+
}
33+
}
34+
}
35+
36+
void notifyOnThetaDetected(final ThetaDevice device) {
37+
synchronized (mDetectionListeners) {
38+
for (DetectionListener cache : mDetectionListeners) {
39+
cache.onThetaDetected(device);
40+
}
41+
}
42+
}
43+
44+
void notifyOnThetaLost(final ThetaDevice device) {
45+
synchronized (mDetectionListeners) {
46+
for (DetectionListener cache : mDetectionListeners) {
47+
cache.onThetaLost(device);
48+
}
49+
}
50+
}
51+
}

dConnectDevicePlugin/dConnectDeviceTheta/app/src/main/java/org/deviceconnect/android/deviceplugin/theta/core/LiveCamera.java

100644100755
File mode changed.

dConnectDevicePlugin/dConnectDeviceTheta/app/src/main/java/org/deviceconnect/android/deviceplugin/theta/core/LivePreviewTask.java

100644100755
File mode changed.

dConnectDevicePlugin/dConnectDeviceTheta/app/src/main/java/org/deviceconnect/android/deviceplugin/theta/core/SphericalImageLiveView.java

100644100755
File mode changed.

dConnectDevicePlugin/dConnectDeviceTheta/app/src/main/java/org/deviceconnect/android/deviceplugin/theta/core/SphericalImageView.java

100644100755
File mode changed.

0 commit comments

Comments
 (0)