Skip to content

Commit

Permalink
[expo][Android] Bump spotless (expo#25966)
Browse files Browse the repository at this point in the history
# Why

Bumps versions of `spotless` and `ktlint`.

# How

Bumped versions and adjusted rules to match what we had previously. 

# Test Plan

- bare-expo ✅
- expo go ✅
  • Loading branch information
lukmccall authored Dec 18, 2023
1 parent 19ec516 commit 266799a
Show file tree
Hide file tree
Showing 379 changed files with 1,527 additions and 945 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ class TestSuiteTests : BaseTestClass() {
@Rule
@JvmField
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
Manifest.permission.SYSTEM_ALERT_WINDOW, Manifest.permission.READ_CONTACTS,
Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR
Manifest.permission.SYSTEM_ALERT_WINDOW,
Manifest.permission.READ_CONTACTS,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_CALENDAR,
Manifest.permission.WRITE_CALENDAR
)

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ object TestContacts {
while (it.moveToNext()) {
val id = it.getString(it.getColumnIndex(ContactsContract.Contacts._ID))
val cur1 = cr.query(
ContactsContract.CommonDataKinds.Email.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?", arrayOf(id), null
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?",
arrayOf(id),
null
)
var shouldDelete = false
while (cur1!!.moveToNext()) {
Expand Down
35 changes: 24 additions & 11 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ plugins {
// WHEN_DISTRIBUTING_REMOVE_FROM_HERE
// We don't need linter on turtle.
plugins {
id "com.diffplug.spotless" version "5.14.1"
id "com.diffplug.spotless" version "6.23.3"
}
// WHEN_DISTRIBUTING_REMOVE_TO_HERE

Expand Down Expand Up @@ -135,16 +135,29 @@ subprojects { project ->
// TODO: (barthap) Replace this with raw string when dropped shell app macros
// The star "*" signs interferes with slash "/" and treated wildcard path as comment ¯\_(ツ)_/¯
targetExclude(["**", "versioned/host/exp/exponent/modules/api", "**", "*.kt"].join("/"))
ktlint("0.41.0").userData([
"disabled_rules" : "no-wildcard-imports,import-ordering",
"charset" : "utf-8",
"end_of_line" : "lf",
"indent_size" : "2",
"indent_style" : "space",
"insert_final_newline" : "true",
"tab_width" : "2",
"trim_trailing_whitespace" : "true"
])
ktlint("1.0.1")
.editorConfigOverride([
"ktlint_standard_no-wildcard-imports" : "disabled",
"ktlint_standard_import-ordering" : "disabled",
"ktlint_standard_filename" : "disabled",
"ktlint_standard_property-naming" : "disabled",
"ktlint_standard_discouraged-comment-location" : "disabled",
"ktlint_standard_comment-wrapping" : "disabled",
"ktlint_standard_function-naming" : "disabled",
"ktlint_standard_class-naming" : "disabled",
"ktlint_standard_package-name" : "disabled",
"ktlint_standard_multiline-expression-wrapping" : "disabled",
"charset" : "utf-8",
"end_of_line" : "lf",
"indent_size" : "2",
"continuation_indent_size" : "2",
"indent_style" : "space",
"insert_final_newline" : "true",
"tab_width" : "2",
"trim_trailing_whitespace" : "true",
"ij_kotlin_allow_trailing_comma_on_call_site": "false",
"ij_kotlin_allow_trailing_comma": "false"
])
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class ExpoUpdatesAppLoader @JvmOverloads constructor(
lateinit var kernel: Kernel

enum class AppLoaderStatus {
CHECKING_FOR_UPDATE, DOWNLOADING_NEW_UPDATE
CHECKING_FOR_UPDATE,
DOWNLOADING_NEW_UPDATE
}

var isEmergencyLaunch = false
Expand Down Expand Up @@ -139,7 +140,7 @@ class ExpoUpdatesAppLoader @JvmOverloads constructor(
configMap[UpdatesConfiguration.UPDATES_CONFIGURATION_CODE_SIGNING_CERTIFICATE] = context.assets.open("expo-root.pem").readBytes().decodeToString()
configMap[UpdatesConfiguration.UPDATES_CONFIGURATION_CODE_SIGNING_METADATA] = mapOf(
CODE_SIGNING_METADATA_KEY_ID_KEY to "expo-root",
CODE_SIGNING_METADATA_ALGORITHM_KEY to CodeSigningAlgorithm.RSA_SHA256.algorithmName,
CODE_SIGNING_METADATA_ALGORITHM_KEY to CodeSigningAlgorithm.RSA_SHA256.algorithmName
)
configMap[UpdatesConfiguration.UPDATES_CONFIGURATION_CODE_SIGNING_INCLUDE_MANIFEST_RESPONSE_CERTIFICATE_CHAIN] = true
configMap[UpdatesConfiguration.UPDATES_CONFIGURATION_CODE_SIGNING_ALLOW_UNSIGNED_MANIFESTS] = true
Expand Down Expand Up @@ -335,8 +336,8 @@ class ExpoUpdatesAppLoader @JvmOverloads constructor(
return !(
host == "exp.host" || host == "expo.io" || host == "exp.direct" || host == "expo.test" ||
host!!.endsWith(".exp.host") || host.endsWith(".expo.io") || host.endsWith(".exp.direct") || host.endsWith(
".expo.test"
)
".expo.test"
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ class ExponentManifest @Inject constructor(
private fun getIconFromCache(iconUrl: String?): Bitmap? {
return if (iconUrl == null || TextUtils.isEmpty(iconUrl)) {
BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher)
} else memoryCache[iconUrl]
} else {
memoryCache[iconUrl]
}
}

private fun loadIconTask(iconUrl: String?): Bitmap? {
Expand Down
4 changes: 3 additions & 1 deletion android/expoview/src/main/java/host/exp/exponent/RNObject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ class RNObject {
val name = clazz!!.name
return if (name.startsWith("abi")) {
name.substring(name.indexOf('.') + 1)
} else name
} else {
name
}
}

private fun objectsToJavaClassTypes(vararg objects: Any?): Array<Class<*>?> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ open class ExperienceActivity : BaseExperienceActivity(), StartReactInstanceDele
.setPositiveButton("Use cache", null)
.setNegativeButton("Reload") { _, _ ->
kernel.reloadVisibleExperience(
manifestUrl!!, false
manifestUrl!!,
false
)
}
.show()
Expand Down Expand Up @@ -625,7 +626,8 @@ open class ExperienceActivity : BaseExperienceActivity(), StartReactInstanceDele
override fun startReactInstance() {
Exponent.instance
.testPackagerStatus(
isDebugModeEnabled, manifest!!,
isDebugModeEnabled,
manifest!!,
object : Exponent.PackagerStatusCallback {
override fun onSuccess() {
reactInstanceManager = startReactInstance(
Expand Down Expand Up @@ -673,17 +675,21 @@ open class ExperienceActivity : BaseExperienceActivity(), StartReactInstanceDele
remoteViews.setOnClickPendingIntent(
R.id.home_image_button,
PendingIntent.getActivity(
this, 0,
homeIntent, mutableFlag
this,
0,
homeIntent,
mutableFlag
)
)

// Reload
remoteViews.setOnClickPendingIntent(
R.id.reload_button,
PendingIntent.getService(
this, 0,
ExponentIntentService.getActionReloadExperience(this, manifestUrl!!), PendingIntent.FLAG_UPDATE_CURRENT or mutableFlag
this,
0,
ExponentIntentService.getActionReloadExperience(this, manifestUrl!!),
PendingIntent.FLAG_UPDATE_CURRENT or mutableFlag
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ open class HomeActivity : BaseExperienceActivity() {
SplashScreenModule::class.java,
TrackingTransparencyModule::class.java,
StoreReviewModule::class.java,
WebBrowserModule::class.java,
WebBrowserModule::class.java
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ abstract class ReactNativeActivity :
containerView.removeAllViews()
}
// region Loading

/**
* Successfully finished loading
*/
Expand Down Expand Up @@ -576,7 +577,9 @@ abstract class ReactNativeActivity :
// in scoped application we don't have `don't ask again` button
return if (checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED) {
true
} else super.shouldShowRequestPermissionRationale(permission)
} else {
super.shouldShowRequestPermissionRationale(permission)
}
}

override fun requestPermissions(
Expand Down Expand Up @@ -633,11 +636,11 @@ abstract class ReactNativeActivity :
val uri = Uri.parse(manifestUrl)
val host = uri.host
return if (host != null && (
host == "exp.host" || host == "expo.io" || host == "exp.direct" || host == "expo.test" ||
host.endsWith(".exp.host") || host.endsWith(".expo.io") || host.endsWith(".exp.direct") || host.endsWith(
".expo.test"
host == "exp.host" || host == "expo.io" || host == "exp.direct" || host == "expo.test" ||
host.endsWith(".exp.host") || host.endsWith(".expo.io") || host.endsWith(".exp.direct") || host.endsWith(
".expo.test"
)
)
)
) {
val pathSegments = uri.pathSegments
val builder = uri.buildUpon()
Expand All @@ -658,6 +661,7 @@ abstract class ReactNativeActivity :
companion object {
private val TAG = ReactNativeActivity::class.java.simpleName
private const val VIEW_TEST_INTERVAL_MS: Long = 20

@JvmStatic protected var errorQueue: Queue<ExponentError> = LinkedList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class ManagedAppSplashScreenConfiguration private constructor() {

return if (ColorParser.isValid(backgroundColor)) {
Color.parseColor(backgroundColor)
} else null
} else {
null
}
}

/**
Expand All @@ -69,7 +71,11 @@ class ManagedAppSplashScreenConfiguration private constructor() {
val dpiRelatedImageUrl = getStringFromJSONObject(
androidSplash,
*arrayOf(
"xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi"
"xxxhdpi",
"xxhdpi",
"xhdpi",
"hdpi",
"mdpi"
)
.map { s -> "${s}Url" }
.map { s -> arrayOf(s) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class InternalHeadlessAppLoader(private val context: Context) :
expoPackages = extraExpoPackages,
exponentPackageDelegate = delegate.exponentPackageDelegate,
manifest = manifest!!,
singletonModules = ExponentPackage.getOrCreateSingletonModules(context, manifest, extraExpoPackages),
singletonModules = ExponentPackage.getOrCreateSingletonModules(context, manifest, extraExpoPackages)
)

val versionedUtils = RNObject("host.exp.exponent.VersionedUtils").loadVersion(mSDKVersion!!)
Expand Down Expand Up @@ -288,11 +288,11 @@ class InternalHeadlessAppLoader(private val context: Context) :
val uri = Uri.parse(manifestUrl)
val host = uri.host
return if (host != null && (
host == "exp.host" || host == "expo.io" || host == "exp.direct" || host == "expo.test" ||
host.endsWith(".exp.host") || host.endsWith(".expo.io") || host.endsWith(".exp.direct") || host.endsWith(
".expo.test"
host == "exp.host" || host == "expo.io" || host == "exp.direct" || host == "expo.test" ||
host.endsWith(".exp.host") || host.endsWith(".expo.io") || host.endsWith(".exp.direct") || host.endsWith(
".expo.test"
)
)
)
) {
val pathSegments = uri.pathSegments
val builder = uri.buildUpon()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class DevMenuManager {
*/
fun requestToClose(activity: ExperienceActivity) {
ExponentKernelModule.queueEvent(
"ExponentKernel.requestToCloseDevMenu", Arguments.createMap(),
"ExponentKernel.requestToCloseDevMenu",
Arguments.createMap(),
object : ExponentKernelModuleProvider.KernelEventCallback {
override fun onEventSuccess(result: ReadableMap) {
hideInActivity(activity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class ExperienceKey(

companion object {
@Throws(JSONException::class)
@JvmStatic fun fromManifest(manifest: Manifest) = ExperienceKey(manifest.getScopeKey())
@JvmStatic
fun fromManifest(manifest: Manifest) = ExperienceKey(manifest.getScopeKey())
}
}
Loading

0 comments on commit 266799a

Please sign in to comment.