Improve: Android Studio's Reformat

This commit is contained in:
LooKeR 2021-11-16 01:12:52 +05:30
parent e49b357173
commit a321e9bfa5
32 changed files with 91 additions and 80 deletions

View File

@ -58,6 +58,7 @@ Run `./gradlew assembleRelease` to build the package, which can be installed usi
package manager. package manager.
## :scroll: License ## :scroll: License
Licensed GPLv3+. \ Licensed GPLv3+. \
Direct Adaptation/Modification of [Foxy-Droid](https://github.com/kitsunyan/foxy-droid/) \ Direct Adaptation/Modification of [Foxy-Droid](https://github.com/kitsunyan/foxy-droid/) \
Copyright © 20202021 Iamlooker and contributors. Copyright © 20202021 Iamlooker and contributors.

View File

@ -53,7 +53,8 @@ class MainApplication : Application(), ImageLoaderFactory {
if (packageName != null) { if (packageName != null) {
when (intent.action.orEmpty()) { when (intent.action.orEmpty()) {
Intent.ACTION_PACKAGE_ADDED, Intent.ACTION_PACKAGE_ADDED,
Intent.ACTION_PACKAGE_REMOVED -> { Intent.ACTION_PACKAGE_REMOVED,
-> {
val packageInfo = try { val packageInfo = try {
packageManager.getPackageInfo( packageManager.getPackageInfo(
packageName, packageName,

View File

@ -155,7 +155,7 @@ object Cache {
override fun query( override fun query(
uri: Uri, projection: Array<String>?, uri: Uri, projection: Array<String>?,
selection: String?, selectionArgs: Array<out String>?, sortOrder: String? selection: String?, selectionArgs: Array<out String>?, sortOrder: String?,
): Cursor { ): Cursor {
val file = getFileAndTypeForUri(uri).first val file = getFileAndTypeForUri(uri).first
val columns = (projection ?: defaultColumns).mapNotNull { val columns = (projection ?: defaultColumns).mapNotNull {
@ -179,7 +179,7 @@ object Cache {
override fun update( override fun update(
uri: Uri, contentValues: ContentValues?, uri: Uri, contentValues: ContentValues?,
selection: String?, selectionArgs: Array<out String>? selection: String?, selectionArgs: Array<out String>?,
): Int = unsupported ): Int = unsupported
override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor? { override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor? {

View File

@ -13,7 +13,7 @@ class CursorOwner : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
data class ProductsAvailable( data class ProductsAvailable(
val searchQuery: String, val section: ProductItem.Section, val searchQuery: String, val section: ProductItem.Section,
val order: ProductItem.Order val order: ProductItem.Order,
) : Request() { ) : Request() {
override val id: Int override val id: Int
get() = 1 get() = 1
@ -21,7 +21,7 @@ class CursorOwner : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
data class ProductsInstalled( data class ProductsInstalled(
val searchQuery: String, val section: ProductItem.Section, val searchQuery: String, val section: ProductItem.Section,
val order: ProductItem.Order val order: ProductItem.Order,
) : Request() { ) : Request() {
override val id: Int override val id: Int
get() = 2 get() = 2
@ -29,7 +29,7 @@ class CursorOwner : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
data class ProductsUpdates( data class ProductsUpdates(
val searchQuery: String, val section: ProductItem.Section, val searchQuery: String, val section: ProductItem.Section,
val order: ProductItem.Order val order: ProductItem.Order,
) : Request() { ) : Request() {
override val id: Int override val id: Int
get() = 3 get() = 3
@ -48,7 +48,7 @@ class CursorOwner : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
private data class ActiveRequest( private data class ActiveRequest(
val request: Request, val request: Request,
val callback: Callback?, val callback: Callback?,
val cursor: Cursor? val cursor: Cursor?,
) )
init { init {

View File

@ -308,7 +308,7 @@ object Database {
private fun SQLiteDatabase.insertOrReplace( private fun SQLiteDatabase.insertOrReplace(
replace: Boolean, replace: Boolean,
table: String, table: String,
contentValues: ContentValues contentValues: ContentValues,
): Long { ): Long {
return if (replace) replace(table, null, contentValues) else insert( return if (replace) replace(table, null, contentValues) else insert(
table, table,
@ -320,7 +320,7 @@ object Database {
private fun SQLiteDatabase.query( private fun SQLiteDatabase.query(
table: String, columns: Array<String>? = null, table: String, columns: Array<String>? = null,
selection: Pair<String, Array<String>>? = null, orderBy: String? = null, selection: Pair<String, Array<String>>? = null, orderBy: String? = null,
signal: CancellationSignal? = null signal: CancellationSignal? = null,
): Cursor { ): Cursor {
return query( return query(
false, false,
@ -501,7 +501,7 @@ object Database {
// Complex left to wiring phase // Complex left to wiring phase
fun query( fun query(
installed: Boolean, updates: Boolean, searchQuery: String, installed: Boolean, updates: Boolean, searchQuery: String,
section: ProductItem.Section, order: ProductItem.Order, signal: CancellationSignal? section: ProductItem.Section, order: ProductItem.Order, signal: CancellationSignal?,
): Cursor { ): Cursor {
val builder = QueryBuilder() val builder = QueryBuilder()

View File

@ -6,10 +6,11 @@ import android.database.Cursor
import android.database.CursorWrapper import android.database.CursorWrapper
class ObservableCursor( class ObservableCursor(
cursor: Cursor, private val observable: ( cursor: Cursor,
private val observable: (
register: Boolean, register: Boolean,
observer: () -> Unit observer: () -> Unit,
) -> Unit ) -> Unit,
) : CursorWrapper(cursor) { ) : CursorWrapper(cursor) {
private var registered = false private var registered = false
private val contentObservable = ContentObservable() private val contentObservable = ContentObservable()

View File

@ -5,5 +5,5 @@ class InstalledItem(
val packageName: String, val packageName: String,
val version: String, val version: String,
val versionCode: Long, val versionCode: Long,
val signature: String val signature: String,
) )

View File

@ -28,7 +28,7 @@ data class Product(
val licenses: List<String>, val licenses: List<String>,
val donates: List<Donate>, val donates: List<Donate>,
val screenshots: List<Screenshot>, val screenshots: List<Screenshot>,
val releases: List<Release> val releases: List<Release>,
) { ) {
data class Author(val name: String, val email: String, val web: String) data class Author(val name: String, val email: String, val web: String)
@ -163,7 +163,7 @@ data class Product(
fun <T> findSuggested( fun <T> findSuggested(
products: List<T>, products: List<T>,
installedItem: InstalledItem?, installedItem: InstalledItem?,
extract: (T) -> Product extract: (T) -> Product,
): T? { ): T? {
return products.maxWithOrNull(compareBy({ return products.maxWithOrNull(compareBy({
extract(it).compatible && extract(it).compatible &&

View File

@ -10,7 +10,7 @@ import com.looker.droidify.utility.extension.json.forEachKey
data class ProductItem( data class ProductItem(
var repositoryId: Long, var packageName: String, var name: String, var summary: String, var repositoryId: Long, var packageName: String, var name: String, var summary: String,
val icon: String, val metadataIcon: String, val version: String, var installedVersion: String, val icon: String, val metadataIcon: String, val version: String, var installedVersion: String,
var compatible: Boolean, var canUpdate: Boolean, var matchRank: Int var compatible: Boolean, var canUpdate: Boolean, var matchRank: Int,
) { ) {
sealed class Section : KParcelable { sealed class Section : KParcelable {
object All : Section() { object All : Section() {

View File

@ -29,7 +29,7 @@ data class Release(
val permissions: List<String>, val permissions: List<String>,
val features: List<String>, val features: List<String>,
val platforms: List<String>, val platforms: List<String>,
val incompatibilities: List<Incompatibility> val incompatibilities: List<Incompatibility>,
) { ) {
sealed class Incompatibility { sealed class Incompatibility {
object MinSdk : Incompatibility() object MinSdk : Incompatibility()

View File

@ -11,7 +11,7 @@ data class Repository(
var id: Long, val address: String, val mirrors: List<String>, var id: Long, val address: String, val mirrors: List<String>,
val name: String, val description: String, val version: Int, val enabled: Boolean, val name: String, val description: String, val version: Int, val enabled: Boolean,
val fingerprint: String, val lastModified: String, val entityTag: String, val fingerprint: String, val lastModified: String, val entityTag: String,
val updated: Long, val timestamp: Long, val authentication: String val updated: Long, val timestamp: Long, val authentication: String,
) { ) {
fun edit(address: String, fingerprint: String, authentication: String): Repository { fun edit(address: String, fingerprint: String, authentication: String): Repository {
val addressChanged = this.address != address val addressChanged = this.address != address
@ -28,7 +28,7 @@ data class Repository(
fun update( fun update(
mirrors: List<String>, name: String, description: String, version: Int, mirrors: List<String>, name: String, description: String, version: Int,
lastModified: String, entityTag: String, timestamp: Long lastModified: String, entityTag: String, timestamp: Long,
): Repository { ): Repository {
return copy( return copy(
mirrors = mirrors, name = name, description = description, mirrors = mirrors, name = name, description = description,
@ -100,7 +100,7 @@ data class Repository(
fun newRepository( fun newRepository(
address: String, address: String,
fingerprint: String, fingerprint: String,
authentication: String authentication: String,
): Repository { ): Repository {
val name = try { val name = try {
URL(address).let { "${it.host}${it.path}" } URL(address).let { "${it.host}${it.path}" }
@ -112,7 +112,7 @@ data class Repository(
private fun defaultRepository( private fun defaultRepository(
address: String, name: String, description: String, address: String, name: String, description: String,
version: Int, enabled: Boolean, fingerprint: String, authentication: String version: Int, enabled: Boolean, fingerprint: String, authentication: String,
): Repository { ): Repository {
return Repository( return Repository(
-1, address, emptyList(), name, description, version, enabled, -1, address, emptyList(), name, description, version, enabled,

View File

@ -30,7 +30,7 @@ class IndexHandler(private val repositoryId: Long, private val callback: Callbac
interface Callback { interface Callback {
fun onRepository( fun onRepository(
mirrors: List<String>, name: String, description: String, mirrors: List<String>, name: String, description: String,
certificate: String, version: Int, timestamp: Long certificate: String, version: Int, timestamp: Long,
) )
fun onProduct(product: Product) fun onProduct(product: Product)
@ -181,7 +181,7 @@ class IndexHandler(private val repositoryId: Long, private val callback: Callbac
uri: String, uri: String,
localName: String, localName: String,
qName: String, qName: String,
attributes: Attributes attributes: Attributes,
) { ) {
super.startElement(uri, localName, qName, attributes) super.startElement(uri, localName, qName, attributes)

View File

@ -16,7 +16,7 @@ object IndexV1Parser {
name: String, name: String,
description: String, description: String,
version: Int, version: Int,
timestamp: Long timestamp: Long,
) )
fun onProduct(product: Product) fun onProduct(product: Product)
@ -26,17 +26,17 @@ object IndexV1Parser {
private class Screenshots( private class Screenshots(
val phone: List<String>, val phone: List<String>,
val smallTablet: List<String>, val smallTablet: List<String>,
val largeTablet: List<String> val largeTablet: List<String>,
) )
private class Localized( private class Localized(
val name: String, val summary: String, val description: String, val name: String, val summary: String, val description: String,
val whatsNew: String, val metadataIcon: String, val screenshots: Screenshots? val whatsNew: String, val metadataIcon: String, val screenshots: Screenshots?,
) )
private fun <T> Map<String, Localized>.getAndCall( private fun <T> Map<String, Localized>.getAndCall(
key: String, key: String,
callback: (String, Localized) -> T? callback: (String, Localized) -> T?,
): T? { ): T? {
return this[key]?.let { callback(key, it) } return this[key]?.let { callback(key, it) }
} }
@ -50,7 +50,7 @@ object IndexV1Parser {
private fun Map<String, Localized>.findString( private fun Map<String, Localized>.findString(
fallback: String, fallback: String,
callback: (Localized) -> String callback: (Localized) -> String,
): String { ): String {
return (find { _, localized -> callback(localized).nullIfEmpty() } ?: fallback).trim() return (find { _, localized -> callback(localized).nullIfEmpty() } ?: fallback).trim()
} }

View File

@ -32,7 +32,7 @@ object RepositoryUpdater {
private enum class IndexType( private enum class IndexType(
val jarName: String, val jarName: String,
val contentName: String, val contentName: String,
val certificateFromIndex: Boolean val certificateFromIndex: Boolean,
) { ) {
INDEX("index.jar", "index.xml", true), INDEX("index.jar", "index.xml", true),
INDEX_V1("index-v1.jar", "index-v1.json", false) INDEX_V1("index-v1.jar", "index-v1.json", false)
@ -93,7 +93,7 @@ object RepositoryUpdater {
fun update( fun update(
context: Context, context: Context,
repository: Repository, unstable: Boolean, repository: Repository, unstable: Boolean,
callback: (Stage, Long, Long?) -> Unit callback: (Stage, Long, Long?) -> Unit,
): Single<Boolean> { ): Single<Boolean> {
return update( return update(
context, context,
@ -107,7 +107,7 @@ object RepositoryUpdater {
private fun update( private fun update(
context: Context, context: Context,
repository: Repository, indexTypes: List<IndexType>, unstable: Boolean, repository: Repository, indexTypes: List<IndexType>, unstable: Boolean,
callback: (Stage, Long, Long?) -> Unit callback: (Stage, Long, Long?) -> Unit,
): Single<Boolean> { ): Single<Boolean> {
val indexType = indexTypes[0] val indexType = indexTypes[0]
return downloadIndex(context, repository, indexType, callback) return downloadIndex(context, repository, indexType, callback)
@ -152,7 +152,7 @@ object RepositoryUpdater {
private fun downloadIndex( private fun downloadIndex(
context: Context, context: Context,
repository: Repository, indexType: IndexType, repository: Repository, indexType: IndexType,
callback: (Stage, Long, Long?) -> Unit callback: (Stage, Long, Long?) -> Unit,
): Single<Pair<Downloader.Result, File>> { ): Single<Pair<Downloader.Result, File>> {
return Single.just(Unit) return Single.just(Unit)
.map { Cache.getTemporaryFile(context) } .map { Cache.getTemporaryFile(context) }
@ -190,7 +190,7 @@ object RepositoryUpdater {
private fun processFile( private fun processFile(
context: Context, context: Context,
repository: Repository, indexType: IndexType, unstable: Boolean, repository: Repository, indexType: IndexType, unstable: Boolean,
file: File, lastModified: String, entityTag: String, callback: (Stage, Long, Long?) -> Unit file: File, lastModified: String, entityTag: String, callback: (Stage, Long, Long?) -> Unit,
): Boolean { ): Boolean {
var rollback = true var rollback = true
return synchronized(updaterLock) { return synchronized(updaterLock) {
@ -216,7 +216,7 @@ object RepositoryUpdater {
IndexHandler(repository.id, object : IndexHandler.Callback { IndexHandler(repository.id, object : IndexHandler.Callback {
override fun onRepository( override fun onRepository(
mirrors: List<String>, name: String, description: String, mirrors: List<String>, name: String, description: String,
certificate: String, version: Int, timestamp: Long certificate: String, version: Int, timestamp: Long,
) { ) {
changedRepository = repository.update( changedRepository = repository.update(
mirrors, name, description, version, mirrors, name, description, version,
@ -278,7 +278,7 @@ object RepositoryUpdater {
name: String, name: String,
description: String, description: String,
version: Int, version: Int,
timestamp: Long timestamp: Long,
) { ) {
changedRepository = repository.update( changedRepository = repository.update(
mirrors, name, description, version, mirrors, name, description, version,
@ -299,7 +299,7 @@ object RepositoryUpdater {
override fun onReleases( override fun onReleases(
packageName: String, packageName: String,
releases: List<Release> releases: List<Release>,
) { ) {
if (Thread.interrupted()) { if (Thread.interrupted()) {
throw InterruptedException() throw InterruptedException()
@ -432,7 +432,7 @@ object RepositoryUpdater {
private fun transformProduct( private fun transformProduct(
product: Product, product: Product,
features: Set<String>, features: Set<String>,
unstable: Boolean unstable: Boolean,
): Product { ): Product {
val releasePairs = val releasePairs =
product.releases.distinctBy { it.identifier }.sortedByDescending { it.versionCode } product.releases.distinctBy { it.identifier }.sortedByDescending { it.versionCode }

View File

@ -92,7 +92,7 @@ object CoilDownloader {
fun createScreenshotUri( fun createScreenshotUri(
repository: Repository, repository: Repository,
packageName: String, packageName: String,
screenshot: Product.Screenshot screenshot: Product.Screenshot,
): Uri { ): Uri {
return Uri.Builder().scheme("https").authority(HOST_SCREENSHOT) return Uri.Builder().scheme("https").authority(HOST_SCREENSHOT)
.appendQueryParameter(QUERY_ADDRESS, repository.address) .appendQueryParameter(QUERY_ADDRESS, repository.address)
@ -115,7 +115,7 @@ object CoilDownloader {
packageName: String, packageName: String,
icon: String, icon: String,
metadataIcon: String, metadataIcon: String,
repository: Repository repository: Repository,
): Uri { ): Uri {
val size = (view.layoutParams.let { min(it.width, it.height) } / val size = (view.layoutParams.let { min(it.width, it.height) } /
view.resources.displayMetrics.density).roundToInt() view.resources.displayMetrics.density).roundToInt()
@ -124,7 +124,7 @@ object CoilDownloader {
private fun createIconUri( private fun createIconUri(
context: Context, packageName: String, icon: String, metadataIcon: String, context: Context, packageName: String, icon: String, metadataIcon: String,
targetSizeDp: Int, repository: Repository targetSizeDp: Int, repository: Repository,
): Uri { ): Uri {
return Uri.Builder().scheme("https").authority(HOST_ICON) return Uri.Builder().scheme("https").authority(HOST_ICON)
.appendQueryParameter(QUERY_ADDRESS, repository.address) .appendQueryParameter(QUERY_ADDRESS, repository.address)

View File

@ -68,7 +68,7 @@ object Downloader {
fun download( fun download(
url: String, target: File, lastModified: String, entityTag: String, authentication: String, url: String, target: File, lastModified: String, entityTag: String, authentication: String,
callback: ((read: Long, total: Long?) -> Unit)? callback: ((read: Long, total: Long?) -> Unit)?,
): Single<Result> { ): Single<Result> {
val start = if (target.exists()) target.length().let { if (it > 0L) it else null } else null val start = if (target.exists()) target.length().let { if (it > 0L) it else null } else null
val request = Request.Builder().url(url) val request = Request.Builder().url(url)

View File

@ -68,7 +68,7 @@ class MessageDialog() : DialogFragment() {
class ReleaseIncompatible( class ReleaseIncompatible(
val incompatibilities: List<Release.Incompatibility>, val incompatibilities: List<Release.Incompatibility>,
val platforms: List<String>, val minSdkVersion: Int, val maxSdkVersion: Int val platforms: List<String>, val minSdkVersion: Int, val maxSdkVersion: Int,
) : Message() { ) : Message() {
override fun writeToParcel(dest: Parcel, flags: Int) { override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeInt(incompatibilities.size) dest.writeInt(incompatibilities.size)

View File

@ -13,7 +13,7 @@ import com.looker.droidify.widget.CursorRecyclerAdapter
class RepositoriesAdapter( class RepositoriesAdapter(
private val onClick: (Repository) -> Unit, private val onClick: (Repository) -> Unit,
private val onSwitch: (repository: Repository, isEnabled: Boolean) -> Boolean private val onSwitch: (repository: Repository, isEnabled: Boolean) -> Boolean,
) : ) :
CursorRecyclerAdapter<RepositoriesAdapter.ViewType, RecyclerView.ViewHolder>() { CursorRecyclerAdapter<RepositoriesAdapter.ViewType, RecyclerView.ViewHolder>() {
enum class ViewType { REPOSITORY } enum class ViewType { REPOSITORY }
@ -38,7 +38,7 @@ class RepositoriesAdapter(
override fun onCreateViewHolder( override fun onCreateViewHolder(
parent: ViewGroup, parent: ViewGroup,
viewType: ViewType viewType: ViewType,
): RecyclerView.ViewHolder { ): RecyclerView.ViewHolder {
return ViewHolder(parent.inflate(R.layout.repository_item)).apply { return ViewHolder(parent.inflate(R.layout.repository_item)).apply {
itemView.setOnClickListener { onClick(getRepository(adapterPosition)) } itemView.setOnClickListener { onClick(getRepository(adapterPosition)) }

View File

@ -22,7 +22,7 @@ class RepositoriesFragment : ScreenFragment(), CursorOwner.Callback {
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?,
): View { ): View {
val view = fragmentBinding.root.apply { val view = fragmentBinding.root.apply {
val content = fragmentBinding.fragmentContent val content = fragmentBinding.fragmentContent

View File

@ -32,7 +32,7 @@ abstract class ScreenActivity : AppCompatActivity() {
private class FragmentStackItem( private class FragmentStackItem(
val className: String, val arguments: Bundle?, val className: String, val arguments: Bundle?,
val savedState: Fragment.SavedState? val savedState: Fragment.SavedState?,
) : KParcelable { ) : KParcelable {
override fun writeToParcel(dest: Parcel, flags: Int) { override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeString(className) dest.writeString(className)

View File

@ -211,7 +211,7 @@ class ScreenshotsFragment() : DialogFragment() {
fun update( fun update(
viewPager: ViewPager2, viewPager: ViewPager2,
repository: Repository?, repository: Repository?,
screenshots: List<Product.Screenshot> screenshots: List<Product.Screenshot>,
) { ) {
this.repository = repository this.repository = repository
this.screenshots = screenshots this.screenshots = screenshots
@ -239,7 +239,7 @@ class ScreenshotsFragment() : DialogFragment() {
override fun onCreateViewHolder( override fun onCreateViewHolder(
parent: ViewGroup, parent: ViewGroup,
viewType: ViewType viewType: ViewType,
): RecyclerView.ViewHolder { ): RecyclerView.ViewHolder {
return ViewHolder(parent.context).apply { return ViewHolder(parent.context).apply {
itemView.setOnClickListener { onClick() } itemView.setOnClickListener { onClick() }

View File

@ -402,7 +402,7 @@ class TabsFragment : ScreenFragment() {
private fun setSectionsAndUpdate( private fun setSectionsAndUpdate(
categories: List<ProductItem.Section.Category>?, categories: List<ProductItem.Section.Category>?,
repositories: List<ProductItem.Section.Repository>? repositories: List<ProductItem.Section.Repository>?,
) { ) {
val oldCategories = collectOldSections(categories) val oldCategories = collectOldSections(categories)
val oldRepositories = collectOldSections(repositories) val oldRepositories = collectOldSections(repositories)
@ -468,7 +468,7 @@ class TabsFragment : ScreenFragment() {
override fun onPageScrolled( override fun onPageScrolled(
position: Int, position: Int,
positionOffset: Float, positionOffset: Float,
positionOffsetPixels: Int positionOffsetPixels: Int,
) { ) {
val layout = layout!! val layout = layout!!
val fromSections = AppListFragment.Source.values()[position].sections val fromSections = AppListFragment.Source.values()[position].sections
@ -520,7 +520,7 @@ class TabsFragment : ScreenFragment() {
private class SectionsAdapter( private class SectionsAdapter(
private val sections: () -> List<ProductItem.Section>, private val sections: () -> List<ProductItem.Section>,
private val onClick: (ProductItem.Section) -> Unit private val onClick: (ProductItem.Section) -> Unit,
) : StableRecyclerAdapter<SectionsAdapter.ViewType, ) : StableRecyclerAdapter<SectionsAdapter.ViewType,
RecyclerView.ViewHolder>() { RecyclerView.ViewHolder>() {
enum class ViewType { SECTION } enum class ViewType { SECTION }
@ -546,7 +546,7 @@ class TabsFragment : ScreenFragment() {
fun configureDivider( fun configureDivider(
context: Context, context: Context,
position: Int, position: Int,
configuration: DividerItemDecoration.Configuration configuration: DividerItemDecoration.Configuration,
) { ) {
val currentSection = sections()[position] val currentSection = sections()[position]
val nextSection = sections().getOrNull(position + 1) val nextSection = sections().getOrNull(position + 1)
@ -580,7 +580,7 @@ class TabsFragment : ScreenFragment() {
override fun onCreateViewHolder( override fun onCreateViewHolder(
parent: ViewGroup, parent: ViewGroup,
viewType: ViewType viewType: ViewType,
): RecyclerView.ViewHolder { ): RecyclerView.ViewHolder {
return SectionViewHolder(parent.context).apply { return SectionViewHolder(parent.context).apply {
itemView.setOnClickListener { onClick(sections()[adapterPosition]) } itemView.setOnClickListener { onClick(sections()[adapterPosition]) }

View File

@ -9,7 +9,7 @@ import android.os.IBinder
class Connection<B : IBinder, S : ConnectionService<B>>( class Connection<B : IBinder, S : ConnectionService<B>>(
private val serviceClass: Class<S>, private val serviceClass: Class<S>,
private val onBind: ((Connection<B, S>, B) -> Unit)? = null, private val onBind: ((Connection<B, S>, B) -> Unit)? = null,
private val onUnbind: ((Connection<B, S>, B) -> Unit)? = null private val onUnbind: ((Connection<B, S>, B) -> Unit)? = null,
) : ServiceConnection { ) : ServiceConnection {
var binder: B? = null var binder: B? = null
private set private set

View File

@ -78,7 +78,7 @@ class DownloadService : ConnectionService<DownloadService.Binder>() {
class Success( class Success(
packageName: String, name: String, val release: Release, packageName: String, name: String, val release: Release,
val consume: () -> Unit val consume: () -> Unit,
) : State(packageName, name) ) : State(packageName, name)
class Error(packageName: String, name: String) : State(packageName, name) class Error(packageName: String, name: String) : State(packageName, name)
@ -89,7 +89,7 @@ class DownloadService : ConnectionService<DownloadService.Binder>() {
private class Task( private class Task(
val packageName: String, val name: String, val release: Release, val packageName: String, val name: String, val release: Release,
val url: String, val authentication: String val url: String, val authentication: String,
) { ) {
val notificationTag: String val notificationTag: String
get() = "download-$packageName" get() = "download-$packageName"

View File

@ -49,7 +49,7 @@ class SyncService : ConnectionService<SyncService.Binder>() {
data class Connecting(val name: String) : State() data class Connecting(val name: String) : State()
data class Syncing( data class Syncing(
val name: String, val stage: RepositoryUpdater.Stage, val name: String, val stage: RepositoryUpdater.Stage,
val read: Long, val total: Long? val read: Long, val total: Long?,
) : State() ) : State()
object Finishing : State() object Finishing : State()
@ -58,7 +58,7 @@ class SyncService : ConnectionService<SyncService.Binder>() {
private class Task(val repositoryId: Long, val manual: Boolean) private class Task(val repositoryId: Long, val manual: Boolean)
private data class CurrentTask( private data class CurrentTask(
val task: Task?, val disposable: Disposable, val task: Task?, val disposable: Disposable,
val hasUpdates: Boolean, val lastState: State val hasUpdates: Boolean, val lastState: State,
) )
private enum class Started { NO, AUTO, MANUAL } private enum class Started { NO, AUTO, MANUAL }

View File

@ -118,7 +118,7 @@ class AppListAdapter(private val onClick: (ProductItem) -> Unit) :
override fun onCreateViewHolder( override fun onCreateViewHolder(
parent: ViewGroup, parent: ViewGroup,
viewType: ViewType viewType: ViewType,
): RecyclerView.ViewHolder { ): RecyclerView.ViewHolder {
return when (viewType) { return when (viewType) {
ViewType.PRODUCT -> ProductViewHolder(parent.inflate(R.layout.product_item)).apply { ViewType.PRODUCT -> ProductViewHolder(parent.inflate(R.layout.product_item)).apply {

View File

@ -18,7 +18,7 @@ object PackageItemResolver {
private fun load( private fun load(
context: Context, localCache: LocalCache, packageName: String, context: Context, localCache: LocalCache, packageName: String,
nonLocalized: CharSequence?, resId: Int nonLocalized: CharSequence?, resId: Int,
): CharSequence? { ): CharSequence? {
return when { return when {
nonLocalized != null -> { nonLocalized != null -> {
@ -63,7 +63,7 @@ object PackageItemResolver {
fun loadLabel( fun loadLabel(
context: Context, context: Context,
localCache: LocalCache, localCache: LocalCache,
packageItemInfo: PackageItemInfo packageItemInfo: PackageItemInfo,
): CharSequence? { ): CharSequence? {
return load( return load(
context, localCache, packageItemInfo.packageName, context, localCache, packageItemInfo.packageName,
@ -74,7 +74,7 @@ object PackageItemResolver {
fun loadDescription( fun loadDescription(
context: Context, context: Context,
localCache: LocalCache, localCache: LocalCache,
permissionInfo: PermissionInfo permissionInfo: PermissionInfo,
): CharSequence? { ): CharSequence? {
return load( return load(
context, localCache, permissionInfo.packageName, context, localCache, permissionInfo.packageName,
@ -88,29 +88,35 @@ object PackageItemResolver {
when (permissionInfo.name) { when (permissionInfo.name) {
android.Manifest.permission.READ_CONTACTS, android.Manifest.permission.READ_CONTACTS,
android.Manifest.permission.WRITE_CONTACTS, android.Manifest.permission.WRITE_CONTACTS,
android.Manifest.permission.GET_ACCOUNTS -> android.Manifest.permission.GET_ACCOUNTS,
->
android.Manifest.permission_group.CONTACTS android.Manifest.permission_group.CONTACTS
android.Manifest.permission.READ_CALENDAR, android.Manifest.permission.READ_CALENDAR,
android.Manifest.permission.WRITE_CALENDAR -> android.Manifest.permission.WRITE_CALENDAR,
->
android.Manifest.permission_group.CALENDAR android.Manifest.permission_group.CALENDAR
android.Manifest.permission.SEND_SMS, android.Manifest.permission.SEND_SMS,
android.Manifest.permission.RECEIVE_SMS, android.Manifest.permission.RECEIVE_SMS,
android.Manifest.permission.READ_SMS, android.Manifest.permission.READ_SMS,
android.Manifest.permission.RECEIVE_MMS, android.Manifest.permission.RECEIVE_MMS,
android.Manifest.permission.RECEIVE_WAP_PUSH, android.Manifest.permission.RECEIVE_WAP_PUSH,
"android.permission.READ_CELL_BROADCASTS" -> "android.permission.READ_CELL_BROADCASTS",
->
android.Manifest.permission_group.SMS android.Manifest.permission_group.SMS
android.Manifest.permission.READ_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
android.Manifest.permission.ACCESS_MEDIA_LOCATION -> android.Manifest.permission.ACCESS_MEDIA_LOCATION,
->
android.Manifest.permission_group.STORAGE android.Manifest.permission_group.STORAGE
android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION,
android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION,
android.Manifest.permission.ACCESS_BACKGROUND_LOCATION -> android.Manifest.permission.ACCESS_BACKGROUND_LOCATION,
->
android.Manifest.permission_group.LOCATION android.Manifest.permission_group.LOCATION
android.Manifest.permission.READ_CALL_LOG, android.Manifest.permission.READ_CALL_LOG,
android.Manifest.permission.WRITE_CALL_LOG, android.Manifest.permission.WRITE_CALL_LOG,
@Suppress("DEPRECATION") android.Manifest.permission.PROCESS_OUTGOING_CALLS -> @Suppress("DEPRECATION") android.Manifest.permission.PROCESS_OUTGOING_CALLS,
->
android.Manifest.permission_group.CALL_LOG android.Manifest.permission_group.CALL_LOG
android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE,
android.Manifest.permission.READ_PHONE_NUMBERS, android.Manifest.permission.READ_PHONE_NUMBERS,
@ -118,7 +124,8 @@ object PackageItemResolver {
android.Manifest.permission.ADD_VOICEMAIL, android.Manifest.permission.ADD_VOICEMAIL,
android.Manifest.permission.USE_SIP, android.Manifest.permission.USE_SIP,
android.Manifest.permission.ANSWER_PHONE_CALLS, android.Manifest.permission.ANSWER_PHONE_CALLS,
android.Manifest.permission.ACCEPT_HANDOVER -> android.Manifest.permission.ACCEPT_HANDOVER,
->
android.Manifest.permission_group.PHONE android.Manifest.permission_group.PHONE
android.Manifest.permission.RECORD_AUDIO -> android.Manifest.permission.RECORD_AUDIO ->
android.Manifest.permission_group.MICROPHONE android.Manifest.permission_group.MICROPHONE

View File

@ -4,7 +4,7 @@ import java.io.InputStream
class ProgressInputStream( class ProgressInputStream(
private val inputStream: InputStream, private val inputStream: InputStream,
private val callback: (Long) -> Unit private val callback: (Long) -> Unit,
) : InputStream() { ) : InputStream() {
private var count = 0L private var count = 0L

View File

@ -25,7 +25,7 @@ object RxUtils {
private fun <T, R> managedSingle( private fun <T, R> managedSingle(
create: () -> T, create: () -> T,
cancel: (T) -> Unit, cancel: (T) -> Unit,
execute: (T) -> R execute: (T) -> R,
): Single<R> { ): Single<R> {
return Single.create { return Single.create {
val task = create() val task = create()

View File

@ -61,7 +61,7 @@ fun JsonParser.forEach(requiredToken: JsonToken, callback: JsonParser.() -> Unit
fun <T> JsonParser.collectNotNull( fun <T> JsonParser.collectNotNull(
requiredToken: JsonToken, requiredToken: JsonToken,
callback: JsonParser.() -> T? callback: JsonParser.() -> T?,
): List<T> { ): List<T> {
val list = mutableListOf<T>() val list = mutableListOf<T>()
forEach(requiredToken) { forEach(requiredToken) {

View File

@ -10,10 +10,11 @@ import com.looker.droidify.utility.extension.resources.getDrawableFromAttr
import kotlin.math.roundToInt import kotlin.math.roundToInt
class DividerItemDecoration( class DividerItemDecoration(
context: Context, private val configure: (
context: Context, context: Context,
position: Int, configuration: Configuration private val configure: (
) -> Unit context: Context,
position: Int, configuration: Configuration,
) -> Unit,
) : RecyclerView.ItemDecoration() { ) : RecyclerView.ItemDecoration() {
interface Configuration { interface Configuration {
fun set(needDivider: Boolean, toTop: Boolean, paddingStart: Int, paddingEnd: Int) fun set(needDivider: Boolean, toTop: Boolean, paddingStart: Int, paddingEnd: Int)
@ -49,7 +50,7 @@ class DividerItemDecoration(
view: View, view: View,
top: Int, top: Int,
width: Int, width: Int,
rtl: Boolean rtl: Boolean,
) { ) {
val divider = divider val divider = divider
val left = if (rtl) configuration.paddingEnd else configuration.paddingStart val left = if (rtl) configuration.paddingEnd else configuration.paddingStart
@ -105,7 +106,7 @@ class DividerItemDecoration(
outRect: Rect, outRect: Rect,
view: View, view: View,
parent: RecyclerView, parent: RecyclerView,
state: RecyclerView.State state: RecyclerView.State,
) { ) {
val configuration = view.configuration val configuration = view.configuration
val position = parent.getChildAdapterPosition(view) val position = parent.getChildAdapterPosition(view)

View File

@ -33,7 +33,7 @@ class RecyclerFastScroller(private val recyclerView: RecyclerView) {
private data class FastScrolling( private data class FastScrolling(
val startAtThumbOffset: Float?, val startAtThumbOffset: Float?,
val startY: Float, val startY: Float,
val currentY: Float val currentY: Float,
) )
private var scrolling = false private var scrolling = false
@ -130,7 +130,7 @@ class RecyclerFastScroller(private val recyclerView: RecyclerView) {
itemHeight: Int, itemHeight: Int,
thumbHeight: Int, thumbHeight: Int,
range: Int, range: Int,
fastScrolling: FastScrolling fastScrolling: FastScrolling,
) { ) {
val offset = calculateOffset(thumbHeight, fastScrolling) val offset = calculateOffset(thumbHeight, fastScrolling)
val scrollPosition = ((range - recyclerView.height) * offset).roundToInt() val scrollPosition = ((range - recyclerView.height) * offset).roundToInt()