Skip to content

Commit

Permalink
Format with ktfmt-gradle 0.18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gino-m committed Apr 30, 2024
1 parent 7f16067 commit 9dc9da5
Show file tree
Hide file tree
Showing 151 changed files with 371 additions and 402 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,14 @@ interface AutomatorRunner {

fun stringResource(
@StringRes resId: Int,
context: Context = InstrumentationRegistry.getInstrumentation().targetContext
context: Context = InstrumentationRegistry.getInstrumentation().targetContext,
): String = context.getString(resId)

fun byText(@StringRes resId: Int): BySelector = By.text(stringResource(resId))

fun <T : Any> byClass(kclass: KClass<T>): BySelector = By.clazz(kclass.java.name)

fun waitClickGone(
selector: BySelector,
timeout: Long = SHORT_TIMEOUT,
): Boolean {
fun waitClickGone(selector: BySelector, timeout: Long = SHORT_TIMEOUT): Boolean {
device.wait(Until.hasObject(selector), timeout)
device.findObject(selector)?.click()
return device.wait(Until.gone(selector), timeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SetPreferencesRule : TestWatcher() {
super.starting(description)
EntryPointAccessors.fromApplication(
getApplicationContext(),
SetPreferencesRuleEntryPoint::class.java
SetPreferencesRuleEntryPoint::class.java,
)
.preferenceStorage()
.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import javax.inject.Singleton
@Module
@TestInstallIn(
components = [SingletonComponent::class],
replaces = [RemotePersistenceModule::class]
replaces = [RemotePersistenceModule::class],
)
abstract class TestRemoteStorageModule {
@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ constructor(
else -> null
}
},
{ onUserSignInError(it) }
{ onUserSignInError(it) },
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SubmitDataUseCase
constructor(
private val locationOfInterestRepository: LocationOfInterestRepository,
private val submissionRepository: SubmissionRepository,
private val userRepository: UserRepository
private val userRepository: UserRepository,
) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ActivateSurveyUseCase
@Inject
constructor(
private val surveyRepository: SurveyRepository,
private val makeSurveyAvailableOffline: MakeSurveyAvailableOfflineUseCase
private val makeSurveyAvailableOffline: MakeSurveyAvailableOfflineUseCase,
) {
/**
* Sets the survey with the specified ID as the currently active. First attempts to load the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MakeSurveyAvailableOfflineUseCase
@Inject
constructor(
private val surveyRepository: SurveyRepository,
private val syncSurvey: SyncSurveyUseCase
private val syncSurvey: SyncSurveyUseCase,
) {
/**
* Makes the survey with the specified ID and related LOIs available offline. Subscribes to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ReactivateLastSurveyUseCase
@Inject
constructor(
private val surveyRepository: SurveyRepository,
private val activateSurvey: ActivateSurveyUseCase
private val activateSurvey: ActivateSurveyUseCase,
) {
suspend operator fun invoke() {
// Do nothing if never activated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SyncSurveyUseCase
@Inject
constructor(
private val surveyRepository: SurveyRepository,
private val loiRepository: LocationOfInterestRepository
private val loiRepository: LocationOfInterestRepository,
) {
/**
* Downloads the survey with the specified ID and related LOIs from remote and inserts and/or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ import java.util.Date
data class AuditInfo(
val user: User,
val clientTimestamp: Date = Date(),
val serverTimestamp: Date? = null
val serverTimestamp: Date? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data class Survey(
val jobMap: Map<String, Job>,
// TODO(#1730): Remove tileSources from survey.
val tileSources: List<TileSource> = listOf(),
val acl: Map<String, String> = mapOf()
val acl: Map<String, String> = mapOf(),
) {
val jobs: Collection<Job>
get() = jobMap.values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data class SurveyListItem(
val id: String,
val title: String,
val description: String,
val availableOffline: Boolean
val availableOffline: Boolean,
)

fun Survey.toListItem(availableOffline: Boolean): SurveyListItem =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ constructor(
val email: String,
val displayName: String,
val photoUrl: String? = null,
val isAnonymous: Boolean = false
val isAnonymous: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ data class OfflineArea(
val bounds: Bounds,
val name: String,
/** The range of zoom levels downloaded. */
val zoomRange: IntRange
val zoomRange: IntRange,
) {
val tiles
get() = zoomRange.flatMap { TileCoordinates.withinBounds(bounds, it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class Job(
val style: Style? = null,
val name: String? = null,
val tasks: Map<String, Task> = mapOf(),
val strategy: DataCollectionStrategy = DataCollectionStrategy.UNKNOWN
val strategy: DataCollectionStrategy = DataCollectionStrategy.UNKNOWN,
) {
enum class DataCollectionStrategy {
PREDEFINED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data class SubmissionMutation(
override val lastError: String = "",
val job: Job,
val submissionId: String = "",
val deltas: List<ValueDelta> = listOf()
val deltas: List<ValueDelta> = listOf(),
) : Mutation() {

override fun toString(): String = super.toString() + "deltas= $deltas"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import kotlinx.serialization.Serializable
@Serializable
class MultipleChoiceTaskData(
private val multipleChoice: MultipleChoice?,
val selectedOptionIds: List<String>
val selectedOptionIds: List<String>,
) : TaskData {

// TODO: Make these inner classes non-static and access Task directly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ constructor(
val job: Job,
val created: AuditInfo,
val lastModified: AuditInfo,
val data: SubmissionData = SubmissionData()
val data: SubmissionData = SubmissionData(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ import com.google.android.ground.persistence.local.room.fields.TileSetEntityStat
ExpressionEntity::class,
],
version = Config.DB_VERSION,
exportSchema = false
exportSchema = false,
)
@TypeConverters(
TaskEntityType::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object SubmissionDeltasConverter {
delta.taskId,
JSONObject()
.put(KEY_TASK_TYPE, delta.taskType.name)
.put(KEY_NEW_VALUE, ValueJsonConverter.toJsonObject(delta.newTaskData))
.put(KEY_NEW_VALUE, ValueJsonConverter.toJsonObject(delta.newTaskData)),
)
} catch (e: JSONException) {
Timber.e(e, "Error building JSON")
Expand All @@ -70,7 +70,7 @@ object SubmissionDeltasConverter {
ValueDelta(
taskId,
toEnum(Task.Type::class.java, jsonDelta.getString(KEY_TASK_TYPE)),
ValueJsonConverter.toResponse(task, jsonDelta[KEY_NEW_VALUE])
ValueJsonConverter.toResponse(task, jsonDelta[KEY_NEW_VALUE]),
)
)
} catch (e: LocalDataConsistencyException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ interface LocationOfInterestMutationDao : BaseDao<LocationOfInterestMutationEnti
)
suspend fun getMutations(
locationOfInterestId: String,
vararg allowedStates: MutationEntitySyncStatus
vararg allowedStates: MutationEntitySyncStatus,
): List<LocationOfInterestMutationEntity>?
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ interface SubmissionDao : BaseDao<SubmissionEntity> {
suspend fun findByLocationOfInterestId(
locationOfInterestId: String,
jobId: String,
state: EntityState
state: EntityState,
): List<SubmissionEntity>?
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface SubmissionMutationDao : BaseDao<SubmissionMutationEntity> {
)
suspend fun findByLocationOfInterestId(
locationOfInterestId: String,
vararg allowedStates: MutationEntitySyncStatus
vararg allowedStates: MutationEntitySyncStatus,
): List<SubmissionMutationEntity>

@Query(
Expand All @@ -45,7 +45,7 @@ interface SubmissionMutationDao : BaseDao<SubmissionMutationEntity> {
suspend fun getSubmissionMutationCount(
loiId: String,
mutationType: MutationEntityType,
vararg allowedStates: MutationEntitySyncStatus
vararg allowedStates: MutationEntitySyncStatus,
): Int

@Query(
Expand All @@ -54,7 +54,7 @@ interface SubmissionMutationDao : BaseDao<SubmissionMutationEntity> {
)
suspend fun findBySubmissionId(
submissionId: String,
vararg allowedStates: MutationEntitySyncStatus
vararg allowedStates: MutationEntitySyncStatus,
): List<SubmissionMutationEntity>?

@Query(
Expand All @@ -63,6 +63,6 @@ interface SubmissionMutationDao : BaseDao<SubmissionMutationEntity> {
)
fun findByLoiIdFlow(
locationOfInterestId: String,
vararg allowedStates: MutationEntitySyncStatus
vararg allowedStates: MutationEntitySyncStatus,
): Flow<List<SubmissionMutationEntity>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ data class AuditInfoEntity(
* Returns the time at which the server received the requested change according to the server's
* internal clock, or null if the updated server time was not yet received.
*/
val serverTimestamp: Long? = null
val serverTimestamp: Long? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import com.google.android.ground.persistence.local.room.fields.MatchEntityType
entity = TaskEntity::class,
parentColumns = ["id"],
childColumns = ["parent_task_id"],
onDelete = ForeignKey.CASCADE
onDelete = ForeignKey.CASCADE,
)
],
indices = [Index("parent_task_id")]
indices = [Index("parent_task_id")],
)
data class ConditionEntity(
@ColumnInfo(name = "parent_task_id") @PrimaryKey val parentTaskId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import com.google.android.ground.persistence.local.room.fields.ExpressionEntityT
entity = ConditionEntity::class,
parentColumns = ["parent_task_id"],
childColumns = ["parent_task_id"],
onDelete = ForeignKey.CASCADE
onDelete = ForeignKey.CASCADE,
)
],
indices = [Index("parent_task_id")]
indices = [Index("parent_task_id")],
)
data class ExpressionEntity(
@ColumnInfo(name = "parent_task_id") @PrimaryKey val parentTaskId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import androidx.room.*
entity = SurveyEntity::class,
parentColumns = ["id"],
childColumns = ["survey_id"],
onDelete = ForeignKey.CASCADE
onDelete = ForeignKey.CASCADE,
)
],
indices = [Index("survey_id")]
indices = [Index("survey_id")],
)
data class JobEntity(
@PrimaryKey @ColumnInfo(name = "id") val id: String,
@ColumnInfo(name = "name") val name: String?,
@ColumnInfo(name = "survey_id") val surveyId: String?,
@ColumnInfo(name = "strategy") val strategy: String,
@Embedded(prefix = "style_") val style: StyleEntity?
@Embedded(prefix = "style_") val style: StyleEntity?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import com.google.android.ground.persistence.local.room.fields.MultipleChoiceEnt
entity = TaskEntity::class,
parentColumns = ["id"],
childColumns = ["task_id"],
onDelete = ForeignKey.CASCADE
onDelete = ForeignKey.CASCADE,
)
],
indices = [Index("task_id")]
indices = [Index("task_id")],
)
data class MultipleChoiceEntity(
@ColumnInfo(name = "task_id") @PrimaryKey val taskId: String,
@ColumnInfo(name = "type") val type: MultipleChoiceEntityType,
@ColumnInfo(name = "has_other_option") val hasOtherOption: Boolean
@ColumnInfo(name = "has_other_option") val hasOtherOption: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ data class OfflineAreaEntity(
@ColumnInfo(name = "east") val east: Double,
@ColumnInfo(name = "west") val west: Double,
@ColumnInfo(name = "min_zoom") val minZoom: Int,
@ColumnInfo(name = "max_zoom") val maxZoom: Int
@ColumnInfo(name = "max_zoom") val maxZoom: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import androidx.room.*
entity = TaskEntity::class,
parentColumns = ["id"],
childColumns = ["task_id"],
onDelete = ForeignKey.CASCADE
onDelete = ForeignKey.CASCADE,
)
],
indices = [Index("task_id")],
primaryKeys = ["id"]
primaryKeys = ["id"],
)
data class OptionEntity(
@ColumnInfo(name = "id") val id: String,
@ColumnInfo(name = "code") val code: String,
@ColumnInfo(name = "label") val label: String,
@ColumnInfo(name = "task_id") val taskId: String
@ColumnInfo(name = "task_id") val taskId: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import com.google.android.ground.persistence.local.room.fields.EntityState
entity = LocationOfInterestEntity::class,
parentColumns = ["id"],
childColumns = ["location_of_interest_id"],
onDelete = ForeignKey.CASCADE
onDelete = ForeignKey.CASCADE,
)
],
tableName = "submission",
indices = [Index("location_of_interest_id", "job_id", "state")]
indices = [Index("location_of_interest_id", "job_id", "state")],
)
data class SubmissionEntity(
@ColumnInfo(name = "id") @PrimaryKey val id: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ import java.util.*
entity = LocationOfInterestEntity::class,
parentColumns = ["id"],
childColumns = ["location_of_interest_id"],
onDelete = ForeignKey.CASCADE
onDelete = ForeignKey.CASCADE,
),
ForeignKey(
entity = SubmissionEntity::class,
parentColumns = ["id"],
childColumns = ["submission_id"],
onDelete = ForeignKey.CASCADE
)
onDelete = ForeignKey.CASCADE,
),
],
indices = [Index("location_of_interest_id"), Index("submission_id")]
indices = [Index("location_of_interest_id"), Index("submission_id")],
)
data class SubmissionMutationEntity(
@ColumnInfo(name = "id") @PrimaryKey(autoGenerate = true) val id: Long? = 0,
Expand All @@ -60,5 +60,5 @@ data class SubmissionMutationEntity(
*
* This method returns `null` for mutation type [MutationEntityType.DELETE].
*/
@ColumnInfo(name = "deltas") val deltas: String?
@ColumnInfo(name = "deltas") val deltas: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ data class SurveyEntity(
@ColumnInfo(name = "id") @PrimaryKey val id: String,
@ColumnInfo(name = "title") val title: String?,
@ColumnInfo(name = "description") val description: String?,
@ColumnInfo(name = "acl") val acl: JSONObject?
@ColumnInfo(name = "acl") val acl: JSONObject?,
)
Loading

0 comments on commit 9dc9da5

Please sign in to comment.