-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a dedicated screen to manage room alias (#2428) - WIP
- Loading branch information
Showing
25 changed files
with
718 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...x-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/alias/AliasService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2020 The Matrix.org Foundation C.I.C. | ||
* | ||
* 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 org.matrix.android.sdk.api.session.room.alias | ||
|
||
interface AliasService { | ||
/** | ||
* Get list of local alias of the room | ||
*/ | ||
suspend fun getRoomAliases(): List<String> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...d/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DefaultAliasService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2020 The Matrix.org Foundation C.I.C. | ||
* | ||
* 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 org.matrix.android.sdk.internal.session.room.alias | ||
|
||
import com.squareup.inject.assisted.Assisted | ||
import com.squareup.inject.assisted.AssistedInject | ||
import org.matrix.android.sdk.api.session.room.alias.AliasService | ||
|
||
internal class DefaultAliasService @AssistedInject constructor( | ||
@Assisted private val roomId: String, | ||
private val getRoomLocalAliasesTask: GetRoomLocalAliasesTask | ||
) : AliasService { | ||
|
||
@AssistedInject.Factory | ||
interface Factory { | ||
fun create(roomId: String): AliasService | ||
} | ||
|
||
override suspend fun getRoomAliases(): List<String> { | ||
return getRoomLocalAliasesTask.execute(GetRoomLocalAliasesTask.Params(roomId)) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...id/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetAliasesResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2020 The Matrix.org Foundation C.I.C. | ||
* | ||
* 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 org.matrix.android.sdk.internal.session.room.alias | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
internal data class GetAliasesResponse( | ||
/** | ||
* The list of aliases currently defined on the local server for the given room | ||
*/ | ||
@Json(name = "aliases") val aliases: List<String> = emptyList() | ||
) |
44 changes: 44 additions & 0 deletions
44
...c/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomLocalAliasesTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2020 The Matrix.org Foundation C.I.C. | ||
* | ||
* 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 org.matrix.android.sdk.internal.session.room.alias | ||
|
||
import org.greenrobot.eventbus.EventBus | ||
import org.matrix.android.sdk.internal.network.executeRequest | ||
import org.matrix.android.sdk.internal.session.room.RoomAPI | ||
import org.matrix.android.sdk.internal.task.Task | ||
import javax.inject.Inject | ||
|
||
internal interface GetRoomLocalAliasesTask : Task<GetRoomLocalAliasesTask.Params, List<String>> { | ||
data class Params( | ||
val roomId: String | ||
) | ||
} | ||
|
||
internal class DefaultGetRoomLocalAliasesTask @Inject constructor( | ||
private val roomAPI: RoomAPI, | ||
private val eventBus: EventBus | ||
) : GetRoomLocalAliasesTask { | ||
|
||
override suspend fun execute(params: GetRoomLocalAliasesTask.Params): List<String> { | ||
// We do not check for "org.matrix.msc2432", so the API may be missing | ||
val response = executeRequest<GetAliasesResponse>(eventBus) { | ||
apiCall = roomAPI.getAliases(roomId = params.roomId) | ||
} | ||
|
||
return response.aliases | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
vector/src/main/java/im/vector/app/features/roomprofile/alias/RoomAliasAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 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.app.features.roomprofile.alias | ||
|
||
import im.vector.app.core.platform.VectorViewModelAction | ||
|
||
sealed class RoomAliasAction : VectorViewModelAction { | ||
// Canonical | ||
data class AddAlias(val alias: String) : RoomAliasAction() | ||
data class RemoveAlias(val alias: String) : RoomAliasAction() | ||
data class SetCanonicalAlias(val canonicalAlias: String) : RoomAliasAction() | ||
object UnSetCanonicalAlias : RoomAliasAction() | ||
|
||
// Local | ||
data class AddLocalAlias(val aliasLocalPart: String) : RoomAliasAction() | ||
data class RemoveLocalAlias(val alias: String) : RoomAliasAction() | ||
} |
Oops, something went wrong.