[Android] TV Song Fragment UI/UX improvements
Nicolas Pomepuy
git at videolan.org
Thu Apr 11 18:37:56 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Mon Apr 1 11:38:55 2019 +0200| [0d7ee49753776f3fb71cbf363c09003bf05dea0f] | committer: Geoffrey Métais
TV Song Fragment UI/UX improvements
Column number depends on screen size
Shadow improvements
Back key implemented
> https://code.videolan.org/videolan/vlc-android/commit/0d7ee49753776f3fb71cbf363c09003bf05dea0f
---
.../res/animator/tv_recyclerview_item_pop.xml | 2 +-
vlc-android/res/layout/audio_browser_tv_item.xml | 1 +
vlc-android/res/layout/song_browser.xml | 7 ++--
vlc-android/res/values-w480dp/integers.xml | 4 +++
vlc-android/res/values-w600dp/integers.xml | 4 +++
vlc-android/res/values-w800dp/integers.xml | 4 +++
vlc-android/res/values/integers.xml | 4 +++
.../vlc/gui/audio/AudioBrowserAdapter.java | 1 +
.../vlc/gui/tv/browser/SongsBrowserFragment.java | 38 +++++++++++++++++-----
.../vlc/gui/tv/browser/VerticalGridActivity.java | 20 ++++++++++++
10 files changed, 72 insertions(+), 13 deletions(-)
diff --git a/vlc-android/res/animator/tv_recyclerview_item_pop.xml b/vlc-android/res/animator/tv_recyclerview_item_pop.xml
index 3fb4047df..8a0280302 100644
--- a/vlc-android/res/animator/tv_recyclerview_item_pop.xml
+++ b/vlc-android/res/animator/tv_recyclerview_item_pop.xml
@@ -17,7 +17,7 @@
<objectAnimator
android:duration="200"
android:propertyName="elevation"
- android:valueTo="0dp"
+ android:valueTo="1dp"
android:valueType="floatType" />
</set>
diff --git a/vlc-android/res/layout/audio_browser_tv_item.xml b/vlc-android/res/layout/audio_browser_tv_item.xml
index 142d4ae24..dd3ce2af0 100644
--- a/vlc-android/res/layout/audio_browser_tv_item.xml
+++ b/vlc-android/res/layout/audio_browser_tv_item.xml
@@ -45,6 +45,7 @@
android:minHeight="@dimen/audio_browser_item_size"
android:onClick="@{holder::onClick}"
android:onLongClick="@{holder::onLongClick}"
+ vlc:elevation="1dp"
android:stateListAnimator="@animator/tv_recyclerview_item_pop">
diff --git a/vlc-android/res/layout/song_browser.xml b/vlc-android/res/layout/song_browser.xml
index ec87b9ea8..278e2942d 100644
--- a/vlc-android/res/layout/song_browser.xml
+++ b/vlc-android/res/layout/song_browser.xml
@@ -30,15 +30,16 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:clipToPadding="false"
+ android:focusable="false"
+ android:focusableInTouchMode="false"
android:paddingLeft="16dp"
android:paddingTop="62dp"
android:paddingRight="16dp"
- android:focusable="false"
- android:focusableInTouchMode="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent">
+ app:layout_constraintTop_toTopOf="parent"
+ tools:listitem="@layout/audio_browser_tv_item">
</androidx.recyclerview.widget.RecyclerView>
diff --git a/vlc-android/res/values-w480dp/integers.xml b/vlc-android/res/values-w480dp/integers.xml
new file mode 100644
index 000000000..72ce90064
--- /dev/null
+++ b/vlc-android/res/values-w480dp/integers.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="tv_songs_col_count">5</integer>
+</resources>
\ No newline at end of file
diff --git a/vlc-android/res/values-w600dp/integers.xml b/vlc-android/res/values-w600dp/integers.xml
new file mode 100644
index 000000000..80139cc5e
--- /dev/null
+++ b/vlc-android/res/values-w600dp/integers.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="tv_songs_col_count">6</integer>
+</resources>
\ No newline at end of file
diff --git a/vlc-android/res/values-w800dp/integers.xml b/vlc-android/res/values-w800dp/integers.xml
new file mode 100644
index 000000000..b99cb4df9
--- /dev/null
+++ b/vlc-android/res/values-w800dp/integers.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="tv_songs_col_count">7</integer>
+</resources>
\ No newline at end of file
diff --git a/vlc-android/res/values/integers.xml b/vlc-android/res/values/integers.xml
new file mode 100644
index 000000000..f7e945ff6
--- /dev/null
+++ b/vlc-android/res/values/integers.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="tv_songs_col_count">4</integer>
+</resources>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
index 2e3a95e46..6cfe39392 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -318,6 +318,7 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
}
}
});
+ binding.container.setClipToOutline(true);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SongsBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SongsBrowserFragment.java
index 245e2ca5a..a3ea0d234 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SongsBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SongsBrowserFragment.java
@@ -25,6 +25,7 @@
package org.videolan.vlc.gui.tv.browser;
import android.annotation.TargetApi;
+import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
@@ -56,6 +57,7 @@ import org.videolan.vlc.viewmodels.paged.MLPagedModel;
import org.videolan.vlc.viewmodels.paged.PagedTracksModel;
import java.util.ArrayList;
+import java.util.Collections;
import androidx.annotation.NonNull;
import androidx.collection.SparseArrayCompat;
@@ -67,7 +69,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
-public class SongsBrowserFragment extends Fragment implements BrowserFragmentInterface, IEventsHandler, PopupMenu.OnMenuItemClickListener, SongHeaderAdapter.OnHeaderSelected {
+public class SongsBrowserFragment extends Fragment implements BrowserFragmentInterface, IEventsHandler, PopupMenu.OnMenuItemClickListener, SongHeaderAdapter.OnHeaderSelected, VerticalGridActivity.OnBackPressedListener {
private MLPagedModel<MediaLibraryItem> viewModel;
private RecyclerView list;
@@ -76,6 +78,7 @@ public class SongsBrowserFragment extends Fragment implements BrowserFragmentInt
private SongHeaderAdapter headerAdapter;
private View headerListContainer;
private int nbColumns;
+ private GridLayoutManager gridLayoutManager;
@Override
@@ -150,8 +153,8 @@ public class SongsBrowserFragment extends Fragment implements BrowserFragmentInt
});
- nbColumns = 6;
- final GridLayoutManager gridLayoutManager = new GridLayoutManager(requireActivity(), nbColumns);
+ nbColumns = getResources().getInteger(R.integer.tv_songs_col_count);
+ gridLayoutManager = new GridLayoutManager(requireActivity(), nbColumns);
final int spacing = getResources().getDimensionPixelSize(R.dimen.recycler_section_header_spacing);
@@ -227,6 +230,16 @@ public class SongsBrowserFragment extends Fragment implements BrowserFragmentInt
super.onViewCreated(view, savedInstanceState);
}
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ nbColumns = getResources().getInteger(R.integer.tv_songs_col_count);
+ gridLayoutManager.setSpanCount(nbColumns);
+ list.setLayoutManager(gridLayoutManager);
+ }
+
@Override
public void onActivityCreated(@androidx.annotation.Nullable Bundle savedInstanceState) {
list.setAdapter(adapter);
@@ -247,10 +260,7 @@ public class SongsBrowserFragment extends Fragment implements BrowserFragmentInt
ArrayList<MediaWrapper> itemList = new ArrayList<>(1);
- for (MediaWrapper track : item.getTracks()) {
-
- itemList.add(track);
- }
+ Collections.addAll(itemList, item.getTracks());
TvUtil.INSTANCE.playAudioList(getActivity(), itemList, 0);
}
@@ -272,6 +282,10 @@ public class SongsBrowserFragment extends Fragment implements BrowserFragmentInt
}
+ @Override
+ public void onImageClick(@NotNull View v, int position, @NotNull MediaLibraryItem item) {
+
+ }
public void sort(@NotNull View v) {
PopupMenu menu = new PopupMenu(v.getContext(), v);
@@ -337,7 +351,13 @@ public class SongsBrowserFragment extends Fragment implements BrowserFragmentInt
}
}
-
@Override
- public void onImageClick(@NotNull View v, int position, @NotNull MediaLibraryItem item) {}
+ public boolean onBackPressed() {
+ if (headerListContainer.getVisibility() == View.VISIBLE) {
+ headerListContainer.setVisibility(View.GONE);
+ list.setVisibility(View.VISIBLE);
+ return true;
+ }
+ return false;
+ }
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
index f4379e5f8..45b168b87 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
@@ -113,6 +113,17 @@ public class VerticalGridActivity extends BaseTvActivity implements BrowserActiv
return super.onKeyDown(keyCode, event);
}
+ @Override
+ public void onBackPressed() {
+ if (mFragment instanceof OnBackPressedListener) {
+ if (!((OnBackPressedListener) mFragment).onBackPressed()) {
+ super.onBackPressed();
+ }
+ return;
+ }
+ super.onBackPressed();
+ }
+
@Override
public void showProgress(final boolean show){
runOnUiThread(new Runnable() {
@@ -137,4 +148,13 @@ public class VerticalGridActivity extends BaseTvActivity implements BrowserActiv
public void sort(View v) {
((Sortable)mFragment).sort(v);
}
+
+ public interface OnBackPressedListener {
+ /**
+ * back has been pressed
+ *
+ * @return true if the event has been intercepted
+ */
+ boolean onBackPressed();
+ }
}
More information about the Android
mailing list