mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
Run ./gradlew ktlintFormat
This commit is contained in:
parent
b7f0efbeb1
commit
f5375c7af2
9 changed files with 48 additions and 58 deletions
|
@ -91,8 +91,8 @@ private fun toFailure(errorBody: ResponseBody?, httpCode: Int, globalErrorReceiv
|
||||||
matrixError.code == MatrixError.M_CONSENT_NOT_GIVEN && !matrixError.consentUri.isNullOrBlank() -> {
|
matrixError.code == MatrixError.M_CONSENT_NOT_GIVEN && !matrixError.consentUri.isNullOrBlank() -> {
|
||||||
globalErrorReceiver?.handleGlobalError(GlobalError.ConsentNotGivenError(matrixError.consentUri))
|
globalErrorReceiver?.handleGlobalError(GlobalError.ConsentNotGivenError(matrixError.consentUri))
|
||||||
}
|
}
|
||||||
httpCode == HttpURLConnection.HTTP_UNAUTHORIZED /* 401 */
|
httpCode == HttpURLConnection.HTTP_UNAUTHORIZED && /* 401 */
|
||||||
&& matrixError.code == MatrixError.M_UNKNOWN_TOKEN -> {
|
matrixError.code == MatrixError.M_UNKNOWN_TOKEN -> {
|
||||||
globalErrorReceiver?.handleGlobalError(GlobalError.InvalidToken(matrixError.isSoftLogout.orFalse()))
|
globalErrorReceiver?.handleGlobalError(GlobalError.InvalidToken(matrixError.isSoftLogout.orFalse()))
|
||||||
}
|
}
|
||||||
matrixError.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT -> {
|
matrixError.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT -> {
|
||||||
|
|
|
@ -30,9 +30,9 @@ import androidx.test.espresso.matcher.ViewMatchers.withClassName
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import org.hamcrest.Matchers.`is`
|
|
||||||
import org.hamcrest.Matchers.allOf
|
import org.hamcrest.Matchers.allOf
|
||||||
import org.hamcrest.Matchers.instanceOf
|
import org.hamcrest.Matchers.instanceOf
|
||||||
|
import org.hamcrest.Matchers.`is`
|
||||||
|
|
||||||
fun clickOnPreference(@StringRes textResId: Int) {
|
fun clickOnPreference(@StringRes textResId: Int) {
|
||||||
onView(withId(R.id.recycler_view))
|
onView(withId(R.id.recycler_view))
|
||||||
|
|
|
@ -58,49 +58,49 @@ class DefaultErrorFormatter @Inject constructor(
|
||||||
}
|
}
|
||||||
is Failure.ServerError -> {
|
is Failure.ServerError -> {
|
||||||
when {
|
when {
|
||||||
throwable.error.code == MatrixError.M_CONSENT_NOT_GIVEN -> {
|
throwable.error.code == MatrixError.M_CONSENT_NOT_GIVEN -> {
|
||||||
// Special case for terms and conditions
|
// Special case for terms and conditions
|
||||||
stringProvider.getString(R.string.error_terms_not_accepted)
|
stringProvider.getString(R.string.error_terms_not_accepted)
|
||||||
}
|
}
|
||||||
throwable.isInvalidPassword() -> {
|
throwable.isInvalidPassword() -> {
|
||||||
stringProvider.getString(R.string.auth_invalid_login_param)
|
stringProvider.getString(R.string.auth_invalid_login_param)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_USER_IN_USE -> {
|
throwable.error.code == MatrixError.M_USER_IN_USE -> {
|
||||||
stringProvider.getString(R.string.login_signup_error_user_in_use)
|
stringProvider.getString(R.string.login_signup_error_user_in_use)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_BAD_JSON -> {
|
throwable.error.code == MatrixError.M_BAD_JSON -> {
|
||||||
stringProvider.getString(R.string.login_error_bad_json)
|
stringProvider.getString(R.string.login_error_bad_json)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_NOT_JSON -> {
|
throwable.error.code == MatrixError.M_NOT_JSON -> {
|
||||||
stringProvider.getString(R.string.login_error_not_json)
|
stringProvider.getString(R.string.login_error_not_json)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_THREEPID_DENIED -> {
|
throwable.error.code == MatrixError.M_THREEPID_DENIED -> {
|
||||||
stringProvider.getString(R.string.login_error_threepid_denied)
|
stringProvider.getString(R.string.login_error_threepid_denied)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_LIMIT_EXCEEDED -> {
|
throwable.error.code == MatrixError.M_LIMIT_EXCEEDED -> {
|
||||||
limitExceededError(throwable.error)
|
limitExceededError(throwable.error)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_TOO_LARGE -> {
|
throwable.error.code == MatrixError.M_TOO_LARGE -> {
|
||||||
stringProvider.getString(R.string.error_file_too_big_simple)
|
stringProvider.getString(R.string.error_file_too_big_simple)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_THREEPID_NOT_FOUND -> {
|
throwable.error.code == MatrixError.M_THREEPID_NOT_FOUND -> {
|
||||||
stringProvider.getString(R.string.login_reset_password_error_not_found)
|
stringProvider.getString(R.string.login_reset_password_error_not_found)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_USER_DEACTIVATED -> {
|
throwable.error.code == MatrixError.M_USER_DEACTIVATED -> {
|
||||||
stringProvider.getString(R.string.auth_invalid_login_deactivated_account)
|
stringProvider.getString(R.string.auth_invalid_login_deactivated_account)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_THREEPID_IN_USE
|
throwable.error.code == MatrixError.M_THREEPID_IN_USE &&
|
||||||
&& throwable.error.message == "Email is already in use" -> {
|
throwable.error.message == "Email is already in use" -> {
|
||||||
stringProvider.getString(R.string.account_email_already_used_error)
|
stringProvider.getString(R.string.account_email_already_used_error)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_THREEPID_IN_USE
|
throwable.error.code == MatrixError.M_THREEPID_IN_USE &&
|
||||||
&& throwable.error.message == "MSISDN is already in use" -> {
|
throwable.error.message == "MSISDN is already in use" -> {
|
||||||
stringProvider.getString(R.string.account_phone_number_already_used_error)
|
stringProvider.getString(R.string.account_phone_number_already_used_error)
|
||||||
}
|
}
|
||||||
throwable.error.code == MatrixError.M_THREEPID_AUTH_FAILED -> {
|
throwable.error.code == MatrixError.M_THREEPID_AUTH_FAILED -> {
|
||||||
stringProvider.getString(R.string.error_threepid_auth_failed)
|
stringProvider.getString(R.string.error_threepid_auth_failed)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
throwable.error.message.takeIf { it.isNotEmpty() }
|
throwable.error.message.takeIf { it.isNotEmpty() }
|
||||||
?: throwable.error.code.takeIf { it.isNotEmpty() }
|
?: throwable.error.code.takeIf { it.isNotEmpty() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,19 +221,19 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
|
||||||
private fun startNextActivityAndFinish(ignoreClearCredentials: Boolean = false) {
|
private fun startNextActivityAndFinish(ignoreClearCredentials: Boolean = false) {
|
||||||
val intent = when {
|
val intent = when {
|
||||||
args.clearCredentials &&
|
args.clearCredentials &&
|
||||||
!ignoreClearCredentials
|
!ignoreClearCredentials &&
|
||||||
&& (!args.isUserLoggedOut || args.isAccountDeactivated) -> {
|
(!args.isUserLoggedOut || args.isAccountDeactivated) -> {
|
||||||
// User has explicitly asked to log out or deactivated his account
|
// User has explicitly asked to log out or deactivated his account
|
||||||
navigator.openLogin(this, null)
|
navigator.openLogin(this, null)
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
args.isSoftLogout ->
|
args.isSoftLogout ->
|
||||||
// The homeserver has invalidated the token, with a soft logout
|
// The homeserver has invalidated the token, with a soft logout
|
||||||
getSoftLogoutActivityIntent()
|
getSoftLogoutActivityIntent()
|
||||||
args.isUserLoggedOut ->
|
args.isUserLoggedOut ->
|
||||||
// the homeserver has invalidated the token (password changed, device deleted, other security reasons)
|
// the homeserver has invalidated the token (password changed, device deleted, other security reasons)
|
||||||
SignedOutActivity.newIntent(this)
|
SignedOutActivity.newIntent(this)
|
||||||
sessionHolder.hasActiveSession() ->
|
sessionHolder.hasActiveSession() ->
|
||||||
// We have a session.
|
// We have a session.
|
||||||
// Check it can be opened
|
// Check it can be opened
|
||||||
if (sessionHolder.getActiveSession().isOpenable) {
|
if (sessionHolder.getActiveSession().isOpenable) {
|
||||||
|
@ -242,7 +242,7 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
|
||||||
// The token is still invalid
|
// The token is still invalid
|
||||||
getSoftLogoutActivityIntent()
|
getSoftLogoutActivityIntent()
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// First start, or no active session
|
// First start, or no active session
|
||||||
navigator.openLogin(this, null)
|
navigator.openLogin(this, null)
|
||||||
null
|
null
|
||||||
|
|
|
@ -78,7 +78,6 @@ class ShortcutCreator @Inject constructor(
|
||||||
.setLongLived(true)
|
.setLongLived(true)
|
||||||
.setRank(rank)
|
.setRank(rank)
|
||||||
.setCategories(categories)
|
.setCategories(categories)
|
||||||
|
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -781,11 +781,11 @@ class LoginViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
val loginMode = when {
|
val loginMode = when {
|
||||||
// SSO login is taken first
|
// SSO login is taken first
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.SSO)
|
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) &&
|
||||||
&& data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.SsoAndPassword(data.ssoIdentityProviders)
|
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.SsoAndPassword(data.ssoIdentityProviders)
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) -> LoginMode.Sso(data.ssoIdentityProviders)
|
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) -> LoginMode.Sso(data.ssoIdentityProviders)
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.Password
|
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.Password
|
||||||
else -> LoginMode.Unsupported
|
else -> LoginMode.Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME We should post a view event here normally?
|
// FIXME We should post a view event here normally?
|
||||||
|
|
|
@ -587,16 +587,16 @@ class LoginViewModel2 @AssistedInject constructor(
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
when (data) {
|
when (data) {
|
||||||
is WellknownResult.Prompt ->
|
is WellknownResult.Prompt ->
|
||||||
onWellknownSuccess(action, data, homeServerConnectionConfig)
|
onWellknownSuccess(action, data, homeServerConnectionConfig)
|
||||||
is WellknownResult.FailPrompt ->
|
is WellknownResult.FailPrompt ->
|
||||||
// Relax on IS discovery if homeserver is valid
|
// Relax on IS discovery if homeserver is valid
|
||||||
if (data.homeServerUrl != null && data.wellKnown != null) {
|
if (data.homeServerUrl != null && data.wellKnown != null) {
|
||||||
onWellknownSuccess(action, WellknownResult.Prompt(data.homeServerUrl!!, null, data.wellKnown!!), homeServerConnectionConfig)
|
onWellknownSuccess(action, WellknownResult.Prompt(data.homeServerUrl!!, null, data.wellKnown!!), homeServerConnectionConfig)
|
||||||
} else {
|
} else {
|
||||||
onWellKnownError()
|
onWellKnownError()
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
onWellKnownError()
|
onWellKnownError()
|
||||||
}
|
}
|
||||||
}.exhaustive
|
}.exhaustive
|
||||||
|
@ -630,11 +630,11 @@ class LoginViewModel2 @AssistedInject constructor(
|
||||||
} ?: return
|
} ?: return
|
||||||
|
|
||||||
val loginMode = when {
|
val loginMode = when {
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.SSO)
|
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) &&
|
||||||
&& data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.SsoAndPassword(data.ssoIdentityProviders)
|
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.SsoAndPassword(data.ssoIdentityProviders)
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) -> LoginMode.Sso(data.ssoIdentityProviders)
|
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) -> LoginMode.Sso(data.ssoIdentityProviders)
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.Password
|
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.Password
|
||||||
else -> LoginMode.Unsupported
|
else -> LoginMode.Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
val viewEvent = when (loginMode) {
|
val viewEvent = when (loginMode) {
|
||||||
|
@ -757,11 +757,11 @@ class LoginViewModel2 @AssistedInject constructor(
|
||||||
rememberHomeServer(homeServerConnectionConfig.homeServerUri.toString())
|
rememberHomeServer(homeServerConnectionConfig.homeServerUri.toString())
|
||||||
|
|
||||||
val loginMode = when {
|
val loginMode = when {
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.SSO)
|
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) &&
|
||||||
&& data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.SsoAndPassword(data.ssoIdentityProviders)
|
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.SsoAndPassword(data.ssoIdentityProviders)
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) -> LoginMode.Sso(data.ssoIdentityProviders)
|
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) -> LoginMode.Sso(data.ssoIdentityProviders)
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.Password
|
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.Password
|
||||||
else -> LoginMode.Unsupported
|
else -> LoginMode.Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
val viewEvent = when (loginMode) {
|
val viewEvent = when (loginMode) {
|
||||||
|
|
|
@ -543,36 +543,27 @@ class NotificationUtils @Inject constructor(private val context: Context,
|
||||||
.setWhen(lastMessageTimestamp)
|
.setWhen(lastMessageTimestamp)
|
||||||
// MESSAGING_STYLE sets title and content for API 16 and above devices.
|
// MESSAGING_STYLE sets title and content for API 16 and above devices.
|
||||||
.setStyle(messageStyle)
|
.setStyle(messageStyle)
|
||||||
|
|
||||||
// A category allows groups of notifications to be ranked and filtered – per user or system settings.
|
// A category allows groups of notifications to be ranked and filtered – per user or system settings.
|
||||||
// For example, alarm notifications should display before promo notifications, or message from known contact
|
// For example, alarm notifications should display before promo notifications, or message from known contact
|
||||||
// that can be displayed in not disturb mode if white listed (the later will need compat28.x)
|
// that can be displayed in not disturb mode if white listed (the later will need compat28.x)
|
||||||
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
|
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
|
||||||
|
|
||||||
// ID of the corresponding shortcut, for conversation features under API 30+
|
// ID of the corresponding shortcut, for conversation features under API 30+
|
||||||
.setShortcutId(roomInfo.roomId)
|
.setShortcutId(roomInfo.roomId)
|
||||||
|
|
||||||
// Title for API < 16 devices.
|
// Title for API < 16 devices.
|
||||||
.setContentTitle(roomInfo.roomDisplayName)
|
.setContentTitle(roomInfo.roomDisplayName)
|
||||||
// Content for API < 16 devices.
|
// Content for API < 16 devices.
|
||||||
.setContentText(stringProvider.getString(R.string.notification_new_messages))
|
.setContentText(stringProvider.getString(R.string.notification_new_messages))
|
||||||
|
|
||||||
// Number of new notifications for API <24 (M and below) devices.
|
// Number of new notifications for API <24 (M and below) devices.
|
||||||
.setSubText(stringProvider.getQuantityString(R.plurals.room_new_messages_notification, messageStyle.messages.size, messageStyle.messages.size))
|
.setSubText(stringProvider.getQuantityString(R.plurals.room_new_messages_notification, messageStyle.messages.size, messageStyle.messages.size))
|
||||||
|
|
||||||
// Auto-bundling is enabled for 4 or more notifications on API 24+ (N+)
|
// Auto-bundling is enabled for 4 or more notifications on API 24+ (N+)
|
||||||
// devices and all Wear devices. But we want a custom grouping, so we specify the groupID
|
// devices and all Wear devices. But we want a custom grouping, so we specify the groupID
|
||||||
// TODO Group should be current user display name
|
// TODO Group should be current user display name
|
||||||
.setGroup(stringProvider.getString(R.string.app_name))
|
.setGroup(stringProvider.getString(R.string.app_name))
|
||||||
|
|
||||||
// In order to avoid notification making sound twice (due to the summary notification)
|
// In order to avoid notification making sound twice (due to the summary notification)
|
||||||
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY)
|
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY)
|
||||||
|
|
||||||
.setSmallIcon(smallIcon)
|
.setSmallIcon(smallIcon)
|
||||||
|
|
||||||
// Set primary color (important for Wear 2.0 Notifications).
|
// Set primary color (important for Wear 2.0 Notifications).
|
||||||
.setColor(accentColor)
|
.setColor(accentColor)
|
||||||
|
|
||||||
// Sets priority for 25 and below. For 26 and above, 'priority' is deprecated for
|
// Sets priority for 25 and below. For 26 and above, 'priority' is deprecated for
|
||||||
// 'importance' which is set in the NotificationChannel. The integers representing
|
// 'importance' which is set in the NotificationChannel. The integers representing
|
||||||
// 'priority' are different from 'importance', so make sure you don't mix them.
|
// 'priority' are different from 'importance', so make sure you don't mix them.
|
||||||
|
|
|
@ -103,11 +103,11 @@ class SoftLogoutViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
val loginMode = when {
|
val loginMode = when {
|
||||||
// SSO login is taken first
|
// SSO login is taken first
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.SSO)
|
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) &&
|
||||||
&& data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.SsoAndPassword(data.ssoIdentityProviders)
|
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.SsoAndPassword(data.ssoIdentityProviders)
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) -> LoginMode.Sso(data.ssoIdentityProviders)
|
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) -> LoginMode.Sso(data.ssoIdentityProviders)
|
||||||
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.Password
|
data.supportedLoginTypes.contains(LoginFlowTypes.PASSWORD) -> LoginMode.Password
|
||||||
else -> LoginMode.Unsupported
|
else -> LoginMode.Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
setState {
|
setState {
|
||||||
|
|
Loading…
Reference in a new issue