fix overlapping icons in ComposeActivity (#1661)

This commit is contained in:
Konrad Pozniak 2020-01-30 21:17:37 +01:00 committed by GitHub
parent 415b526885
commit 29ef92edd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View file

@ -113,6 +113,8 @@ class ComposeActivity : BaseActivity(),
private var composeOptions: ComposeOptions? = null private var composeOptions: ComposeOptions? = null
private lateinit var viewModel: ComposeViewModel private lateinit var viewModel: ComposeViewModel
private var mediaCount = 0
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val preferences = PreferenceManager.getDefaultSharedPreferences(this) val preferences = PreferenceManager.getDefaultSharedPreferences(this)
@ -304,9 +306,12 @@ class ComposeActivity : BaseActivity(),
setStatusVisibility(visibility) setStatusVisibility(visibility)
} }
viewModel.media.observe { media -> viewModel.media.observe { media ->
composeMediaPreviewBar.visible(media.isNotEmpty())
mediaAdapter.submitList(media) mediaAdapter.submitList(media)
updateSensitiveMediaToggle(viewModel.markMediaAsSensitive.value != false, viewModel.showContentWarning.value != false) if(media.size != mediaCount) {
mediaCount = media.size
composeMediaPreviewBar.visible(media.isNotEmpty())
updateSensitiveMediaToggle(viewModel.markMediaAsSensitive.value != false, viewModel.showContentWarning.value != false)
}
} }
viewModel.poll.observe { poll -> viewModel.poll.observe { poll ->
pollPreview.visible(poll != null) pollPreview.visible(poll != null)
@ -493,8 +498,6 @@ class ComposeActivity : BaseActivity(),
} }
private fun updateSensitiveMediaToggle(markMediaSensitive: Boolean, contentWarningShown: Boolean) { private fun updateSensitiveMediaToggle(markMediaSensitive: Boolean, contentWarningShown: Boolean) {
TransitionManager.beginDelayedTransition(composeHideMediaButton.parent as ViewGroup)
if (viewModel.media.value.isNullOrEmpty()) { if (viewModel.media.value.isNullOrEmpty()) {
composeHideMediaButton.hide() composeHideMediaButton.hide()
} else { } else {

View file

@ -243,6 +243,7 @@
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="?android:colorBackground" android:background="?android:colorBackground"
android:elevation="12dp" android:elevation="12dp"
android:animateLayoutChanges="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingTop="4dp" android:paddingTop="4dp"
@ -274,13 +275,12 @@
<ImageButton <ImageButton
android:id="@+id/composeHideMediaButton" android:id="@+id/composeHideMediaButton"
style="?attr/image_button_style" style="?attr/image_button_style"
android:layout_width="40dp" android:layout_width="36dp"
android:layout_height="40dp" android:layout_height="36dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:contentDescription="@string/action_hide_media" android:contentDescription="@string/action_hide_media"
android:padding="4dp" android:padding="4dp"
android:tooltipText="@string/action_hide_media" android:tooltipText="@string/action_hide_media"
android:visibility="gone"
tools:src="@drawable/ic_eye_24dp" /> tools:src="@drawable/ic_eye_24dp" />
<ImageButton <ImageButton