Apply automated ktlint 1.2.1 formatting.

This commit is contained in:
Nicholas Tinsley
2024-05-15 21:57:46 -04:00
committed by Clark Chen
parent e861c022da
commit cfb4377de3
39 changed files with 190 additions and 60 deletions

View File

@@ -216,7 +216,7 @@ class ImportExportTest {
@Test
fun largeNumberOfMessagesAndChats() {
val NUM_INDIVIDUAL_RECIPIENTS = 1000
val numIndividualRecipients = 1000
val numIndividualMessages = 500
val numGroupMessagesPerPerson = 200
@@ -225,7 +225,7 @@ class ImportExportTest {
val recipients = ArrayList<Recipient>(1010)
val chats = ArrayList<Chat>(1010)
var id = 3L
for (i in 0 until NUM_INDIVIDUAL_RECIPIENTS) {
for (i in 0 until numIndividualRecipients) {
val recipientId = id++
recipients.add(
Recipient(

View File

@@ -139,7 +139,9 @@ class BobClient(val serviceId: ServiceId, val e164: String, val identityKeyPair:
override fun isTrustedIdentity(address: SignalProtocolAddress?, identityKey: IdentityKey?, direction: IdentityKeyStore.Direction?): Boolean = true
override fun loadSession(address: SignalProtocolAddress?): SessionRecord = aliceSessionRecord ?: SessionRecord()
override fun saveIdentity(address: SignalProtocolAddress?, identityKey: IdentityKey?): Boolean = false
override fun storeSession(address: SignalProtocolAddress?, record: SessionRecord?) { aliceSessionRecord = record }
override fun storeSession(address: SignalProtocolAddress?, record: SessionRecord?) {
aliceSessionRecord = record
}
override fun getSubDeviceSessions(name: String?): List<Int> = emptyList()
override fun containsSession(address: SignalProtocolAddress?): Boolean = aliceSessionRecord != null
override fun getIdentity(address: SignalProtocolAddress?): IdentityKey = SignalStore.account().aciIdentityKey.publicKey

View File

@@ -7,6 +7,8 @@ package org.thoughtcrime.securesms.backup.v2
class BackupV2Event(val type: Type, val count: Long, val estimatedTotalCount: Long) {
enum class Type {
PROGRESS_MESSAGES, PROGRESS_ATTACHMENTS, FINISHED
PROGRESS_MESSAGES,
PROGRESS_ATTACHMENTS,
FINISHED
}
}

View File

@@ -466,7 +466,15 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
return MessageAttachment(
pointer = builder.build(),
wasDownloaded = this.transferState == AttachmentTable.TRANSFER_PROGRESS_DONE || this.transferState == AttachmentTable.TRANSFER_NEEDS_RESTORE,
flag = if (voiceNote) MessageAttachment.Flag.VOICE_MESSAGE else if (videoGif) MessageAttachment.Flag.GIF else if (borderless) MessageAttachment.Flag.BORDERLESS else MessageAttachment.Flag.NONE
flag = if (voiceNote) {
MessageAttachment.Flag.VOICE_MESSAGE
} else if (videoGif) {
MessageAttachment.Flag.GIF
} else if (borderless) {
MessageAttachment.Flag.BORDERLESS
} else {
MessageAttachment.Flag.NONE
}
)
}

View File

@@ -76,6 +76,8 @@ class MessageBackupsTestRestoreViewModel : ViewModel() {
)
enum class ImportState(val inProgress: Boolean = false) {
NONE, IN_PROGRESS(true), RESTORED
NONE,
IN_PROGRESS(true),
RESTORED
}
}

View File

@@ -145,7 +145,8 @@ class DebugLogsPromptDialogFragment : FixedRoundedCornerBottomSheetDialogFragmen
enum class Purpose(val serialized: Int) {
NOTIFICATIONS(1), CRASH(2);
NOTIFICATIONS(1),
CRASH(2);
companion object {
fun deserialize(serialized: Int): Purpose {

View File

@@ -60,7 +60,10 @@ class ContextMenuList(recyclerView: RecyclerView, onItemClick: () -> Unit) {
}
private enum class DisplayType {
TOP, BOTTOM, MIDDLE, ONLY
TOP,
BOTTOM,
MIDDLE,
ONLY
}
private class ItemViewHolder(

View File

@@ -114,11 +114,13 @@ class SignalContextMenu private constructor(
}
enum class HorizontalPosition {
START, END
START,
END
}
enum class VerticalPosition {
ABOVE, BELOW
ABOVE,
BELOW
}
/**

View File

@@ -117,7 +117,7 @@ class ClickPreferenceViewHolder(itemView: View) : PreferenceViewHolder<ClickPref
class LongClickPreferenceViewHolder(itemView: View) : PreferenceViewHolder<LongClickPreference>(itemView) {
override fun bind(model: LongClickPreference) {
super.bind(model)
itemView.setOnLongClickListener() {
itemView.setOnLongClickListener {
model.onLongClick()
true
}

View File

@@ -355,11 +355,18 @@ class InternalBackupPlaygroundViewModel : ViewModel() {
)
enum class BackupState(val inProgress: Boolean = false) {
NONE, EXPORT_IN_PROGRESS(true), EXPORT_DONE, BACKUP_JOB_DONE, IMPORT_IN_PROGRESS(true)
NONE,
EXPORT_IN_PROGRESS(true),
EXPORT_DONE,
BACKUP_JOB_DONE,
IMPORT_IN_PROGRESS(true)
}
enum class BackupUploadState(val inProgress: Boolean = false) {
NONE, UPLOAD_IN_PROGRESS(true), UPLOAD_DONE, UPLOAD_FAILED
NONE,
UPLOAD_IN_PROGRESS(true),
UPLOAD_DONE,
UPLOAD_FAILED
}
sealed class RemoteBackupState {

View File

@@ -17,6 +17,7 @@ data class UsernameLinkSettingsState(
val indeterminateProgress: Boolean = false
) {
enum class ActiveTab {
Code, Scan
Code,
Scan
}
}

View File

@@ -817,7 +817,13 @@ class ConversationSettingsFragment : DSLSettingsFragment(
else -> R.string.ConversationSettingsFragment__block
}
val titleTint = if (isBlocked) null else if (state.isDeprecatedOrUnregistered) alertDisabledTint else alertTint
val titleTint = if (isBlocked) {
null
} else if (state.isDeprecatedOrUnregistered) {
alertDisabledTint
} else {
alertTint
}
clickPref(
title = if (titleTint != null) DSLSettingsText.from(title, titleTint) else DSLSettingsText.from(title),

View File

@@ -1,4 +1,4 @@
@file:Suppress("ktlint:filename")
@file:Suppress("ktlint:standard:filename")
package org.thoughtcrime.securesms.components.settings

View File

@@ -375,6 +375,7 @@ data class CallParticipantsState(
}
enum class SelectedPage {
GRID, FOCUSED
GRID,
FOCUSED
}
}

View File

@@ -732,7 +732,13 @@ open class ContactSearchAdapter(
val isLeftSelf = lhs?.isSelf == true
val isRightSelf = rhs?.isSelf == true
return if (isLeftSelf == isRightSelf) 0 else if (isLeftSelf) 1 else -1
return if (isLeftSelf == isRightSelf) {
0
} else if (isLeftSelf) {
1
} else {
-1
}
}
}

View File

@@ -57,7 +57,8 @@ sealed class MessageSendType(
)
enum class TransportType {
SIGNAL, SMS
SIGNAL,
SMS
}
companion object {

View File

@@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.conversation.colors.ui.custom
enum class CustomChatColorEdge {
TOP, BOTTOM
TOP,
BOTTOM
}

View File

@@ -1271,7 +1271,8 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) : DatabaseT
}
enum class MemberSet(val includeSelf: Boolean, val includePending: Boolean) {
FULL_MEMBERS_INCLUDING_SELF(true, false), FULL_MEMBERS_EXCLUDING_SELF(false, false)
FULL_MEMBERS_INCLUDING_SELF(true, false),
FULL_MEMBERS_EXCLUDING_SELF(false, false)
}
/**

View File

@@ -244,7 +244,9 @@ class IdentityTable internal constructor(context: Context?, databaseHelper: Sign
}
enum class VerifiedStatus {
DEFAULT, VERIFIED, UNVERIFIED;
DEFAULT,
VERIFIED,
UNVERIFIED;
fun toInt(): Int {
return when (this) {

View File

@@ -4884,7 +4884,12 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
)
enum class MessageStatus {
PENDING, SENT, DELIVERED, READ, VIEWED, FAILED
PENDING,
SENT,
DELIVERED,
READ,
VIEWED,
FAILED
}
data class SyncMessageId(

View File

@@ -1,4 +1,4 @@
@file:Suppress("ktlint:filename")
@file:Suppress("ktlint:standard:filename")
package org.thoughtcrime.securesms.database

View File

@@ -4587,7 +4587,9 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
enum class VibrateState(val id: Int) {
DEFAULT(0), ENABLED(1), DISABLED(2);
DEFAULT(0),
ENABLED(1),
DISABLED(2);
companion object {
fun fromId(id: Int): VibrateState {
@@ -4601,7 +4603,9 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
enum class RegisteredState(val id: Int) {
UNKNOWN(0), REGISTERED(1), NOT_REGISTERED(2);
UNKNOWN(0),
REGISTERED(1),
NOT_REGISTERED(2);
companion object {
fun fromId(id: Int): RegisteredState {
@@ -4611,7 +4615,10 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
enum class UnidentifiedAccessMode(val mode: Int) {
UNKNOWN(0), DISABLED(1), ENABLED(2), UNRESTRICTED(3);
UNKNOWN(0),
DISABLED(1),
ENABLED(2),
UNRESTRICTED(3);
companion object {
fun fromMode(mode: Int): UnidentifiedAccessMode {
@@ -4621,7 +4628,9 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
enum class InsightsBannerTier(val id: Int) {
NO_TIER(0), TIER_ONE(1), TIER_TWO(2);
NO_TIER(0),
TIER_ONE(1),
TIER_TWO(2);
fun seen(tier: InsightsBannerTier): Boolean {
return tier.id <= id
@@ -4635,7 +4644,12 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
enum class RecipientType(val id: Int) {
INDIVIDUAL(0), MMS(1), GV1(2), GV2(3), DISTRIBUTION_LIST(4), CALL_LINK(5);
INDIVIDUAL(0),
MMS(1),
GV1(2),
GV2(3),
DISTRIBUTION_LIST(4),
CALL_LINK(5);
companion object {
fun fromId(id: Int): RecipientType {
@@ -4645,7 +4659,8 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
enum class MentionSetting(val id: Int) {
ALWAYS_NOTIFY(0), DO_NOT_NOTIFY(1);
ALWAYS_NOTIFY(0),
DO_NOT_NOTIFY(1);
companion object {
fun fromId(id: Int): MentionSetting {
@@ -4655,7 +4670,9 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
enum class PhoneNumberSharingState(val id: Int) {
UNKNOWN(0), ENABLED(1), DISABLED(2);
UNKNOWN(0),
ENABLED(1),
DISABLED(2);
val enabled
get() = this == ENABLED || this == UNKNOWN
@@ -4668,7 +4685,9 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
enum class PhoneNumberDiscoverableState(val id: Int) {
UNKNOWN(0), DISCOVERABLE(1), NOT_DISCOVERABLE(2);
UNKNOWN(0),
DISCOVERABLE(1),
NOT_DISCOVERABLE(2);
companion object {
fun fromId(id: Int): PhoneNumberDiscoverableState {

View File

@@ -2109,7 +2109,9 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
}
internal enum class ReadStatus(private val value: Int) {
READ(1), UNREAD(0), FORCED_UNREAD(2);
READ(1),
UNREAD(0),
FORCED_UNREAD(2);
fun serialize(): Int {
return value

View File

@@ -101,5 +101,6 @@ object V220_PreKeyConstraints : SignalDatabaseMigration {
db.execSQL("DROP TABLE one_time_prekeys")
db.execSQL("ALTER TABLE one_time_prekeys_temp RENAME TO one_time_prekeys") }
db.execSQL("ALTER TABLE one_time_prekeys_temp RENAME TO one_time_prekeys")
}
}

View File

@@ -84,7 +84,8 @@ data class CallParticipant(
}
enum class DeviceOrdinal {
PRIMARY, SECONDARY
PRIMARY,
SECONDARY
}
enum class AudioLevel {

View File

@@ -47,11 +47,15 @@ data class JobSpec(
if (serializedData != null) {
if (other.serializedData == null) return false
if (!serializedData.contentEquals(other.serializedData)) return false
} else if (other.serializedData != null) return false
} else if (other.serializedData != null) {
return false
}
if (serializedInputData != null) {
if (other.serializedInputData == null) return false
if (!serializedInputData.contentEquals(other.serializedInputData)) return false
} else if (other.serializedInputData != null) return false
} else if (other.serializedInputData != null) {
return false
}
if (isRunning != other.isRunning) return false
if (isMemoryOnly != other.isMemoryOnly) return false

View File

@@ -233,7 +233,9 @@ class ApkUpdateJob private constructor(parameters: Parameters) : BaseJob(paramet
private class DownloadStatus(val status: Status, val downloadId: Long) {
enum class Status {
PENDING, COMPLETE, MISSING
PENDING,
COMPLETE,
MISSING
}
}

View File

@@ -358,7 +358,9 @@ internal class PaymentsValues internal constructor(store: KeyValueStore) : Signa
}
enum class WalletRestoreResult {
ENTROPY_CHANGED, ENTROPY_UNCHANGED, MNEMONIC_ERROR
ENTROPY_CHANGED,
ENTROPY_UNCHANGED,
MNEMONIC_ERROR
}
private fun userHasLargeBalance(): Boolean {

View File

@@ -45,7 +45,8 @@ class MediaPreviewPlayerControlView @JvmOverloads constructor(
private val forwardButton: ImageButton = findViewById(R.id.exo_forward)
enum class MediaMode {
IMAGE, VIDEO;
IMAGE,
VIDEO;
companion object {
@JvmStatic

View File

@@ -45,7 +45,8 @@ data class MediaSelectionState(
}
enum class ViewOnceToggleState(val code: Int) {
INFINITE(0), ONCE(1);
INFINITE(0),
ONCE(1);
fun next(): ViewOnceToggleState {
return when (this) {

View File

@@ -54,7 +54,13 @@ class MessageRequestsBottomView @JvmOverloads constructor(context: Context, attr
when (messageRequestState.state) {
MessageRequestState.State.INDIVIDUAL_BLOCKED -> {
val message = if (recipient.isReleaseNotes) R.string.MessageRequestBottomView_get_updates_and_news_from_s_you_wont_receive_any_updates_until_you_unblock_them else if (recipient.isRegistered) R.string.MessageRequestBottomView_do_you_want_to_let_s_message_you_wont_receive_any_messages_until_you_unblock_them else R.string.MessageRequestBottomView_do_you_want_to_let_s_message_you_wont_receive_any_messages_until_you_unblock_them_SMS
val message = if (recipient.isReleaseNotes) {
R.string.MessageRequestBottomView_get_updates_and_news_from_s_you_wont_receive_any_updates_until_you_unblock_them
} else if (recipient.isRegistered) {
R.string.MessageRequestBottomView_do_you_want_to_let_s_message_you_wont_receive_any_messages_until_you_unblock_them
} else {
R.string.MessageRequestBottomView_do_you_want_to_let_s_message_you_wont_receive_any_messages_until_you_unblock_them_SMS
}
question.text = HtmlCompat.fromHtml(
context.getString(
message,

View File

@@ -386,11 +386,23 @@ internal class UsernameEditViewModel private constructor(private val mode: Usern
}
enum class ButtonState {
SUBMIT, SUBMIT_DISABLED, SUBMIT_LOADING, DELETE, DELETE_LOADING, DELETE_DISABLED
SUBMIT,
SUBMIT_DISABLED,
SUBMIT_LOADING,
DELETE,
DELETE_LOADING,
DELETE_DISABLED
}
enum class Event {
NETWORK_FAILURE, SUBMIT_SUCCESS, DELETE_SUCCESS, SUBMIT_FAIL_INVALID, SUBMIT_FAIL_TAKEN, SKIPPED, NEEDS_CONFIRM_RESET, RATE_LIMIT_EXCEEDED
NETWORK_FAILURE,
SUBMIT_SUCCESS,
DELETE_SUCCESS,
SUBMIT_FAIL_INVALID,
SUBMIT_FAIL_TAKEN,
SKIPPED,
NEEDS_CONFIRM_RESET,
RATE_LIMIT_EXCEEDED
}
class Factory(private val mode: UsernameEditMode) : ViewModelProvider.Factory {

View File

@@ -509,15 +509,23 @@ object UsernameRepository {
}
enum class UsernameSetResult {
SUCCESS, USERNAME_UNAVAILABLE, USERNAME_INVALID, NETWORK_ERROR, CANDIDATE_GENERATION_ERROR, RATE_LIMIT_ERROR
SUCCESS,
USERNAME_UNAVAILABLE,
USERNAME_INVALID,
NETWORK_ERROR,
CANDIDATE_GENERATION_ERROR,
RATE_LIMIT_ERROR
}
enum class UsernameReclaimResult {
SUCCESS, PERMANENT_ERROR, NETWORK_ERROR
SUCCESS,
PERMANENT_ERROR,
NETWORK_ERROR
}
enum class UsernameDeleteResult {
SUCCESS, NETWORK_ERROR
SUCCESS,
NETWORK_ERROR
}
internal interface Callback<E> {

View File

@@ -32,7 +32,9 @@ class VideoEditorPlayButtonLayout @JvmOverloads constructor(context: Context, at
fun fadePlayButton() {
playOverlay.animate()
.setListener(object : Animator.AnimatorListener {
override fun onAnimationEnd(animation: Animator) { playOverlay.visibility = GONE }
override fun onAnimationEnd(animation: Animator) {
playOverlay.visibility = GONE
}
override fun onAnimationStart(animation: Animator) = Unit
override fun onAnimationCancel(animation: Animator) = Unit
override fun onAnimationRepeat(animation: Animator) = Unit

View File

@@ -32,7 +32,9 @@ data class CallLinkCredentials(
if (adminPassBytes != null) {
if (other.adminPassBytes == null) return false
if (!adminPassBytes.contentEquals(other.adminPassBytes)) return false
} else if (other.adminPassBytes != null) return false
} else if (other.adminPassBytes != null) {
return false
}
return true
}

View File

@@ -136,12 +136,16 @@ data class SafetyNumberFingerprint(
if (localStableIdentifier != null) {
if (other.localStableIdentifier == null) return false
if (!localStableIdentifier.contentEquals(other.localStableIdentifier)) return false
} else if (other.localStableIdentifier != null) return false
} else if (other.localStableIdentifier != null) {
return false
}
if (localIdentityKey != other.localIdentityKey) return false
if (remoteStableIdentifier != null) {
if (other.remoteStableIdentifier == null) return false
if (!remoteStableIdentifier.contentEquals(other.remoteStableIdentifier)) return false
} else if (other.remoteStableIdentifier != null) return false
} else if (other.remoteStableIdentifier != null) {
return false
}
if (remoteIdentityKey != other.remoteIdentityKey) return false
if (fingerprint != other.fingerprint) return false

View File

@@ -103,11 +103,17 @@ sealed class SignalAudioManager(protected val context: Context, protected val ev
}
enum class AudioDevice {
SPEAKER_PHONE, WIRED_HEADSET, EARPIECE, BLUETOOTH, NONE
SPEAKER_PHONE,
WIRED_HEADSET,
EARPIECE,
BLUETOOTH,
NONE
}
enum class State {
UNINITIALIZED, PREINITIALIZED, RUNNING
UNINITIALIZED,
PREINITIALIZED,
RUNNING
}
/**

View File

@@ -32,8 +32,14 @@ class NotificationProfileDatabaseTest {
@Before
fun setup() {
val sqlCipher = TestDatabaseUtil.inMemoryDatabase {
NotificationProfileDatabase.CREATE_TABLE.forEach { println(it); this.execSQL(it) }
NotificationProfileDatabase.CREATE_INDEXES.forEach { println(it); this.execSQL(it) }
NotificationProfileDatabase.CREATE_TABLE.forEach {
println(it)
this.execSQL(it)
}
NotificationProfileDatabase.CREATE_INDEXES.forEach {
println(it)
this.execSQL(it)
}
}
if (!ApplicationDependencies.isInitialized()) {

View File

@@ -52,14 +52,14 @@ internal fun DropdownMenuContent(
if (false isTransitioningTo true) {
// Dismissed to expanded
tween(
durationMillis = InTransitionDuration,
durationMillis = IN_TRANSITION_DURATION,
easing = LinearOutSlowInEasing
)
} else {
// Expanded to dismissed.
tween(
durationMillis = 1,
delayMillis = OutTransitionDuration - 1
delayMillis = OUT_TRANSITION_DURATION - 1
)
}
}
@@ -80,7 +80,7 @@ internal fun DropdownMenuContent(
tween(durationMillis = 30)
} else {
// Expanded to dismissed.
tween(durationMillis = OutTransitionDuration)
tween(durationMillis = OUT_TRANSITION_DURATION)
}
}
) {
@@ -211,5 +211,5 @@ internal data class DropdownMenuPositionProvider(
internal val MenuVerticalMargin = 48.dp
// Menu open/close animation.
internal const val InTransitionDuration = 120
internal const val OutTransitionDuration = 75
internal const val IN_TRANSITION_DURATION = 120
internal const val OUT_TRANSITION_DURATION = 75