Add user photo to the "My location" screen
This commit is contained in:
parent
834cc5b700
commit
4683281377
4 changed files with 30 additions and 13 deletions
|
@ -24,13 +24,25 @@
|
|||
android:scaleType="center"
|
||||
android:src="@drawable/img_my_location_roadbg"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/my_location_user_image"
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:paddingTop="@dimen/content_padding_standard"
|
||||
tools:src="@drawable/img_my_location_user"/>
|
||||
android:layout_marginTop="@dimen/content_padding_standard">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/img_my_location_user"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/user_icon"
|
||||
android:layout_width="@dimen/my_location_user_icon_size"
|
||||
android:layout_height="@dimen/my_location_user_icon_size"
|
||||
android:layout_gravity="center"
|
||||
tools:src="@drawable/img_user_picture"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
<dimen name="my_location_image_height">168dp</dimen>
|
||||
<dimen name="my_location_text_sides_margin">32dp</dimen>
|
||||
<dimen name="my_location_user_icon_size">60dp</dimen>
|
||||
|
||||
<dimen name="search_box_height">48dp</dimen>
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ package net.osmand.telegram.helpers
|
|||
import android.text.TextUtils
|
||||
import net.osmand.PlatformUtil
|
||||
import net.osmand.telegram.helpers.TelegramHelper.TelegramAuthenticationParameterType.*
|
||||
import net.osmand.telegram.utils.*
|
||||
import net.osmand.telegram.utils.GRAYSCALE_PHOTOS_DIR
|
||||
import net.osmand.telegram.utils.GRAYSCALE_PHOTOS_EXT
|
||||
import org.drinkless.td.libcore.telegram.Client
|
||||
import org.drinkless.td.libcore.telegram.Client.ResultHandler
|
||||
import org.drinkless.td.libcore.telegram.TdApi
|
||||
|
@ -310,10 +311,10 @@ class TelegramHelper private constructor() {
|
|||
|
||||
fun isInit() = client != null && haveAuthorization
|
||||
|
||||
fun getUserPhotoPath(user: TdApi.User): String? {
|
||||
return if (hasLocalUserPhoto(user)) {
|
||||
user.profilePhoto?.small?.local?.path
|
||||
} else {
|
||||
fun getUserPhotoPath(user: TdApi.User?) = when {
|
||||
user == null -> null
|
||||
hasLocalUserPhoto(user) -> user.profilePhoto?.small?.local?.path
|
||||
else -> {
|
||||
if (hasRemoteUserPhoto(user)) {
|
||||
requestUserPhoto(user)
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
private val settings get() = app.settings
|
||||
|
||||
private lateinit var appBarLayout: AppBarLayout
|
||||
private lateinit var userImage: ImageView
|
||||
private lateinit var imageContainer: FrameLayout
|
||||
private lateinit var textContainer: LinearLayout
|
||||
private lateinit var titleContainer: LinearLayout
|
||||
|
@ -120,9 +119,13 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
})
|
||||
}
|
||||
|
||||
userImage = mainView.findViewById<ImageView>(R.id.my_location_user_image).apply {
|
||||
setImageResource(R.drawable.img_my_location_user)
|
||||
}
|
||||
TelegramUiHelper.setupPhoto(
|
||||
app,
|
||||
mainView.findViewById(R.id.user_icon),
|
||||
telegramHelper.getUserPhotoPath(telegramHelper.getCurrentUser()),
|
||||
R.drawable.img_user_picture,
|
||||
false
|
||||
)
|
||||
|
||||
optionsBtn = mainView.findViewById<ImageView>(R.id.options)
|
||||
with(activity as MainActivity) {
|
||||
|
|
Loading…
Reference in a new issue