-
Notifications
You must be signed in to change notification settings - Fork 732
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FTUE - Choose a display picture (#5323)
* adding tests around the onboarding view model - cases for the personalisation and display name actions * adding base choose name fragment with UI * add click handling for the display name actions * adding tests around the onboarding view model - cases for the personalisation and display name actions * adding barebones profile picture fragment with ability to select a user avatar * extracting uri filename resolving to a class which can be injected - includes tests * updating upstream avatar on profile picture save and continue step - moves the personalisation state to a dedicated model to allow for back and forth state restoration * adding test case for skipping profile picture setting * taking the profile loading into account when rendering the onboarding loading * extracting method for the handling of the profile picture selection * adding dedicated camera icon for choosing profile picture * adding toolbar to back to profile picture page - this toolbar will fade in with the fragment as it sits at the fragment level, probably worth revisiting once more pages have a toolbar * changing edit/add picture icon based on if we're already selected an image * making use of debounced clicks to avoid potential extra clicks * making the avatar height and camera icon relative percentage based - also makes the avatar itself clicking, including a foreground ripple * fixing formatting * making use of fake session id for user id assertion * using a real matrix id syntax for the fake session user id * removing duplicated dimens * using self closing imageview tag
- Loading branch information
Showing
26 changed files
with
803 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
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
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
41 changes: 41 additions & 0 deletions
41
vector/src/main/java/im/vector/app/features/onboarding/UriFilenameResolver.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,41 @@ | ||
/* | ||
* Copyright (c) 2022 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.onboarding | ||
|
||
import android.content.Context | ||
import android.net.Uri | ||
import android.provider.OpenableColumns | ||
import im.vector.lib.multipicker.utils.readStringColumnOrNull | ||
import javax.inject.Inject | ||
|
||
class UriFilenameResolver @Inject constructor(private val context: Context) { | ||
|
||
fun getFilenameFromUri(uri: Uri): String? { | ||
val fallback = uri.path?.substringAfterLast('/') | ||
return when (uri.scheme) { | ||
"content" -> readResolvedDisplayName(uri) ?: fallback | ||
else -> fallback | ||
} | ||
} | ||
|
||
private fun readResolvedDisplayName(uri: Uri): String? { | ||
return context.contentResolver.query(uri, null, null, null, null)?.use { cursor -> | ||
cursor.takeIf { cursor.moveToFirst() } | ||
?.readStringColumnOrNull(OpenableColumns.DISPLAY_NAME) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.