forked from GitHub-Mirror/riotX-android
Handle permalink click
This commit is contained in:
committed by
Benoit Marty
parent
b1e009f8b4
commit
76ade2957e
@ -24,7 +24,7 @@ import im.vector.matrix.android.api.session.events.model.Event
|
||||
*/
|
||||
object PermalinkFactory {
|
||||
|
||||
private val MATRIX_TO_URL_BASE = "https://matrix.to/#/"
|
||||
const val MATRIX_TO_URL_BASE = "https://matrix.to/#/"
|
||||
|
||||
/**
|
||||
* Creates a permalink for an event.
|
||||
|
@ -36,12 +36,20 @@ object PermalinkParser {
|
||||
* Turns an uri to a [PermalinkData]
|
||||
*/
|
||||
fun parse(uri: Uri): PermalinkData {
|
||||
if (!uri.toString().startsWith(PermalinkFactory.MATRIX_TO_URL_BASE)) {
|
||||
return PermalinkData.FallbackLink(uri)
|
||||
}
|
||||
|
||||
val fragment = uri.fragment
|
||||
if (fragment.isNullOrEmpty()) {
|
||||
return PermalinkData.FallbackLink(uri)
|
||||
}
|
||||
|
||||
val indexOfQuery = fragment.indexOf("?")
|
||||
val safeFragment = if (indexOfQuery != -1) fragment.substring(0, indexOfQuery) else fragment
|
||||
|
||||
// we are limiting to 2 params
|
||||
val params = fragment
|
||||
val params = safeFragment
|
||||
.split(MatrixPatterns.SEP_REGEX.toRegex())
|
||||
.filter { it.isNotEmpty() }
|
||||
.take(2)
|
||||
|
@ -32,7 +32,7 @@ package im.vector.matrix.android.api.session.room.timeline
|
||||
*/
|
||||
interface Timeline {
|
||||
|
||||
var listener: Timeline.Listener?
|
||||
var listener: Listener?
|
||||
|
||||
/**
|
||||
* This should be called before any other method after creating the timeline. It ensures the underlying database is open
|
||||
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 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.matrix.android.api.session.room.timeline
|
||||
|
||||
import androidx.paging.PagedList
|
||||
|
||||
/**
|
||||
* This data class is a holder for timeline data.
|
||||
* It's returned by [TimelineService]
|
||||
*/
|
||||
data class TimelineData(
|
||||
|
||||
/**
|
||||
* The [PagedList] of [TimelineEvent] to usually be render in a RecyclerView.
|
||||
*/
|
||||
val events: PagedList<TimelineEvent>,
|
||||
|
||||
/**
|
||||
* True if Timeline is currently paginating forward on server
|
||||
*/
|
||||
val isLoadingForward: Boolean = false,
|
||||
|
||||
/**
|
||||
* True if Timeline is currently paginating backward on server
|
||||
*/
|
||||
val isLoadingBackward: Boolean = false
|
||||
)
|
@ -23,7 +23,7 @@ import im.vector.matrix.android.api.session.room.send.SendState
|
||||
|
||||
/**
|
||||
* This data class is a wrapper around an Event. It allows to get useful data in the context of a timeline.
|
||||
* This class is used by [TimelineService] through [TimelineData]
|
||||
* This class is used by [TimelineService]
|
||||
* Users can also enrich it with metadata.
|
||||
*/
|
||||
data class TimelineEvent(
|
||||
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 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.matrix.android.api.session.room.timeline
|
||||
|
||||
|
||||
interface TimelineEventInterceptor {
|
||||
|
||||
fun canEnrich(event: TimelineEvent): Boolean
|
||||
|
||||
fun enrich(event: TimelineEvent)
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user