[Android] Fix HeaderMediaListActivity top margin and editor
Nicolas Pomepuy
git at videolan.org
Mon Jan 30 15:06:11 UTC 2023
vlc-android | branch: 2840-ab-repeat-setting-lost-when-screen-is-turned-off | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jan 26 10:07:42 2023 +0100| [add319baa59c486e0fba70ad330d3f622f587163] | committer: Nicolas Pomepuy
Fix HeaderMediaListActivity top margin and editor
> https://code.videolan.org/videolan/vlc-android/commit/add319baa59c486e0fba70ad330d3f622f587163
---
application/vlc-android/res/layout/header_media_list_activity.xml | 8 +++++++-
.../src/org/videolan/vlc/gui/HeaderMediaListActivity.kt | 4 ++++
application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt | 8 ++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/res/layout/header_media_list_activity.xml b/application/vlc-android/res/layout/header_media_list_activity.xml
index f450c15e04..cbad3131d4 100644
--- a/application/vlc-android/res/layout/header_media_list_activity.xml
+++ b/application/vlc-android/res/layout/header_media_list_activity.xml
@@ -23,6 +23,9 @@
<variable
name="releaseYear"
type="String" />
+ <variable
+ name="topmargin"
+ type="Integer" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
@@ -59,6 +62,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/header_layout"
android:layout_width="@dimen/default_content_width"
+ tools:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:clipChildren="false"
@@ -81,7 +85,8 @@
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_marginStart="@dimen/default_margin"
- android:layout_marginTop="86dp"
+ tools:layout_marginTop="86dp"
+ vlc:layoutMarginTop="@{topmargin}"
android:layout_marginEnd="@dimen/default_margin"
android:fitsSystemWindows="true"
android:scaleType="fitCenter"
@@ -234,6 +239,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/songs"
android:layout_width="@dimen/default_content_width"
+ tools:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top"
android:background="?attr/background_default"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
index d849a8addf..c35dff3f46 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
@@ -104,6 +104,10 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
originalBottomPadding = fragmentContainer.paddingBottom
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.title = ""
+ binding.topmargin = 86.dp
+ toolbar.addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom ->
+ binding.topmargin = bottom + 8.dp
+ }
val playlist = if (savedInstanceState != null)
savedInstanceState.parcelable<Parcelable>(AudioBrowserFragment.TAG_ITEM) as MediaLibraryItem?
diff --git a/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt b/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
index 58cc57d91b..0a0c28e871 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
@@ -14,6 +14,7 @@ import android.text.style.DynamicDrawableSpan
import android.text.style.ImageSpan
import android.util.DisplayMetrics
import android.view.View
+import android.view.ViewGroup.MarginLayoutParams
import android.widget.TextView
import androidx.annotation.WorkerThread
import androidx.appcompat.app.AppCompatActivity
@@ -208,6 +209,13 @@ fun asyncTextItem(view: TextView, item: MediaLibraryItem?) {
setTextAsync(view, text, params)
}
+ at BindingAdapter("layoutMarginTop")
+fun setLayoutMarginTop(view: View, dimen: Int) {
+ val layoutParams = view.layoutParams as MarginLayoutParams
+ layoutParams.topMargin = dimen
+ view.layoutParams = layoutParams
+}
+
private fun setTextAsync(view: TextView, text: CharSequence, params: PrecomputedTextCompat.Params) {
val ref = WeakReference(view)
AppScope.launch(Dispatchers.Default) {
More information about the Android
mailing list