Clear history (#1933)
This commit is contained in:
parent
5a69b33600
commit
09040b7095
|
@ -13,6 +13,7 @@ Improvements 🙌:
|
|||
- Add Setting Item to Change PIN (#2462)
|
||||
- Improve room history visibility setting UX (#1579)
|
||||
- Matrix.to deeplink custom scheme support
|
||||
- Homeserver history (#1933)
|
||||
|
||||
Bugfix 🐛:
|
||||
- Fix cancellation of sending event (#2438)
|
||||
|
|
|
@ -24,9 +24,7 @@ import dagger.Module
|
|||
import dagger.Provides
|
||||
import io.realm.RealmConfiguration
|
||||
import okhttp3.OkHttpClient
|
||||
import org.matrix.android.sdk.api.auth.HomeServerHistoryService
|
||||
import org.matrix.android.sdk.api.raw.RawService
|
||||
import org.matrix.android.sdk.internal.auth.DefaultHomeServerHistoryService
|
||||
import org.matrix.android.sdk.internal.database.RealmKeysUtils
|
||||
import org.matrix.android.sdk.internal.di.GlobalDatabase
|
||||
import org.matrix.android.sdk.internal.di.MatrixScope
|
||||
|
@ -61,6 +59,7 @@ internal abstract class RawModule {
|
|||
.name("matrix-sdk-global.realm")
|
||||
.schemaVersion(GlobalRealmMigration.SCHEMA_VERSION)
|
||||
.migration(GlobalRealmMigration)
|
||||
.allowWritesOnUiThread(true)
|
||||
.modules(GlobalRealmModule())
|
||||
.build()
|
||||
}
|
||||
|
|
|
@ -60,6 +60,9 @@ sealed class LoginAction : VectorViewModelAction {
|
|||
object ResetLogin : ResetAction()
|
||||
object ResetResetPassword : ResetAction()
|
||||
|
||||
// Homeserver history
|
||||
object ClearHomeServerHistory : LoginAction()
|
||||
|
||||
// For the soft logout case
|
||||
data class SetupSsoForSessionRecovery(val homeServerUrl: String,
|
||||
val deviceId: String,
|
||||
|
|
|
@ -21,10 +21,12 @@ import android.os.Bundle
|
|||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import butterknife.OnClick
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.jakewharton.rxbinding3.widget.textChanges
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.hideKeyboard
|
||||
import im.vector.app.core.utils.ensureProtocol
|
||||
|
@ -84,7 +86,7 @@ class LoginServerUrlFormFragment @Inject constructor() : AbstractLoginFragment()
|
|||
loginServerUrlFormNotice.text = getString(R.string.login_server_url_form_common_notice)
|
||||
}
|
||||
}
|
||||
val completions = state.knownCustomHomeServersUrls
|
||||
val completions = state.knownCustomHomeServersUrls + if (BuildConfig.DEBUG) listOf("http://10.0.2.2:8080") else emptyList()
|
||||
loginServerUrlFormHomeServerUrl.setAdapter(ArrayAdapter(
|
||||
requireContext(),
|
||||
R.layout.item_completion_homeserver,
|
||||
|
@ -100,6 +102,11 @@ class LoginServerUrlFormFragment @Inject constructor() : AbstractLoginFragment()
|
|||
openUrlInChromeCustomTab(requireActivity(), null, EMS_LINK)
|
||||
}
|
||||
|
||||
@OnClick(R.id.loginServerUrlFormClearHistory)
|
||||
fun clearHistory() {
|
||||
loginViewModel.handle(LoginAction.ClearHomeServerHistory)
|
||||
}
|
||||
|
||||
override fun resetViewModel() {
|
||||
loginViewModel.handle(LoginAction.ResetHomeServerUrl)
|
||||
}
|
||||
|
@ -141,6 +148,8 @@ class LoginServerUrlFormFragment @Inject constructor() : AbstractLoginFragment()
|
|||
override fun updateWithState(state: LoginViewState) {
|
||||
setupUi(state)
|
||||
|
||||
loginServerUrlFormClearHistory.isInvisible = state.knownCustomHomeServersUrls.isEmpty()
|
||||
|
||||
if (state.loginMode != LoginMode.Unknown) {
|
||||
// The home server url is valid
|
||||
loginViewModel.handle(LoginAction.PostViewEvent(LoginViewEvents.OnLoginFlowRetrieved))
|
||||
|
|
|
@ -28,7 +28,6 @@ import com.airbnb.mvrx.Uninitialized
|
|||
import com.airbnb.mvrx.ViewModelContext
|
||||
import com.squareup.inject.assisted.Assisted
|
||||
import com.squareup.inject.assisted.AssistedInject
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.configureAndStart
|
||||
|
@ -80,10 +79,7 @@ class LoginViewModel @AssistedInject constructor(
|
|||
|
||||
private fun getKnownCustomHomeServersUrls() {
|
||||
setState {
|
||||
copy(
|
||||
knownCustomHomeServersUrls = homeServerHistoryService.getKnownServersUrls()
|
||||
+ if (BuildConfig.DEBUG) listOf("http://10.0.2.2:8080") else emptyList()
|
||||
)
|
||||
copy(knownCustomHomeServersUrls = homeServerHistoryService.getKnownServersUrls())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,6 +133,7 @@ class LoginViewModel @AssistedInject constructor(
|
|||
is LoginAction.ResetAction -> handleResetAction(action)
|
||||
is LoginAction.SetupSsoForSessionRecovery -> handleSetupSsoForSessionRecovery(action)
|
||||
is LoginAction.UserAcceptCertificate -> handleUserAcceptCertificate(action)
|
||||
LoginAction.ClearHomeServerHistory -> handleClearHomeServerHistory()
|
||||
is LoginAction.PostViewEvent -> _viewEvents.post(action.viewEvent)
|
||||
}.exhaustive
|
||||
}
|
||||
|
@ -167,6 +164,11 @@ class LoginViewModel @AssistedInject constructor(
|
|||
getKnownCustomHomeServersUrls()
|
||||
}
|
||||
|
||||
private fun handleClearHomeServerHistory() {
|
||||
homeServerHistoryService.clearHistory()
|
||||
getKnownCustomHomeServersUrls()
|
||||
}
|
||||
|
||||
private fun handleLoginWithToken(action: LoginAction.LoginWithToken) {
|
||||
val safeLoginWizard = loginWizard
|
||||
|
||||
|
|
|
@ -70,6 +70,17 @@
|
|||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loginServerUrlFormClearHistory"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/login_clear_homeserver_history"
|
||||
android:textAppearance="@style/TextAppearance.Vector.Login.Text.Small"
|
||||
android:textColor="@color/riotx_accent"
|
||||
android:visibility="invisible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loginServerUrlFormNotice"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -2001,6 +2001,7 @@
|
|||
<string name="login_signup">Sign Up</string>
|
||||
<string name="login_signin">Sign In</string>
|
||||
<string name="login_signin_sso">Continue with SSO</string>
|
||||
<string name="login_clear_homeserver_history">Clear history</string>
|
||||
|
||||
<string name="login_server_url_form_modular_hint">Element Matrix Services Address</string>
|
||||
<string name="login_server_url_form_other_hint">Address</string>
|
||||
|
|
Loading…
Reference in New Issue