diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/activity/MainActivity.java b/app/src/main/java/com/cappielloantonio/tempo/ui/activity/MainActivity.java index 1a75b242..3509175f 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/activity/MainActivity.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/activity/MainActivity.java @@ -2,6 +2,8 @@ package com.cappielloantonio.tempo.ui.activity; import android.content.Context; import android.content.Intent; +import android.content.res.Configuration; +import android.graphics.Rect; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -11,6 +13,7 @@ import android.os.Handler; import android.text.TextUtils; import android.util.Log; import android.view.View; +import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.core.splashscreen.SplashScreen; @@ -62,6 +65,7 @@ public class MainActivity extends BaseActivity { private BottomNavigationView bottomNavigationView; public NavController navController; private BottomSheetBehavior bottomSheetBehavior; + private boolean isLandscape = false; private AssetLinkNavigator assetLinkNavigator; private AssetLinkUtil.AssetLink pendingAssetLink; @@ -85,6 +89,8 @@ public class MainActivity extends BaseActivity { connectivityStatusBroadcastReceiver = new ConnectivityStatusBroadcastReceiver(this); connectivityStatusReceiverManager(true); + isLandscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); + init(); checkConnectionType(); getOpenSubsonicExtensions(); @@ -141,6 +147,15 @@ public class MainActivity extends BaseActivity { } else { goToLogin(); } + + // Set bottom navigation height + if (isLandscape) { + ViewGroup.LayoutParams layoutParams = bottomNavigationView.getLayoutParams(); + Rect windowRect = new Rect(); + bottomNavigationView.getWindowVisibleDisplayFrame(windowRect); + layoutParams.width = windowRect.height(); + bottomNavigationView.setLayoutParams(layoutParams); + } } // BOTTOM SHEET/NAVIGATION @@ -215,7 +230,9 @@ public class MainActivity extends BaseActivity { @Override public void onSlide(@NonNull View view, float slideOffset) { animateBottomSheet(slideOffset); - animateBottomNavigation(slideOffset, navigationHeight); + if (!isLandscape) { + animateBottomNavigation(slideOffset, navigationHeight); + } } }; diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/adapter/SongHorizontalAdapter.java b/app/src/main/java/com/cappielloantonio/tempo/ui/adapter/SongHorizontalAdapter.java index 1d78f2ea..6e5eefe4 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/adapter/SongHorizontalAdapter.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/adapter/SongHorizontalAdapter.java @@ -173,10 +173,12 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter originalAlbums; @@ -90,6 +92,10 @@ public class AlbumCatalogueFragment extends Fragment implements ClickCallback { bind = FragmentAlbumCatalogueBinding.inflate(inflater, container, false); View view = bind.getRoot(); + if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + spanCount = Preferences.getLandscapeItemsPerRow(); + } + initAppBar(); initAlbumCatalogueView(); initProgressLoader(); @@ -133,8 +139,8 @@ public class AlbumCatalogueFragment extends Fragment implements ClickCallback { @SuppressLint("ClickableViewAccessibility") private void initAlbumCatalogueView() { - bind.albumCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); - bind.albumCatalogueRecyclerView.addItemDecoration(new GridItemDecoration(2, 20, false)); + bind.albumCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), spanCount)); + bind.albumCatalogueRecyclerView.addItemDecoration(new GridItemDecoration(spanCount, 20, false)); bind.albumCatalogueRecyclerView.setHasFixedSize(true); albumAdapter = new AlbumCatalogueAdapter(this, true); diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistCatalogueFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistCatalogueFragment.java index 7e7ce759..5a2aa1ee 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistCatalogueFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistCatalogueFragment.java @@ -2,6 +2,7 @@ package com.cappielloantonio.tempo.ui.fragment; import android.annotation.SuppressLint; import android.content.Context; +import android.content.res.Configuration; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; @@ -50,6 +51,7 @@ public class ArtistCatalogueFragment extends Fragment implements ClickCallback { private ArtistCatalogueViewModel artistCatalogueViewModel; private ArtistCatalogueAdapter artistAdapter; + private int spanCount = 2; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -66,6 +68,10 @@ public class ArtistCatalogueFragment extends Fragment implements ClickCallback { bind = FragmentArtistCatalogueBinding.inflate(inflater, container, false); View view = bind.getRoot(); + if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + spanCount = Preferences.getLandscapeItemsPerRow(); + } + initAppBar(); initArtistCatalogueView(); @@ -108,8 +114,8 @@ public class ArtistCatalogueFragment extends Fragment implements ClickCallback { @SuppressLint("ClickableViewAccessibility") private void initArtistCatalogueView() { - bind.artistCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); - bind.artistCatalogueRecyclerView.addItemDecoration(new GridItemDecoration(2, 20, false)); + bind.artistCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), spanCount)); + bind.artistCatalogueRecyclerView.addItemDecoration(new GridItemDecoration(spanCount, 20, false)); bind.artistCatalogueRecyclerView.setHasFixedSize(true); artistAdapter = new ArtistCatalogueAdapter(this); diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java index 06bcd984..e995d209 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java @@ -2,6 +2,7 @@ package com.cappielloantonio.tempo.ui.fragment; import android.content.ComponentName; import android.content.Intent; +import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -63,6 +64,8 @@ public class ArtistPageFragment extends Fragment implements ClickCallback { private ListenableFuture mediaBrowserListenableFuture; + private int spanCount = 2; + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { activity = (MainActivity) getActivity(); @@ -72,6 +75,10 @@ public class ArtistPageFragment extends Fragment implements ClickCallback { artistPageViewModel = new ViewModelProvider(requireActivity()).get(ArtistPageViewModel.class); playbackViewModel = new ViewModelProvider(requireActivity()).get(PlaybackViewModel.class); + if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + spanCount = Preferences.getLandscapeItemsPerRow(); + } + init(view); initAppBar(); initArtistInfo(); @@ -277,8 +284,8 @@ public class ArtistPageFragment extends Fragment implements ClickCallback { } private void initAlbumsView() { - bind.albumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); - bind.albumsRecyclerView.addItemDecoration(new GridItemDecoration(2, 20, false)); + bind.albumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), spanCount)); + bind.albumsRecyclerView.addItemDecoration(new GridItemDecoration(spanCount, 20, false)); bind.albumsRecyclerView.setHasFixedSize(true); albumCatalogueAdapter = new AlbumCatalogueAdapter(this, false); @@ -296,8 +303,8 @@ public class ArtistPageFragment extends Fragment implements ClickCallback { } private void initSimilarArtistsView() { - bind.similarArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); - bind.similarArtistsRecyclerView.addItemDecoration(new GridItemDecoration(2, 20, false)); + bind.similarArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), spanCount)); + bind.similarArtistsRecyclerView.addItemDecoration(new GridItemDecoration(spanCount, 20, false)); bind.similarArtistsRecyclerView.setHasFixedSize(true); artistCatalogueAdapter = new ArtistCatalogueAdapter(this); diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/GenreCatalogueFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/GenreCatalogueFragment.java index 801c323d..52e8b825 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/GenreCatalogueFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/GenreCatalogueFragment.java @@ -2,6 +2,7 @@ package com.cappielloantonio.tempo.ui.fragment; import android.annotation.SuppressLint; import android.content.Context; +import android.content.res.Configuration; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; @@ -32,6 +33,7 @@ import com.cappielloantonio.tempo.interfaces.ClickCallback; import com.cappielloantonio.tempo.ui.activity.MainActivity; import com.cappielloantonio.tempo.ui.adapter.GenreCatalogueAdapter; import com.cappielloantonio.tempo.util.Constants; +import com.cappielloantonio.tempo.util.Preferences; import com.cappielloantonio.tempo.viewmodel.GenreCatalogueViewModel; @OptIn(markerClass = UnstableApi.class) @@ -41,6 +43,7 @@ public class GenreCatalogueFragment extends Fragment implements ClickCallback { private GenreCatalogueViewModel genreCatalogueViewModel; private GenreCatalogueAdapter genreCatalogueAdapter; + private int spanCount = 2; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -56,6 +59,10 @@ public class GenreCatalogueFragment extends Fragment implements ClickCallback { View view = bind.getRoot(); genreCatalogueViewModel = new ViewModelProvider(requireActivity()).get(GenreCatalogueViewModel.class); + if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + spanCount = Preferences.getLandscapeItemsPerRow(); + } + init(); initAppBar(); initGenreCatalogueView(); @@ -97,8 +104,8 @@ public class GenreCatalogueFragment extends Fragment implements ClickCallback { @SuppressLint("ClickableViewAccessibility") private void initGenreCatalogueView() { - bind.genreCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); - bind.genreCatalogueRecyclerView.addItemDecoration(new GridItemDecoration(2, 16, false)); + bind.genreCatalogueRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), spanCount)); + bind.genreCatalogueRecyclerView.addItemDecoration(new GridItemDecoration(spanCount, 16, false)); bind.genreCatalogueRecyclerView.setHasFixedSize(true); genreCatalogueAdapter = new GenreCatalogueAdapter(this); diff --git a/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt b/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt index 485aa587..a95c84ae 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt +++ b/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt @@ -29,6 +29,7 @@ object Preferences { private const val REPEAT_MODE = "repeat_mode" private const val IMAGE_CACHE_SIZE = "image_cache_size" private const val STREAMING_CACHE_SIZE = "streaming_cache_size" + private const val LANDSCAPE_ITEMS_PER_ROW = "landscape_items_per_row" private const val IMAGE_SIZE = "image_size" private const val MAX_BITRATE_WIFI = "max_bitrate_wifi" private const val MAX_BITRATE_MOBILE = "max_bitrate_mobile" @@ -304,6 +305,11 @@ object Preferences { return App.getInstance().preferences.getString(IMAGE_CACHE_SIZE, "500")!!.toInt() } + @JvmStatic + fun getLandscapeItemsPerRow(): Int { + return App.getInstance().preferences.getString(LANDSCAPE_ITEMS_PER_ROW, "4")!!.toInt() + } + @JvmStatic fun getImageSize(): Int { return App.getInstance().preferences.getString(IMAGE_SIZE, "-1")!!.toInt() diff --git a/app/src/main/res/drawable/ic_graphic_eq_land.xml b/app/src/main/res/drawable/ic_graphic_eq_land.xml new file mode 100644 index 00000000..1ce7e155 --- /dev/null +++ b/app/src/main/res/drawable/ic_graphic_eq_land.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_home_land.xml b/app/src/main/res/drawable/ic_home_land.xml new file mode 100644 index 00000000..9aad448a --- /dev/null +++ b/app/src/main/res/drawable/ic_home_land.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_play_for_work_land.xml b/app/src/main/res/drawable/ic_play_for_work_land.xml new file mode 100644 index 00000000..29ab2950 --- /dev/null +++ b/app/src/main/res/drawable/ic_play_for_work_land.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-land/activity_main.xml b/app/src/main/res/layout-land/activity_main.xml new file mode 100644 index 00000000..25ee0493 --- /dev/null +++ b/app/src/main/res/layout-land/activity_main.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_album_page.xml b/app/src/main/res/layout-land/fragment_album_page.xml new file mode 100644 index 00000000..2fb22cb1 --- /dev/null +++ b/app/src/main/res/layout-land/fragment_album_page.xml @@ -0,0 +1,305 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +