Skip to content
Snippets Groups Projects
Commit a8ddf322 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix widget layout in landscape mode

Fixes #2057
parent 80bfee2a
No related branches found
No related tags found
1 merge request!1006Various UI fixes
Pipeline #107339 passed with stage
in 18 minutes and 36 seconds
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/widget_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/widget_margin"
android:background="@color/grey900"
android:clickable="true"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/cover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@color/grey850"
android:src="@drawable/icon" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/half_default_margin"
android:paddingRight="@dimen/half_default_margin">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:layout_marginLeft="@dimen/half_default_margin"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/grey500"
android:textSize="14sp"
android:visibility="gone"
tools:text="Beethoven" />
<TextView
android:id="@+id/songName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:layout_marginLeft="@dimen/half_default_margin"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:text="@string/widget_default_text"
android:textColor="@color/grey50"
android:textSize="16sp"
tools:text="5th symphony" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:weightSum="3">
<ImageButton
android:id="@+id/backward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00ffffff"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/ic_widget_previous_w" />
<ImageButton
android:id="@+id/play_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00ffffff"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/ic_widget_play_w" />
<ImageButton
android:id="@+id/forward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00ffffff"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/ic_widget_next_w" />
<ImageButton
android:id="@+id/stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00ffffff"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/ic_widget_close_w" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/timeline_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ProgressBar
android:id="@+id/timeline"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:indeterminate="false"
android:maxHeight="2dip"
android:minHeight="2dip"
android:paddingLeft="0px"
android:paddingRight="0px"
android:progressDrawable="@drawable/progress_widget"
android:splitTrack="false" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/widget_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/widget_margin"
android:background="@color/grey50"
android:clickable="true"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/cover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@color/orange100"
android:src="@drawable/icon" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/half_default_margin"
android:paddingRight="@dimen/half_default_margin">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:layout_marginLeft="@dimen/half_default_margin"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/grey600"
android:textSize="14sp"
android:visibility="gone"
tools:text="Beethoven" />
<TextView
android:id="@+id/songName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:layout_marginLeft="@dimen/half_default_margin"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:text="@string/widget_default_text"
android:textColor="@color/grey900"
android:textSize="16sp"
tools:text="5th symphony" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:weightSum="3">
<ImageButton
android:id="@+id/backward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00ffffff"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/ic_widget_previous" />
<ImageButton
android:id="@+id/play_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00ffffff"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/ic_widget_play" />
<ImageButton
android:id="@+id/forward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00ffffff"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/ic_widget_next" />
<ImageButton
android:id="@+id/stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00ffffff"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/ic_widget_close" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/timeline_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ProgressBar
android:id="@+id/timeline"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:indeterminate="false"
android:maxHeight="2dip"
android:minHeight="2dip"
android:paddingLeft="0px"
android:paddingRight="0px"
android:progressDrawable="@drawable/progress_widget"
android:splitTrack="false" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
......@@ -24,10 +24,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:paddingLeft="@dimen/half_default_margin"
android:paddingRight="@dimen/half_default_margin">
android:padding="@dimen/half_default_margin">
<TextView
android:id="@+id/artist"
......@@ -37,6 +36,7 @@
android:layout_marginLeft="@dimen/half_default_margin"
android:ellipsize="end"
android:singleLine="true"
android:visibility="gone"
android:maxLines="1"
android:textColor="@color/grey500"
android:textSize="14sp" />
......
......@@ -24,10 +24,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:paddingLeft="@dimen/half_default_margin"
android:paddingRight="@dimen/half_default_margin">
android:padding="@dimen/half_default_margin">
<TextView
android:id="@+id/artist"
......@@ -35,6 +34,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:layout_marginLeft="@dimen/half_default_margin"
android:visibility="gone"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
......
......@@ -112,24 +112,28 @@ abstract class VLCAppWidgetProvider : AppWidgetProvider() {
views.setTextViewText(R.id.songName, title)
views.setTextViewText(R.id.artist, artist)
if (title == context.getString(R.string.widget_default_text))
views.setViewVisibility(R.id.artist, View.GONE)
else
views.setViewVisibility(R.id.artist, View.VISIBLE)
views.setImageViewResource(R.id.play_pause, getPlayPauseImage(isplaying))
}
ACTION_WIDGET_UPDATE_COVER == action -> {
val artworkMrl = intent.getStringExtra("artworkMrl")
if (!artworkMrl.isNullOrEmpty()) {
runIO(Runnable {
runIO {
val cover = AudioUtil.readCoverBitmap(Uri.decode(artworkMrl), 320)
val wm = context.getSystemService<WindowManager>()!!
val dm = DisplayMetrics().also { wm.defaultDisplay.getMetrics(it) }
runOnMainThread(Runnable {
runOnMainThread {
if (cover != null) {
if (cover.byteSize() < dm.widthPixels * dm.heightPixels * 6) views.setImageViewBitmap(R.id.cover, cover)
} else
views.setImageViewResource(R.id.cover, R.drawable.icon)
views.setProgressBar(R.id.timeline, 100, 0, false)
applyUpdate(context, views, partial)
})
})
}
}
} else
views.setImageViewResource(R.id.cover, R.drawable.icon)
views.setProgressBar(R.id.timeline, 100, 0, false)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment