Skip to content

Commit

Permalink
Gradle version upgrade to 7.4.2 to support new version of Spotless. K…
Browse files Browse the repository at this point in the history
…otlin and Spotless upgrades. Code style refactoring (automated by Spotless)
  • Loading branch information
sherzodnosirov committed Oct 17, 2023
1 parent 04a6f7a commit 4c25e5f
Show file tree
Hide file tree
Showing 40 changed files with 167 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ExampleActivity : AppCompatActivity() {
maxCount = 10,
sendIcon = R.drawable.ic_send,
header = getString(R.string.pickpic_actionbar_header),
title = getString(R.string.pickpic_title)
title = getString(R.string.pickpic_title),
)
// pass the config to PickPic
PickPicActivity.applyConfig(it, config)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.10'
ext.kotlin_version = '1.6.21'
ext.multidex_version = "2.0.1"

ext.legacy_v4_version = "1.0.0"
Expand Down Expand Up @@ -53,10 +53,10 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:0.9.18'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:3.27.1'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.22.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import com.lovoo.android.pickui.view.GalleryFragment
class PickPicAdapter(
private val context: Context,
manager: FragmentManager,
private val dependencies: PickDependencies
private val dependencies: PickDependencies,
) : FragmentStatePagerAdapter(manager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

override fun getItem(position: Int) = buildFragment(getType(position))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class SelectionAdapter(

class ViewHolder(
view: View,
private val imageEngine: ImageEngine
private val imageEngine: ImageEngine,
) : RecyclerView.ViewHolder(view) {
private val size = view.context.resources.getDimensionPixelSize(R.dimen.pickpic_thumbnail_size)
private val corner = view.context.resources.getDimensionPixelSize(R.dimen.pickpic_thumbnail_corner_size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ class GlideEngine : ImageEngine {
RequestOptions()
.override(width, height)
.also {
if (corner > 0) it.transform(CenterCrop(), RoundedCorners(corner))
else it.centerCrop()
}
if (corner > 0) {
it.transform(CenterCrop(), RoundedCorners(corner))
} else {
it.centerCrop()
}
},
)
.apply {
if (errorRes != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ data class PickPicConfig(
val sendText: String? = null,
@DrawableRes val sendIcon: Int? = null,
val header: String? = null,
val faqUrl: String? = null
val faqUrl: String? = null,
) : Parcelable {

constructor(parcel: Parcel) : this(
Expand All @@ -54,7 +54,7 @@ data class PickPicConfig(
parcel.readString(),
parcel.readValue(Int::class.java.classLoader) as? Int,
parcel.readString(),
parcel.readString()
parcel.readString(),
)

override fun writeToParcel(parcel: Parcel, flags: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ package com.lovoo.android.pickapp.model
*/
enum class PickType {
GALLERY,
FACEBOOK
FACEBOOK,
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import io.reactivex.subjects.BehaviorSubject
* @param config the [PickConfig] to determine the limits
*/
class Picker(
val config: PickConfig
val config: PickConfig,
) {

/**
Expand Down Expand Up @@ -136,7 +136,7 @@ class Picker(
*/
data class PickConfig(
val minCount: Int = 1,
val maxCount: Int = 1
val maxCount: Int = 1,
)

sealed class State {
Expand All @@ -148,7 +148,7 @@ class Picker(
*/
data class Select(
val position: Int,
val uri: Uri?
val uri: Uri?,
) : State()

/**
Expand All @@ -159,7 +159,7 @@ class Picker(
*/
data class Add(
val uri: Uri,
val gallery: Gallery
val gallery: Gallery,
) : State()

/**
Expand All @@ -170,7 +170,7 @@ class Picker(
*/
data class Remove(
val uri: Uri,
val gallery: Gallery
val gallery: Gallery,
) : State()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class PickPicActivity : AppCompatActivity(), SelectionHolder, CameraEngine, Capt
maxCount = 10,
sendText = "DONE",
title = getString(R.string.pickpic_title),
header = getString(R.string.pickpic_actionbar_header)
header = getString(R.string.pickpic_actionbar_header),
)

config = intent?.getParcelableExtra(INTENT_IN_CONFIG) ?: default
Expand Down Expand Up @@ -140,8 +140,9 @@ class PickPicActivity : AppCompatActivity(), SelectionHolder, CameraEngine, Capt
try {
val uris = savedInstanceState.getParcelableArray(BUNDLE_URIS)?.map { it as Uri }?.toTypedArray()
val galleries = savedInstanceState.getParcelableArray(BUNDLE_GALLERIES)?.map { it as Gallery }?.toTypedArray()
if (uris != null && galleries != null)
if (uris != null && galleries != null) {
picker.toggle(uris, galleries)
}
} catch (e: Exception) {
e.printStackTrace()
}
Expand Down Expand Up @@ -219,8 +220,8 @@ class PickPicActivity : AppCompatActivity(), SelectionHolder, CameraEngine, Capt
is Picker.State.Select -> selectedUri = state.uri
}
},
{ error -> error.printStackTrace() }
)
{ error -> error.printStackTrace() },
),
)
}

Expand All @@ -233,12 +234,12 @@ class PickPicActivity : AppCompatActivity(), SelectionHolder, CameraEngine, Capt
{
finishSelection()
},
AUTO_FINISH_DELAY
AUTO_FINISH_DELAY,
)
}
},
{ /* no-op */ }
)
{ /* no-op */ },
),
)
}

Expand Down Expand Up @@ -298,7 +299,7 @@ class PickPicActivity : AppCompatActivity(), SelectionHolder, CameraEngine, Capt
this.paddingStart,
this.paddingTop,
this.paddingEnd,
resources.getDimensionPixelOffset(R.dimen.pickpic_actionbar_headline_margin)
resources.getDimensionPixelOffset(R.dimen.pickpic_actionbar_headline_margin),
)
}
(toolbar.layoutParams as CollapsingToolbarLayout.LayoutParams).collapseMode =
Expand All @@ -314,9 +315,8 @@ class PickPicActivity : AppCompatActivity(), SelectionHolder, CameraEngine, Capt
selectionbar = Selectionbar(
picker,
binding.selectionBar,
arrayOf(binding.fragmentPager, binding.previewPager)
arrayOf(binding.fragmentPager, binding.previewPager),
).apply {

setButtonText(this@PickPicActivity.config.sendText)
setButtonIcon(this@PickPicActivity.config.sendIcon)
setButtonOnClick { finishSelection() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import io.reactivex.disposables.CompositeDisposable
class Preview(
val pager: ViewPager,
val fragmentManager: FragmentManager,
val picker: Picker
val picker: Picker,
) {

private val subscriptions = CompositeDisposable()
Expand Down Expand Up @@ -77,8 +77,8 @@ class Preview(
}
}
},
{ error -> error.printStackTrace() }
)
{ error -> error.printStackTrace() },
),
)
}

Expand All @@ -87,7 +87,7 @@ class Preview(
it.adapter = object : FragmentStatePagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
override fun getItem(position: Int) = PreviewFragment.createInstance(
position,
picker.getPickedUris().getOrNull(position)
picker.getPickedUris().getOrNull(position),
)

override fun getCount() = picker.map.size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class PreviewFragment : Fragment() {
it.measuredHeight,
uri,
it,
0
0,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import io.reactivex.disposables.CompositeDisposable
class Selectionbar(
private val picker: Picker,
private val binding: PickpicLayoutSelectionbarBinding,
private val dependingViews: Array<View>
private val dependingViews: Array<View>,
) {

private val adapter = SelectionAdapter(picker.config.maxCount)
Expand Down Expand Up @@ -201,8 +201,8 @@ class Selectionbar(
}
}
},
{ error -> error.printStackTrace() }
)
{ error -> error.printStackTrace() },
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@
package com.lovoo.android.pickcam.view

import android.app.Activity
import android.content.*
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager
import android.os.*
import android.view.*
import android.os.Build
import android.os.Bundle
import android.os.Environment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.fragment.app.*
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import com.lovoo.android.pickcam.R
import com.lovoo.android.pickcam.worker.CaptureResultWorker
import com.lovoo.android.pickcore.contract.CameraDestination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import java.io.File
*/
class CaptureResultWorker(
private val context: Context,
params: WorkerParameters
params: WorkerParameters,
) : RxWorker(context, params) {

private var inputFile: File = File(params.inputData.getString(INPUT_FILE))
Expand All @@ -72,7 +72,7 @@ class CaptureResultWorker(
// LiveData holds to long the old result so we have to forward the result as broadcast
context.sendBroadcast(Intent(INTENT_ACTION_ON_RESULT).putExtra(OUTPUT_URI, uri))
emitter.onSuccess(Result.success())
}
},
)
}
}
Expand All @@ -99,7 +99,7 @@ class CaptureResultWorker(
fun start(context: Context, destination: CameraDestination, name: String = "CaptureResultWorker") {
val data = workDataOf(
INPUT_IS_PUBLIC to (destination !is PrivateDirectory),
INPUT_FILE to (destination.file?.path ?: "")
INPUT_FILE to (destination.file?.path ?: ""),
)

val request = OneTimeWorkRequest.Builder(CaptureResultWorker::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ fun CameraDestination.getUri(context: Context): Uri? = when {
* @param fileName optional complete filename or if not set JPEG_<date>.jpg
*/
fun CameraDestination.createTempFile(fileName: String = ""): File? {

if (Environment.MEDIA_MOUNTED != EnvironmentCompat.getStorageState(directory)) {
// the storage state is broken
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import androidx.loader.content.Loader
class Collector(
private val manager: LoaderManager,
private val loader: Loader<Cursor>,
private val id: Int
private val id: Int,
) : LoaderManager.LoaderCallbacks<Cursor> {

/**
Expand Down
Loading

0 comments on commit 4c25e5f

Please sign in to comment.