Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/1.5.0 #47

Merged
merged 77 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
22d7a2b
Implement ThetaRepository.updateFirmware() with hard coded API path
simago May 26, 2023
8195710
Move API path to environment variable. Actual getENvironmentVar() on…
simago May 29, 2023
8337677
Add comments to UpdateFirmwareTest class
simago May 29, 2023
111d424
Improve redundant descriptions
simago May 30, 2023
8c21945
Add documentation comments
simago May 30, 2023
e4eeda2
Add catch blocks to ThetaRepository.updateFirmware()
simago May 30, 2023
7fb48eb
Implement getEnvironmentVar() for iOS
ywatanabe-dev May 31, 2023
ea49d8a
Add comment to getEnvironmentVar() for iOS
ywatanabe-dev May 31, 2023
d130f44
Merge remote-tracking branch 'origin/feat/write-file-protcol' into fe…
simago May 31, 2023
3c612fb
Change the way to pass apiPath
simago May 31, 2023
b31d9cb
Replace getEnvironmentVar() with System.getenv()
simago Jun 7, 2023
13c0af4
Fix UpdateFirmwareTest
simago Jun 7, 2023
c230680
Add test
simago Jul 6, 2023
f7e0c82
Merge branch 'dev/1.3.0' into feat/write-file-protcol
simago Jul 6, 2023
fc6b58a
Add some http headers
simago Jul 7, 2023
52fb809
Change time out
simago Jul 10, 2023
ba988ad
Confirm v-up/v-dowm
simago Jul 11, 2023
d135a81
Rewrite test codes
simago Jul 12, 2023
15b004b
Refine test
simago Jul 12, 2023
bbc85c7
Delete unnecessary comment
simago Jul 12, 2023
46a88d9
Rename test file
simago Jul 12, 2023
1e1a795
Add test for Theta X
simago Jul 13, 2023
97456e9
Merge branch 'dev/1.3.0' into feat/write-file-protcol
simago Jul 13, 2023
303f768
write a test for Theta X
simago Jul 18, 2023
0c48bf6
Merge branch 'dev/1.3.0' into feat/write-file-protcol
simago Jul 18, 2023
016f076
Use client mode for Theta X
simago Jul 18, 2023
c0f283d
Change to read firmware from a file
simago Jul 31, 2023
53ea356
Add unit test
simago Jul 31, 2023
49b7e32
Change return type of request() from String to ByteArray
simago Jul 31, 2023
0c02a22
Sucess SC2B test
simago Aug 1, 2023
2e9fcb7
Change timeout settings
simago Aug 3, 2023
5bfbefd
Update FW version of Theta X
simago Aug 7, 2023
a96f05d
Improve some descriptions
simago Aug 8, 2023
d0a5c2c
Remove unused timeout
simago Aug 9, 2023
79fd46f
merge dev/1.4.0
simago Aug 28, 2023
9ef5467
Add callback to notify the percentage of transmission
simago Aug 28, 2023
4e45f0d
Update kotlin-gradle-plugin version
ywatanabe-dev Aug 29, 2023
b113e88
Set useMock true
simago Aug 29, 2023
e145a59
Improve exceptions of MultipartPostClient
simago Aug 31, 2023
127bae0
Improve exceptions of MultipartPostClient
simago Aug 31, 2023
f17b6e0
Improve exceptions of MultipartPostClient
simago Sep 1, 2023
eadc441
Improve exceptions of MultipartPostClient
simago Sep 1, 2023
6109dda
If head of apiPath is not a slash, add it
simago Sep 1, 2023
a2cc394
Remove println() for debug
simago Sep 1, 2023
f263077
On diget authentication, keep socket connection
simago Sep 4, 2023
8e7eac0
Improve updateFirmwareXTest()
simago Sep 6, 2023
b00fb24
Improve a check whether authentication is needed or not
simago Sep 7, 2023
66138f4
Change auth check command to /osc/state
simago Sep 8, 2023
b726141
Remove content-length header
simago Sep 8, 2023
edf68d9
Add host header and accept header
simago Sep 11, 2023
ac50523
Change condition for file upload
simago Sep 12, 2023
d75b082
Add delay before close SelectorManager
simago Sep 14, 2023
750cedb
Add delay before close SelectorManager
simago Sep 14, 2023
7ae494a
Make not call SelectorManager.close()
simago Sep 14, 2023
6bfaadf
Pass 100 to callback function
simago Sep 15, 2023
243b1df
Support other camera
osakila Sep 19, 2023
e20a203
Limit requests to a single connection
osakila Sep 20, 2023
d082f90
Close previewClient before update firmware
simago Sep 21, 2023
4eee75c
Merge dev/1.5.0
ywatanabe-dev Sep 21, 2023
a731cdc
Merge dev/1.5.0
ywatanabe-dev Sep 22, 2023
73bb5a5
Remove `previewClient.close()` before firm update
ywatanabe-dev Sep 22, 2023
1f12f99
Allow endpont URL without last slash
simago Sep 22, 2023
5ca52cc
Remove magic numbers
simago Sep 22, 2023
0c77048
Supress some Detect messages
simago Sep 25, 2023
9eccce7
Make some objects internal
simago Sep 25, 2023
f93e628
Supress CyclomaticComplexMethod to some functions
simago Sep 25, 2023
c2c76d7
add limitless interval shooting
LassicYM Sep 28, 2023
84b1419
Improve codes regarding to nullable type
simago Sep 28, 2023
0694c29
Minor fixes
simago Sep 28, 2023
5e05132
Make some class internal
simago Oct 3, 2023
cc714ab
Add options _latestExposureDelayTime, videoStitching, and _visibility…
ywatanabe-dev Oct 3, 2023
4c900c1
Merge pull request #214 from ricohapi/feat/write-file-protcol-1.5.0
simago Oct 3, 2023
c694e22
add options _topBottomCorrection and _topBottomCorrectionRotation.
LassicYM Oct 4, 2023
018d1b6
Add tests of get/set options LatestEnabledExposureDelayTime, VideoSti…
ywatanabe-dev Oct 16, 2023
cac2ff0
add interval shooting with the shot count specified
LassicYM Oct 20, 2023
97c047a
Fix type of 'function' property of ThetaState on ReactNative
ywatanabe-dev Oct 23, 2023
43f7a68
update version 1.5.0 and format code.
LassicYM Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20")
classpath("com.android.tools.build:gradle:7.2.2")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.8.20")
classpath("org.jetbrains.dokka:versioning-plugin:1.8.20")
Expand Down
32 changes: 16 additions & 16 deletions config/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ complexity:
# threshold: 10
# includeStaticDeclarations: false
# includePrivateDeclarations: false
# ComplexMethod:
# active: true
# threshold: 15
ComplexMethod:
active: true
threshold: 20
# ignoreSingleWhenExpression: false
# ignoreSimpleWhenEntries: false
# ignoreNestingFunctions: false
Expand Down Expand Up @@ -237,13 +237,13 @@ exceptions:
# active: false
# PrintStackTrace:
# active: true
# RethrowCaughtException:
# active: true
RethrowCaughtException:
active: false
# ReturnFromFinally:
# active: true
# ignoreLabeled: false
# SwallowedException:
# active: true
SwallowedException:
active: false
# ignoredExceptionTypes:
# - 'InterruptedException'
# - 'MalformedURLException'
Expand Down Expand Up @@ -282,8 +282,8 @@ exceptions:
# - 'RuntimeException'
# - 'Throwable'
# allowedExceptionNameRegex: '_|(ignore|expected).*'
# TooGenericExceptionThrown:
# active: true
TooGenericExceptionThrown:
active: false
# exceptionNames:
# - 'Error'
# - 'Exception'
Expand Down Expand Up @@ -546,9 +546,9 @@ style:
# LibraryEntitiesShouldNotBePublic:
# active: true
# excludes: [ '**' ]
# LoopWithTooManyJumpStatements:
# active: true
# maxJumpCount: 1
LoopWithTooManyJumpStatements:
active: true
maxJumpCount: 3
MagicNumber:
active: true
excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ]
Expand Down Expand Up @@ -620,10 +620,10 @@ style:
# active: true
# SpacingBetweenPackageAndImports:
# active: false
# ThrowsCount:
# active: true
# max: 2
# excludeGuardClauses: false
ThrowsCount:
active: true
max: 8
excludeGuardClauses: false
# TrailingWhitespace:
# active: false
# UnderscoresInNumericLiterals:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ import timber.log.Timber
fun PreviewScreen(toPhoto: (photoUrl: String) -> Unit, viewModel: ThetaViewModel = androidx.lifecycle.viewmodel.compose.viewModel()) {

class TakenCallback : PhotoCapture.TakePictureCallback {
override fun onSuccess(fileUrl: String) {
override fun onSuccess(fileUrl: String?) {
Timber.i("takePicture onSuccess: $fileUrl")
val scope = CoroutineScope(Job() + Dispatchers.Main)
scope.launch {
toPhoto(fileUrl) // need to execute on the main thread.
when (fileUrl) {
null -> { // Cancel shooting.
viewModel.startPreview()
}

else -> {
scope.launch {
toPhoto(fileUrl) // need to execute on the main thread.
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion demos/demo-flutter/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
Expand Down
31 changes: 18 additions & 13 deletions demos/demo-flutter/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
final _thetaClientFlutter = ThetaClientFlutter();
bool _isInitTheta = false;
bool _initializing = false;
ThetaModel? _thetaModel;

final String endpoint = 'http://192.168.1.1:80/';

Expand Down Expand Up @@ -76,20 +77,20 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
return;
}
bool isInitTheta;
ThetaModel? thetaModel;
try {
_initializing = true;
isInitTheta = await _thetaClientFlutter.isInitialized();
if (!isInitTheta) {
_initializing = true;
debugPrint('start initialize');
await _thetaClientFlutter.initialize(endpoint);

// // Client mode authentication settings
// final config = ThetaConfig();
// config.clientMode = DigestAuth('THETAXX12345678', '12345678');
// await _thetaClientFlutter.initialize(endpoint, config);

isInitTheta = true;
}
debugPrint('start initialize');
await _thetaClientFlutter.initialize(endpoint);
thetaModel = await _thetaClientFlutter.getThetaModel();

// // Client mode authentication settings
// final config = ThetaConfig();
// config.clientMode = DigestAuth('THETAXX12345678', '12345678');
// await _thetaClientFlutter.initialize(endpoint, config);

isInitTheta = true;
} on PlatformException {
if (!mounted) return;
debugPrint('Error. init');
Expand All @@ -103,6 +104,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {

setState(() {
_isInitTheta = isInitTheta;
_thetaModel = thetaModel;
});
}

Expand All @@ -114,6 +116,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
platformVersion: _platformVersion,
isInitialized: _isInitTheta,
connectTheta: initTheta,
thetaModel: _thetaModel,
),
);
}
Expand All @@ -123,16 +126,18 @@ class Home extends StatelessWidget {
final String platformVersion;
final bool isInitialized;
final Function connectTheta;
final ThetaModel? thetaModel;
const Home({Key? key,
required this.platformVersion,
required this.isInitialized,
required this.connectTheta,
required this.thetaModel,
}) : super(key: key);


@override
Widget build(BuildContext context) {
String camera = isInitialized ? 'connected!': 'disconnected';
String camera = isInitialized ? 'connected! $thetaModel': 'disconnected';
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
Expand Down
19 changes: 13 additions & 6 deletions demos/demo-flutter/lib/take_picture_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,20 @@ class _TakePictureScreen extends State<TakePictureScreen> with WidgetsBindingObs
});
debugPrint('take picture: $fileUrl');
if (!mounted) return;
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => PhotoScreen(
name: 'Take Picture',
fileUrl: fileUrl,
if (fileUrl != null) {
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => PhotoScreen(
name: 'Take Picture',
fileUrl: fileUrl,
)
)
)
).then((value) => startLivePreview());
).then((value) => startLivePreview());
} else {
setState(() {
shooting = true;
});
debugPrint('takePicture canceled.');
}
}, (exception) {
setState(() {
shooting = false;
Expand Down
15 changes: 9 additions & 6 deletions demos/demo-ios/SdkSample/TakePhotoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ struct TakePhotoView: View {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
Task {
do {
try await theta.takePicture {photoUrl in
let parts = photoUrl.components(separatedBy: "/")
item = FileItem(
name: parts[parts.count - 1],
url: photoUrl
)
try await theta.takePicture { photoUrl in
// When nil, it is canceled.
if let photoUrl {
let parts = photoUrl.components(separatedBy: "/")
item = FileItem(
name: parts[parts.count - 1],
url: photoUrl
)
}
isActive = true
}
} catch {
Expand Down
13 changes: 6 additions & 7 deletions demos/demo-ios/SdkSample/ThetaSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Theta {
completionHandler(response)
}

func takePicture(_ callback: @escaping (_ url: String) -> Void) async throws {
func takePicture(_ callback: @escaping (_ url: String?) -> Void) async throws {
try await initialize()
let photoCapture: PhotoCapture = try await withCheckedThrowingContinuation {continuation in
thetaRepository!.getPhotoCaptureBuilder()
Expand All @@ -144,23 +144,22 @@ class Theta {
init(_ callback: @escaping (_ url: String?, _ error: Error?) -> Void) {
self.callback = callback
}
func onSuccess(fileUrl: String) {
func onSuccess(fileUrl: String?) {
callback(fileUrl, nil)
}
func onProgress(completion: Float) {
}
func onError(exception: ThetaException) {
callback(nil, exception as? Error)
callback(nil, exception.asError())
}
}
let photoUrl: String = try await withCheckedThrowingContinuation {continuation in
let photoUrl: String? = try await withCheckedThrowingContinuation {continuation in
photoCapture.takePicture(
callback: Callback {fileUrl, error in
if let photoUrl = fileUrl {
continuation.resume(returning: photoUrl)
}
if let thetaError = error {
continuation.resume(throwing: thetaError)
} else {
continuation.resume(returning: fileUrl)
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group 'com.ricoh360.thetaclient.theta_client_flutter'
version '1.0.0'

buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.ricoh360.thetaclient.capture.Capture
import com.ricoh360.thetaclient.capture.PhotoCapture
import com.ricoh360.thetaclient.capture.TimeShiftCapture
import com.ricoh360.thetaclient.capture.VideoCapture
import com.ricoh360.thetaclient.capture.LimitlessIntervalCapture
import com.ricoh360.thetaclient.capture.ShotCountSpecifiedIntervalCapture
import io.flutter.plugin.common.MethodCall

const val KEY_CLIENT_MODE = "clientMode"
Expand Down Expand Up @@ -160,6 +162,14 @@ fun toTimeShift(map: Map<String, Any>): TimeShiftSetting {
return timeShift
}

fun toTopBottomCorrectionRotation(map: Map<String, Any>): TopBottomCorrectionRotation {
return TopBottomCorrectionRotation(
pitch = (map["pitch"] as Double).toFloat(),
roll = (map["roll"] as Double).toFloat(),
yaw = (map["yaw"] as Double).toFloat()
)
}

fun <T> setCaptureBuilderParams(call: MethodCall, builder: Capture.Builder<T>) {
call.argument<String>(OptionNameEnum.Aperture.name)?.also { enumName ->
ApertureEnum.values().find { it.name == enumName }?.let {
Expand All @@ -169,6 +179,11 @@ fun <T> setCaptureBuilderParams(call: MethodCall, builder: Capture.Builder<T>) {
call.argument<Int>(OptionNameEnum.ColorTemperature.name)?.also {
builder.setColorTemperature(it)
}
call.argument<String>(OptionNameEnum.ExposureCompensation.name)?.also { enumName ->
ExposureCompensationEnum.values().find { it.name == enumName }?.let {
builder.setExposureCompensation(it)
}
}
call.argument<String>(OptionNameEnum.ExposureDelay.name)?.also { enumName ->
ExposureDelayEnum.values().find { it.name == enumName }?.let {
builder.setExposureDelay(it)
Expand Down Expand Up @@ -255,6 +270,23 @@ fun setVideoCaptureBuilderParams(call: MethodCall, builder: VideoCapture.Builder
}
}

fun setLimitlessIntervalCaptureBuilderParams(call: MethodCall, builder: LimitlessIntervalCapture.Builder) {
call.argument<Int>(OptionNameEnum.CaptureInterval.name)?.also {
builder.setCaptureInterval(it)
}
}

fun setShotCountSpecifiedIntervalCaptureBuilderParams(call: MethodCall, builder: ShotCountSpecifiedIntervalCapture.Builder) {
call.argument<Int>("_capture_interval")?.let {
if (it >= 0) {
builder.setCheckStatusCommandInterval(it.toLong())
}
}
call.argument<Int>(OptionNameEnum.CaptureInterval.name)?.also {
builder.setCaptureInterval(it)
}
}

fun toGetOptionsParam(data: List<String>): List<OptionNameEnum> {
val optionNames = mutableListOf<OptionNameEnum>()
data.forEach { name ->
Expand Down Expand Up @@ -298,6 +330,14 @@ fun toResult(timeShift: TimeShiftSetting): Map<String, Any> {
return result
}

fun toResult(rotation: TopBottomCorrectionRotation): Map<String, Any> {
return mapOf(
"pitch" to rotation.pitch,
"roll" to rotation.roll,
"yaw" to rotation.yaw
)
}

fun toResult(options: Options): Map<String, Any> {
val result = mutableMapOf<String, Any>()

Expand Down Expand Up @@ -342,6 +382,10 @@ fun toResult(options: Options): Map<String, Any> {
options.getValue<TimeShiftSetting>(OptionNameEnum.TimeShift)?.let { timeShift ->
result[OptionNameEnum.TimeShift.name] = toResult(timeShift)
}
} else if (name == OptionNameEnum.TopBottomCorrectionRotation) {
options.getValue<TopBottomCorrectionRotation>(OptionNameEnum.TopBottomCorrectionRotation)?.let { rotation ->
result[OptionNameEnum.TopBottomCorrectionRotation.name] = toResult(rotation)
}
} else if (valueOptions.contains(name)) {
addOptionsValueToMap<Any>(options, name, result)
} else {
Expand Down Expand Up @@ -415,6 +459,9 @@ fun setOptionValue(options: Options, name: OptionNameEnum, value: Any) {
} else if (name == OptionNameEnum.TimeShift) {
@Suppress("UNCHECKED_CAST")
options.setValue(name, toTimeShift(value as Map<String, Any>))
} else if (name == OptionNameEnum.TopBottomCorrectionRotation) {
@Suppress("UNCHECKED_CAST")
options.setValue(name, toTopBottomCorrectionRotation(value as Map<String, Any>))
} else {
getOptionValueEnum(name, value as String)?.let {
options.setValue(name, it)
Expand Down Expand Up @@ -442,8 +489,9 @@ fun getOptionValueEnum(name: OptionNameEnum, valueName: String): Any? {
OptionNameEnum.Gain -> GainEnum.values().find { it.name == valueName }
OptionNameEnum.ImageStitching -> ImageStitchingEnum.values().find { it.name == valueName }
OptionNameEnum.Iso -> IsoEnum.values().find { it.name == valueName }
OptionNameEnum.IsoAutoHighLimit -> ApertureEnum.values().find { it.name == valueName }
OptionNameEnum.IsoAutoHighLimit -> IsoAutoHighLimitEnum.values().find { it.name == valueName }
OptionNameEnum.Language -> LanguageEnum.values().find { it.name == valueName }
OptionNameEnum.LatestEnabledExposureDelayTime -> ExposureDelayEnum.values().find { it.name == valueName }
OptionNameEnum.MaxRecordableTime -> MaxRecordableTimeEnum.values().find { it.name == valueName }
OptionNameEnum.NetworkType -> NetworkTypeEnum.values().find { it.name == valueName }
OptionNameEnum.OffDelay -> OffDelayEnum.values().find { it.name == valueName }
Expand All @@ -453,6 +501,9 @@ fun getOptionValueEnum(name: OptionNameEnum, valueName: String): Any? {
OptionNameEnum.ShootingMethod -> ShootingMethodEnum.values().find { it.name == valueName }
OptionNameEnum.ShutterSpeed -> ShutterSpeedEnum.values().find { it.name == valueName }
OptionNameEnum.SleepDelay -> SleepDelayEnum.values().find { it.name == valueName }
OptionNameEnum.TopBottomCorrection -> TopBottomCorrectionOptionEnum.values().find { it.name == valueName }
OptionNameEnum.VideoStitching -> VideoStitchingEnum.values().find { it.name == valueName }
OptionNameEnum.VisibilityReduction -> VisibilityReductionEnum.values().find { it.name == valueName }
OptionNameEnum.WhiteBalance -> WhiteBalanceEnum.values().find { it.name == valueName }
OptionNameEnum.WhiteBalanceAutoStrength -> WhiteBalanceAutoStrengthEnum.values().find { it.name == valueName }
OptionNameEnum.WlanFrequency -> WlanFrequencyEnum.values().find { it.name == valueName }
Expand Down
Loading
Loading