Added new progress bar for file transfers
This commit is contained in:
parent
399233bc65
commit
d07ff2ebfd
3 changed files with 32 additions and 0 deletions
|
@ -50,6 +50,7 @@ class ChatMessageContentData(
|
||||||
val downloadable = MutableLiveData<Boolean>()
|
val downloadable = MutableLiveData<Boolean>()
|
||||||
val downloadEnabled = MutableLiveData<Boolean>()
|
val downloadEnabled = MutableLiveData<Boolean>()
|
||||||
val downloadProgress = MutableLiveData<Int>()
|
val downloadProgress = MutableLiveData<Int>()
|
||||||
|
val downloadProgressString = MutableLiveData<String>()
|
||||||
val downloadLabel = MutableLiveData<String>()
|
val downloadLabel = MutableLiveData<String>()
|
||||||
|
|
||||||
val isAlone: Boolean
|
val isAlone: Boolean
|
||||||
|
@ -74,6 +75,7 @@ class ChatMessageContentData(
|
||||||
val percent = offset * 100 / total
|
val percent = offset * 100 / total
|
||||||
Log.d("[Content] Download progress is: $offset / $total ($percent%)")
|
Log.d("[Content] Download progress is: $offset / $total ($percent%)")
|
||||||
downloadProgress.postValue(percent)
|
downloadProgress.postValue(percent)
|
||||||
|
downloadProgressString.postValue("$percent%")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +138,7 @@ class ChatMessageContentData(
|
||||||
isGenericFile.value = !isPdf.value!! && !isAudio.value!! && !isVideo.value!! && !isImage.value!!
|
isGenericFile.value = !isPdf.value!! && !isAudio.value!! && !isVideo.value!! && !isImage.value!!
|
||||||
downloadEnabled.value = !chatMessage.isFileTransferInProgress
|
downloadEnabled.value = !chatMessage.isFileTransferInProgress
|
||||||
downloadProgress.value = 0
|
downloadProgress.value = 0
|
||||||
|
downloadProgressString.value = "0%"
|
||||||
chatMessage.addListener(chatMessageListener)
|
chatMessage.addListener(chatMessageListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
|
||||||
|
<solid android:color="@color/dark_grey_color"/>
|
||||||
|
<size android:width="35dp" android:height="35dp" />
|
||||||
|
</shape>
|
|
@ -86,6 +86,30 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="@{data.downloadProgress > 0 ? View.VISIBLE : View.GONE}"
|
||||||
|
android:layout_centerInParent="true">
|
||||||
|
|
||||||
|
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:max="100"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
app:trackColor="?attr/backgroundColor"
|
||||||
|
android:progress="@{data.downloadProgress, default=50}"
|
||||||
|
android:background="@drawable/background_round_secondary_color"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:textColor="?attr/secondaryTextColor"
|
||||||
|
android:text="@{data.downloadProgressString, default=`50%`}"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in a new issue