Merge branch 'develop' into feature/integration_manager

This commit is contained in:
ganfra 2020-06-02 20:26:03 +02:00
commit d8848a6062
27 changed files with 444 additions and 176 deletions

View file

@ -6,10 +6,10 @@ Features ✨:
- Send stickers (#51)
Improvements 🙌:
-
- New wording for notice when current user is the sender
Bugfix 🐛:
-
- Switch theme is not fully taken into account without restarting the app
Translations 🗣:
-

View file

@ -2,53 +2,92 @@
<resources>
<string name="summary_message">%1$s: %2$s</string>
<string name="summary_user_sent_image">%1$s sent an image.</string>
<string name="summary_you_sent_image">You sent an image.</string>
<string name="summary_user_sent_sticker">%1$s sent a sticker.</string>
<string name="summary_you_sent_sticker">You sent a sticker.</string>
<string name="notice_room_invite_no_invitee">%s\'s invitation</string>
<string name="notice_room_invite_no_invitee_by_you">Your invitation</string>
<string name="notice_room_created">%1$s created the room</string>
<string name="notice_room_created_by_you">You created the room</string>
<string name="notice_room_invite">%1$s invited %2$s</string>
<string name="notice_room_invite_by_you">You invited %1$s</string>
<string name="notice_room_invite_you">%1$s invited you</string>
<string name="notice_room_join">%1$s joined the room</string>
<string name="notice_room_join_by_you">You joined the room</string>
<string name="notice_room_leave">%1$s left the room</string>
<string name="notice_room_leave_by_you">You left the room</string>
<string name="notice_room_reject">%1$s rejected the invitation</string>
<string name="notice_room_reject_by_you">You rejected the invitation</string>
<string name="notice_room_kick">%1$s kicked %2$s</string>
<string name="notice_room_kick_by_you">You kicked %1$s</string>
<string name="notice_room_unban">%1$s unbanned %2$s</string>
<string name="notice_room_unban_by_you">You unbanned %1$s</string>
<string name="notice_room_ban">%1$s banned %2$s</string>
<string name="notice_room_ban_by_you">You banned %1$s</string>
<string name="notice_room_withdraw">%1$s withdrew %2$s\'s invitation</string>
<string name="notice_room_withdraw_by_you">You withdrew %1$s\'s invitation</string>
<string name="notice_avatar_url_changed">%1$s changed their avatar</string>
<string name="notice_avatar_url_changed_by_you">You changed your avatar</string>
<string name="notice_display_name_set">%1$s set their display name to %2$s</string>
<string name="notice_display_name_set_by_you">You set your display name to %1$s</string>
<string name="notice_display_name_changed_from">%1$s changed their display name from %2$s to %3$s</string>
<string name="notice_display_name_changed_from_by_you">You changed your display name from %1$s to %2$s</string>
<string name="notice_display_name_removed">%1$s removed their display name (%2$s)</string>
<string name="notice_display_name_removed_by_you">You removed your display name (%1$s)</string>
<string name="notice_room_topic_changed">%1$s changed the topic to: %2$s</string>
<string name="notice_room_topic_changed_by_you">You changed the topic to: %1$s</string>
<string name="notice_room_name_changed">%1$s changed the room name to: %2$s</string>
<string name="notice_room_name_changed_by_you">You changed the room name to: %1$s</string>
<string name="notice_placed_video_call">%s placed a video call.</string>
<string name="notice_placed_video_call_by_you">You placed a video call.</string>
<string name="notice_placed_voice_call">%s placed a voice call.</string>
<string name="notice_placed_voice_call_by_you">You placed a voice call.</string>
<string name="notice_answered_call">%s answered the call.</string>
<string name="notice_answered_call_by_you">You answered the call.</string>
<string name="notice_ended_call">%s ended the call.</string>
<string name="notice_ended_call_by_you">You ended the call.</string>
<string name="notice_made_future_room_visibility">%1$s made future room history visible to %2$s</string>
<string name="notice_made_future_room_visibility_by_you">You made future room history visible to %1$s</string>
<string name="notice_room_visibility_invited">all room members, from the point they are invited.</string>
<string name="notice_room_visibility_joined">all room members, from the point they joined.</string>
<string name="notice_room_visibility_shared">all room members.</string>
<string name="notice_room_visibility_world_readable">anyone.</string>
<string name="notice_room_visibility_unknown">unknown (%s).</string>
<string name="notice_end_to_end">%1$s turned on end-to-end encryption (%2$s)</string>
<string name="notice_end_to_end_by_you">You turned on end-to-end encryption (%1$s)</string>
<string name="notice_room_update">%s upgraded this room.</string>
<string name="notice_room_update_by_you">You upgraded this room.</string>
<string name="notice_requested_voip_conference">%1$s requested a VoIP conference</string>
<string name="notice_requested_voip_conference_by_you">You requested a VoIP conference</string>
<string name="notice_voip_started">VoIP conference started</string>
<string name="notice_voip_finished">VoIP conference finished</string>
<string name="notice_avatar_changed_too">(avatar was changed too)</string>
<string name="notice_room_name_removed">%1$s removed the room name</string>
<string name="notice_room_name_removed_by_you">You removed the room name</string>
<string name="notice_room_topic_removed">%1$s removed the room topic</string>
<string name="notice_room_topic_removed_by_you">You removed the room topic</string>
<string name="notice_event_redacted">Message removed</string>
<string name="notice_event_redacted_by">Message removed by %1$s</string>
<string name="notice_event_redacted_with_reason">Message removed [reason: %1$s]</string>
<string name="notice_event_redacted_by_with_reason">Message removed by %1$s [reason: %2$s]</string>
<string name="notice_profile_change_redacted">%1$s updated their profile %2$s</string>
<string name="notice_profile_change_redacted_by_you">You updated your profile %1$s</string>
<string name="notice_room_third_party_invite">%1$s sent an invitation to %2$s to join the room</string>
<string name="notice_room_third_party_invite_by_you">You sent an invitation to %1$s to join the room</string>
<string name="notice_room_third_party_revoked_invite">%1$s revoked the invitation for %2$s to join the room</string>
<string name="notice_room_third_party_revoked_invite_by_you">You revoked the invitation for %1$s to join the room</string>
<string name="notice_room_third_party_registered_invite">%1$s accepted the invitation for %2$s</string>
<string name="notice_room_third_party_registered_invite_by_you">You accepted the invitation for %1$s</string>
<string name="notice_widget_added">%1$s widget added by %2$s</string>
<string name="notice_widget_added_by_you">%1$s widget added by you</string>
<string name="notice_widget_removed">%1$s widget removed by %2$s</string>
<string name="notice_widget_removed_by_you">%1$s widget removed by you</string>
<string name="notice_widget_modified">%1$s widget modified by %2$s</string>
<string name="notice_widget_modified_by_you">%1$s widget modified by you</string>
<string name="notice_crypto_unable_to_decrypt">** Unable to decrypt: %s **</string>
<string name="notice_crypto_error_unkwown_inbound_session_id">The sender\'s device has not sent us the keys for this message.</string>
@ -245,39 +284,68 @@
<string name="clear_timeline_send_queue">Clear sending queue</string>
<string name="notice_room_invite_no_invitee_with_reason">%1$s\'s invitation. Reason: %2$s</string>
<string name="notice_room_invite_no_invitee_with_reason_by_you">Your invitation. Reason: %1$s</string>
<string name="notice_room_invite_with_reason">%1$s invited %2$s. Reason: %3$s</string>
<string name="notice_room_invite_with_reason_by_you">You invited %1$s. Reason: %2$s</string>
<string name="notice_room_invite_you_with_reason">%1$s invited you. Reason: %2$s</string>
<string name="notice_room_join_with_reason">%1$s joined the room. Reason: %2$s</string>
<string name="notice_room_join_with_reason_by_you">You joined the room. Reason: %1$s</string>
<string name="notice_room_leave_with_reason">%1$s left the room. Reason: %2$s</string>
<string name="notice_room_leave_with_reason_by_you">You left the room. Reason: %1$s</string>
<string name="notice_room_reject_with_reason">%1$s rejected the invitation. Reason: %2$s</string>
<string name="notice_room_reject_with_reason_by_you">You rejected the invitation. Reason: %1$s</string>
<string name="notice_room_kick_with_reason">%1$s kicked %2$s. Reason: %3$s</string>
<string name="notice_room_kick_with_reason_by_you">You kicked %1$s. Reason: %2$s</string>
<string name="notice_room_unban_with_reason">%1$s unbanned %2$s. Reason: %3$s</string>
<string name="notice_room_unban_with_reason_by_you">You unbanned %1$s. Reason: %2$s</string>
<string name="notice_room_ban_with_reason">%1$s banned %2$s. Reason: %3$s</string>
<string name="notice_room_ban_with_reason_by_you">You banned %1$s. Reason: %2$s</string>
<string name="notice_room_third_party_invite_with_reason">%1$s sent an invitation to %2$s to join the room. Reason: %3$s</string>
<string name="notice_room_third_party_invite_with_reason_by_you">You sent an invitation to %1$s to join the room. Reason: %2$s</string>
<string name="notice_room_third_party_revoked_invite_with_reason">%1$s revoked the invitation for %2$s to join the room. Reason: %3$s</string>
<string name="notice_room_third_party_revoked_invite_with_reason_by_you">You revoked the invitation for %1$s to join the room. Reason: %2$s</string>
<string name="notice_room_third_party_registered_invite_with_reason">%1$s accepted the invitation for %2$s. Reason: %3$s</string>
<string name="notice_room_third_party_registered_invite_with_reason_by_you">You accepted the invitation for %1$s. Reason: %2$s</string>
<string name="notice_room_withdraw_with_reason">%1$s withdrew %2$s\'s invitation. Reason: %3$s</string>
<string name="notice_room_withdraw_with_reason_by_you">You withdrew %1$s\'s invitation. Reason: %2$s</string>
<plurals name="notice_room_aliases_added">
<item quantity="one">%1$s added %2$s as an address for this room.</item>
<item quantity="other">%1$s added %2$s as addresses for this room.</item>
</plurals>
<plurals name="notice_room_aliases_added_by_you">
<item quantity="one">You added %1$s as an address for this room.</item>
<item quantity="other">You added %1$s as addresses for this room.</item>
</plurals>
<plurals name="notice_room_aliases_removed">
<item quantity="one">%1$s removed %2$s as an address for this room.</item>
<item quantity="other">%1$s removed %3$s as addresses for this room.</item>
</plurals>
<plurals name="notice_room_aliases_removed_by_you">
<item quantity="one">You removed %1$s as an address for this room.</item>
<item quantity="other">You removed %2$s as addresses for this room.</item>
</plurals>
<string name="notice_room_aliases_added_and_removed">%1$s added %2$s and removed %3$s as addresses for this room.</string>
<string name="notice_room_aliases_added_and_removed_by_you">You added %1$s and removed %2$s as addresses for this room.</string>
<string name="notice_room_canonical_alias_set">"%1$s set the main address for this room to %2$s."</string>
<string name="notice_room_canonical_alias_set_by_you">"You set the main address for this room to %1$s."</string>
<string name="notice_room_canonical_alias_unset">"%1$s removed the main address for this room."</string>
<string name="notice_room_canonical_alias_unset_by_you">"You removed the main address for this room."</string>
<string name="notice_room_guest_access_can_join">"%1$s has allowed guests to join the room."</string>
<string name="notice_room_guest_access_can_join_by_you">"You have allowed guests to join the room."</string>
<string name="notice_room_guest_access_forbidden">"%1$s has prevented guests from joining the room."</string>
<string name="notice_room_guest_access_forbidden_by_you">"You have prevented guests from joining the room."</string>
<string name="notice_end_to_end_ok">%1$s turned on end-to-end encryption.</string>
<string name="notice_end_to_end_ok_by_you">You turned on end-to-end encryption.</string>
<string name="notice_end_to_end_unknown_algorithm">%1$s turned on end-to-end encryption (unrecognised algorithm %2$s).</string>
<string name="notice_end_to_end_unknown_algorithm_by_you">You turned on end-to-end encryption (unrecognised algorithm %1$s).</string>
<string name="key_verification_request_fallback_message">%s is requesting to verify your key, but your client does not support in-chat key verification. You will need to use legacy key verification to verify keys.</string>

View file

@ -95,7 +95,6 @@ abstract class VectorBaseActivity : AppCompatActivity(), HasScreenInjector {
protected val viewModelProvider
get() = ViewModelProvider(this, viewModelFactory)
// TODO Other Activity should use this also
protected fun <T : VectorViewEvents> VectorViewModel<*, *, T>.observeViewEvents(observer: (T) -> Unit) {
viewEvents
.observe()

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2020 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.riotx.core.utils
import im.vector.riotx.R
import im.vector.riotx.core.resources.ColorProvider
import org.billcarsonfr.jsonviewer.JSonViewerStyleProvider
fun createJSonViewerStyleProvider(colorProvider: ColorProvider): JSonViewerStyleProvider {
return JSonViewerStyleProvider(
keyColor = colorProvider.getColor(R.color.riotx_accent),
secondaryColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_secondary),
stringColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color),
baseColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_primary),
booleanColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color),
numberColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color)
)
}

View file

@ -18,8 +18,6 @@ package im.vector.riotx.core.utils
import androidx.annotation.ColorRes
import im.vector.riotx.R
import im.vector.riotx.core.resources.ColorProvider
import org.billcarsonfr.jsonviewer.JSonViewerStyleProvider
import kotlin.math.abs
@ColorRes
@ -39,14 +37,3 @@ fun getColorFromUserId(userId: String?): Int {
else -> R.color.riotx_username_1
}
}
fun jsonViewerStyler(colorProvider: ColorProvider): JSonViewerStyleProvider {
return JSonViewerStyleProvider(
keyColor = colorProvider.getColor(R.color.riotx_accent),
secondaryColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_secondary),
stringColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color),
baseColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_primary),
booleanColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color),
numberColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color)
)
}

View file

@ -31,7 +31,6 @@ import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.error.ErrorFormatter
import im.vector.riotx.core.extensions.commitTransaction
import im.vector.riotx.core.platform.SimpleFragmentActivity
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.activity.*
import javax.inject.Inject
@ -59,17 +58,9 @@ class SharedSecureStorageActivity : SimpleFragmentActivity() {
super.onCreate(savedInstanceState)
toolbar.visibility = View.GONE
viewModel.viewEvents
.observe()
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
observeViewEvents(it)
}
.disposeOnDestroy()
viewModel.observeViewEvents { observeViewEvents(it) }
viewModel.subscribe(this) {
renderState(it)
}
viewModel.subscribe(this) { renderState(it) }
}
override fun onBackPressed() {

View file

@ -22,22 +22,18 @@ import android.os.Bundle
import android.view.View
import android.view.inputmethod.EditorInfo
import com.airbnb.mvrx.activityViewModel
import com.airbnb.mvrx.withState
import com.jakewharton.rxbinding3.widget.editorActionEvents
import com.jakewharton.rxbinding3.widget.textChanges
import im.vector.matrix.android.api.extensions.tryThis
import im.vector.riotx.R
import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.utils.startImportTextFromFileIntent
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.android.synthetic.main.fragment_ssss_access_from_key.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
class SharedSecuredStorageKeyFragment @Inject constructor(
private val colorProvider: ColorProvider
) : VectorBaseFragment() {
class SharedSecuredStorageKeyFragment @Inject constructor() : VectorBaseFragment() {
override fun getLayoutResId() = R.layout.fragment_ssss_access_from_key
@ -48,7 +44,7 @@ class SharedSecuredStorageKeyFragment @Inject constructor(
ssss_restore_with_key_text.text = getString(R.string.enter_secret_storage_input_key)
ssss_key_enter_edittext.editorActionEvents()
.debounce(300, TimeUnit.MILLISECONDS)
.throttleFirst(300, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
if (it.actionId == EditorInfo.IME_ACTION_DONE) {
@ -102,9 +98,6 @@ class SharedSecuredStorageKeyFragment @Inject constructor(
super.onActivityResult(requestCode, resultCode, data)
}
override fun invalidate() = withState(sharedViewModel) { _ ->
}
companion object {
private const val IMPORT_FILE_REQ = 0
}

View file

@ -58,7 +58,7 @@ class SharedSecuredStoragePassphraseFragment @Inject constructor(
.colorizeMatchingText(key, colorProvider.getColorFromAttribute(android.R.attr.textColorLink))
ssss_passphrase_enter_edittext.editorActionEvents()
.debounce(300, TimeUnit.MILLISECONDS)
.throttleFirst(300, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
if (it.actionId == EditorInfo.IME_ACTION_DONE) {

View file

@ -56,7 +56,7 @@ class BootstrapAccountPasswordFragment @Inject constructor(
bootstrapAccountPasswordEditText.hint = getString(R.string.account_password)
bootstrapAccountPasswordEditText.editorActionEvents()
.debounce(300, TimeUnit.MILLISECONDS)
.throttleFirst(300, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
if (it.actionId == EditorInfo.IME_ACTION_DONE) {
@ -98,8 +98,6 @@ class BootstrapAccountPasswordFragment @Inject constructor(
}
override fun invalidate() = withState(sharedViewModel) { state ->
super.invalidate()
if (state.step is BootstrapStep.AccountPassword) {
val isPasswordVisible = state.step.isPasswordVisible
bootstrapAccountPasswordEditText.showPassword(isPasswordVisible, updateCursor = false)

View file

@ -63,7 +63,7 @@ class BootstrapConfirmPassphraseFragment @Inject constructor(
}
ssss_passphrase_enter_edittext.editorActionEvents()
.debounce(300, TimeUnit.MILLISECONDS)
.throttleFirst(300, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
if (it.actionId == EditorInfo.IME_ACTION_DONE) {
@ -96,13 +96,15 @@ class BootstrapConfirmPassphraseFragment @Inject constructor(
return@withState
}
val passphrase = ssss_passphrase_enter_edittext.text?.toString()
if (passphrase.isNullOrBlank()) {
ssss_passphrase_enter_til.error = getString(R.string.passphrase_empty_error_message)
} else if (passphrase != state.passphrase) {
ssss_passphrase_enter_til.error = getString(R.string.passphrase_passphrase_does_not_match)
} else {
view?.hideKeyboard()
sharedViewModel.handle(BootstrapActions.DoInitialize(passphrase))
when {
passphrase.isNullOrBlank() ->
ssss_passphrase_enter_til.error = getString(R.string.passphrase_empty_error_message)
passphrase != state.passphrase ->
ssss_passphrase_enter_til.error = getString(R.string.passphrase_passphrase_does_not_match)
else -> {
view?.hideKeyboard()
sharedViewModel.handle(BootstrapActions.DoInitialize(passphrase))
}
}
}

View file

@ -53,11 +53,11 @@ class BootstrapEnterPassphraseFragment @Inject constructor(
ssss_passphrase_enter_edittext.hint = getString(R.string.passphrase_enter_passphrase)
withState(sharedViewModel) {
// set initial value (usefull when coming back)
// set initial value (useful when coming back)
ssss_passphrase_enter_edittext.setText(it.passphrase ?: "")
}
ssss_passphrase_enter_edittext.editorActionEvents()
.debounce(300, TimeUnit.MILLISECONDS)
.throttleFirst(300, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
if (it.actionId == EditorInfo.IME_ACTION_DONE) {

View file

@ -57,11 +57,11 @@ class BootstrapMigrateBackupFragment @Inject constructor(
super.onViewCreated(view, savedInstanceState)
withState(sharedViewModel) {
// set initial value (usefull when coming back)
// set initial value (useful when coming back)
bootstrapMigrateEditText.setText(it.passphrase ?: "")
}
bootstrapMigrateEditText.editorActionEvents()
.debounce(300, TimeUnit.MILLISECONDS)
.throttleFirst(300, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
if (it.actionId == EditorInfo.IME_ACTION_DONE) {

View file

@ -22,6 +22,7 @@ import android.view.View
import com.airbnb.mvrx.Incomplete
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import im.vector.matrix.android.api.session.group.model.GroupSummary
import im.vector.riotx.R
import im.vector.riotx.core.extensions.cleanup
@ -50,7 +51,6 @@ class GroupListFragment @Inject constructor(
groupController.callback = this
stateView.contentView = groupListView
groupListView.configureWith(groupController)
viewModel.subscribe { renderState(it) }
viewModel.observeViewEvents {
when (it) {
is GroupListViewEvents.OpenGroupSummary -> sharedActionViewModel.post(HomeActivitySharedAction.OpenGroup)
@ -64,7 +64,7 @@ class GroupListFragment @Inject constructor(
super.onDestroyView()
}
private fun renderState(state: GroupListViewState) {
override fun invalidate() = withState(viewModel) { state ->
when (state.asyncGroups) {
is Incomplete -> stateView.state = StateView.State.Loading
is Success -> stateView.state = StateView.State.Content

View file

@ -19,6 +19,7 @@ package im.vector.riotx.features.home.room.breadcrumbs
import android.os.Bundle
import android.view.View
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import im.vector.riotx.R
import im.vector.riotx.core.extensions.cleanup
import im.vector.riotx.core.extensions.configureWith
@ -42,8 +43,6 @@ class BreadcrumbsFragment @Inject constructor(
super.onViewCreated(view, savedInstanceState)
setupRecyclerView()
sharedActionViewModel = activityViewModelProvider.get(RoomDetailSharedActionViewModel::class.java)
breadcrumbsViewModel.subscribe { renderState(it) }
}
override fun onDestroyView() {
@ -57,8 +56,7 @@ class BreadcrumbsFragment @Inject constructor(
breadcrumbsController.listener = this
}
// TODO Use invalidate() ?
private fun renderState(state: BreadcrumbsViewState) {
override fun invalidate() = withState(breadcrumbsViewModel) { state ->
breadcrumbsController.update(state)
}

View file

@ -114,10 +114,10 @@ import im.vector.riotx.core.utils.allGranted
import im.vector.riotx.core.utils.checkPermissions
import im.vector.riotx.core.utils.colorizeMatchingText
import im.vector.riotx.core.utils.copyToClipboard
import im.vector.riotx.core.utils.createJSonViewerStyleProvider
import im.vector.riotx.core.utils.createUIHandler
import im.vector.riotx.core.utils.getColorFromUserId
import im.vector.riotx.core.utils.isValidUrl
import im.vector.riotx.core.utils.jsonViewerStyler
import im.vector.riotx.core.utils.openUrlInExternalBrowser
import im.vector.riotx.core.utils.saveMedia
import im.vector.riotx.core.utils.shareMedia
@ -273,7 +273,6 @@ class RoomDetailFragment @Inject constructor(
roomToolbarContentView.debouncedClicks {
navigator.openRoomProfile(requireActivity(), roomDetailArgs.roomId)
}
roomDetailViewModel.subscribe { renderState(it) }
sharedActionViewModel
.observe()
@ -722,7 +721,7 @@ class RoomDetailFragment @Inject constructor(
inviteView.callback = this
}
private fun renderState(state: RoomDetailViewState) {
override fun invalidate() = withState(roomDetailViewModel) { state ->
renderRoomSummary(state)
val summary = state.asyncRoomSummary()
val inviter = state.asyncInviter()
@ -1259,14 +1258,14 @@ class RoomDetailFragment @Inject constructor(
JSonViewerDialog.newInstance(
action.content,
-1,
jsonViewerStyler(colorProvider)
createJSonViewerStyleProvider(colorProvider)
).show(childFragmentManager, "JSON_VIEWER")
}
is EventSharedAction.ViewDecryptedSource -> {
JSonViewerDialog.newInstance(
action.content,
-1,
jsonViewerStyler(colorProvider)
createJSonViewerStyleProvider(colorProvider)
).show(childFragmentManager, "JSON_VIEWER")
}
is EventSharedAction.QuickReact -> {

View file

@ -22,6 +22,7 @@ import im.vector.matrix.android.api.session.room.model.create.RoomCreateContent
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
import im.vector.matrix.android.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
import im.vector.matrix.android.internal.crypto.model.event.EncryptionEventContent
import im.vector.riotx.core.di.ActiveSessionHolder
import im.vector.riotx.core.extensions.prevOrNull
import im.vector.riotx.features.home.AvatarRenderer
import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController
@ -38,7 +39,8 @@ import im.vector.riotx.features.home.room.detail.timeline.item.MergedRoomCreatio
import javax.inject.Inject
class MergedHeaderItemFactory @Inject constructor(private val avatarRenderer: AvatarRenderer,
private val avatarSizeProvider: AvatarSizeProvider) {
private val avatarSizeProvider: AvatarSizeProvider,
private val activeSessionHolder: ActiveSessionHolder) {
private val collapsedEventIds = linkedSetOf<Long>()
private val mergeItemCollapseStates = HashMap<Long, Boolean>()
@ -188,7 +190,8 @@ class MergedHeaderItemFactory @Inject constructor(private val avatarRenderer: Av
},
hasEncryptionEvent = hasEncryption,
isEncryptionAlgorithmSecure = encryptionAlgorithm == MXCRYPTO_ALGORITHM_MEGOLM,
readReceiptsCallback = callback
readReceiptsCallback = callback,
currentUserId = activeSessionHolder.getSafeActiveSession()?.myUserId ?: ""
)
MergedRoomCreationItem_()
.id(mergeId)

View file

@ -47,6 +47,8 @@ import javax.inject.Inject
class NoticeEventFormatter @Inject constructor(private val sessionHolder: ActiveSessionHolder,
private val sp: StringProvider) {
private fun Event.isSentByCurrentUser() = senderId != null && senderId == sessionHolder.getSafeActiveSession()?.myUserId
fun format(timelineEvent: TimelineEvent): CharSequence? {
return when (val type = timelineEvent.root.getClearType()) {
EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
@ -59,9 +61,9 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_GUEST_ACCESS -> formatRoomGuestAccessEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_ENCRYPTION -> formatRoomEncryptionEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_WIDGET,
EventType.STATE_ROOM_WIDGET_LEGACY -> formatWidgetEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.CALL_INVITE,
EventType.CALL_HANGUP,
EventType.CALL_ANSWER -> formatCallEvent(type, timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
@ -88,13 +90,25 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
return if (widgetContent.isActive()) {
val name = widgetContent.getHumanName()
if (previousWidgetContent?.isActive().orFalse()) {
sp.getString(R.string.event_formatter_widget_modified, name, disambiguatedDisplayName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_widget_modified_by_you, name, disambiguatedDisplayName)
} else {
sp.getString(R.string.notice_widget_modified, name, disambiguatedDisplayName)
}
} else {
sp.getString(R.string.event_formatter_widget_added, name, disambiguatedDisplayName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_widget_added_by_you, name, disambiguatedDisplayName)
} else {
sp.getString(R.string.notice_widget_added, name, disambiguatedDisplayName)
}
}
} else {
val name = previousWidgetContent?.getHumanName()
sp.getString(R.string.event_formatter_widget_removed, name, disambiguatedDisplayName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_widget_removed_by_you, name, disambiguatedDisplayName)
} else {
sp.getString(R.string.notice_widget_removed, name, disambiguatedDisplayName)
}
}
}
@ -108,7 +122,7 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
EventType.CALL_INVITE,
EventType.CALL_HANGUP,
EventType.CALL_ANSWER -> formatCallEvent(type, event, senderName)
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(senderName)
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName)
else -> {
Timber.v("Type $type not handled by this formatter")
null
@ -123,28 +137,54 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
private fun formatRoomCreateEvent(event: Event): CharSequence? {
return event.getClearContent().toModel<RoomCreateContent>()
?.takeIf { it.creator.isNullOrBlank().not() }
?.let { sp.getString(R.string.notice_room_created, it.creator) }
?.let {
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_created_by_you)
} else {
sp.getString(R.string.notice_room_created, it.creator)
}
}
}
private fun formatRoomNameEvent(event: Event, senderName: String?): CharSequence? {
val content = event.getClearContent().toModel<RoomNameContent>() ?: return null
return if (content.name.isNullOrBlank()) {
sp.getString(R.string.notice_room_name_removed, senderName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_name_removed_by_you)
} else {
sp.getString(R.string.notice_room_name_removed, senderName)
}
} else {
sp.getString(R.string.notice_room_name_changed, senderName, content.name)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_name_changed_by_you, content.name)
} else {
sp.getString(R.string.notice_room_name_changed, senderName, content.name)
}
}
}
private fun formatRoomTombstoneEvent(senderName: String?): CharSequence? {
return sp.getString(R.string.notice_room_update, senderName)
private fun formatRoomTombstoneEvent(event: Event, senderName: String?): CharSequence? {
return if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_update_by_you)
} else {
sp.getString(R.string.notice_room_update, senderName)
}
}
private fun formatRoomTopicEvent(event: Event, senderName: String?): CharSequence? {
val content = event.getClearContent().toModel<RoomTopicContent>() ?: return null
return if (content.topic.isNullOrEmpty()) {
sp.getString(R.string.notice_room_topic_removed, senderName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_topic_removed_by_you)
} else {
sp.getString(R.string.notice_room_topic_removed, senderName)
}
} else {
sp.getString(R.string.notice_room_topic_changed, senderName, content.topic)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_topic_changed_by_you, content.topic)
} else {
sp.getString(R.string.notice_room_topic_changed, senderName, content.topic)
}
}
}
@ -157,7 +197,11 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
RoomHistoryVisibility.JOINED -> sp.getString(R.string.notice_room_visibility_joined)
RoomHistoryVisibility.WORLD_READABLE -> sp.getString(R.string.notice_room_visibility_world_readable)
}
return sp.getString(R.string.notice_made_future_room_visibility, senderName, formattedVisibility)
return if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_made_future_room_visibility_by_you, formattedVisibility)
} else {
sp.getString(R.string.notice_made_future_room_visibility, senderName, formattedVisibility)
}
}
private fun formatCallEvent(type: String, event: Event, senderName: String?): CharSequence? {
@ -166,13 +210,31 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
val content = event.getClearContent().toModel<CallInviteContent>() ?: return null
val isVideoCall = content.offer.sdp == CallInviteContent.Offer.SDP_VIDEO
return if (isVideoCall) {
sp.getString(R.string.notice_placed_video_call, senderName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_placed_video_call_by_you)
} else {
sp.getString(R.string.notice_placed_video_call, senderName)
}
} else {
sp.getString(R.string.notice_placed_voice_call, senderName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_placed_voice_call_by_you)
} else {
sp.getString(R.string.notice_placed_voice_call, senderName)
}
}
}
EventType.CALL_ANSWER -> sp.getString(R.string.notice_answered_call, senderName)
EventType.CALL_HANGUP -> sp.getString(R.string.notice_ended_call, senderName)
EventType.CALL_ANSWER ->
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_answered_call_by_you)
} else {
sp.getString(R.string.notice_answered_call, senderName)
}
EventType.CALL_HANGUP ->
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_ended_call_by_you)
} else {
sp.getString(R.string.notice_ended_call, senderName)
}
else -> null
}
}
@ -195,15 +257,29 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
val addedAliases = eventContent?.aliases.orEmpty() - prevEventContent?.aliases.orEmpty()
val removedAliases = prevEventContent?.aliases.orEmpty() - eventContent?.aliases.orEmpty()
return if (addedAliases.isNotEmpty() && removedAliases.isNotEmpty()) {
sp.getString(R.string.notice_room_aliases_added_and_removed, senderName, addedAliases.joinToString(), removedAliases.joinToString())
} else if (addedAliases.isNotEmpty()) {
sp.getQuantityString(R.plurals.notice_room_aliases_added, addedAliases.size, senderName, addedAliases.joinToString())
} else if (removedAliases.isNotEmpty()) {
sp.getQuantityString(R.plurals.notice_room_aliases_removed, removedAliases.size, senderName, removedAliases.joinToString())
} else {
Timber.w("Alias event without any change...")
null
return when {
addedAliases.isNotEmpty() && removedAliases.isNotEmpty() ->
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_aliases_added_and_removed_by_you, addedAliases.joinToString(), removedAliases.joinToString())
} else {
sp.getString(R.string.notice_room_aliases_added_and_removed, senderName, addedAliases.joinToString(), removedAliases.joinToString())
}
addedAliases.isNotEmpty() ->
if (event.isSentByCurrentUser()) {
sp.getQuantityString(R.plurals.notice_room_aliases_added_by_you, addedAliases.size, addedAliases.joinToString())
} else {
sp.getQuantityString(R.plurals.notice_room_aliases_added, addedAliases.size, senderName, addedAliases.joinToString())
}
removedAliases.isNotEmpty() ->
if (event.isSentByCurrentUser()) {
sp.getQuantityString(R.plurals.notice_room_aliases_removed_by_you, removedAliases.size, removedAliases.joinToString())
} else {
sp.getQuantityString(R.plurals.notice_room_aliases_removed, removedAliases.size, senderName, removedAliases.joinToString())
}
else -> {
Timber.w("Alias event without any change...")
null
}
}
}
@ -212,25 +288,54 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
val canonicalAlias = eventContent?.canonicalAlias
return canonicalAlias
?.takeIf { it.isNotBlank() }
?.let { sp.getString(R.string.notice_room_canonical_alias_set, senderName, it) }
?: sp.getString(R.string.notice_room_canonical_alias_unset, senderName)
?.let {
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_canonical_alias_set_by_you, it)
} else {
sp.getString(R.string.notice_room_canonical_alias_set, senderName, it)
}
}
?: if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_canonical_alias_unset_by_you)
} else {
sp.getString(R.string.notice_room_canonical_alias_unset, senderName)
}
}
private fun formatRoomGuestAccessEvent(event: Event, senderName: String?): String? {
val eventContent: RoomGuestAccessContent? = event.getClearContent().toModel()
return when (eventContent?.guestAccess) {
GuestAccess.CanJoin -> sp.getString(R.string.notice_room_guest_access_can_join, senderName)
GuestAccess.Forbidden -> sp.getString(R.string.notice_room_guest_access_forbidden, senderName)
GuestAccess.CanJoin ->
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_guest_access_can_join_by_you)
} else {
sp.getString(R.string.notice_room_guest_access_can_join, senderName)
}
GuestAccess.Forbidden ->
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_guest_access_forbidden_by_you)
} else {
sp.getString(R.string.notice_room_guest_access_forbidden, senderName)
}
else -> null
}
}
private fun formatRoomEncryptionEvent(event: Event, senderName: String?): CharSequence? {
val content = event.content.toModel<EncryptionEventContent>() ?: return null
return if (content.algorithm == MXCRYPTO_ALGORITHM_MEGOLM) {
sp.getString(R.string.notice_end_to_end_ok, senderName)
} else {
sp.getString(R.string.notice_end_to_end_unknown_algorithm, senderName, content.algorithm)
return when (content.algorithm) {
MXCRYPTO_ALGORITHM_MEGOLM ->
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_end_to_end_ok_by_you)
} else {
sp.getString(R.string.notice_end_to_end_ok, senderName)
}
else ->
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_end_to_end_unknown_algorithm_by_you, content.algorithm)
} else {
sp.getString(R.string.notice_end_to_end_unknown_algorithm, senderName, content.algorithm)
}
}
}
@ -240,11 +345,23 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
if (eventContent?.displayName != prevEventContent?.displayName) {
val displayNameText = when {
prevEventContent?.displayName.isNullOrEmpty() ->
sp.getString(R.string.notice_display_name_set, event.senderId, eventContent?.displayName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_display_name_set_by_you, eventContent?.displayName)
} else {
sp.getString(R.string.notice_display_name_set, event.senderId, eventContent?.displayName)
}
eventContent?.displayName.isNullOrEmpty() ->
sp.getString(R.string.notice_display_name_removed, event.senderId, prevEventContent?.displayName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_display_name_removed_by_you, prevEventContent?.displayName)
} else {
sp.getString(R.string.notice_display_name_removed, event.senderId, prevEventContent?.displayName)
}
else ->
sp.getString(R.string.notice_display_name_changed_from, event.senderId, prevEventContent?.displayName, eventContent?.displayName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_display_name_changed_from_by_you, prevEventContent?.displayName, eventContent?.displayName)
} else {
sp.getString(R.string.notice_display_name_changed_from, event.senderId, prevEventContent?.displayName, eventContent?.displayName)
}
}
displayText.append(displayNameText)
}
@ -254,13 +371,21 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
displayText.append(" ")
sp.getString(R.string.notice_avatar_changed_too)
} else {
sp.getString(R.string.notice_avatar_url_changed, senderName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_avatar_url_changed_by_you)
} else {
sp.getString(R.string.notice_avatar_url_changed, senderName)
}
}
displayText.append(displayAvatarText)
}
if (displayText.isEmpty()) {
displayText.append(
sp.getString(R.string.notice_member_no_changes, senderName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_member_no_changes_by_you)
} else {
sp.getString(R.string.notice_member_no_changes, senderName)
}
)
}
return displayText.toString()
@ -277,62 +402,133 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
val userWhoHasAccepted = eventContent.thirdPartyInvite?.signed?.mxid ?: event.stateKey
val threePidDisplayName = eventContent.thirdPartyInvite?.displayName ?: ""
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_third_party_registered_invite_with_reason, userWhoHasAccepted, threePidDisplayName, reason)
} ?: sp.getString(R.string.notice_room_third_party_registered_invite, userWhoHasAccepted, threePidDisplayName)
if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_third_party_registered_invite_with_reason_by_you, threePidDisplayName, reason)
} else {
sp.getString(R.string.notice_room_third_party_registered_invite_with_reason, userWhoHasAccepted, threePidDisplayName, reason)
}
} ?: if (event.isSentByCurrentUser()) {
sp.getString(R.string.notice_room_third_party_registered_invite_by_you, threePidDisplayName)
} else {
sp.getString(R.string.notice_room_third_party_registered_invite, userWhoHasAccepted, threePidDisplayName)
}
}
event.stateKey == selfUserId ->
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_invite_you_with_reason, senderDisplayName, reason)
} ?: sp.getString(R.string.notice_room_invite_you, senderDisplayName)
event.stateKey.isNullOrEmpty() ->
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_invite_no_invitee_with_reason, senderDisplayName, reason)
} ?: sp.getString(R.string.notice_room_invite_no_invitee, senderDisplayName)
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_invite_no_invitee_with_reason_by_you, reason)
} ?: sp.getString(R.string.notice_room_invite_no_invitee_by_you)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_invite_no_invitee_with_reason, senderDisplayName, reason)
} ?: sp.getString(R.string.notice_room_invite_no_invitee, senderDisplayName)
}
else ->
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_invite_with_reason, senderDisplayName, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_invite, senderDisplayName, targetDisplayName)
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_invite_with_reason_by_you, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_invite_by_you, targetDisplayName)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_invite_with_reason, senderDisplayName, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_invite, senderDisplayName, targetDisplayName)
}
}
}
Membership.JOIN ->
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_join_with_reason, senderDisplayName, reason)
} ?: sp.getString(R.string.notice_room_join, senderDisplayName)
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_join_with_reason_by_you, reason)
} ?: sp.getString(R.string.notice_room_join_by_you)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_join_with_reason, senderDisplayName, reason)
} ?: sp.getString(R.string.notice_room_join, senderDisplayName)
}
Membership.LEAVE ->
// 2 cases here: this member may have left voluntarily or they may have been "left" by someone else ie. kicked
if (event.senderId == event.stateKey) {
if (prevEventContent?.membership == Membership.INVITE) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_reject_with_reason, senderDisplayName, reason)
} ?: sp.getString(R.string.notice_room_reject, senderDisplayName)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_leave_with_reason, senderDisplayName, reason)
} ?: sp.getString(R.string.notice_room_leave, senderDisplayName)
when (prevEventContent?.membership) {
Membership.INVITE ->
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_reject_with_reason_by_you, reason)
} ?: sp.getString(R.string.notice_room_reject_by_you)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_reject_with_reason, senderDisplayName, reason)
} ?: sp.getString(R.string.notice_room_reject, senderDisplayName)
}
else ->
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_leave_with_reason_by_you, reason)
} ?: sp.getString(R.string.notice_room_leave_by_you)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_leave_with_reason, senderDisplayName, reason)
} ?: sp.getString(R.string.notice_room_leave, senderDisplayName)
}
}
} else if (prevEventContent?.membership == Membership.INVITE) {
} else {
when (prevEventContent?.membership) {
Membership.INVITE ->
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_withdraw_with_reason_by_you, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_withdraw_by_you, targetDisplayName)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_withdraw_with_reason, senderDisplayName, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_withdraw, senderDisplayName, targetDisplayName)
}
Membership.JOIN ->
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_kick_with_reason_by_you, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_kick_by_you, targetDisplayName)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_kick_with_reason, senderDisplayName, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_kick, senderDisplayName, targetDisplayName)
}
Membership.BAN ->
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_unban_with_reason_by_you, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_unban_by_you, targetDisplayName)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_unban_with_reason, senderDisplayName, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_unban, senderDisplayName, targetDisplayName)
}
else -> null
}
}
Membership.BAN ->
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let {
sp.getString(R.string.notice_room_ban_with_reason_by_you, targetDisplayName, it)
} ?: sp.getString(R.string.notice_room_ban_by_you, targetDisplayName)
} else {
eventContent.safeReason?.let {
sp.getString(R.string.notice_room_ban_with_reason, senderDisplayName, targetDisplayName, it)
} ?: sp.getString(R.string.notice_room_ban, senderDisplayName, targetDisplayName)
}
Membership.KNOCK ->
if (event.isSentByCurrentUser()) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_withdraw_with_reason, senderDisplayName, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_withdraw, senderDisplayName, targetDisplayName)
} else if (prevEventContent?.membership == Membership.JOIN) {
sp.getString(R.string.notice_room_kick_with_reason_by_you, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_kick_by_you, targetDisplayName)
} else {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_kick_with_reason, senderDisplayName, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_kick, senderDisplayName, targetDisplayName)
} else if (prevEventContent?.membership == Membership.BAN) {
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_unban_with_reason, senderDisplayName, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_unban, senderDisplayName, targetDisplayName)
} else {
null
}
Membership.BAN ->
eventContent.safeReason?.let {
sp.getString(R.string.notice_room_ban_with_reason, senderDisplayName, targetDisplayName, it)
} ?: sp.getString(R.string.notice_room_ban, senderDisplayName, targetDisplayName)
Membership.KNOCK ->
eventContent.safeReason?.let { reason ->
sp.getString(R.string.notice_room_kick_with_reason, senderDisplayName, targetDisplayName, reason)
} ?: sp.getString(R.string.notice_room_kick, senderDisplayName, targetDisplayName)
else -> null
}
}
@ -340,8 +536,18 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
private fun formatJoinRulesEvent(event: Event, senderName: String?): CharSequence? {
val content = event.getClearContent().toModel<RoomJoinRulesContent>() ?: return null
return when (content.joinRules) {
RoomJoinRules.INVITE -> sp.getString(R.string.room_join_rules_invite, senderName)
RoomJoinRules.PUBLIC -> sp.getString(R.string.room_join_rules_public, senderName)
RoomJoinRules.INVITE ->
if (event.isSentByCurrentUser()) {
sp.getString(R.string.room_join_rules_invite_by_you)
} else {
sp.getString(R.string.room_join_rules_invite, senderName)
}
RoomJoinRules.PUBLIC ->
if (event.isSentByCurrentUser()) {
sp.getString(R.string.room_join_rules_public_by_you)
} else {
sp.getString(R.string.room_join_rules_public, senderName)
}
else -> null
}
}

View file

@ -46,8 +46,12 @@ abstract class MergedRoomCreationItem : BasedMergedItem<MergedRoomCreationItem.H
// Take the oldest data
val data = distinctMergeData.lastOrNull()
val summary = holder.expandView.resources.getString(R.string.room_created_summary_item,
data?.memberName ?: data?.userId ?: "")
val createdFromCurrentUser = data?.userId == attributes.currentUserId
val summary = if (createdFromCurrentUser) {
holder.expandView.resources.getString(R.string.room_created_summary_item_by_you)
} else {
holder.expandView.resources.getString(R.string.room_created_summary_item, data?.memberName ?: data?.userId ?: "")
}
holder.summaryView.text = summary
holder.summaryView.visibility = View.VISIBLE
holder.avatarView.visibility = View.VISIBLE
@ -110,7 +114,8 @@ abstract class MergedRoomCreationItem : BasedMergedItem<MergedRoomCreationItem.H
override val avatarRenderer: AvatarRenderer,
override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null,
override val onCollapsedStateChanged: (Boolean) -> Unit,
val hasEncryptionEvent : Boolean,
val currentUserId: String,
val hasEncryptionEvent: Boolean,
val isEncryptionAlgorithmSecure: Boolean
) : BasedMergedItem.Attributes
}

View file

@ -32,6 +32,7 @@ import com.airbnb.mvrx.Incomplete
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.args
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import im.vector.matrix.android.api.failure.Failure
import im.vector.matrix.android.api.session.room.model.Membership
import im.vector.matrix.android.api.session.room.model.RoomSummary
@ -99,7 +100,6 @@ class RoomListFragment @Inject constructor(
setupCreateRoomButton()
setupRecyclerView()
sharedActionViewModel = activityViewModelProvider.get(RoomListQuickActionsSharedActionViewModel::class.java)
roomListViewModel.subscribe { renderState(it) }
roomListViewModel.observeViewEvents {
when (it) {
is RoomListViewEvents.Loading -> showLoading(it.message)
@ -243,7 +243,7 @@ class RoomListFragment @Inject constructor(
}
}
private fun renderState(state: RoomListViewState) {
override fun invalidate() = withState(roomListViewModel) { state ->
when (state.asyncFilteredRooms) {
is Incomplete -> renderLoading()
is Success -> renderSuccess(state)

View file

@ -45,7 +45,6 @@ import im.vector.riotx.features.home.HomeActivity
import im.vector.riotx.features.login.terms.LoginTermsFragment
import im.vector.riotx.features.login.terms.LoginTermsFragmentArgument
import im.vector.riotx.features.login.terms.toLocalizedLoginTerms
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.android.synthetic.main.activity_login.*
import javax.inject.Inject
@ -103,13 +102,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarConfigurable {
updateWithState(it)
}
loginViewModel.viewEvents
.observe()
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
handleLoginViewEvents(it)
}
.disposeOnDestroy()
loginViewModel.observeViewEvents { handleLoginViewEvents(it) }
}
protected open fun addFirstFragment() {

View file

@ -58,7 +58,6 @@ class DeviceListFragment @Inject constructor(
override fun invalidate() = withState(viewModel) {
epoxyController.setData(it)
super.invalidate()
}
override fun onDeviceSelected(device: CryptoDeviceInfo) {

View file

@ -58,7 +58,6 @@ class DeviceTrustInfoActionFragment @Inject constructor(
override fun invalidate() = withState(viewModel) {
epoxyController.setData(it)
super.invalidate()
}
override fun onVerifyManually(device: CryptoDeviceInfo) {

View file

@ -54,7 +54,7 @@ class VectorSettingsPreferencesFragment @Inject constructor(
findPreference<VectorListPreference>(ThemeUtils.APPLICATION_THEME_KEY)!!
.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
if (newValue is String) {
ThemeUtils.setApplicationTheme(requireContext(), newValue)
ThemeUtils.setApplicationTheme(requireContext().applicationContext, newValue)
// Restart the Activity
activity?.restart()
true

View file

@ -29,7 +29,7 @@ import im.vector.riotx.core.extensions.configureWith
import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.utils.jsonViewerStyler
import im.vector.riotx.core.utils.createJSonViewerStyleProvider
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
import org.billcarsonfr.jsonviewer.JSonViewerDialog
import javax.inject.Inject
@ -73,7 +73,7 @@ class AccountDataFragment @Inject constructor(
JSonViewerDialog.newInstance(
jsonString,
-1, // open All
jsonViewerStyler(colorProvider)
createJSonViewerStyleProvider(colorProvider)
).show(childFragmentManager, "JSON_VIEWER")
}
}

View file

@ -26,7 +26,7 @@ import im.vector.riotx.core.extensions.cleanup
import im.vector.riotx.core.extensions.configureWith
import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.utils.jsonViewerStyler
import im.vector.riotx.core.utils.createJSonViewerStyleProvider
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
import org.billcarsonfr.jsonviewer.JSonViewerDialog
import javax.inject.Inject
@ -66,7 +66,7 @@ class GossipingEventsPaperTrailFragment @Inject constructor(
JSonViewerDialog.newInstance(
it,
-1,
jsonViewerStyler(colorProvider)
createJSonViewerStyleProvider(colorProvider)
).show(childFragmentManager, "JSON_VIEWER")
}
}

View file

@ -32,7 +32,6 @@ import im.vector.riotx.core.extensions.replaceFragment
import im.vector.riotx.features.MainActivity
import im.vector.riotx.features.MainActivityArgs
import im.vector.riotx.features.login.LoginActivity
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.android.synthetic.main.activity_login.*
import timber.log.Timber
import javax.inject.Inject
@ -57,18 +56,11 @@ class SoftLogoutActivity : LoginActivity() {
override fun initUiAndData() {
super.initUiAndData()
softLogoutViewModel
.subscribe(this) {
updateWithState(it)
}
softLogoutViewModel.subscribe(this) {
updateWithState(it)
}
softLogoutViewModel.viewEvents
.observe()
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
handleSoftLogoutViewEvents(it)
}
.disposeOnDestroy()
softLogoutViewModel.observeViewEvents { handleSoftLogoutViewEvents(it) }
}
private fun handleSoftLogoutViewEvents(softLogoutViewEvents: SoftLogoutViewEvents) {

View file

@ -347,7 +347,7 @@
<string name="settings_call_category">Calls</string>
<string name="settings_call_ringtone_use_riot_ringtone">Use default Riot ringtone for incoming calls</string>
<string name="settings_call_ringtone_use_default_stun">Allow fallback call assist server</string>
<string name="settings_call_ringtone_use_default_stun_sum">Will use "%s" as assist when your home server does not offers one (your IP address will be shared during a call)</string>
<string name="settings_call_ringtone_use_default_stun_sum">Will use "%s" as assist when your home server does not offer one (your IP address will be shared during a call)</string>
<string name="settings_call_ringtone_title">Incoming call ringtone</string>
<string name="settings_call_ringtone_dialog_title">Select ringtone for calls:</string>
@ -1826,6 +1826,7 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming
<string name="room_list_quick_actions_settings">"Settings"</string>
<string name="room_list_quick_actions_leave">"Leave the room"</string>
<string name="notice_member_no_changes">"%1$s made no changes"</string>
<string name="notice_member_no_changes_by_you">"You made no changes"</string>
<string name="command_description_spoiler">Sends the given message as a spoiler</string>
<string name="spoiler">Spoiler</string>
<string name="reaction_search_type_hint">Type keywords to find a reaction.</string>
@ -1836,7 +1837,9 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming
<string name="room_join_rules_public">%1$s made the room public to whoever knows the link.</string>
<string name="room_join_rules_public_by_you">You made the room public to whoever knows the link.</string>
<string name="room_join_rules_invite">%1$s made the room invite only.</string>
<string name="room_join_rules_invite_by_you">You made the room invite only.</string>
<string name="timeline_unread_messages">Unread messages</string>
<string name="login_splash_title">Liberate your communication</string>
@ -2306,6 +2309,7 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming
<string name="encryption_unknown_algorithm_tile_description">The encryption used by this room is not supported</string>
<string name="room_created_summary_item">%s created and configured the room.</string>
<string name="room_created_summary_item_by_you">You created and configured the room.</string>
<string name="qr_code_scanned_self_verif_notice">Almost there! Is the other device showing the same shield?</string>
<string name="qr_code_scanned_verif_waiting_notice">Almost there! Waiting for confirmation…</string>