diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2289f354..3171cd432 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,10 @@ jobs: steps: - name: Fetch Sources uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'adopt' - name: Setup Gradle Dependencies Cache uses: actions/cache@v2 @@ -49,10 +49,10 @@ jobs: steps: - name: Fetch Sources uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'adopt' - name: Setup Gradle Dependencies Cache uses: actions/cache@v2 diff --git a/.github/workflows/release-automated.yml b/.github/workflows/release-automated.yml index f28d3202a..978b8c04f 100644 --- a/.github/workflows/release-automated.yml +++ b/.github/workflows/release-automated.yml @@ -9,10 +9,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'adopt' - name: Generate Javadoc run: javadoc @.javadoc || true diff --git a/.github/workflows/release-manual-docs.yml b/.github/workflows/release-manual-docs.yml index eae133ce2..a4344fbe0 100644 --- a/.github/workflows/release-manual-docs.yml +++ b/.github/workflows/release-manual-docs.yml @@ -11,10 +11,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'adopt' - name: Generate Javadoc run: javadoc @.javadoc || true diff --git a/bolts-tasks/build.gradle b/bolts-tasks/build.gradle index 79f4aefa0..c30998e83 100644 --- a/bolts-tasks/build.gradle +++ b/bolts-tasks/build.gradle @@ -18,12 +18,13 @@ java { javadoc.options.addStringOption('Xdoclint:none', '-quiet') -task sourcesJar(type: Jar) { +tasks.register('sourcesJar', Jar) { archiveClassifier.set('sources') from sourceSets.main.allJava } -task javadocJar(type: Jar, dependsOn: javadoc) { +tasks.register('javadocJar', Jar) { + dependsOn javadoc archiveClassifier.set('javadoc') from javadoc.destinationDir } @@ -39,7 +40,7 @@ afterEvaluate { publishing { publications { boltsPublication(MavenPublication) { - from components.java + from components.findByName('java') } } } @@ -55,8 +56,8 @@ jacocoTestReport { group = "Reporting" description = "Generate Jacoco coverage reports after running tests." reports { - xml.enabled true - html.enabled true + xml { enabled true } + html { enabled true } } } diff --git a/bolts-tasks/src/main/java/com/parse/boltsinternal/AndroidExecutors.java b/bolts-tasks/src/main/java/com/parse/boltsinternal/AndroidExecutors.java index 2dcc65f11..5cdde6816 100644 --- a/bolts-tasks/src/main/java/com/parse/boltsinternal/AndroidExecutors.java +++ b/bolts-tasks/src/main/java/com/parse/boltsinternal/AndroidExecutors.java @@ -35,6 +35,7 @@ /* package */ static final long KEEP_ALIVE_TIME = 1L; private static final AndroidExecutors INSTANCE = new AndroidExecutors(); + /** * Nexus 5: Quad-Core Moto X: Dual-Core * @@ -43,6 +44,7 @@ *

https://github.com/android/platform_frameworks_base/commit/719c44e03b97e850a46136ba336d729f5fbd1f47 */ private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors(); + /* package */ static final int CORE_POOL_SIZE = CPU_COUNT + 1; /* package */ static final int MAX_POOL_SIZE = CPU_COUNT * 2 + 1; private final Executor uiThread; diff --git a/bolts-tasks/src/main/java/com/parse/boltsinternal/CancellationTokenSource.java b/bolts-tasks/src/main/java/com/parse/boltsinternal/CancellationTokenSource.java index 2ca4a19f9..210eae9cf 100644 --- a/bolts-tasks/src/main/java/com/parse/boltsinternal/CancellationTokenSource.java +++ b/bolts-tasks/src/main/java/com/parse/boltsinternal/CancellationTokenSource.java @@ -46,7 +46,9 @@ public boolean isCancellationRequested() { } } - /** @return the token that can be passed to asynchronous method to control cancellation. */ + /** + * @return the token that can be passed to asynchronous method to control cancellation. + */ public CancellationToken getToken() { synchronized (lock) { throwIfClosed(); diff --git a/bolts-tasks/src/main/java/com/parse/boltsinternal/Task.java b/bolts-tasks/src/main/java/com/parse/boltsinternal/Task.java index 8e73588b2..4cb36b396 100644 --- a/bolts-tasks/src/main/java/com/parse/boltsinternal/Task.java +++ b/bolts-tasks/src/main/java/com/parse/boltsinternal/Task.java @@ -28,8 +28,10 @@ public class Task { /** An {@link java.util.concurrent.Executor} that executes tasks in parallel. */ public static final ExecutorService BACKGROUND_EXECUTOR = BoltsExecutors.background(); + /** An {@link java.util.concurrent.Executor} that executes tasks on the UI thread. */ public static final Executor UI_THREAD_EXECUTOR = AndroidExecutors.uiThread(); + /** * An {@link java.util.concurrent.Executor} that executes tasks in the current thread unless the * stack runs too deep, at which point it will delegate to {@link Task#BACKGROUND_EXECUTOR} in @@ -541,28 +543,36 @@ public boolean isCompleted() { } } - /** @return {@code true} if the task was cancelled, {@code false} otherwise. */ + /** + * @return {@code true} if the task was cancelled, {@code false} otherwise. + */ public boolean isCancelled() { synchronized (lock) { return cancelled; } } - /** @return {@code true} if the task has an error, {@code false} otherwise. */ + /** + * @return {@code true} if the task has an error, {@code false} otherwise. + */ public boolean isFaulted() { synchronized (lock) { return getError() != null; } } - /** @return The result of the task, if set. {@code null} otherwise. */ + /** + * @return The result of the task, if set. {@code null} otherwise. + */ public TResult getResult() { synchronized (lock) { return result; } } - /** @return The error for the task, if set. {@code null} otherwise. */ + /** + * @return The error for the task, if set. {@code null} otherwise. + */ public Exception getError() { synchronized (lock) { if (error != null) { diff --git a/bolts-tasks/src/main/java/com/parse/boltsinternal/TaskCompletionSource.java b/bolts-tasks/src/main/java/com/parse/boltsinternal/TaskCompletionSource.java index 4406cefbd..4513b76d6 100644 --- a/bolts-tasks/src/main/java/com/parse/boltsinternal/TaskCompletionSource.java +++ b/bolts-tasks/src/main/java/com/parse/boltsinternal/TaskCompletionSource.java @@ -24,7 +24,9 @@ public TaskCompletionSource() { task = new Task<>(); } - /** @return the Task associated with this TaskCompletionSource. */ + /** + * @return the Task associated with this TaskCompletionSource. + */ public Task getTask() { return task; } diff --git a/build.gradle b/build.gradle index 04721faf7..783c39f09 100644 --- a/build.gradle +++ b/build.gradle @@ -1,23 +1,23 @@ buildscript { - ext.kotlin_version = "1.7.10" + ext.kotlin_version = "1.9.20" ext.jacocoVersion = '0.8.12' + ext.spotlessVersion = '6.25.0' + repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.3' + classpath 'com.android.tools.build:gradle:8.5.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jacoco:org.jacoco.core:$jacocoVersion" - classpath "com.dicedmelon.gradle:jacoco-android:0.1.5" - classpath "io.freefair.gradle:android-gradle-plugins:4.2.0-m1" - classpath "com.diffplug.spotless:spotless-plugin-gradle:5.17.1" + classpath "io.freefair.gradle:android-gradle-plugins:7.2.0-m1" + classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion" } } plugins { id "com.github.ben-manes.versions" version "0.28.0" - id "com.diffplug.spotless" version "5.17.1" + id "com.diffplug.spotless" version "$spotlessVersion" } allprojects { @@ -39,7 +39,7 @@ allprojects { } kotlin { target '**/*.kt' - ktlint().userData(["disabled_rules": "no-wildcard-imports"]) + ktlint() trimTrailingWhitespace() indentWithSpaces() endWithNewline() diff --git a/coroutines/build.gradle b/coroutines/build.gradle index bf4bce59c..c1ede84be 100644 --- a/coroutines/build.gradle +++ b/coroutines/build.gradle @@ -5,7 +5,8 @@ apply plugin: "io.freefair.android-javadoc-jar" apply plugin: "io.freefair.android-sources-jar" android { - compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'com.parse.coroutines' + compileSdk rootProject.ext.compileSdkVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -37,6 +38,10 @@ android { kotlinOptions { jvmTarget = "1.8" } + + buildFeatures { + buildConfig true + } } ext { @@ -54,7 +59,7 @@ afterEvaluate { publishing { publications { release(MavenPublication) { - from components.release + from components.findByName('release') } } } diff --git a/coroutines/src/main/java/com/parse/coroutines/ParseCloudCoroutinesExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseCloudCoroutinesExtensions.kt index 7e774c5d8..c01bbe6c8 100644 --- a/coroutines/src/main/java/com/parse/coroutines/ParseCloudCoroutinesExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseCloudCoroutinesExtensions.kt @@ -7,11 +7,17 @@ import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine -suspend fun callCloudFunction(functionName: String, params: Map): T { +suspend fun callCloudFunction( + functionName: String, + params: Map, +): T { return suspendCoroutine { continuation -> ParseCloud.callFunctionInBackground(functionName, params) { result, e -> - if (e == null) continuation.resume(result) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(result) + } else { + continuation.resumeWithException(e) + } } } } diff --git a/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesExtensions.kt index 210148d99..bfef47f91 100644 --- a/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesExtensions.kt @@ -11,8 +11,11 @@ suspend fun ParseObject.suspendFetch(): T { return suspendCoroutine { continuation -> fetchInBackground { obj, e -> - if (e == null) continuation.resume(obj) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(obj) + } else { + continuation.resumeWithException(e) + } } } } @@ -21,8 +24,11 @@ suspend fun ParseObject.suspendFetchIfNeeded(): T { return suspendCoroutine { continuation -> fetchIfNeededInBackground { obj, e -> - if (e == null) continuation.resume(obj) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(obj) + } else { + continuation.resumeWithException(e) + } } } } @@ -31,8 +37,11 @@ suspend fun ParseObject.fetchFromLocal(): T { return suspendCoroutine { continuation -> fetchFromLocalDatastoreInBackground { obj, e -> - if (e == null) continuation.resume(obj) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(obj) + } else { + continuation.resumeWithException(e) + } } } } diff --git a/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesWriteExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesWriteExtensions.kt index ce3512c0c..061feba86 100644 --- a/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesWriteExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesWriteExtensions.kt @@ -10,8 +10,11 @@ import kotlin.coroutines.suspendCoroutine suspend fun ParseObject.suspendSave() { return suspendCoroutine { continuation -> saveInBackground { - if (it == null) continuation.resume(Unit) - else continuation.resumeWithException(it) + if (it == null) { + continuation.resume(Unit) + } else { + continuation.resumeWithException(it) + } } } } @@ -19,8 +22,11 @@ suspend fun ParseObject.suspendSave() { suspend fun ParseObject.suspendPin() { return suspendCoroutine { continuation -> pinInBackground { - if (it == null) continuation.resume(Unit) - else continuation.resumeWithException(it) + if (it == null) { + continuation.resume(Unit) + } else { + continuation.resumeWithException(it) + } } } } diff --git a/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesBuilder.kt b/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesBuilder.kt index 8b2d30988..478456f43 100644 --- a/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesBuilder.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesBuilder.kt @@ -13,7 +13,7 @@ import kotlin.coroutines.EmptyCoroutineContext fun CoroutineScope.launchQuery( query: ParseQuery, context: CoroutineContext = EmptyCoroutineContext, - block: suspend ParseQueryOperation.() -> Unit + block: suspend ParseQueryOperation.() -> Unit, ): Job { return launch(context) { block.invoke(ParseQueryOperationImpl(query)) diff --git a/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesExtensions.kt index a0749d22f..b8bbb85b4 100644 --- a/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesExtensions.kt @@ -19,8 +19,11 @@ internal suspend fun ParseQuery.findInternal(): List { } findInBackground { objects, e -> - if (e == null) continuation.resume(objects) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(objects) + } else { + continuation.resumeWithException(e) + } } } } @@ -36,8 +39,11 @@ internal suspend fun ParseQuery.getInternal(id: String): T } getInBackground(id) { obj, e -> - if (e == null) continuation.resume(obj) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(obj) + } else { + continuation.resumeWithException(e) + } } } } @@ -53,8 +59,11 @@ internal suspend fun ParseQuery.firstInternal(): T { } getFirstInBackground { obj, e -> - if (e == null) continuation.resume(obj) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(obj) + } else { + continuation.resumeWithException(e) + } } } } @@ -70,8 +79,11 @@ internal suspend fun ParseQuery.countInternal(): Int { } countInBackground { count, e -> - if (e == null) continuation.resume(count) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(count) + } else { + continuation.resumeWithException(e) + } } } } diff --git a/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperation.kt b/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperation.kt index 8f0ecc642..44c6366c7 100644 --- a/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperation.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperation.kt @@ -2,7 +2,10 @@ package com.parse.coroutines interface ParseQueryOperation { suspend fun find(): List + suspend fun get(id: String): T + suspend fun first(): T + suspend fun count(): Int } diff --git a/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperationImpl.kt b/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperationImpl.kt index cdf41b612..0cb5c7556 100644 --- a/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperationImpl.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperationImpl.kt @@ -5,7 +5,6 @@ import com.parse.ParseQuery class ParseQueryOperationImpl(private val query: ParseQuery) : ParseQueryOperation { - override suspend fun find(): List = query.findInternal() override suspend fun get(id: String): T = query.getInternal(id) diff --git a/coroutines/src/main/java/com/parse/coroutines/ParseTaskExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseTaskExtensions.kt index 061f2b5ed..336244dbc 100644 --- a/coroutines/src/main/java/com/parse/coroutines/ParseTaskExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseTaskExtensions.kt @@ -12,19 +12,27 @@ import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine @Suppress("BlockingMethodInNonBlockingContext") -suspend fun Task.suspendGet(dispatcher: CoroutineDispatcher = Dispatchers.IO) = withContext(dispatcher) { - return@withContext suspendCoroutine { continuation -> - waitForCompletion() - if (isFaulted) continuation.resumeWithException(error) - else continuation.resume(result) +suspend fun Task.suspendGet(dispatcher: CoroutineDispatcher = Dispatchers.IO) = + withContext(dispatcher) { + return@withContext suspendCoroutine { continuation -> + waitForCompletion() + if (isFaulted) { + continuation.resumeWithException(error) + } else { + continuation.resume(result) + } + } } -} @Suppress("BlockingMethodInNonBlockingContext") -suspend fun Task.suspendRun(dispatcher: CoroutineDispatcher = Dispatchers.IO) = withContext(dispatcher) { - return@withContext suspendCoroutine { continuation -> - waitForCompletion() - if (isFaulted) continuation.resumeWithException(error) - else continuation.resume(Unit) +suspend fun Task.suspendRun(dispatcher: CoroutineDispatcher = Dispatchers.IO) = + withContext(dispatcher) { + return@withContext suspendCoroutine { continuation -> + waitForCompletion() + if (isFaulted) { + continuation.resumeWithException(error) + } else { + continuation.resume(Unit) + } + } } -} diff --git a/coroutines/src/main/java/com/parse/coroutines/ParseUserCoroutinesExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseUserCoroutinesExtensions.kt index 09606e80e..bf8cc0b85 100644 --- a/coroutines/src/main/java/com/parse/coroutines/ParseUserCoroutinesExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseUserCoroutinesExtensions.kt @@ -10,17 +10,26 @@ import kotlin.coroutines.suspendCoroutine suspend fun ParseUser.suspendSignUp(): ParseUser { return suspendCoroutine { continuation -> signUpInBackground { e -> - if (e == null) continuation.resume(this) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(this) + } else { + continuation.resumeWithException(e) + } } } } -suspend fun parseLogIn(username: String, password: String): ParseUser { +suspend fun parseLogIn( + username: String, + password: String, +): ParseUser { return suspendCoroutine { continuation -> ParseUser.logInInBackground(username, password) { user, e -> - if (e == null) continuation.resume(user) - else continuation.resumeWithException(e) + if (e == null) { + continuation.resume(user) + } else { + continuation.resumeWithException(e) + } } } } diff --git a/facebook/build.gradle b/facebook/build.gradle index 89ed422f8..b4daf4c5e 100644 --- a/facebook/build.gradle +++ b/facebook/build.gradle @@ -4,7 +4,8 @@ apply plugin: "io.freefair.android-javadoc-jar" apply plugin: "io.freefair.android-sources-jar" android { - compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'com.parse.facebook' + compileSdk rootProject.ext.compileSdkVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -32,6 +33,10 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + buildFeatures { + buildConfig true + } } dependencies { @@ -48,7 +53,7 @@ afterEvaluate { publishing { publications { release(MavenPublication) { - from components.release + from components.findByName('release') } } } diff --git a/facebook/src/main/java/com/parse/facebook/FacebookController.java b/facebook/src/main/java/com/parse/facebook/FacebookController.java index f353ca4d0..a2fc2a946 100644 --- a/facebook/src/main/java/com/parse/facebook/FacebookController.java +++ b/facebook/src/main/java/com/parse/facebook/FacebookController.java @@ -40,6 +40,7 @@ class FacebookController { // Used as default activityCode. From FacebookSdk.java. public static final int DEFAULT_AUTH_ACTIVITY_CODE = 0xface; + /** Precise date format required for auth expiration data. */ private static final DateFormat PRECISE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); diff --git a/fcm/build.gradle b/fcm/build.gradle index c8542a26b..1ac303e1b 100644 --- a/fcm/build.gradle +++ b/fcm/build.gradle @@ -4,7 +4,8 @@ apply plugin: "io.freefair.android-javadoc-jar" apply plugin: "io.freefair.android-sources-jar" android { - compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'com.parse.fcm' + compileSdk rootProject.ext.compileSdkVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -33,6 +34,9 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } + buildFeatures { + buildConfig true + } } dependencies { @@ -44,7 +48,7 @@ afterEvaluate { publishing { publications { release(MavenPublication) { - from components.release + from components.findByName('release') } } } diff --git a/google/build.gradle b/google/build.gradle index b4ab74106..b5fdc26ec 100644 --- a/google/build.gradle +++ b/google/build.gradle @@ -5,7 +5,8 @@ apply plugin: "io.freefair.android-javadoc-jar" apply plugin: "io.freefair.android-sources-jar" android { - compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'com.parse.google' + compileSdk rootProject.ext.compileSdkVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -37,6 +38,10 @@ android { kotlinOptions { jvmTarget = "1.8" } + + buildFeatures { + buildConfig true + } } dependencies { @@ -51,7 +56,7 @@ afterEvaluate { publishing { publications { release(MavenPublication) { - from components.release + from components.findByName('release') } } } diff --git a/google/src/main/java/com/parse/google/ParseGoogleUtils.kt b/google/src/main/java/com/parse/google/ParseGoogleUtils.kt index d9bad72e0..01920d795 100644 --- a/google/src/main/java/com/parse/google/ParseGoogleUtils.kt +++ b/google/src/main/java/com/parse/google/ParseGoogleUtils.kt @@ -21,7 +21,6 @@ import com.parse.boltsinternal.TaskCompletionSource */ @Suppress("MemberVisibilityCanBePrivate", "unused") object ParseGoogleUtils { - private const val AUTH_TYPE = "google" private lateinit var clientId: String @@ -70,7 +69,11 @@ object ParseGoogleUtils { * } */ @JvmStatic - fun logIn(activity: Activity, launcher: ActivityResultLauncher, callback: LogInCallback) { + fun logIn( + activity: Activity, + launcher: ActivityResultLauncher, + callback: LogInCallback, + ) { checkInitialization() this.currentCallback = callback val googleSignInClient = buildGoogleSignInClient(activity) @@ -86,7 +89,10 @@ object ParseGoogleUtils { * @return true if the result could be handled. */ @JvmStatic - fun onActivityResult(resultCode: Int, data: Intent?): Boolean { + fun onActivityResult( + resultCode: Int, + data: Intent?, + ): Boolean { if (resultCode != Activity.RESULT_OK) { return false } @@ -108,7 +114,10 @@ object ParseGoogleUtils { * @return A task that will be resolved when linking is complete. */ @JvmStatic - fun unlinkInBackground(user: ParseUser, callback: SaveCallback): Task { + fun unlinkInBackground( + user: ParseUser, + callback: SaveCallback, + ): Task { return callbackOnMainThreadAsync(unlinkInBackground(user), callback, false) } @@ -133,7 +142,10 @@ object ParseGoogleUtils { * @return A task that will be resolved when linking is complete. */ @JvmStatic - fun linkInBackground(user: ParseUser, account: GoogleSignInAccount): Task { + fun linkInBackground( + user: ParseUser, + account: GoogleSignInAccount, + ): Task { return user.linkWithInBackground(AUTH_TYPE, getAuthData(account)) } @@ -182,21 +194,26 @@ object ParseGoogleUtils { return authData } - private fun onSignInCallbackResult(user: ParseUser?, exception: Exception?) { - val exceptionToThrow = when (exception) { - is ParseException -> exception - null -> null - else -> ParseException(exception) - } + private fun onSignInCallbackResult( + user: ParseUser?, + exception: Exception?, + ) { + val exceptionToThrow = + when (exception) { + is ParseException -> exception + null -> null + else -> ParseException(exception) + } currentCallback?.done(user, exceptionToThrow) } private fun buildGoogleSignInClient(context: Context): GoogleSignInClient { - val signInOptions = GoogleSignInOptions.Builder() - .requestId() - .requestEmail() - .requestIdToken(clientId) - .build() + val signInOptions = + GoogleSignInOptions.Builder() + .requestId() + .requestEmail() + .requestIdToken(clientId) + .build() return GoogleSignIn.getClient(context, signInOptions) } @@ -207,7 +224,7 @@ object ParseGoogleUtils { private fun callbackOnMainThreadAsync( task: Task, callback: SaveCallback, - reportCancellation: Boolean + reportCancellation: Boolean, ): Task { return callbackOnMainThreadInternalAsync(task, callback, reportCancellation) } @@ -220,7 +237,7 @@ object ParseGoogleUtils { private fun callbackOnMainThreadInternalAsync( task: Task, callback: Any?, - reportCancellation: Boolean + reportCancellation: Boolean, ): Task { if (callback == null) { return task @@ -242,7 +259,8 @@ object ParseGoogleUtils { callback.done(error as? ParseException) } else if (callback is LogInCallback) { callback.done( - task2.result as? ParseUser, error as? ParseException + task2.result as? ParseUser, + error as? ParseException, ) } } finally { @@ -260,7 +278,7 @@ object ParseGoogleUtils { } } null - } + }, ) return tcs.task } diff --git a/gradle.properties b/gradle.properties index 5582f05c9..756ba2f83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ version = 4.3.0 android.enableJetifier = true android.useAndroidX = true +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f2026a82a..1baee4355 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Apr 16 09:27:50 CEST 2022 +#Thu Aug 15 20:11:31 GST 2024 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/ktx/build.gradle b/ktx/build.gradle index 14b773df4..cf2353f63 100644 --- a/ktx/build.gradle +++ b/ktx/build.gradle @@ -5,7 +5,8 @@ apply plugin: "io.freefair.android-javadoc-jar" apply plugin: "io.freefair.android-sources-jar" android { - compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'com.parse.ktx' + compileSdk rootProject.ext.compileSdkVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -38,6 +39,10 @@ android { kotlinOptions { jvmTarget = "1.8" } + + buildFeatures { + buildConfig true + } } dependencies { @@ -49,7 +54,7 @@ afterEvaluate { publishing { publications { release(MavenPublication) { - from components.release + from components.findByName('release') } } } diff --git a/ktx/src/main/java/com/parse/ktx/ParseObject.kt b/ktx/src/main/java/com/parse/ktx/ParseObject.kt index 61fba1b63..27adae8aa 100644 --- a/ktx/src/main/java/com/parse/ktx/ParseObject.kt +++ b/ktx/src/main/java/com/parse/ktx/ParseObject.kt @@ -30,7 +30,10 @@ inline fun ParseObject.getAsOrNull(key: String): T? { /** * [ParseObject.put] the value, doing nothing if the value is null */ -inline fun ParseObject.putOrIgnore(key: String, value: Any?) { +inline fun ParseObject.putOrIgnore( + key: String, + value: Any?, +) { if (value != null) { put(key, value) } @@ -39,7 +42,10 @@ inline fun ParseObject.putOrIgnore(key: String, value: Any?) { /** * [ParseObject.put] the value, or [ParseObject.remove] it if the value is null */ -inline fun ParseObject.putOrRemove(key: String, value: Any?) { +inline fun ParseObject.putOrRemove( + key: String, + value: Any?, +) { if (value == null) { remove(key) } else { diff --git a/ktx/src/main/java/com/parse/ktx/ParseQuery.kt b/ktx/src/main/java/com/parse/ktx/ParseQuery.kt index b1242acc9..4ee2e7845 100644 --- a/ktx/src/main/java/com/parse/ktx/ParseQuery.kt +++ b/ktx/src/main/java/com/parse/ktx/ParseQuery.kt @@ -1,4 +1,5 @@ @file:Suppress("NOTHING_TO_INLINE", "unused") + package com.parse.ktx import com.parse.ParseException @@ -76,7 +77,7 @@ fun ParseQuery.selectKeys(keys: Collection> */ inline fun ParseQuery.whereContainedIn( key: KProperty, - values: Collection + values: Collection, ): ParseQuery { return whereContainedIn(key.name, values) } @@ -86,7 +87,7 @@ inline fun ParseQuery.whereContainedIn( */ inline fun ParseQuery.whereContains( key: KProperty, - substring: String + substring: String, ): ParseQuery { return whereContains(key.name, substring) } @@ -96,7 +97,7 @@ inline fun ParseQuery.whereContains( */ inline fun ParseQuery.whereContainsAll( key: KProperty, - values: Collection + values: Collection, ): ParseQuery { return whereContainsAll(key.name, values) } @@ -106,7 +107,7 @@ inline fun ParseQuery.whereContainsAll( */ inline fun ParseQuery.whereContainsAllStartsWith( key: KProperty, - values: Collection + values: Collection, ): ParseQuery { return whereContainsAllStartsWith(key.name, values) } @@ -124,7 +125,7 @@ inline fun ParseQuery.whereDoesNotExist(key: KProperty ParseQuery.whereDoesNotMatchKeyInQuery( key: KProperty, keyInQuery: KProperty, - query: ParseQuery + query: ParseQuery, ): ParseQuery { return whereDoesNotMatchKeyInQuery(key.name, keyInQuery.name, query) } @@ -134,7 +135,7 @@ inline fun ParseQuery.whereDoesNotMatchKeyInQuery( */ inline fun ParseQuery.whereDoesNotMatchQuery( key: KProperty, - query: ParseQuery + query: ParseQuery, ): ParseQuery { return whereDoesNotMatchQuery(key.name, query) } @@ -144,7 +145,7 @@ inline fun ParseQuery.whereDoesNotMatchQuery( */ inline fun ParseQuery.whereEndsWith( key: KProperty, - suffix: String + suffix: String, ): ParseQuery { return whereEndsWith(key.name, suffix) } @@ -154,7 +155,7 @@ inline fun ParseQuery.whereEndsWith( */ inline fun ParseQuery.whereEqualTo( key: KProperty, - value: Any? + value: Any?, ): ParseQuery { return whereEqualTo(key.name, value) } @@ -171,7 +172,7 @@ inline fun ParseQuery.whereExists(key: KProperty): Pa */ inline fun ParseQuery.whereFullText( key: KProperty, - text: String + text: String, ): ParseQuery { return whereFullText(key.name, text) } @@ -181,7 +182,7 @@ inline fun ParseQuery.whereFullText( */ inline fun ParseQuery.whereGreaterThan( key: KProperty, - value: Any + value: Any, ): ParseQuery { return whereGreaterThan(key.name, value) } @@ -191,7 +192,7 @@ inline fun ParseQuery.whereGreaterThan( */ inline fun ParseQuery.whereGreaterThanOrEqualTo( key: KProperty, - value: Any + value: Any, ): ParseQuery { return whereGreaterThanOrEqualTo(key.name, value) } @@ -201,7 +202,7 @@ inline fun ParseQuery.whereGreaterThanOrEqualTo( */ inline fun ParseQuery.whereLessThan( key: KProperty, - value: Any + value: Any, ): ParseQuery { return whereLessThan(key.name, value) } @@ -211,7 +212,7 @@ inline fun ParseQuery.whereLessThan( */ inline fun ParseQuery.whereLessThanOrEqualTo( key: KProperty, - value: Any + value: Any, ): ParseQuery { return whereLessThanOrEqualTo(key.name, value) } @@ -221,7 +222,7 @@ inline fun ParseQuery.whereLessThanOrEqualTo( */ inline fun ParseQuery.whereMatches( key: KProperty, - regex: String + regex: String, ): ParseQuery { return whereMatches(key.name, regex) } @@ -232,7 +233,7 @@ inline fun ParseQuery.whereMatches( inline fun ParseQuery.whereMatches( key: KProperty, regex: String, - modifiers: String + modifiers: String, ): ParseQuery { return whereMatches(key.name, regex, modifiers) } @@ -243,7 +244,7 @@ inline fun ParseQuery.whereMatches( inline fun ParseQuery.whereMatchesKeyInQuery( key: KProperty, keyInQuery: KProperty, - query: ParseQuery + query: ParseQuery, ): ParseQuery { return whereMatchesKeyInQuery(key.name, keyInQuery.name, query) } @@ -253,7 +254,7 @@ inline fun ParseQuery.whereMatchesKeyInQuery( */ inline fun ParseQuery.whereMatchesQuery( key: KProperty, - query: ParseQuery + query: ParseQuery, ): ParseQuery { return whereMatchesQuery(key.name, query) } @@ -263,7 +264,7 @@ inline fun ParseQuery.whereMatchesQuery( */ inline fun ParseQuery.whereNear( key: KProperty, - point: ParseGeoPoint + point: ParseGeoPoint, ): ParseQuery { return whereNear(key.name, point) } @@ -273,7 +274,7 @@ inline fun ParseQuery.whereNear( */ inline fun ParseQuery.whereNotContainedIn( key: KProperty, - values: Collection + values: Collection, ): ParseQuery { return whereNotContainedIn(key.name, values) } @@ -283,7 +284,7 @@ inline fun ParseQuery.whereNotContainedIn( */ inline fun ParseQuery.whereNotEqualTo( key: KProperty, - value: Any? + value: Any?, ): ParseQuery { return whereNotEqualTo(key.name, value) } @@ -293,7 +294,7 @@ inline fun ParseQuery.whereNotEqualTo( */ inline fun ParseQuery.wherePolygonContains( key: KProperty, - point: ParseGeoPoint + point: ParseGeoPoint, ): ParseQuery { return wherePolygonContains(key.name, point) } @@ -303,7 +304,7 @@ inline fun ParseQuery.wherePolygonContains( */ inline fun ParseQuery.whereStartsWith( key: KProperty, - prefix: String + prefix: String, ): ParseQuery { return whereStartsWith(key.name, prefix) } @@ -314,7 +315,7 @@ inline fun ParseQuery.whereStartsWith( inline fun ParseQuery.whereWithinGeoBox( key: KProperty, southwest: ParseGeoPoint, - northeast: ParseGeoPoint + northeast: ParseGeoPoint, ): ParseQuery { return whereWithinGeoBox(key.name, southwest, northeast) } @@ -325,7 +326,7 @@ inline fun ParseQuery.whereWithinGeoBox( inline fun ParseQuery.whereWithinKilometers( key: KProperty, point: ParseGeoPoint, - maxDistance: Double + maxDistance: Double, ): ParseQuery { return whereWithinKilometers(key.name, point, maxDistance) } @@ -336,7 +337,7 @@ inline fun ParseQuery.whereWithinKilometers( inline fun ParseQuery.whereWithinMiles( key: KProperty, point: ParseGeoPoint, - maxDistance: Double + maxDistance: Double, ): ParseQuery { return whereWithinMiles(key.name, point, maxDistance) } @@ -346,7 +347,7 @@ inline fun ParseQuery.whereWithinMiles( */ inline fun ParseQuery.whereWithinPolygon( key: KProperty, - points: List + points: List, ): ParseQuery { return whereWithinPolygon(key.name, points) } @@ -356,7 +357,7 @@ inline fun ParseQuery.whereWithinPolygon( */ inline fun ParseQuery.whereWithinPolygon( key: KProperty, - polygon: ParsePolygon + polygon: ParsePolygon, ): ParseQuery { return whereWithinPolygon(key.name, polygon) } @@ -367,7 +368,7 @@ inline fun ParseQuery.whereWithinPolygon( inline fun ParseQuery.whereWithinRadians( key: KProperty, point: ParseGeoPoint, - maxDistance: Double + maxDistance: Double, ): ParseQuery { return whereWithinRadians(key.name, point, maxDistance) } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/BooleanParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/BooleanParseDelegate.kt index 04d784548..909562123 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/BooleanParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/BooleanParseDelegate.kt @@ -9,12 +9,18 @@ import kotlin.reflect.KProperty * A [Boolean] property delegation for [ParseObject]. */ class BooleanParseDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): Boolean { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): Boolean { return parseObject.getBoolean(name ?: property.name) } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: Boolean) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: Boolean, + ) { parseObject.put(name ?: property.name, value) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/BytesParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/BytesParseDelegate.kt index 8e39ed1bc..d5eb474fb 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/BytesParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/BytesParseDelegate.kt @@ -10,12 +10,18 @@ import kotlin.reflect.KProperty * A [ByteArray] property delegation for [ParseObject]. */ class BytesParseDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): ByteArray? { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): ByteArray? { return parseObject.getBytes(name ?: property.name) } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: ByteArray?) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: ByteArray?, + ) { parseObject.putOrIgnore(name ?: property.name, value) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/DoubleParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/DoubleParseDelegate.kt index 8a79d3a71..bcec820f7 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/DoubleParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/DoubleParseDelegate.kt @@ -9,12 +9,18 @@ import kotlin.reflect.KProperty * A [Double] property delegation for [ParseObject]. */ class DoubleParseDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): Double { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): Double { return parseObject.getDouble(name ?: property.name) } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: Double) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: Double, + ) { parseObject.put(name ?: property.name, value) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/EnumParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/EnumParseDelegate.kt index 9f45ec6c0..e659615fc 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/EnumParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/EnumParseDelegate.kt @@ -14,21 +14,27 @@ import kotlin.reflect.KProperty class EnumParseDelegate>( private val name: String?, private val default: T?, - private val enumClass: Class + private val enumClass: Class, ) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): T { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): T { return try { java.lang.Enum.valueOf( enumClass, - parseObject.getString(name ?: property.name)!!.uppercase() + parseObject.getString(name ?: property.name)!!.uppercase(), ) } catch (e: Exception) { default ?: throw e } } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, t: T) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + t: T, + ) { parseObject.put(name ?: property.name, t.name.lowercase()) } } @@ -37,12 +43,13 @@ class EnumParseDelegate>( * Returns a [Enum] property delegate for [ParseObject]s. This uses custom implementation for get * to retrieve a local version of the your enum and [ParseObject.put]. */ -inline fun > enumAttribute(default: T? = null) = - EnumParseDelegate(null, default, T::class.java) +inline fun > enumAttribute(default: T? = null) = EnumParseDelegate(null, default, T::class.java) /** * Returns a [Enum] property delegate for [ParseObject]s. This uses custom implementation for get * to retrieve a local version of the your enum and [ParseObject.put]. */ -inline fun > enumAttribute(name: String? = null, default: T? = null) = - EnumParseDelegate(name, default, T::class.java) +inline fun > enumAttribute( + name: String? = null, + default: T? = null, +) = EnumParseDelegate(name, default, T::class.java) diff --git a/ktx/src/main/java/com/parse/ktx/delegates/FloatParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/FloatParseDelegate.kt index 2023f8e26..ad031d3bb 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/FloatParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/FloatParseDelegate.kt @@ -9,12 +9,18 @@ import kotlin.reflect.KProperty * A [Float] property delegation for [ParseObject]. */ class FloatParseDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): Float { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): Float { return parseObject.getDouble(name ?: property.name).toFloat() } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: Float) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: Float, + ) { parseObject.put(name ?: property.name, value) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/IntParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/IntParseDelegate.kt index 6d5c051e1..30242e197 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/IntParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/IntParseDelegate.kt @@ -9,12 +9,18 @@ import kotlin.reflect.KProperty * A [Int] property delegation for [ParseObject]. */ class IntParseDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): Int { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): Int { return parseObject.getInt(name ?: property.name) } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: Int) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: Int, + ) { parseObject.put(name ?: property.name, value) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/JsonArrayParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/JsonArrayParseDelegate.kt index 5a0132bb7..79cddf22d 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/JsonArrayParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/JsonArrayParseDelegate.kt @@ -11,12 +11,18 @@ import kotlin.reflect.KProperty * A [JSONArray] property delegation for [ParseObject]. */ class JsonArrayParseDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): JSONArray? { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): JSONArray? { return parseObject.getJSONArray(name ?: property.name) } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: JSONArray?) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: JSONArray?, + ) { parseObject.putOrIgnore(name ?: property.name, value) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/JsonObjectParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/JsonObjectParseDelegate.kt index cf50b1a62..f4dc80878 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/JsonObjectParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/JsonObjectParseDelegate.kt @@ -11,12 +11,18 @@ import kotlin.reflect.KProperty * A [JSONObject] property delegation for [ParseObject]. */ class JsonObjectParseDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): JSONObject? { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): JSONObject? { return parseObject.getJSONObject(name ?: property.name) } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: JSONObject?) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: JSONObject?, + ) { parseObject.putOrIgnore(name ?: property.name, value) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/ListParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/ListParseDelegate.kt index f0b2dd616..b93a80a1d 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/ListParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/ListParseDelegate.kt @@ -10,15 +10,17 @@ import kotlin.reflect.KProperty * A [List] property delegation for [ParseObject]. */ class ListParseDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): MutableList? { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): MutableList? { return parseObject.getList(name ?: property.name) as? MutableList } operator fun setValue( parseObject: ParseObject, property: KProperty<*>, - value: MutableList? + value: MutableList?, ) { parseObject.putOrIgnore(name ?: property.name, value) } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/LongParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/LongParseDelegate.kt index c04add1b7..faa171ed0 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/LongParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/LongParseDelegate.kt @@ -9,12 +9,18 @@ import kotlin.reflect.KProperty * A [Long] property delegation for [ParseObject]. */ class LongParseDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): Long { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): Long { return parseObject.getLong(name ?: property.name) } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: Long) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: Long, + ) { parseObject.put(name ?: property.name, value) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/MapParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/MapParseDelegate.kt index f72788ed7..ce8abfe2d 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/MapParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/MapParseDelegate.kt @@ -10,10 +10,9 @@ import kotlin.reflect.KProperty * A [Map] property delegation for [ParseObject]. */ class MapParseDelegate(private val name: String?) { - operator fun getValue( parseObject: ParseObject, - property: KProperty<*> + property: KProperty<*>, ): MutableMap? { return parseObject.getMap(name ?: property.name) as? MutableMap } @@ -21,7 +20,7 @@ class MapParseDelegate(private val name: String?) { operator fun setValue( parseObject: ParseObject, property: KProperty<*>, - value: MutableMap? + value: MutableMap?, ) { parseObject.putOrIgnore(name ?: property.name, value) } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/ParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/ParseDelegate.kt index adf5959a2..1b708e3cb 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/ParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/ParseDelegate.kt @@ -11,13 +11,19 @@ import kotlin.reflect.KProperty * A generic property delegation for [ParseObject]. */ class ParseDelegate(private val name: String?) { - @Suppress("UNCHECKED_CAST") - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): T { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): T { return parseObject.getAs(name ?: property.name) } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: T) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: T, + ) { parseObject.putOrIgnore(name ?: property.name, value) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/ParseRelationDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/ParseRelationDelegate.kt index a358da10f..3f618b6a8 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/ParseRelationDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/ParseRelationDelegate.kt @@ -10,8 +10,10 @@ import kotlin.reflect.KProperty * A [ParseRelation] property delegation for [ParseObject]. */ class ParseRelationDelegate(private val name: String?) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): ParseRelation { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): ParseRelation { return parseObject.getRelation(name ?: property.name) } } @@ -20,5 +22,4 @@ class ParseRelationDelegate(private val name: String?) { * Returns a [ParseRelation] property delegate for [ParseObject]s. * This uses [ParseObject.getRelation]. */ -inline fun relationAttribute(name: String? = null) = - ParseRelationDelegate(name) +inline fun relationAttribute(name: String? = null) = ParseRelationDelegate(name) diff --git a/ktx/src/main/java/com/parse/ktx/delegates/SafeParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/SafeParseDelegate.kt index 351645bfb..20469f4dd 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/SafeParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/SafeParseDelegate.kt @@ -12,15 +12,18 @@ import kotlin.reflect.KProperty * exceptions. */ class SafeParseDelegate(private val name: String?) { - @Suppress("UNCHECKED_CAST") - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): T? { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): T? { val name = name ?: property.name - val value = if (parseObject.has(name)) { - parseObject.get(name) - } else { - null - } + val value = + if (parseObject.has(name)) { + parseObject.get(name) + } else { + null + } return if (JSONObject.NULL == value) { null } else { @@ -28,7 +31,11 @@ class SafeParseDelegate(private val name: String?) { } } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, t: T?) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + t: T?, + ) { parseObject.putOrRemove(property.name, t) } } diff --git a/ktx/src/main/java/com/parse/ktx/delegates/StringParseDelegate.kt b/ktx/src/main/java/com/parse/ktx/delegates/StringParseDelegate.kt index bf4cdff43..bf8a1c668 100644 --- a/ktx/src/main/java/com/parse/ktx/delegates/StringParseDelegate.kt +++ b/ktx/src/main/java/com/parse/ktx/delegates/StringParseDelegate.kt @@ -11,14 +11,20 @@ import kotlin.reflect.KProperty */ class StringParseDelegate( private val name: String?, - private val filter: (String) -> String + private val filter: (String) -> String, ) { - - operator fun getValue(parseObject: ParseObject, property: KProperty<*>): S { + operator fun getValue( + parseObject: ParseObject, + property: KProperty<*>, + ): S { return parseObject.getAs(name ?: property.name) } - operator fun setValue(parseObject: ParseObject, property: KProperty<*>, value: S) { + operator fun setValue( + parseObject: ParseObject, + property: KProperty<*>, + value: S, + ) { if (value != null) { parseObject.put(name ?: property.name, filter.invoke(value)) } @@ -31,7 +37,7 @@ class StringParseDelegate( */ inline fun nullableStringAttribute( name: String? = null, - noinline filter: (String) -> String = { it } + noinline filter: (String) -> String = { it }, ) = StringParseDelegate(name, filter) /** @@ -40,5 +46,5 @@ inline fun nullableStringAttribute( */ inline fun stringAttribute( name: String? = null, - noinline filter: (String) -> String = { it } + noinline filter: (String) -> String = { it }, ) = StringParseDelegate(name, filter) diff --git a/parse/build.gradle b/parse/build.gradle index 9253396d9..6fe029679 100644 --- a/parse/build.gradle +++ b/parse/build.gradle @@ -4,7 +4,8 @@ apply plugin: "io.freefair.android-javadoc-jar" apply plugin: "io.freefair.android-sources-jar" android { - compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'com.parse' + compileSdk rootProject.ext.compileSdkVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -15,6 +16,18 @@ android { testOptions { unitTests { includeAndroidResources = true + + all { + // Configure JaCoCo options + jacoco { + includeNoLocationClasses = true + excludes.add("jdk.internal.*") + } + // Configure test logging + testLogging { + events("failed") + } + } } } @@ -25,13 +38,13 @@ android { buildTypes { debug { testCoverageEnabled = true - buildConfigField("String","PARSE_VERSION","\"${version}\"") + buildConfigField("String", "PARSE_VERSION", "\"${version}\"") } release { minifyEnabled false testCoverageEnabled = false proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - buildConfigField("String","PARSE_VERSION","\"${version}\"") + buildConfigField("String", "PARSE_VERSION", "\"${version}\"") } } @@ -39,6 +52,10 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + buildFeatures { + buildConfig true + } } ext { @@ -65,39 +82,26 @@ afterEvaluate { publishing { publications { release(MavenPublication) { - from components.release + from components.findByName('release') } } } } //endregion - -//region Code Coverage - -apply plugin: "com.dicedmelon.gradle.jacoco-android" - -jacoco { - toolVersion = "0.8.12" -} - -tasks.withType(Test) { - jacoco.includeNoLocationClasses = true - jacoco.excludes = ['jdk.internal.*'] - testLogging { - events "SKIPPED", "FAILED" - showStandardStreams true - showExceptions true - showCauses true - showStackTraces true - exceptionFormat "full" +//region Testing + +tasks.withType(JacocoReport).configureEach { + jacoco.toolVersion = rootProject.ext.jacocoVersion + reports { + csv.required.set(false) + html.required.set(true) + xml.required.set(true) } } -jacocoAndroidUnitTestReport { - csv.enabled false - html.enabled true - xml.enabled true +tasks.withType(Test).configureEach { + useJUnitPlatform() } //endregion diff --git a/parse/src/main/java/com/parse/ManifestInfo.java b/parse/src/main/java/com/parse/ManifestInfo.java index 31b221976..276fcd14b 100644 --- a/parse/src/main/java/com/parse/ManifestInfo.java +++ b/parse/src/main/java/com/parse/ManifestInfo.java @@ -150,7 +150,9 @@ private static ApplicationInfo getApplicationInfo(Context context, int flags) { } } - /** @return A {@link Bundle} if meta-data is specified in AndroidManifest, otherwise null. */ + /** + * @return A {@link Bundle} if meta-data is specified in AndroidManifest, otherwise null. + */ public static Bundle getApplicationMetadata(Context context) { ApplicationInfo info = getApplicationInfo(context, PackageManager.GET_META_DATA); if (info != null) { diff --git a/parse/src/main/java/com/parse/OfflineSQLiteOpenHelper.java b/parse/src/main/java/com/parse/OfflineSQLiteOpenHelper.java index 76fda7b50..235f0bf8e 100644 --- a/parse/src/main/java/com/parse/OfflineSQLiteOpenHelper.java +++ b/parse/src/main/java/com/parse/OfflineSQLiteOpenHelper.java @@ -27,6 +27,7 @@ class OfflineSQLiteOpenHelper extends ParseSQLiteOpenHelper { /** Various keys in the table of ParseObjects. */ /* package */ /* package */ static final String KEY_UUID = "uuid"; + /* package */ static final String KEY_CLASS_NAME = "className"; /* package */ static final String KEY_OBJECT_ID = "objectId"; /* package */ static final String KEY_JSON = "json"; @@ -38,6 +39,7 @@ class OfflineSQLiteOpenHelper extends ParseSQLiteOpenHelper { /** Various keys in the table of Dependencies. */ // TODO (grantland): rename this since we use UUIDs as keys now. root_uuid? /* package */ static final String KEY_KEY = "key"; + // static final String KEY_UUID = "uuid"; /** The SQLite Database name. */ diff --git a/parse/src/main/java/com/parse/OfflineStore.java b/parse/src/main/java/com/parse/OfflineStore.java index accd4b78f..95e10e7a8 100644 --- a/parse/src/main/java/com/parse/OfflineStore.java +++ b/parse/src/main/java/com/parse/OfflineStore.java @@ -34,15 +34,18 @@ class OfflineStore { /** SQLite has a max of 999 SQL variables in a single statement. */ private static final int MAX_SQL_VARIABLES = 999; + // Lock for all members of the store. private final Object lock = new Object(); // Helper for accessing the database. private final OfflineSQLiteOpenHelper helper; + /** * In-memory map of UUID -> ParseObject. This is used so that we can always return the same * instance for a given object. The only objects in this map are ones that are in the database. */ private final WeakValueHashMap uuidToObjectMap = new WeakValueHashMap<>(); + /** * In-memory map of ParseObject -> UUID. This is used to that when we see an unsaved ParseObject * that's already in the database, we can update the same record in the database. It stores a @@ -50,12 +53,14 @@ class OfflineStore { * finished, there will be a row for this UUID in the database. */ private final WeakHashMap> objectToUuidMap = new WeakHashMap<>(); + /** * In-memory set of ParseObjects that have been fetched from the local database already. If the * object is in the map, a fetch of it has been started. If the value is a finished task, then * the fetch was completed. */ private final WeakHashMap> fetchedObjects = new WeakHashMap<>(); + /** * In-memory map of (className, objectId) -> ParseObject. This is used so that we can always * return the same instance for a given object. Objects in this map may or may not be in the diff --git a/parse/src/main/java/com/parse/Parse.java b/parse/src/main/java/com/parse/Parse.java index c3ad5c1ee..66fa2502a 100644 --- a/parse/src/main/java/com/parse/Parse.java +++ b/parse/src/main/java/com/parse/Parse.java @@ -288,7 +288,9 @@ public static void destroy() { allowCustomObjectId = false; } - /** @return {@code True} if {@link #initialize} has been called, otherwise {@code false}. */ + /** + * @return {@code True} if {@link #initialize} has been called, otherwise {@code false}. + */ static boolean isInitialized() { return ParsePlugins.get() != null; } diff --git a/parse/src/main/java/com/parse/ParseACL.java b/parse/src/main/java/com/parse/ParseACL.java index cec83f940..16ce8f894 100644 --- a/parse/src/main/java/com/parse/ParseACL.java +++ b/parse/src/main/java/com/parse/ParseACL.java @@ -44,6 +44,7 @@ public ParseACL[] newArray(int size) { // State private final Map permissionsById = new HashMap<>(); private boolean shared; + /** A lazy user that hasn't been saved to Parse. */ // TODO (grantland): This should be a list for multiple lazy users with read/write permissions. private ParseUser unresolvedUser; diff --git a/parse/src/main/java/com/parse/ParseClassName.java b/parse/src/main/java/com/parse/ParseClassName.java index d2f4a3562..ab5b436a2 100644 --- a/parse/src/main/java/com/parse/ParseClassName.java +++ b/parse/src/main/java/com/parse/ParseClassName.java @@ -21,6 +21,8 @@ @Inherited @Documented public @interface ParseClassName { - /** @return The Parse class name associated with the ParseObject subclass. */ + /** + * @return The Parse class name associated with the ParseObject subclass. + */ String value(); } diff --git a/parse/src/main/java/com/parse/ParseException.java b/parse/src/main/java/com/parse/ParseException.java index 5dc3b5f90..1fab37cf6 100644 --- a/parse/src/main/java/com/parse/ParseException.java +++ b/parse/src/main/java/com/parse/ParseException.java @@ -16,124 +16,167 @@ @SuppressWarnings("unused") public class ParseException extends Exception { public static final int OTHER_CAUSE = -1; + /** Error code indicating the connection to the Parse servers failed. */ public static final int CONNECTION_FAILED = 100; + /** Error code indicating the specified object doesn't exist. */ public static final int OBJECT_NOT_FOUND = 101; + /** * Error code indicating you tried to query with a datatype that doesn't support it, like exact * matching an array or object. */ public static final int INVALID_QUERY = 102; + /** * Error code indicating a missing or invalid classname. Classnames are case-sensitive. They * must start with a letter, and a-zA-Z0-9_ are the only valid characters. */ public static final int INVALID_CLASS_NAME = 103; + /** Error code indicating an unspecified object id. */ public static final int MISSING_OBJECT_ID = 104; + /** * Error code indicating an invalid key name. Keys are case-sensitive. They must start with a * letter, and a-zA-Z0-9_ are the only valid characters. */ public static final int INVALID_KEY_NAME = 105; + /** * Error code indicating a malformed pointer. You should not see this unless you have been * mucking about changing internal Parse code. */ public static final int INVALID_POINTER = 106; + /** * Error code indicating that badly formed JSON was received upstream. This either indicates you * have done something unusual with modifying how things encode to JSON, or the network is * failing badly. */ public static final int INVALID_JSON = 107; + /** * Error code indicating that the feature you tried to access is only available internally for * testing purposes. */ public static final int COMMAND_UNAVAILABLE = 108; + /** You must call Parse.initialize before using the Parse library. */ public static final int NOT_INITIALIZED = 109; + /** Error code indicating that a field was set to an inconsistent type. */ public static final int INCORRECT_TYPE = 111; + /** * Error code indicating an invalid channel name. A channel name is either an empty string (the * broadcast channel) or contains only a-zA-Z0-9_ characters and starts with a letter. */ public static final int INVALID_CHANNEL_NAME = 112; + /** Error code indicating that push is misconfigured. */ public static final int PUSH_MISCONFIGURED = 115; + /** Error code indicating that the object is too large. */ public static final int OBJECT_TOO_LARGE = 116; + /** Error code indicating that the operation isn't allowed for clients. */ public static final int OPERATION_FORBIDDEN = 119; + /** Error code indicating the result was not found in the cache. */ public static final int CACHE_MISS = 120; + /** Error code indicating that an invalid key was used in a nested JSONObject. */ public static final int INVALID_NESTED_KEY = 121; + /** * Error code indicating that an invalid filename was used for ParseFile. A valid file name * contains only a-zA-Z0-9_. characters and is between 1 and 128 characters. */ public static final int INVALID_FILE_NAME = 122; + /** Error code indicating an invalid ACL was provided. */ public static final int INVALID_ACL = 123; + /** * Error code indicating that the request timed out on the server. Typically this indicates that * the request is too expensive to run. */ public static final int TIMEOUT = 124; + /** Error code indicating that the email address was invalid. */ public static final int INVALID_EMAIL_ADDRESS = 125; + /** Error code indicating that required field is missing. */ public static final int MISSING_REQUIRED_FIELD_ERROR = 135; + /** Error code indicating that a unique field was given a value that is already taken. */ public static final int DUPLICATE_VALUE = 137; + /** Error code indicating that a role's name is invalid. */ public static final int INVALID_ROLE_NAME = 139; + /** Error code indicating that an application quota was exceeded. Upgrade to resolve. */ public static final int EXCEEDED_QUOTA = 140; + /** Error code indicating that a Cloud Code script failed. */ public static final int SCRIPT_ERROR = 141; + /** Error code indicating that cloud code validation failed. */ public static final int VALIDATION_ERROR = 142; + /** Error code indicating that deleting a file failed. */ public static final int FILE_DELETE_ERROR = 153; + /** Error code indicating that the application has exceeded its request limit. */ public static final int REQUEST_LIMIT_EXCEEDED = 155; + /** Error code indicating that the provided event name is invalid. */ public static final int INVALID_EVENT_NAME = 160; + /** Error code indicating that the username is missing or empty. */ public static final int USERNAME_MISSING = 200; + /** Error code indicating that the password is missing or empty. */ public static final int PASSWORD_MISSING = 201; + /** Error code indicating that the username has already been taken. */ public static final int USERNAME_TAKEN = 202; + /** Error code indicating that the email has already been taken. */ public static final int EMAIL_TAKEN = 203; + /** Error code indicating that the email is missing, but must be specified. */ public static final int EMAIL_MISSING = 204; + /** Error code indicating that a user with the specified email was not found. */ public static final int EMAIL_NOT_FOUND = 205; + /** Error code indicating that a user object without a valid session could not be altered. */ public static final int SESSION_MISSING = 206; + /** Error code indicating that a user can only be created through signup. */ public static final int MUST_CREATE_USER_THROUGH_SIGNUP = 207; + /** Error code indicating that an an account being linked is already linked to another user. */ public static final int ACCOUNT_ALREADY_LINKED = 208; + /** Error code indicating that the current session token is invalid. */ public static final int INVALID_SESSION_TOKEN = 209; + /** * Error code indicating that a user cannot be linked to an account because that account's id * could not be found. */ public static final int LINKED_ID_MISSING = 250; + /** * Error code indicating that a user with a linked (e.g. Facebook) account has an invalid * session. */ public static final int INVALID_LINKED_SESSION = 251; + /** * Error code indicating that a service being linked (e.g. Facebook or Twitter) is unsupported. */ diff --git a/parse/src/main/java/com/parse/ParseFile.java b/parse/src/main/java/com/parse/ParseFile.java index 76a95e072..db4ae2bd6 100644 --- a/parse/src/main/java/com/parse/ParseFile.java +++ b/parse/src/main/java/com/parse/ParseFile.java @@ -59,11 +59,13 @@ public ParseFile[] newArray(int size) { /* package for tests */ final TaskQueue taskQueue = new TaskQueue(); private final Set> currentTasks = Collections.synchronizedSet(new HashSet<>()); + /** * Staging of {@code ParseFile}'s data is stored in memory until the {@code ParseFile} has been * successfully synced with the server. */ /* package for tests */ byte[] data; + /* package for tests */ File file; /* package for tests */ Uri uri; private State state; diff --git a/parse/src/main/java/com/parse/ParseKeyValueCache.java b/parse/src/main/java/com/parse/ParseKeyValueCache.java index 1267181a1..8b0d5d702 100644 --- a/parse/src/main/java/com/parse/ParseKeyValueCache.java +++ b/parse/src/main/java/com/parse/ParseKeyValueCache.java @@ -28,6 +28,7 @@ class ParseKeyValueCache { /* package */ static final int DEFAULT_MAX_KEY_VALUE_CACHE_FILES = 1000; private static final String TAG = "ParseKeyValueCache"; private static final String DIR_NAME = "ParseKeyValueCache"; + /** Prevent multiple threads from modifying the cache at the same time. */ private static final Object MUTEX_IO = new Object(); diff --git a/parse/src/main/java/com/parse/ParseObject.java b/parse/src/main/java/com/parse/ParseObject.java index 5407bcf3e..210aa2cb0 100644 --- a/parse/src/main/java/com/parse/ParseObject.java +++ b/parse/src/main/java/com/parse/ParseObject.java @@ -57,6 +57,7 @@ public class ParseObject implements Parcelable { * @see #unpin() */ public static final String DEFAULT_PIN = "_default"; + /* REST JSON Keys */ diff --git a/parse/src/main/java/com/parse/ParsePinningEventuallyQueue.java b/parse/src/main/java/com/parse/ParsePinningEventuallyQueue.java index a7d3a3bfc..3f344967e 100644 --- a/parse/src/main/java/com/parse/ParsePinningEventuallyQueue.java +++ b/parse/src/main/java/com/parse/ParsePinningEventuallyQueue.java @@ -32,21 +32,26 @@ class ParsePinningEventuallyQueue extends ParseEventuallyQueue { private static final String TAG = "ParsePinningEventuallyQueue"; private final Object connectionLock = new Object(); private final ParseHttpClient httpClient; + /** Lock to make sure all changes to the below parameters happen atomically. */ private final Object taskQueueSyncLock = new Object(); + /** TCS that is held until a {@link ParseOperationSet} is completed. */ private final HashMap> pendingOperationSetUUIDTasks = new HashMap<>(); + /** * Queue for reading/writing eventually operations. Makes all reads/writes atomic operations. */ private final TaskQueue taskQueue = new TaskQueue(); + /** * Queue for running *Eventually operations. It uses waitForOperationSetAndEventuallyPin to * synchronize {@link ParseObject#taskQueue} until they are both ready to process the same * ParseOperationSet. */ private final TaskQueue operationSetTaskQueue = new TaskQueue(); + /** * List of {@link ParseOperationSet#uuid} that are currently queued in {@link * ParsePinningEventuallyQueue#operationSetTaskQueue}. @@ -54,13 +59,17 @@ class ParsePinningEventuallyQueue extends ParseEventuallyQueue { private final ArrayList eventuallyPinUUIDQueue = new ArrayList<>(); private final ConnectivityNotifier notifier; + /** Map of eventually operation UUID to TCS that is resolved when the operation is complete. */ private final HashMap> pendingEventuallyTasks = new HashMap<>(); + /** Map of eventually operation UUID to matching ParseOperationSet. */ private final HashMap uuidToOperationSet = new HashMap<>(); + /** Map of eventually operation UUID to matching EventuallyPin. */ private final HashMap uuidToEventuallyPin = new HashMap<>(); + /** * TCS that is created when there is no internet connection and isn't resolved until * connectivity is achieved. diff --git a/parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java b/parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java index 489fa01ef..6335b0890 100644 --- a/parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java +++ b/parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java @@ -84,14 +84,19 @@ public class ParsePushBroadcastReceiver extends BroadcastReceiver { * {@code null}. */ public static final String KEY_PUSH_CHANNEL = "com.parse.Channel"; + /** The name of the Intent extra which contains the JSON payload of the Notification. */ public static final String KEY_PUSH_DATA = "com.parse.Data"; + /** The name of the Intent fired when a push has been received. */ public static final String ACTION_PUSH_RECEIVE = "com.parse.push.intent.RECEIVE"; + /** The name of the Intent fired when a notification has been opened. */ public static final String ACTION_PUSH_OPEN = "com.parse.push.intent.OPEN"; + /** The name of the Intent fired when a notification has been dismissed. */ public static final String ACTION_PUSH_DELETE = "com.parse.push.intent.DELETE"; + /** The name of the meta-data field used to override the icon used in Notifications. */ public static final String PROPERTY_PUSH_ICON = "com.parse.push.notification_icon"; diff --git a/parse/src/main/java/com/parse/ParseQuery.java b/parse/src/main/java/com/parse/ParseQuery.java index 132ad4e39..67c44b3ef 100644 --- a/parse/src/main/java/com/parse/ParseQuery.java +++ b/parse/src/main/java/com/parse/ParseQuery.java @@ -282,7 +282,9 @@ public T getFirst() throws ParseException { return ParseTaskUtils.wait(getFirstInBackground()); } - /** @return the caching policy. */ + /** + * @return the caching policy. + */ public CachePolicy getCachePolicy() { return builder.getCachePolicy(); } diff --git a/parse/src/main/java/com/parse/ParseRequest.java b/parse/src/main/java/com/parse/ParseRequest.java index 1ba304913..d80f35611 100644 --- a/parse/src/main/java/com/parse/ParseRequest.java +++ b/parse/src/main/java/com/parse/ParseRequest.java @@ -41,6 +41,7 @@ public Thread newThread(@NonNull Runnable r) { r, "ParseRequest.NETWORK_EXECUTOR-thread-" + mCount.getAndIncrement()); } }; + /** * We want to use more threads than default in {@code bolts.Executors} since most of the time * the threads will be asleep waiting for data. diff --git a/parse/src/main/java/com/parse/ParseSession.java b/parse/src/main/java/com/parse/ParseSession.java index a2d5b2e4d..a656966d0 100644 --- a/parse/src/main/java/com/parse/ParseSession.java +++ b/parse/src/main/java/com/parse/ParseSession.java @@ -122,7 +122,9 @@ public static ParseQuery getQuery() { return !READ_ONLY_KEYS.contains(key); } - /** @return the session token for a user, if they are logged in. */ + /** + * @return the session token for a user, if they are logged in. + */ public String getSessionToken() { return getString(KEY_SESSION_TOKEN); } diff --git a/parse/src/main/java/com/parse/ParseUser.java b/parse/src/main/java/com/parse/ParseUser.java index 6fdf91845..c52c34862 100644 --- a/parse/src/main/java/com/parse/ParseUser.java +++ b/parse/src/main/java/com/parse/ParseUser.java @@ -717,7 +717,9 @@ public void remove(@NonNull String key) { } } - /** @return the session token for a user, if they are logged in. */ + /** + * @return the session token for a user, if they are logged in. + */ public String getSessionToken() { return getState().sessionToken(); } diff --git a/parse/src/main/java/com/parse/TaskQueue.java b/parse/src/main/java/com/parse/TaskQueue.java index f53f5c90e..b58561f6f 100644 --- a/parse/src/main/java/com/parse/TaskQueue.java +++ b/parse/src/main/java/com/parse/TaskQueue.java @@ -17,6 +17,7 @@ /** A helper class for enqueueing tasks */ class TaskQueue { private final Lock lock = new ReentrantLock(); + /** * We only need to keep the tail of the queue. Cancelled tasks will just complete * normally/immediately when their turn arrives. diff --git a/parse/src/test/java/com/parse/ParseACLTest.java b/parse/src/test/java/com/parse/ParseACLTest.java index 34aa29037..6a9384fc0 100644 --- a/parse/src/test/java/com/parse/ParseACLTest.java +++ b/parse/src/test/java/com/parse/ParseACLTest.java @@ -468,6 +468,7 @@ public void testSetUserWriteAccessWithLazyUser() { assertTrue(acl.getWriteAccess(user)); assertEquals(1, acl.getPermissionsById().size()); } + // endregion // region testGetAccess diff --git a/parse/src/test/java/com/parse/ParsePushTest.java b/parse/src/test/java/com/parse/ParsePushTest.java index ca169a9bd..87182dfb4 100644 --- a/parse/src/test/java/com/parse/ParsePushTest.java +++ b/parse/src/test/java/com/parse/ParsePushTest.java @@ -641,6 +641,7 @@ public void testSendFail() throws Exception { assertTrue(state.channelSet().contains("test")); assertTrue(state.channelSet().contains("testAgain")); } + // endregion // region testSendMessageInBackground diff --git a/rxjava/build.gradle b/rxjava/build.gradle index a6c7b0ba0..50ca41d0b 100644 --- a/rxjava/build.gradle +++ b/rxjava/build.gradle @@ -6,7 +6,8 @@ apply plugin: "io.freefair.android-sources-jar" android { - compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'com.parse.rxjava' + compileSdk rootProject.ext.compileSdkVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -38,6 +39,10 @@ android { kotlinOptions { jvmTarget = "1.8" } + + buildFeatures { + buildConfig true + } } dependencies { @@ -50,7 +55,7 @@ afterEvaluate { publishing { publications { release(MavenPublication) { - from components.release + from components.findByName('release') } } } diff --git a/rxjava/src/main/java/com/parse/rxjava/Extensions.kt b/rxjava/src/main/java/com/parse/rxjava/Extensions.kt index 2db9b2123..442af0e1c 100644 --- a/rxjava/src/main/java/com/parse/rxjava/Extensions.kt +++ b/rxjava/src/main/java/com/parse/rxjava/Extensions.kt @@ -7,7 +7,7 @@ import com.parse.boltsinternal.Task import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Single -fun Task.toSingle(): Single { +fun Task.toSingle(): Single { return Single.defer { this.waitForCompletion() if (isFaulted) { diff --git a/twitter/build.gradle b/twitter/build.gradle index 7aabc1c57..641a13013 100644 --- a/twitter/build.gradle +++ b/twitter/build.gradle @@ -4,7 +4,8 @@ apply plugin: "io.freefair.android-javadoc-jar" apply plugin: "io.freefair.android-sources-jar" android { - compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'com.parse.twitter' + compileSdk rootProject.ext.compileSdkVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -32,6 +33,10 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + buildFeatures { + buildConfig true + } } dependencies { @@ -48,7 +53,7 @@ afterEvaluate { publishing { publications { release(MavenPublication) { - from components.release + from components.findByName('release') } } } diff --git a/twitter/src/main/java/com/parse/twitter/ParseTwitterUtils.java b/twitter/src/main/java/com/parse/twitter/ParseTwitterUtils.java index 76707cb6f..2966df279 100644 --- a/twitter/src/main/java/com/parse/twitter/ParseTwitterUtils.java +++ b/twitter/src/main/java/com/parse/twitter/ParseTwitterUtils.java @@ -108,7 +108,9 @@ private static void checkInitialization() { } } - /** @return {@code true} if the user is linked to a Twitter account. */ + /** + * @return {@code true} if the user is linked to a Twitter account. + */ public static boolean isLinked(ParseUser user) { return user.isLinked(AUTH_TYPE); }