Skip to content

Commit

Permalink
Merge pull request #1882 from OneSignal/fix/linting
Browse files Browse the repository at this point in the history
Fix linting errors in GitHub Actions build test workflow
  • Loading branch information
jennantilla authored and jinliu9508 committed Jan 31, 2024
2 parents 98490fe + 0faa7ee commit c7d69a4
Show file tree
Hide file tree
Showing 346 changed files with 8,123 additions and 4,916 deletions.
3 changes: 3 additions & 0 deletions OneSignalSDK/onesignal/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ dependencies {

ktlint {
version = "$ktlintVersion"
additionalEditorconfig = [
"max_line_length": "500",
]
}

apply from: '../maven-push.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ import kotlin.coroutines.CoroutineContext
* The result provided by [Continue.with] when the Java user wants to inspect the results
* of a Kotlin coroutine completing.
*/
class ContinueResult<R> (
class ContinueResult<R>(
/**
* Whether the coroutine call was successful (`true`) or not (`false`)
*/
val isSuccess: Boolean,

/**
* The data that is returned by the coroutine when complete. This will be `null` if [isSuccess]
* is `false`.
*/
val data: R?,

/**
* The throwable that was thrown by the coroutine. This will be `null` if [isSuccess] is `true`.
*/
Expand All @@ -47,7 +45,6 @@ class ContinueResult<R> (
* ```
*/
object Continue {

/**
* Allows java code to provide a lambda as a continuation to a Kotlin coroutine.
*
Expand All @@ -62,7 +59,10 @@ object Continue {
@RequiresApi(Build.VERSION_CODES.N)
@JvmOverloads
@JvmStatic
fun <R> with(onFinished: Consumer<ContinueResult<R>>, context: CoroutineContext = Dispatchers.Main): Continuation<R> {
fun <R> with(
onFinished: Consumer<ContinueResult<R>>,
context: CoroutineContext = Dispatchers.Main,
): Continuation<R> {
return object : Continuation<R> {
override val context: CoroutineContext
get() = context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@ interface IOneSignal {
* The user manager for accessing user-scoped
* management.
*/
val User: IUserManager
val user: IUserManager

/**
* The session manager for accessing session-scoped management.
*/
val Session: ISessionManager
val session: ISessionManager

/**
* The notification manager for accessing device-scoped
* notification management.
*/
val Notifications: INotificationsManager
val notifications: INotificationsManager

/**
* The location manager for accessing device-scoped
* location management.
*/
val Location: ILocationManager
val location: ILocationManager

/**
* The In App Messaging manager for accessing device-scoped
* IAP management.
*/
val InAppMessages: IInAppMessagesManager
val inAppMessages: IInAppMessagesManager

/**
* Access to debug the SDK in the event additional information is required to diagnose any
* SDK-related issues.
*
* WARNING: This should not be used in a production setting.
*/
val Debug: IDebugManager
val debug: IDebugManager

/**
* Determines whether a user must consent to privacy prior
Expand Down Expand Up @@ -83,11 +83,14 @@ interface IOneSignal {
*
* @return true if the SDK could be successfully initialized, false otherwise.
*/
fun initWithContext(context: Context, appId: String?): Boolean
fun initWithContext(
context: Context,
appId: String?,
): Boolean

/**
* Login to OneSignal under the user identified by the [externalId] provided. The act of
* logging a user into the OneSignal SDK will switch the [User] context to that specific user.
* logging a user into the OneSignal SDK will switch the [user] context to that specific user.
*
* * If the [externalId] exists the user will be retrieved and the context set from that
* user information. If operations have already been performed under a guest user, they
Expand All @@ -106,11 +109,15 @@ interface IOneSignal {
* trust for the login operation. Required when identity verification has been enabled. See
* [Identity Verification | OneSignal](https://documentation.onesignal.com/docs/identity-verification)
*/
fun login(externalId: String, jwtBearerToken: String? = null)
fun login(
externalId: String,
jwtBearerToken: String? = null,
)

fun login(externalId: String) = login(externalId, null)

/**
* Logout the user previously logged in via [login]. The [User] property now references
* Logout the user previously logged in via [login]. The [user] property now references
* a new device-scoped user. A device-scoped user has no user identity that can later
* be retrieved, except through this device as long as the app remains installed and the app
* data is not cleared.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,39 @@ object OneSignal {
*/
@JvmStatic
val User: IUserManager
get() = oneSignal.User
get() = oneSignal.user

/**
* The session manager for accessing session-scoped management. Initialized only after [initWithContext]
* has been called.
*/
@JvmStatic
val Session: ISessionManager
get() = oneSignal.Session
get() = oneSignal.session

/**
* The notification manager for accessing device-scoped notification management. Initialized
* only after [initWithContext] has been called.
*/
@JvmStatic
val Notifications: INotificationsManager
get() = oneSignal.Notifications
get() = oneSignal.notifications

/**
* The location manager for accessing device-scoped location management. Initialized
* only after [initWithContext] has been called.
*/
@JvmStatic
val Location: ILocationManager
get() = oneSignal.Location
get() = oneSignal.location

/**
* The In App Messaging manager for accessing device-scoped IAP management. Initialized
* only after [initWithContext] has been called.
*/
@JvmStatic
val InAppMessages: IInAppMessagesManager
get() = oneSignal.InAppMessages
get() = oneSignal.inAppMessages

/**
* Access to debug the SDK in the additional information is required to diagnose any
Expand All @@ -85,7 +85,7 @@ object OneSignal {
*/
@JvmStatic
val Debug: IDebugManager
get() = oneSignal.Debug
get() = oneSignal.debug

/**
* Determines whether a user must consent to privacy prior
Expand All @@ -96,7 +96,9 @@ object OneSignal {
@JvmStatic
var consentRequired: Boolean
get() = oneSignal.consentRequired
set(value) { oneSignal.consentRequired = value }
set(value) {
oneSignal.consentRequired = value
}

/**
* Indicates whether privacy consent has been granted. This field is only relevant when
Expand All @@ -105,15 +107,19 @@ object OneSignal {
@JvmStatic
var consentGiven: Boolean
get() = oneSignal.consentGiven
set(value) { oneSignal.consentGiven = value }
set(value) {
oneSignal.consentGiven = value
}

/**
* Whether to disable the "GMS is missing" prompt to the user.
*/
@JvmStatic
var disableGMSMissingPrompt: Boolean
get() = oneSignal.disableGMSMissingPrompt
set(value) { oneSignal.disableGMSMissingPrompt = value }
set(value) {
oneSignal.disableGMSMissingPrompt = value
}

/**
* Initialize the OneSignal SDK. This should be called during startup of the application.
Expand All @@ -122,7 +128,10 @@ object OneSignal {
* @param appId The application ID the OneSignal SDK is bound to.
*/
@JvmStatic
fun initWithContext(context: Context, appId: String) {
fun initWithContext(
context: Context,
appId: String,
) {
oneSignal.initWithContext(context, appId)
}

Expand Down Expand Up @@ -169,7 +178,10 @@ object OneSignal {
* [Identity Verification | OneSignal](https://documentation.onesignal.com/docs/identity-verification)
*/
@JvmStatic
fun login(externalId: String, jwtBearerToken: String? = null) = oneSignal.login(externalId, jwtBearerToken)
fun login(
externalId: String,
jwtBearerToken: String? = null,
) = oneSignal.login(externalId, jwtBearerToken)

/**
* Logout the user previously logged in via [login]. The [User] property now references
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import android.util.Log
// Designed as a compat for use of Android Support v4 revision 23.+ methods when an older revision of the library is included with the app developer's project.
class AndroidSupportV4Compat {
object ContextCompat {
fun checkSelfPermission(context: Context, permission: String): Int {
fun checkSelfPermission(
context: Context,
permission: String,
): Int {
// Catch for rare "Unknown exception code: 1 msg null" exception
// See https://github.com/one-signal/OneSignal-Android-SDK/issues/48 for more details.
return try {
Expand All @@ -50,7 +53,10 @@ class AndroidSupportV4Compat {
}
}

fun getColor(context: Context, id: Int): Int {
fun getColor(
context: Context,
id: Int,
): Int {
return if (Build.VERSION.SDK_INT > 22) {
context.getColor(id)
} else {
Expand All @@ -66,7 +72,11 @@ class AndroidSupportV4Compat {
}

internal object ActivityCompat {
fun requestPermissions(activity: Activity, permissions: Array<String?>, requestCode: Int) {
fun requestPermissions(
activity: Activity,
permissions: Array<String?>,
requestCode: Int,
) {
// OneSignal SDK code already checks that device is Android M, omit else code from the support library.
ActivityCompatApi23.requestPermissions(activity, permissions, requestCode)
}
Expand All @@ -81,7 +91,11 @@ class AndroidSupportV4Compat {

@TargetApi(23)
internal object ActivityCompatApi23 {
fun requestPermissions(activity: Activity, permissions: Array<String?>?, requestCode: Int) {
fun requestPermissions(
activity: Activity,
permissions: Array<String?>?,
requestCode: Int,
) {
if (activity is RequestPermissionsRequestCodeValidator) {
(activity as RequestPermissionsRequestCodeValidator).validateRequestPermissionsRequestCode(
requestCode,
Expand Down
Loading

0 comments on commit c7d69a4

Please sign in to comment.