From d3466f9ccec1e11ecbdf9524e730fbd6a1533745 Mon Sep 17 00:00:00 2001 From: Ivan Agosto Date: Tue, 14 May 2024 18:20:46 -0600 Subject: [PATCH] Add reponsive views --- app/src/main/AndroidManifest.xml | 6 +- .../org/libre/agosto/p2play/MainActivity.kt | 19 +- .../res/layout-large/activity_reproductor.xml | 361 ++++++++++++++++++ .../layout-large/custom_player_controls.xml | 110 ++++++ .../main/res/layout-large/dialog_thread.xml | 51 +++ app/src/main/res/layout/activity_channel.xml | 10 +- app/src/main/res/layout/content_main.xml | 4 +- 7 files changed, 545 insertions(+), 16 deletions(-) create mode 100644 app/src/main/res/layout-large/activity_reproductor.xml create mode 100644 app/src/main/res/layout-large/custom_player_controls.xml create mode 100644 app/src/main/res/layout-large/dialog_thread.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7721137..0e34e85 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -67,10 +67,10 @@ + android:exported="true" + android:foregroundServiceType="mediaPlayback"> - + diff --git a/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt b/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt index 43d6c51..82086ee 100644 --- a/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt @@ -1,6 +1,7 @@ package org.libre.agosto.p2play import android.content.Intent +import android.content.res.Configuration import android.os.AsyncTask import android.os.Bundle import android.os.Handler @@ -11,6 +12,7 @@ import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.SearchView import androidx.core.view.GravityCompat +import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.material.navigation.NavigationView @@ -46,18 +48,23 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte setContentView(R.layout.activity_main) setSupportActionBar(toolbar) - /* fab.setOnClickListener { view -> - Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) - .setAction("Action", null).show() - } */ - val toggle = ActionBarDrawerToggle(this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) drawer_layout.addDrawerListener(toggle) toggle.syncState() nav_view.setNavigationItemSelectedListener(this) - viewManager = LinearLayoutManager(this) + val screenSize = resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK + viewManager = if (screenSize > Configuration.SCREENLAYOUT_SIZE_LARGE) { + val orientation = resources.configuration.orientation + val gridItems = when (orientation) { + Configuration.ORIENTATION_LANDSCAPE -> 4 + else -> 3 + } + GridLayoutManager(this, gridItems) + } else { + LinearLayoutManager(this) + } // Init RecyclerView this.initRecycler() diff --git a/app/src/main/res/layout-large/activity_reproductor.xml b/app/src/main/res/layout-large/activity_reproductor.xml new file mode 100644 index 0000000..18706e2 --- /dev/null +++ b/app/src/main/res/layout-large/activity_reproductor.xml @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-large/custom_player_controls.xml b/app/src/main/res/layout-large/custom_player_controls.xml new file mode 100644 index 0000000..9a1609d --- /dev/null +++ b/app/src/main/res/layout-large/custom_player_controls.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-large/dialog_thread.xml b/app/src/main/res/layout-large/dialog_thread.xml new file mode 100644 index 0000000..af93bd5 --- /dev/null +++ b/app/src/main/res/layout-large/dialog_thread.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_channel.xml b/app/src/main/res/layout/activity_channel.xml index e838d16..d0df814 100644 --- a/app/src/main/res/layout/activity_channel.xml +++ b/app/src/main/res/layout/activity_channel.xml @@ -6,9 +6,9 @@ android:layout_height="wrap_content" tools:context=".ChannelActivity"> - + android:baselineAligned="false" + android:orientation="horizontal"> - + \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 0ccecaf..57b9524 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -16,7 +16,7 @@ android:visibility="visible" app:layout_constraintTop_toTopOf="parent"> - - \ No newline at end of file +