srctree

Robin Linden parent a3cc2a20 df9cc946
Update to ktlint 1.3.0

.github/workflows/ci.yaml added: 50, removed: 77, total 0
@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.2.1/ktlint && chmod a+x ktlint
- run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.3.0/ktlint && chmod a+x ktlint
- run: ./ktlint
 
gradle-wrapper-validation:
 
atox/src/androidTest/kotlin/IntegrationTest.kt added: 50, removed: 77, total 0
@@ -40,10 +40,8 @@ import org.hamcrest.core.AllOf.allOf
import org.junit.Rule
import org.junit.runner.RunWith
 
class InjectedActivityTestRule<T : Activity>(
activityClass: Class<T>,
private val listener: () -> Unit,
) : ActivityTestRule<T>(activityClass, false, true) {
class InjectedActivityTestRule<T : Activity>(activityClass: Class<T>, private val listener: () -> Unit) :
ActivityTestRule<T>(activityClass, false, true) {
override fun beforeActivityLaunched() {
super.beforeActivityLaunched()
listener()
 
atox/src/main/kotlin/tox/EventListenerCallbacks.kt added: 50, removed: 77, total 0
@@ -210,10 +210,17 @@ class EventListenerCallbacks @Inject constructor(
Log.e(TAG, "videoBitRate ${pk.fingerprint()} $bitRate")
}
 
videoReceiveFrameHandler = { pk,
width, height,
y, u, v,
yStride, uStride, vStride, ->
videoReceiveFrameHandler = {
pk,
width,
height,
y,
u,
v,
yStride,
uStride,
vStride,
->
Log.v(
TAG,
"videoReceiveFrame ${pk.fingerprint()}" +
 
atox/src/main/kotlin/ui/BaseFragment.kt added: 50, removed: 77, total 0
@@ -11,9 +11,8 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
 
abstract class BaseFragment<T : ViewBinding>(
private val inflate: (LayoutInflater, ViewGroup?, Boolean) -> T,
) : Fragment() {
abstract class BaseFragment<T : ViewBinding>(private val inflate: (LayoutInflater, ViewGroup?, Boolean) -> T) :
Fragment() {
private var _binding: T? = null
val binding get() = _binding!!
 
 
atox/src/main/kotlin/ui/NotificationHelper.kt added: 50, removed: 77, total 0
@@ -56,9 +56,7 @@ private const val FRIEND_REQUEST = "aTox friend requests"
private const val CALL = "aTox calls"
 
@Singleton
class NotificationHelper @Inject constructor(
private val context: Context,
) {
class NotificationHelper @Inject constructor(private val context: Context) {
private val notifier = NotificationManagerCompat.from(context)
private val notifierOld = context.getSystemService<NotificationManager>()!!
 
 
atox/src/main/kotlin/ui/chat/ChatAdapter.kt added: 50, removed: 77, total 0
@@ -87,10 +87,7 @@ private class FileTransferViewHolder(row: View) {
val imagePreview: ImageView = row.findViewById(R.id.imagePreview)
}
 
class ChatAdapter(
private val inflater: LayoutInflater,
private val resources: Resources,
) : BaseAdapter() {
class ChatAdapter(private val inflater: LayoutInflater, private val resources: Resources) : BaseAdapter() {
var messages: List<Message> = listOf()
var fileTransfers: List<FileTransfer> = listOf()
 
 
atox/src/main/kotlin/ui/chat/ChatFragment.kt added: 50, removed: 77, total 0
@@ -59,10 +59,8 @@ const val FOCUS_ON_MESSAGE_BOX = "focusOnMessageBox"
private const val MAX_CONFIRM_DELETE_STRING_LENGTH = 20
 
class OpenMultiplePersistableDocuments : ActivityResultContracts.OpenMultipleDocuments() {
override fun createIntent(context: Context, input: Array<String>): Intent {
return super.createIntent(context, input)
.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
}
override fun createIntent(context: Context, input: Array<String>): Intent = super.createIntent(context, input)
.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
}
 
class ChatFragment : BaseFragment<FragmentChatBinding>(FragmentChatBinding::inflate) {
 
atox/src/main/kotlin/ui/contactlist/ContactAdapter.kt added: 50, removed: 77, total 0
@@ -26,10 +26,7 @@ enum class ContactListItemType {
Contact,
}
 
class ContactAdapter(
private val inflater: LayoutInflater,
private val context: Context,
) : BaseAdapter() {
class ContactAdapter(private val inflater: LayoutInflater, private val context: Context) : BaseAdapter() {
var friendRequests: List<FriendRequest> = listOf()
var contacts: List<Contact> = listOf()
 
 
atox/src/main/kotlin/ui/settings/SettingsFragment.kt added: 50, removed: 77, total 0
@@ -250,7 +250,8 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding>(FragmentSettingsB
nospam.setText("%08X".format(vm.getNospam()))
nospam.doAfterTextChanged {
saveNospam.isEnabled =
nospam.text.length == 8 && nospam.text.toString().toUInt(16).toInt() != vm.getNospam()
nospam.text.length == 8 &&
nospam.text.toString().toUInt(16).toInt() != vm.getNospam()
}
saveNospam.isEnabled = false
saveNospam.setOnClickListener {
 
atox/src/main/kotlin/ui/userprofile/UserProfileViewModel.kt added: 50, removed: 77, total 0
@@ -13,10 +13,8 @@ import ltd.evilcorp.core.vo.UserStatus
import ltd.evilcorp.domain.feature.UserManager
import ltd.evilcorp.domain.tox.Tox
 
class UserProfileViewModel @Inject constructor(
private val userManager: UserManager,
private val tox: Tox,
) : ViewModel() {
class UserProfileViewModel @Inject constructor(private val userManager: UserManager, private val tox: Tox) :
ViewModel() {
val publicKey by lazy { tox.publicKey }
val toxId by lazy { tox.toxId }
val user: LiveData<User> = userManager.get(publicKey).asLiveData()
 
core/src/main/kotlin/repository/ContactRepository.kt added: 50, removed: 77, total 0
@@ -13,9 +13,7 @@ import ltd.evilcorp.core.vo.Contact
import ltd.evilcorp.core.vo.UserStatus
 
@Singleton
class ContactRepository @Inject constructor(
private val dao: ContactDao,
) {
class ContactRepository @Inject constructor(private val dao: ContactDao) {
fun exists(publicKey: String): Boolean = dao.exists(publicKey)
fun add(contact: Contact) = dao.save(contact)
fun update(contact: Contact) = dao.update(contact)
 
core/src/main/kotlin/repository/FileTransferRepository.kt added: 50, removed: 77, total 0
@@ -11,9 +11,7 @@ import ltd.evilcorp.core.db.FileTransferDao
import ltd.evilcorp.core.vo.FileTransfer
 
@Singleton
class FileTransferRepository @Inject internal constructor(
private val dao: FileTransferDao,
) {
class FileTransferRepository @Inject internal constructor(private val dao: FileTransferDao) {
fun add(ft: FileTransfer): Long = dao.save(ft)
 
fun delete(id: Int) = dao.delete(id)
 
core/src/main/kotlin/repository/FriendRequestRepository.kt added: 50, removed: 77, total 0
@@ -11,9 +11,7 @@ import ltd.evilcorp.core.db.FriendRequestDao
import ltd.evilcorp.core.vo.FriendRequest
 
@Singleton
class FriendRequestRepository @Inject internal constructor(
private val friendRequestDao: FriendRequestDao,
) {
class FriendRequestRepository @Inject internal constructor(private val friendRequestDao: FriendRequestDao) {
fun add(friendRequest: FriendRequest) = friendRequestDao.save(friendRequest)
 
fun delete(friendRequest: FriendRequest) = friendRequestDao.delete(friendRequest)
 
core/src/main/kotlin/repository/UserRepository.kt added: 50, removed: 77, total 0
@@ -13,9 +13,7 @@ import ltd.evilcorp.core.vo.User
import ltd.evilcorp.core.vo.UserStatus
 
@Singleton
class UserRepository @Inject constructor(
private val userDao: UserDao,
) {
class UserRepository @Inject constructor(private val userDao: UserDao) {
fun exists(publicKey: String): Boolean = userDao.exists(publicKey)
 
fun add(user: User) = userDao.save(user)
 
domain/src/main/kotlin/feature/CallManager.kt added: 50, removed: 77, total 0
@@ -34,11 +34,7 @@ private const val AUDIO_SAMPLING_RATE_HZ = 48_000
private const val AUDIO_SEND_INTERVAL_MS = 20
 
@Singleton
class CallManager @Inject constructor(
private val tox: Tox,
private val scope: CoroutineScope,
context: Context,
) {
class CallManager @Inject constructor(private val tox: Tox, private val scope: CoroutineScope, context: Context) {
private val _inCall = MutableStateFlow<CallState>(CallState.NotInCall)
val inCall: StateFlow<CallState> get() = _inCall
 
 
domain/src/main/kotlin/feature/ExportManager.kt added: 50, removed: 77, total 0
@@ -15,9 +15,7 @@ import ltd.evilcorp.core.repository.MessageRepository
import org.json.JSONArray
import org.json.JSONObject
 
class ExportManager @Inject constructor(
private val messageRepository: MessageRepository,
) {
class ExportManager @Inject constructor(private val messageRepository: MessageRepository) {
fun generateExportMessagesJString(publicKey: String): String {
val messages = runBlocking { messageRepository.get(publicKey).first() }
 
 
domain/src/main/kotlin/feature/FileTransferManager.kt added: 50, removed: 77, total 0
@@ -46,15 +46,9 @@ private const val FINGERPRINT_LEN = 8
private fun String.fingerprint() = take(FINGERPRINT_LEN)
 
@Suppress("ArrayInDataClass")
private data class Chunk(
val pos: Long,
val data: ByteArray,
)
private data class Chunk(val pos: Long, val data: ByteArray)
 
private data class OutgoingFile(
val inputStream: InputStream,
val unsentChunks: MutableList<Chunk>,
)
private data class OutgoingFile(val inputStream: InputStream, val unsentChunks: MutableList<Chunk>)
 
@Singleton
class FileTransferManager @Inject constructor(