Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/src/main/java/com/nextcloud/talk/api/NcApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,6 @@ Observable<SignalingOverall> pullSignalingMessages(@Nullable @Header("Authorizat
Observable<UserProfileOverall> getUserProfile(@Header("Authorization") String authorization, @Url String url);


@GET
Observable<UserProfileOverall> getUserData(@Header("Authorization") String authorization, @Url String url);

@DELETE
Observable<GenericOverall> revertStatus(@Header("Authentication") String authorization, @Url String url);

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,15 @@ interface NcApiCoroutines {
@GET
suspend fun getUserProfile(@Header("Authorization") authorization: String, @Url url: String): UserProfileOverall

@FormUrlEncoded
@PUT
suspend fun setUserData(
@Header("Authorization") authorization: String,
@Url url: String,
@Field("key") key: String,
@Field("value") value: String
): GenericOverall

@GET
suspend fun getReminder(@Header("Authorization") authorization: String, @Url url: String): ReminderOverall

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.nextcloud.talk.components

import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputConnection
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.InterceptPlatformTextInput
import androidx.compose.ui.platform.PlatformTextInputMethodRequest

/**
* Asks the keyboard not to learn from what is typed into the text fields of [content] while [enabled], like
* `BaseActivity` does for the text fields of views.
*/
@Composable
fun IncognitoKeyboard(enabled: Boolean, content: @Composable () -> Unit) {
InterceptPlatformTextInput(
interceptor = { request, nextHandler ->
// a changed flag passes a new interceptor, which restarts an active session with it
if (enabled) {
nextHandler.startInputMethod(
object : PlatformTextInputMethodRequest {
override fun createInputConnection(outAttributes: EditorInfo): InputConnection {
val inputConnection = request.createInputConnection(outAttributes)
outAttributes.imeOptions =
outAttributes.imeOptions or EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING
return inputConnection
}
}
)
} else {
nextHandler.startInputMethod(request)
}
},
content = content
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ConversationsListActivity : BaseActivity() {
private val showUnreadBubbleState = MutableStateFlow(false)
private val isFabVisibleState = MutableStateFlow(true)
private val showNotificationWarningState = MutableStateFlow(false)
private val showEcosystemState = MutableStateFlow(false)
private val isRefreshingState = MutableStateFlow(false)
private val showAccountDialogState = MutableStateFlow(false)

Expand Down Expand Up @@ -461,7 +462,7 @@ class ConversationsListActivity : BaseActivity() {
credentials = credentials ?: "",
showLogo = BrandingUtils.isOriginalNextcloudClient(applicationContext),
viewThemeUtils = viewThemeUtils,
isShowEcosystem = appPreferences.isShowEcosystem && !resources.getBoolean(R.bool.is_branded_client),
showEcosystemFlow = showEcosystemState,
snackbarHostState = snackbarHostState,
isMaintenanceModeFlow = isMaintenanceModeState,
isOnlineFlow = networkMonitor.isOnline,
Expand Down Expand Up @@ -646,6 +647,9 @@ class ConversationsListActivity : BaseActivity() {
}

showNotificationWarningState.value = shouldShowNotificationWarning()
// may have been changed in the settings meanwhile
val isBrandedClient = resources.getBoolean(R.bool.is_branded_client)
showEcosystemState.value = appPreferences.isShowEcosystem && !isBrandedClient
showShareToScreenState.value = isShare(intent)

takeConversationOfShortcut()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ data class ConversationsListScreenState(
val credentials: String,
val showLogo: Boolean,
val viewThemeUtils: ViewThemeUtils,
val isShowEcosystem: Boolean,
val showEcosystemFlow: StateFlow<Boolean>,
val snackbarHostState: SnackbarHostState,
val isMaintenanceModeFlow: StateFlow<Boolean>,
val isOnlineFlow: StateFlow<Boolean>,
Expand Down Expand Up @@ -168,6 +168,7 @@ fun ConversationsListScreen(
val isForward by state.forwardMessageFlow.collectAsStateWithLifecycle()
val hasMultipleAccounts by state.hasMultipleAccountsFlow.collectAsStateWithLifecycle()
val showAccountDialog by state.showAccountDialogFlow.collectAsStateWithLifecycle()
val showEcosystem by state.showEcosystemFlow.collectAsStateWithLifecycle()
val selectedConversationForOps by state.selectedConversationForOpsFlow.collectAsStateWithLifecycle()
val opsSheetState = rememberModalBottomSheetState()

Expand Down Expand Up @@ -405,7 +406,7 @@ fun ConversationsListScreen(
LaunchedEffect(shouldDismiss.value) {
if (shouldDismiss.value) callbacks.onAccountDialogDismiss()
}
dialog.GetChooseAccountDialog(shouldDismiss, activity, state.isShowEcosystem)
dialog.GetChooseAccountDialog(shouldDismiss, activity, showEcosystem)
}

// Conversation-operations bottom sheet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.nextcloud.talk.dagger.modules

import javax.inject.Qualifier

/** The dispatcher for blocking I/O, replaceable in tests. */
@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class IoDispatcher
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ import com.nextcloud.talk.repositories.reactions.ReactionsRepository
import com.nextcloud.talk.repositories.reactions.ReactionsRepositoryImpl
import com.nextcloud.talk.repositories.unifiedsearch.UnifiedSearchRepository
import com.nextcloud.talk.repositories.unifiedsearch.UnifiedSearchRepositoryImpl
import com.nextcloud.talk.settings.data.SettingsRepository
import com.nextcloud.talk.settings.data.SettingsRepositoryImpl
import com.nextcloud.talk.shareditems.repositories.SharedItemsRepository
import com.nextcloud.talk.shareditems.repositories.SharedItemsRepositoryImpl
import com.nextcloud.talk.threadsoverview.data.ThreadsRepository
Expand Down Expand Up @@ -225,6 +227,10 @@ class RepositoryModule {
fun provideContactsRepository(ncApiCoroutines: NcApiCoroutines): ContactsRepository =
ContactsRepositoryImpl(ncApiCoroutines)

@Provides
fun provideSettingsRepository(ncApiCoroutines: NcApiCoroutines): SettingsRepository =
SettingsRepositoryImpl(ncApiCoroutines)

@Provides
fun provideConversationCreationRepository(ncApiCoroutines: NcApiCoroutines): ConversationCreationRepository =
ConversationCreationRepositoryImpl(ncApiCoroutines)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.nextcloud.talk.dagger.modules

import android.content.Context
import androidx.work.WorkManager
import com.nextcloud.talk.logger.FileLogHandler
import com.nextcloud.talk.logger.Level
import com.nextcloud.talk.logger.Logger
Expand All @@ -22,6 +23,7 @@ import dagger.Provides
import dagger.Reusable
import java.io.File
import javax.inject.Singleton
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
Expand All @@ -40,6 +42,9 @@ class UtilsModule {
@Reusable
fun provideMessageUtils(context: Context): MessageUtils = MessageUtils(context)

@Provides
fun provideWorkManager(context: Context): WorkManager = WorkManager.getInstance(context)

@Provides
@Singleton
fun provideLoggerImpl(context: Context): LoggerImpl {
Expand Down Expand Up @@ -73,4 +78,8 @@ class UtilsModule {
@Singleton
@ApplicationScope
fun provideApplicationScope(): CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)

@Provides
@IoDispatcher
fun provideIoDispatcher(): CoroutineDispatcher = Dispatchers.IO
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package com.nextcloud.talk.jobs
import android.Manifest
import android.accounts.Account
import android.accounts.AccountManager
import android.app.Activity
import android.content.ContentProviderOperation
import android.content.Context
import android.content.OperationApplicationException
Expand Down Expand Up @@ -454,7 +453,6 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar

companion object {
const val TAG = "ContactAddressBook"
const val REQUEST_PERMISSION = 231
const val KEY_FORCE = "KEY_FORCE"
const val DELETE_ALL = "DELETE_ALL"
private const val HTTP_CODE_TOO_MANY_REQUESTS: Int = 429
Expand All @@ -472,37 +470,21 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar
}
}

fun checkPermission(activity: Activity, context: Context): Boolean {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_CONTACTS) !=
PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS) !=
PackageManager.PERMISSION_GRANTED
) {
activity.requestPermissions(
arrayOf(Manifest.permission.WRITE_CONTACTS, Manifest.permission.READ_CONTACTS),
REQUEST_PERMISSION
)
return false
} else {
WorkManager
.getInstance()
.enqueue(
OneTimeWorkRequest.Builder(ContactAddressBookWorker::class.java)
.setInputData(Data.Builder().putBoolean(KEY_FORCE, true).build())
.build()
)
return true
}
/** Synchronizes the address book now, regardless of when it was synchronized last. */
fun syncNow(workManager: WorkManager) {
workManager.enqueue(
OneTimeWorkRequest.Builder(ContactAddressBookWorker::class.java)
.setInputData(Data.Builder().putBoolean(KEY_FORCE, true).build())
.build()
)
}

fun deleteAll() {
WorkManager
.getInstance()
.enqueue(
OneTimeWorkRequest.Builder(ContactAddressBookWorker::class.java)
.setInputData(Data.Builder().putBoolean(DELETE_ALL, true).build())
.build()
)
fun deleteAll(workManager: WorkManager) {
workManager.enqueue(
OneTimeWorkRequest.Builder(ContactAddressBookWorker::class.java)
.setInputData(Data.Builder().putBoolean(DELETE_ALL, true).build())
.build()
)
}
}
}
63 changes: 63 additions & 0 deletions app/src/main/java/com/nextcloud/talk/settings/AccountRemover.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.nextcloud.talk.settings

import android.content.Context
import android.widget.Toast
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkInfo
import androidx.work.WorkManager
import com.nextcloud.talk.R
import com.nextcloud.talk.dagger.modules.ApplicationScope
import com.nextcloud.talk.jobs.AccountRemovalWorker
import com.nextcloud.talk.logger.Logger
import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.AppTasks
import com.nextcloud.talk.utils.setExpeditedIfSupported
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject

/**
* Removes an account and restarts the app afterwards. Runs in the application scope, as the screen that started it is
* closed as soon as the account is gone.
*/
class AccountRemover @Inject constructor(
private val context: Context,
private val userManager: UserManager,
private val workManager: WorkManager,
private val logger: Logger,
@ApplicationScope private val appScope: CoroutineScope
) {
fun remove(userId: Long, displayName: String) {
appScope.launch {
userManager.scheduleUserForDeletionWithId(userId)
val request = OneTimeWorkRequest.Builder(AccountRemovalWorker::class.java)
.setExpeditedIfSupported()
.build()
workManager.enqueue(request)
val result = workManager.getWorkInfoByIdFlow(request.id).first { it?.state?.isFinished == true }
val message = if (result?.state == WorkInfo.State.SUCCEEDED) {
context.getString(R.string.nc_deleted_user, displayName)
} else {
logger.e(TAG, "Failed to remove the account with id $userId")
context.getString(R.string.nc_common_error_sorry)
}
withContext(Dispatchers.Main) {
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
context.startActivity(AppTasks.createRestartIntent(context))
}
}
}

companion object {
private val TAG = AccountRemover::class.java.simpleName
}
}
Loading
Loading