Skip to content

Commit

Permalink
Merge pull request #275 from jasonbekolay/master
Browse files Browse the repository at this point in the history
Gradle and Android Gradle Plugin upgrade for targetSdkVersion 33
  • Loading branch information
akshay2211 authored Sep 2, 2023
2 parents 4155fc6 + 7700283 commit 45a960d
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 87 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

android {
compileSdkVersion 33
buildToolsVersion "30.0.3"
buildToolsVersion "31.0.0"

defaultConfig {
applicationId "io.ak1.pixsample"
Expand All @@ -24,11 +24,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
buildFeatures {
viewBinding true
Expand Down
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.15.1'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.24.0'
}
}

allprojects {
plugins.withId("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
}
}
repositories {
google()
mavenCentral()
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Jun 17 15:40:27 IST 2021
#Wed Aug 30 18:27:41 CDT 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
19 changes: 10 additions & 9 deletions pix/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ plugins {
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'maven-publish'
id 'com.vanniktech.maven.publish'
}

android {
compileSdkVersion 33
buildToolsVersion "30.0.3"
buildToolsVersion "31.0.0"

defaultConfig {
minSdkVersion 21
Expand All @@ -26,11 +27,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}

buildFeatures {
Expand All @@ -45,20 +46,20 @@ repositories {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.4.0-alpha02'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.fragment:fragment-ktx:1.3.4'

def camerax_version = '1.1.0-alpha05'
def camerax_version = '1.2.3'
// CameraX core library using camera2 implementation
implementation "androidx.camera:camera-camera2:$camerax_version"
// CameraX Lifecycle Library
implementation "androidx.camera:camera-lifecycle:$camerax_version"
// CameraX View class
implementation 'androidx.camera:camera-view:1.0.0-alpha25'
implementation 'androidx.camera:camera-view:1.2.3'
// If you want to additionally use the CameraX Extensions library
implementation 'androidx.camera:camera-extensions:1.0.0-alpha25'
implementation 'androidx.camera:camera-extensions:1.2.3'

//Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
Expand Down
5 changes: 4 additions & 1 deletion pix/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=akshay2211
POM_DEVELOPER_NAME=Akshay Sharma
POM_DEVELOPER_URL=https://github.com/akshay2211
POM_DEVELOPER_URL=https://github.com/akshay2211

SONATYPE_HOST=S01
RELEASE_SIGNING_ENABLED=true
22 changes: 17 additions & 5 deletions pix/src/main/java/io/ak1/pix/PixFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import androidx.fragment.app.viewModels
import com.google.android.material.bottomsheet.BottomSheetBehavior
import io.ak1.pix.adapters.InstantImageAdapter
import io.ak1.pix.adapters.MainImageAdapter
import io.ak1.pix.databinding.ControlsLayoutBinding
import io.ak1.pix.databinding.FragmentPixBinding
import io.ak1.pix.databinding.GridLayoutBinding
import io.ak1.pix.databinding.PermissionsLayoutBinding
import io.ak1.pix.databinding.VideoCounterLayoutBinding
import io.ak1.pix.helpers.*
import io.ak1.pix.interfaces.OnSelectionListener
import io.ak1.pix.models.Img
Expand All @@ -29,6 +33,7 @@ import io.ak1.pix.models.PixViewModel
import io.ak1.pix.utility.ARG_PARAM_PIX
import io.ak1.pix.utility.ARG_PARAM_PIX_KEY
import io.ak1.pix.utility.CustomItemTouchListener
import io.ak1.pix.utility.PixBindings
import kotlinx.coroutines.*
import java.lang.Runnable
import kotlin.coroutines.cancellation.CancellationException
Expand All @@ -42,7 +47,7 @@ class PixFragment(private val resultCallback: ((PixEventCallback.Results) -> Uni
Fragment(), View.OnTouchListener {

private val model: PixViewModel by viewModels()
private var _binding: FragmentPixBinding? = null
private var _binding: PixBindings? = null
private val binding get() = _binding!!

private var permReqLauncher =
Expand Down Expand Up @@ -102,8 +107,15 @@ class PixFragment(private val resultCallback: ((PixEventCallback.Results) -> Uni
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?,
) = run {
_binding = FragmentPixBinding.inflate(inflater, container, false)
binding.root
val fragmentPixBinding = FragmentPixBinding.inflate(inflater, container, false)
_binding = PixBindings(
fragmentPixBinding,
VideoCounterLayoutBinding.bind(fragmentPixBinding.root),
PermissionsLayoutBinding.bind(fragmentPixBinding.root),
GridLayoutBinding.bind(fragmentPixBinding.root),
ControlsLayoutBinding.bind(fragmentPixBinding.root)
)
fragmentPixBinding.root
}


Expand Down Expand Up @@ -152,7 +164,7 @@ class PixFragment(private val resultCallback: ((PixEventCallback.Results) -> Uni
private fun initialise(context: FragmentActivity) {
binding.permissionsLayout.permissionsLayout.hide()
binding.gridLayout.gridLayout.show()
cameraXManager = CameraXManager(binding.viewFinder, context, options).also {
cameraXManager = CameraXManager(binding.fragmentPix.viewFinder, context, options).also {
it.startCamera()
}
setupAdapters(context)
Expand Down Expand Up @@ -371,7 +383,7 @@ class PixFragment(private val resultCallback: ((PixEventCallback.Results) -> Uni

private fun CameraXManager.startCamera() {
setUpCamera(binding)
binding.gridLayout.controlsLayout.flashButton.show()
binding.controlsLayout.flashButton.show()
binding.setDrawableIconForFlash(options)
}

Expand Down
21 changes: 11 additions & 10 deletions pix/src/main/java/io/ak1/pix/helpers/AnimationHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,59 @@ package io.ak1.pix.helpers

import android.view.animation.AccelerateDecelerateInterpolator
import io.ak1.pix.databinding.FragmentPixBinding
import io.ak1.pix.utility.PixBindings

/**
* Created By Akshay Sharma on 17,June,2021
* https://ak1.io
*/


fun FragmentPixBinding.videoRecordingStartAnim() {
fun PixBindings.videoRecordingStartAnim() {
val adInterpolator = AccelerateDecelerateInterpolator()
gridLayout.controlsLayout.primaryClickButton.animate().apply {
controlsLayout.primaryClickButton.animate().apply {
scaleX(1.2f)
scaleY(1.2f)
duration = 300
interpolator = adInterpolator
}.start()
gridLayout.controlsLayout.flashButton.animate().apply {
controlsLayout.flashButton.animate().apply {
alpha(0f)
duration = 300
interpolator = adInterpolator
}.start()
gridLayout.controlsLayout.messageBottom.animate().apply {
controlsLayout.messageBottom.animate().apply {
alpha(0f)
duration = 300
interpolator = adInterpolator
}.start()
gridLayout.controlsLayout.lensFacing.animate().apply {
controlsLayout.lensFacing.animate().apply {
alpha(0f)
duration = 300
interpolator = adInterpolator
}.start()
}

fun FragmentPixBinding.videoRecordingEndAnim() {
fun PixBindings.videoRecordingEndAnim() {
val adInterpolator = AccelerateDecelerateInterpolator()
gridLayout.controlsLayout.primaryClickButton.animate().apply {
controlsLayout.primaryClickButton.animate().apply {
scaleX(1f)
scaleY(1f)
duration = 300
interpolator = adInterpolator
}.start()
gridLayout.controlsLayout.flashButton.animate().apply {
controlsLayout.flashButton.animate().apply {
alpha(1f)
duration = 300
interpolator = adInterpolator
}.start()
gridLayout.controlsLayout.messageBottom.animate().apply {
controlsLayout.messageBottom.animate().apply {
scaleX(1f)
scaleY(1f)
duration = 300
interpolator = adInterpolator
}.start()
gridLayout.controlsLayout.lensFacing.animate().apply {
controlsLayout.lensFacing.animate().apply {
alpha(1f)
duration = 300
interpolator = adInterpolator
Expand Down
13 changes: 7 additions & 6 deletions pix/src/main/java/io/ak1/pix/helpers/BottomSheetHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import androidx.core.view.isVisible
import androidx.fragment.app.FragmentActivity
import com.google.android.material.bottomsheet.BottomSheetBehavior
import io.ak1.pix.databinding.FragmentPixBinding
import io.ak1.pix.utility.PixBindings

/**
* Created By Akshay Sharma on 17,June,2021
* https://ak1.io
*/

internal fun FragmentActivity.setup(
binding: FragmentPixBinding,
binding: PixBindings,
bottomSheetBehavior: BottomSheetBehavior<View>?,
callback: (Boolean) -> Unit
) {
Expand All @@ -30,7 +31,7 @@ internal fun FragmentActivity.setup(
binding.gridLayout.sendButtonStateAnimation(false)

}
binding.root.requestDisallowInterceptTouchEvent(newState == BottomSheetBehavior.STATE_DRAGGING)
binding.fragmentPix.root.requestDisallowInterceptTouchEvent(newState == BottomSheetBehavior.STATE_DRAGGING)

localState = newState
}
Expand All @@ -50,23 +51,23 @@ internal fun FragmentActivity.setup(
}

private fun manipulateVisibility(
activity: FragmentActivity, binding: FragmentPixBinding,
activity: FragmentActivity, binding: PixBindings,
slideOffset: Float
) {
binding.gridLayout.apply {
instantRecyclerView.alpha = 1 - slideOffset
arrowUp.alpha = 1 - slideOffset
controlsLayout.controlsLayout.alpha = 1 - slideOffset
binding.controlsLayout.controlsLayout.alpha = 1 - slideOffset
topbar.alpha = slideOffset
recyclerView.alpha = slideOffset
if (1 - slideOffset == 0f) {
instantRecyclerView.hide()
arrowUp.hide()
controlsLayout.primaryClickButton.hide()
binding.controlsLayout.primaryClickButton.hide()
} else if (instantRecyclerView.isGone && 1 - slideOffset > 0) {
instantRecyclerView.show()
arrowUp.show()
controlsLayout.primaryClickButton.show()
binding.controlsLayout.primaryClickButton.show()
}
if (slideOffset > 0 && recyclerView.isInvisible) {
recyclerView.show()
Expand Down
9 changes: 5 additions & 4 deletions pix/src/main/java/io/ak1/pix/helpers/CameraXManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import io.ak1.pix.models.Flash
import io.ak1.pix.models.Mode
import io.ak1.pix.models.Options
import io.ak1.pix.models.Ratio
import io.ak1.pix.utility.PixBindings
import java.io.File
import java.text.SimpleDateFormat
import java.util.*
Expand Down Expand Up @@ -46,7 +47,7 @@ class CameraXManager(


/** Initialize CameraX, and prepare to bind the camera use cases */
fun setUpCamera(binding: FragmentPixBinding) {
fun setUpCamera(binding: PixBindings) {
val cameraProviderFuture = ProcessCameraProvider.getInstance(requireActivity)
cameraProviderFuture.addListener({
// CameraProvider
Expand All @@ -57,7 +58,7 @@ class CameraXManager(
}

/** Declare and bind preview, capture and analysis use cases */
fun bindCameraUseCases(binding: FragmentPixBinding) {
fun bindCameraUseCases(binding: PixBindings) {
// Check if view is correctly attached to window, stop binding otherwise
val display = previewView.display ?: return

Expand Down Expand Up @@ -172,11 +173,11 @@ class CameraXManager(
*useCases.toTypedArray()
)
if (camera.cameraInfo.hasFlashUnit()) {
binding.gridLayout.controlsLayout.flashButton.show()
binding.controlsLayout.flashButton.show()
binding.setDrawableIconForFlash(options)
}
if (options.flash == Flash.Disabled) {
binding.gridLayout.controlsLayout.flashButton.hide()
binding.controlsLayout.flashButton.hide()
}
// Attach the viewfinder's surface provider to preview use case
preview?.setSurfaceProvider(previewView.surfaceProvider)
Expand Down
Loading

0 comments on commit 45a960d

Please sign in to comment.