From 9cadd65b9022f698d4afb6c8bfc287b0b77356b9 Mon Sep 17 00:00:00 2001 From: Denver Braganza Date: Tue, 14 Mar 2023 20:14:28 +0530 Subject: [PATCH] Updated libraries but still not working --- build.gradle | 41 +++-- deploy.gradle | 10 +- fotoapparat-adapters/rxjava/build.gradle | 20 +-- fotoapparat-adapters/rxjava2/build.gradle | 20 +-- fotoapparat/build.gradle | 26 +-- .../coroutines/AwaitBroadcastChannel.kt | 10 +- .../fotoapparat/hardware/display/Display.kt | 6 +- gradle/wrapper/gradle-wrapper.properties | 2 +- sample/build.gradle | 19 +- sample/src/main/AndroidManifest.xml | 3 +- .../io/fotoapparat/sample/MainActivity.kt | 43 +++-- sample/src/main/res/layout/activity_main.xml | 163 +++++++++--------- 12 files changed, 197 insertions(+), 166 deletions(-) diff --git a/build.gradle b/build.gradle index 8e5ea8c3..638c5ce8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,9 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -subprojects { - ext { - artifactVersion = '2.7.0' - } -} - buildscript { ext { versions = [ - kotlin : '1.3.50', + kotlin : '1.8.0', code : 1, name : '1.0.0', sdk : [ @@ -20,35 +14,48 @@ buildscript { buildTools: '28.0.3', appcompat : '1.1.0', annotation : '1.1.0', - exifinterface : '1.0.0' + exifinterface : '1.3.6' ], rx : [ rxJava1: '1.3.8', - rxJava2: '2.2.12' + rxJava2: '2.2.19' ], test : [ - junit : '4.12', - mockito: '2.23.0' + junit : '4.13.2', + mockito: '4.4.0' ] ] } repositories { google() - jcenter() + mavenCentral() + //jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" + classpath "com.android.tools.build:gradle:7.4.2" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0" + + //classpath "com.github.dcendents:android-maven-gradle-plugin:2.1" + //classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' + } +} + +plugins { + //id 'com.jfrog.bintray' version '1.8.4' + id 'maven-publish' +} - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' +subprojects { + ext { + artifactVersion = '2.7.0' } } allprojects { repositories { google() - jcenter() + mavenCentral() + //jcenter() } } diff --git a/deploy.gradle b/deploy.gradle index daa57440..5a11b8e7 100644 --- a/deploy.gradle +++ b/deploy.gradle @@ -1,5 +1,5 @@ -apply plugin: 'com.jfrog.bintray' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.jfrog.bintray' +//apply plugin: 'com.github.dcendents.android-maven' ext { bintrayOrganisation = 'fotoapparat' @@ -7,12 +7,12 @@ ext { publishedGroupId = 'io.fotoapparat' - siteUrl = 'https://github.com/RedApparat/Fotoapparat' - gitUrl = 'https://github.com/RedApparat/Fotoapparat.git' + siteUrl = 'https://github.com/Devenom1/Fotoapparat' + gitUrl = 'https://github.com/Devenom1/Fotoapparat.git' developerId = 'fotoapparat' developerName = 'Fotoapparat' - developerEmail = 'dmitry.zaicew@gmail.com' + developerEmail = 'braganza.denver@gmail.com' licenseName = 'The Apache Software License, Version 2.0' licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' diff --git a/fotoapparat-adapters/rxjava/build.gradle b/fotoapparat-adapters/rxjava/build.gradle index 88b90df9..a22a08c3 100644 --- a/fotoapparat-adapters/rxjava/build.gradle +++ b/fotoapparat-adapters/rxjava/build.gradle @@ -1,16 +1,16 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'kotlin-android' group = 'io.fotoapparat' android { - buildToolsVersion versions.android.buildTools - compileSdkVersion versions.sdk.target + //buildToolsVersion versions.android.buildTools + compileSdkVersion 33 defaultConfig { - minSdkVersion versions.sdk.minimum - targetSdkVersion versions.sdk.target + minSdkVersion 14 + targetSdkVersion 33 } archivesBaseName = 'adapter-rxjava' @@ -22,10 +22,10 @@ android { dependencies { compileOnly project(':fotoapparat') - compileOnly "io.reactivex:rxjava:${versions.rx.rxJava1}" - implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}" - testImplementation "io.reactivex:rxjava:${versions.rx.rxJava1}" - testImplementation "junit:junit:${versions.test.junit}" + compileOnly "io.reactivex:rxjava:1.3.8" + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.10" + testImplementation "io.reactivex:rxjava:1.3.8" + testImplementation "junit:junit:4.13.2" } ext { @@ -38,4 +38,4 @@ ext { libraryDescription = 'RxJava1 adapter for Fotoapparat.' } -apply from: '../../deploy.gradle' +//apply from: '../../deploy.gradle' diff --git a/fotoapparat-adapters/rxjava2/build.gradle b/fotoapparat-adapters/rxjava2/build.gradle index e8bfd202..3516cb90 100644 --- a/fotoapparat-adapters/rxjava2/build.gradle +++ b/fotoapparat-adapters/rxjava2/build.gradle @@ -1,16 +1,16 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'kotlin-android' group = 'io.fotoapparat' android { - buildToolsVersion versions.android.buildTools - compileSdkVersion versions.sdk.target + //buildToolsVersion versions.android.buildTools + compileSdkVersion 33 defaultConfig { - minSdkVersion versions.sdk.minimum - targetSdkVersion versions.sdk.target + minSdkVersion 14 + targetSdkVersion 33 } archivesBaseName = 'adapter-rxjava2' @@ -22,10 +22,10 @@ android { dependencies { compileOnly project(':fotoapparat') - compileOnly "io.reactivex.rxjava2:rxjava:${versions.rx.rxJava2}" - implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}" - testImplementation "io.reactivex.rxjava2:rxjava:${versions.rx.rxJava2}" - testImplementation "junit:junit:${versions.test.junit}" + compileOnly "io.reactivex.rxjava2:rxjava:2.2.19" + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.10" + testImplementation "io.reactivex.rxjava2:rxjava:2.2.19" + testImplementation "junit:junit:4.13.2" } ext { @@ -38,4 +38,4 @@ ext { libraryDescription = 'RxJava2 adapter for Fotoapparat.' } -apply from: '../../deploy.gradle' +//apply from: '../../deploy.gradle' diff --git a/fotoapparat/build.gradle b/fotoapparat/build.gradle index 628043e7..c47a0153 100644 --- a/fotoapparat/build.gradle +++ b/fotoapparat/build.gradle @@ -1,16 +1,16 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'kotlin-android' group = 'io.fotoapparat' android { - buildToolsVersion versions.android.buildTools - compileSdkVersion versions.sdk.target + //buildToolsVersion versions.android.buildTools + compileSdkVersion 33 defaultConfig { - minSdkVersion versions.sdk.minimum - targetSdkVersion versions.sdk.target + minSdkVersion 14 + targetSdkVersion 33 } buildTypes { @@ -29,13 +29,13 @@ android { } dependencies { - implementation "androidx.annotation:annotation:${versions.android.annotation}" - implementation "androidx.exifinterface:exifinterface:${versions.android.exifinterface}" - implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0' - testImplementation "junit:junit:${versions.test.junit}" - testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${versions.kotlin}" - testImplementation "org.mockito:mockito-core:${versions.test.mockito}" + implementation "androidx.annotation:annotation:1.6.0" + implementation "androidx.exifinterface:exifinterface:1.3.6" + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.10" + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' + testImplementation "junit:junit:4.13.2" + testImplementation "org.jetbrains.kotlin:kotlin-test-junit:1.8.10" + testImplementation "org.mockito:mockito-core:4.4.0" } ext { @@ -48,4 +48,4 @@ ext { libraryDescription = 'Camera library for Android with a more user-friendly API.' } -apply from: '../deploy.gradle' +//apply from: '../deploy.gradle' diff --git a/fotoapparat/src/main/java/io/fotoapparat/coroutines/AwaitBroadcastChannel.kt b/fotoapparat/src/main/java/io/fotoapparat/coroutines/AwaitBroadcastChannel.kt index f22bbaf1..46684d51 100644 --- a/fotoapparat/src/main/java/io/fotoapparat/coroutines/AwaitBroadcastChannel.kt +++ b/fotoapparat/src/main/java/io/fotoapparat/coroutines/AwaitBroadcastChannel.kt @@ -2,6 +2,7 @@ package io.fotoapparat.coroutines import kotlinx.coroutines.* import kotlinx.coroutines.channels.BroadcastChannel +import kotlinx.coroutines.channels.ChannelResult import kotlinx.coroutines.channels.ConflatedBroadcastChannel /** @@ -21,9 +22,14 @@ internal class AwaitBroadcastChannel( return channel.value } - override fun offer(element: T): Boolean { + /*override fun offer(element: T): Boolean { deferred.complete(true) - return channel.offer(element) + return channel.try(element) + }*/ + + override fun trySend(element: T): ChannelResult { + deferred.complete(true) + return channel.trySend(element) } override suspend fun send(element: T) { diff --git a/fotoapparat/src/main/java/io/fotoapparat/hardware/display/Display.kt b/fotoapparat/src/main/java/io/fotoapparat/hardware/display/Display.kt index d9b2866a..dd8f1a18 100644 --- a/fotoapparat/src/main/java/io/fotoapparat/hardware/display/Display.kt +++ b/fotoapparat/src/main/java/io/fotoapparat/hardware/display/Display.kt @@ -14,12 +14,12 @@ import io.fotoapparat.hardware.orientation.Orientation.Vertical.ReversePortrait */ internal open class Display(context: Context) { - private val display = context.getDisplay() + private val display = context.getDisplay1() /** * Returns the orientation of the screen. */ - open fun getOrientation(): Orientation = when (display.rotation) { + open fun getOrientation(): Orientation = when (display?.rotation) { Surface.ROTATION_0 -> Portrait Surface.ROTATION_90 -> Landscape Surface.ROTATION_180 -> ReversePortrait @@ -29,4 +29,4 @@ internal open class Display(context: Context) { } -private fun Context.getDisplay() = (getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay +private fun Context.getDisplay1() = (getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d757f3d3..0e9a6105 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip diff --git a/sample/build.gradle b/sample/build.gradle index 4d4096c5..1508ffcc 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,15 +1,16 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-kapt' +//apply plugin: 'kotlin-android-extensions' android { - buildToolsVersion versions.android.buildTools - compileSdkVersion versions.sdk.target + //buildToolsVersion versions.android.buildTools + compileSdkVersion 33 defaultConfig { applicationId "io.fotoapparat.sample" - minSdkVersion versions.sdk.minimum - targetSdkVersion versions.sdk.target + minSdkVersion 14 + targetSdkVersion 33 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -20,10 +21,14 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + buildFeatures { + viewBinding true + dataBinding true + } } dependencies { implementation project(':fotoapparat') - implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}" - implementation "androidx.appcompat:appcompat:${versions.android.appcompat}" + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.10" + implementation "androidx.appcompat:appcompat:1.6.1" } diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 8db8e5da..0cd4ca85 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -13,7 +13,8 @@ + android:screenOrientation="fullSensor" + android:exported="true"> diff --git a/sample/src/main/java/io/fotoapparat/sample/MainActivity.kt b/sample/src/main/java/io/fotoapparat/sample/MainActivity.kt index 0410994b..f6b46a11 100644 --- a/sample/src/main/java/io/fotoapparat/sample/MainActivity.kt +++ b/sample/src/main/java/io/fotoapparat/sample/MainActivity.kt @@ -6,6 +6,7 @@ import android.view.View import android.widget.CompoundButton import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity +import androidx.databinding.DataBindingUtil import io.fotoapparat.Fotoapparat import io.fotoapparat.configuration.CameraConfiguration import io.fotoapparat.configuration.UpdateConfiguration @@ -13,8 +14,8 @@ import io.fotoapparat.log.logcat import io.fotoapparat.parameter.Flash import io.fotoapparat.parameter.Zoom import io.fotoapparat.result.transformer.scaled +import io.fotoapparat.sample.databinding.ActivityMainBinding import io.fotoapparat.selector.* -import kotlinx.android.synthetic.main.activity_main.* import java.io.File import kotlin.math.roundToInt @@ -30,6 +31,10 @@ class MainActivity : AppCompatActivity() { private var curZoom: Float = 0f + private val binding by lazy { + DataBindingUtil.setContentView(this, R.layout.activity_main) + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) @@ -37,24 +42,24 @@ class MainActivity : AppCompatActivity() { permissionsGranted = permissionsDelegate.hasCameraPermission() if (permissionsGranted) { - cameraView.visibility = View.VISIBLE + binding.cameraView.visibility = View.VISIBLE } else { permissionsDelegate.requestCameraPermission() } fotoapparat = Fotoapparat( context = this, - view = cameraView, - focusView = focusView, + view = binding.cameraView, + focusView = binding.focusView, logger = logcat(), lensPosition = activeCamera.lensPosition, cameraConfiguration = activeCamera.configuration, cameraErrorCallback = { Log.e(LOGGING_TAG, "Camera error: ", it) } ) - capture onClick takePicture() - switchCamera onClick changeCamera() - torchSwitch onCheckedChanged toggleFlash() + binding.capture onClick takePicture() + binding.switchCamera onClick changeCamera() + binding.torchSwitch onCheckedChanged toggleFlash() } private fun takePicture(): () -> Unit = { @@ -97,7 +102,7 @@ class MainActivity : AppCompatActivity() { adjustViewsVisibility() - torchSwitch.isChecked = false + binding.torchSwitch.isChecked = false Log.i(LOGGING_TAG, "New camera position: ${if (activeCamera is Camera.Back) "back" else "front"}") } @@ -140,7 +145,7 @@ class MainActivity : AppCompatActivity() { permissionsGranted = true fotoapparat.start() adjustViewsVisibility() - cameraView.visibility = View.VISIBLE + binding.cameraView.visibility = View.VISIBLE } } @@ -152,21 +157,21 @@ class MainActivity : AppCompatActivity() { (it.zoom as? Zoom.VariableZoom) ?.let { cameraZoom = it - focusView.scaleListener = this::scaleZoom - focusView.ptrListener = this::pointerChanged + binding.focusView.scaleListener = this::scaleZoom + binding.focusView.ptrListener = this::pointerChanged } ?: run { - zoomLvl?.visibility = View.GONE - focusView.scaleListener = null - focusView.ptrListener = null + binding.zoomLvl.visibility = View.GONE + binding.focusView.scaleListener = null + binding.focusView.ptrListener = null } - torchSwitch.visibility = if (it.flashModes.contains(Flash.Torch)) View.VISIBLE else View.GONE + binding.torchSwitch.visibility = if (it.flashModes.contains(Flash.Torch)) View.VISIBLE else View.GONE } ?: Log.e(LOGGING_TAG, "Couldn't obtain capabilities.") } - switchCamera.visibility = if (fotoapparat.isAvailable(front())) View.VISIBLE else View.GONE + binding.switchCamera.visibility = if (fotoapparat.isAvailable(front())) View.VISIBLE else View.GONE } //When zooming slowly, the values are approximately 0.9 ~ 1.1 @@ -182,13 +187,13 @@ class MainActivity : AppCompatActivity() { val value = cameraZoom.zoomRatios[progress] val roundedValue = ((value.toFloat()) / 10).roundToInt().toFloat() / 10 - zoomLvl.visibility = View.VISIBLE - zoomLvl.text = String.format("%.1f×", roundedValue) + binding.zoomLvl.visibility = View.VISIBLE + binding.zoomLvl.text = String.format("%.1f×", roundedValue) } private fun pointerChanged(fingerCount: Int){ if(fingerCount == 0) { - zoomLvl?.visibility = View.GONE + binding.zoomLvl.visibility = View.GONE } } } diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index c42818cb..0a00cfed 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -1,93 +1,100 @@ - - - + + + + + + - - - + + - - - - - - + android:layout_height="match_parent" + android:visibility="gone" + tools:layout_editor_absoluteX="8dp" + tools:layout_editor_absoluteY="8dp" + tools:visibility="visible"> + + + + + + + + android:layout_height="match_parent" + android:fitsSystemWindows="true"> - + android:layout_gravity="top"> - + + + + + + + android:layout_gravity="center" + android:textColor="#FFF" + android:textSize="20sp" + tools:text="2.4" /> + + + - - - - - - - - + +