Skip to content

Commit

Permalink
Merge pull request #47 from ricohapi/dev/1.5.0
Browse files Browse the repository at this point in the history
Dev/1.5.0
  • Loading branch information
simago authored Oct 23, 2023
2 parents e8a5bdd + 43f7a68 commit c2445a0
Show file tree
Hide file tree
Showing 157 changed files with 10,565 additions and 1,694 deletions.
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
2 changes: 1 addition & 1 deletion demos/demo-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ dependencies {
implementation 'com.jakewharton.timber:timber:5.0.1'
implementation 'io.coil-kt:coil-compose:2.2.2'
implementation "io.ktor:ktor-client-cio:2.1.3"
implementation "com.ricoh360.thetaclient:theta-client:1.4.0"
implementation "com.ricoh360.thetaclient:theta-client:1.5.0"

testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
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
2 changes: 1 addition & 1 deletion demos/demo-ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ target 'SdkSample' do
use_frameworks!

# Pods for SdkSample
pod 'THETAClient', '1.4.0'
pod 'THETAClient', '1.5.0'
end
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 demos/demo-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@react-navigation/native": "^6.1.0",
"@react-navigation/native-stack": "^6.9.5",
"theta-client-react-native": "1.4.0",
"theta-client-react-native": "1.5.0",
"react": "18.2.0",
"react-native": "0.70.6",
"react-native-safe-area-context": "^4.4.1",
Expand Down
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -53,5 +53,5 @@ dependencies {
implementation("io.ktor:ktor-serialization-kotlinx-json:2.1.2")
implementation("com.soywiz.korlibs.krypto:krypto:3.4.0")

implementation("com.ricoh360.thetaclient:theta-client:1.4.0")
implementation("com.ricoh360.thetaclient:theta-client:1.5.0")
}
Loading

0 comments on commit c2445a0

Please sign in to comment.