Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ import org.koin.android.ext.android.inject
import timber.log.Timber
import java.io.File

// Error snackbars need longer than the default LENGTH_LONG (2.75s) so the user can read a failure
// and react (retry, reconnect). Passed as a raw millisecond value, which Snackbar.make accepts.
const val SNACKBAR_DURATION_ERROR_MS = 7000

fun Activity.showErrorInSnackbar(genericErrorMessageId: Int, throwable: Throwable?) =
throwable?.let {
showMessageInSnackbar(
message = it.parseError(getString(genericErrorMessageId), resources)
message = it.parseError(getString(genericErrorMessageId), resources),
duration = SNACKBAR_DURATION_ERROR_MS
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import kotlinx.coroutines.launch

fun Fragment.showErrorInSnackbar(genericErrorMessageId: Int, throwable: Throwable?) =
throwable?.let {
showMessageInSnackbar(it.parseError(getString(genericErrorMessageId), resources))
showMessageInSnackbar(it.parseError(getString(genericErrorMessageId), resources), SNACKBAR_DURATION_ERROR_MS)
}

fun Fragment.showMessageInSnackbar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import eu.opencloud.android.extensions.goToUrl
import eu.opencloud.android.extensions.manageOptionLockSelected
import eu.opencloud.android.extensions.parseError
import eu.opencloud.android.extensions.showErrorInToast
import eu.opencloud.android.extensions.SNACKBAR_DURATION_ERROR_MS
import eu.opencloud.android.extensions.showMessageInSnackbar
import eu.opencloud.android.lib.common.accounts.AccountTypeUtils
import eu.opencloud.android.lib.common.accounts.AccountUtils
Expand Down Expand Up @@ -331,7 +332,10 @@ class LoginActivity : AppCompatActivity(), SslUntrustedCertDialog.OnSslUntrusted
if (getAccounts(baseContext).isNotEmpty()) {
launchFileDisplayActivity()
} else {
showMessageInSnackbar(message = baseContext.getString(R.string.uploader_wrn_no_account_title))
showMessageInSnackbar(
message = baseContext.getString(R.string.uploader_wrn_no_account_title),
duration = SNACKBAR_DURATION_ERROR_MS
)
}
}
}
Expand Down Expand Up @@ -806,7 +810,7 @@ class LoginActivity : AppCompatActivity(), SslUntrustedCertDialog.OnSslUntrusted

if (state != authenticationViewModel.oidcState) {
Timber.e("OAuth: state mismatch (expected=${authenticationViewModel.oidcState}, got=$state). Finishing.")
showMessageInSnackbar(message = getString(R.string.auth_oauth_error))
showMessageInSnackbar(message = getString(R.string.auth_oauth_error), duration = SNACKBAR_DURATION_ERROR_MS)
finish()
} else {
if (authorizationCode != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import eu.opencloud.android.extensions.filterMenuOptions
import eu.opencloud.android.extensions.isDownload
import eu.opencloud.android.extensions.openOCFile
import eu.opencloud.android.extensions.sendDownloadedFilesByShareSheet
import eu.opencloud.android.extensions.SNACKBAR_DURATION_ERROR_MS
import eu.opencloud.android.extensions.showErrorInSnackbar
import eu.opencloud.android.extensions.showMessageInSnackbar
import eu.opencloud.android.presentation.authentication.ACTION_UPDATE_EXPIRED_TOKEN
Expand Down Expand Up @@ -203,15 +204,15 @@ class FileDetailsFragment : FileFragment() {
}

SynchronizeFileUseCase.SyncType.FileNotFound -> {
showMessageInSnackbar(getString(R.string.sync_file_not_found_msg))
showMessageInSnackbar(getString(R.string.sync_file_not_found_msg), SNACKBAR_DURATION_ERROR_MS)
}

is SynchronizeFileUseCase.SyncType.UploadEnqueued -> {
fileDetailsViewModel.startListeningToWorkInfo(uiResult.data.workerId)
}

null -> {
showMessageInSnackbar(getString(R.string.common_error_unknown))
showMessageInSnackbar(getString(R.string.common_error_unknown), SNACKBAR_DURATION_ERROR_MS)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import eu.opencloud.android.extensions.collectLatestLifecycleFlow
import eu.opencloud.android.extensions.filterMenuOptions
import eu.opencloud.android.extensions.parseError
import eu.opencloud.android.extensions.sendDownloadedFilesByShareSheet
import eu.opencloud.android.extensions.SNACKBAR_DURATION_ERROR_MS
import eu.opencloud.android.extensions.showErrorInSnackbar
import eu.opencloud.android.extensions.showMessageInSnackbar
import eu.opencloud.android.extensions.toDrawableRes
Expand Down Expand Up @@ -865,7 +866,7 @@ class MainFileListFragment : Fragment(),

is UIResult.Error -> {
fileActivity.dismissLoadingDialog()
showMessageInSnackbar(resources.getString(R.string.common_error_unknown))
showMessageInSnackbar(resources.getString(R.string.common_error_unknown), SNACKBAR_DURATION_ERROR_MS)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import eu.opencloud.android.R
import eu.opencloud.android.extensions.SNACKBAR_DURATION_ERROR_MS
import eu.opencloud.android.extensions.showMessageInSnackbar
import eu.opencloud.android.ui.activity.enableEdgeToEdgePostSetContentView
import eu.opencloud.android.ui.activity.enableEdgeToEdgePreSetContentView
Expand Down Expand Up @@ -97,7 +98,10 @@ class PrivacyPolicyActivity : AppCompatActivity() {

webViewClient = object : WebViewClient() {
override fun onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String) {
showMessageInSnackbar(message = getString(R.string.privacy_policy_error) + description)
showMessageInSnackbar(
message = getString(R.string.privacy_policy_error) + description,
duration = SNACKBAR_DURATION_ERROR_MS
)
}

override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import eu.opencloud.android.extensions.observeWorkerTillItFinishes
import eu.opencloud.android.extensions.openOCFile
import eu.opencloud.android.extensions.parseError
import eu.opencloud.android.extensions.sendDownloadedFilesByShareSheet
import eu.opencloud.android.extensions.SNACKBAR_DURATION_ERROR_MS
import eu.opencloud.android.extensions.showErrorInSnackbar
import eu.opencloud.android.extensions.showMessageInSnackbar
import eu.opencloud.android.lib.common.accounts.AccountUtils
Expand Down Expand Up @@ -930,7 +931,7 @@ class FileDisplayActivity : FileActivity(),
if (synchResult.httpPhrase == "Error: Call to a member function getUID() on null") {
showRequestAccountChangeNotice(getString(R.string.auth_failure_snackbar), false)
} else {
showMessageInSnackbar(R.id.list_layout, synchResult.httpPhrase)
showMessageInSnackbar(R.id.list_layout, synchResult.httpPhrase, SNACKBAR_DURATION_ERROR_MS)
}
} else {
showRequestAccountChangeNotice(getString(R.string.auth_failure_snackbar), false)
Expand Down Expand Up @@ -1430,7 +1431,7 @@ class FileDisplayActivity : FileActivity(),
}

else -> {
showMessageInSnackbar(R.id.list_layout, getString(R.string.sync_fail_ticker))
showMessageInSnackbar(R.id.list_layout, getString(R.string.sync_fail_ticker), SNACKBAR_DURATION_ERROR_MS)
}
}
}
Expand Down Expand Up @@ -1538,7 +1539,7 @@ class FileDisplayActivity : FileActivity(),
}

else -> {
showMessageInSnackbar(R.id.list_layout, getString(R.string.sync_fail_ticker))
showMessageInSnackbar(R.id.list_layout, getString(R.string.sync_fail_ticker), SNACKBAR_DURATION_ERROR_MS)
}
}
}
Expand Down Expand Up @@ -1982,7 +1983,11 @@ class FileDisplayActivity : FileActivity(),
is UIResult.Error -> {
dismissLoadingDialog()
if (uiResult.error is FileNotFoundException) {
showMessageInSnackbar(R.id.list_layout, message = getString(R.string.deep_link_user_no_access))
showMessageInSnackbar(
R.id.list_layout,
message = getString(R.string.deep_link_user_no_access),
duration = SNACKBAR_DURATION_ERROR_MS
)
changeUser()
} else {
showMessageInSnackbar(
Expand All @@ -1993,7 +1998,8 @@ class FileDisplayActivity : FileActivity(),
} else {
R.string.default_error_msg
}
)
),
duration = SNACKBAR_DURATION_ERROR_MS
)
}
}
Expand Down
Loading