From 0fddc66d42b4926d547ca925c2d105fca149191b Mon Sep 17 00:00:00 2001 From: Arturo Espinosa Date: Wed, 18 Dec 2024 00:26:26 -0600 Subject: [PATCH 1/4] main/AndroidManifest.xml: removed android:screenOrientation as it is limiting activities to a portrait orientation, but they are working acceptably for landscape orientation as well. Orientation configuration changes should be managed correctly; as the application stands, navigation flips to the Devices tab when orientation changes, instead of persisting in the current tab. --- app/src/main/AndroidManifest.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c509552..0bae8ee 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,7 +24,6 @@ @@ -96,7 +90,6 @@ android:name="wseemann.media.romote.activity.ManualConnectionActivity" android:theme="@style/AppTheme" android:label="@string/title_connect_manually" - android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden"/> Date: Wed, 18 Dec 2024 12:16:06 -0600 Subject: [PATCH 2/4] layout-w960dp/fragment_remote.xml: new layout for landscape orient Splits the buttons in two clusters. Right cluster mimics the original Roku navigation cluster. Left cluster groups tv/media and unconventional or elite buttons. --- .../res/layout-w960dp/fragment_remote.xml | 299 ++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 app/src/main/res/layout-w960dp/fragment_remote.xml diff --git a/app/src/main/res/layout-w960dp/fragment_remote.xml b/app/src/main/res/layout-w960dp/fragment_remote.xml new file mode 100644 index 0000000..6f584f0 --- /dev/null +++ b/app/src/main/res/layout-w960dp/fragment_remote.xml @@ -0,0 +1,299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 388a45fc1be3bca7348b0243920486832a2ff664 Mon Sep 17 00:00:00 2001 From: Arturo Espinosa Date: Wed, 18 Dec 2024 12:32:05 -0600 Subject: [PATCH 3/4] layout-w960dp/fragment_remote.xml: aesthetic, spacing --- app/src/main/res/layout-w960dp/fragment_remote.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/res/layout-w960dp/fragment_remote.xml b/app/src/main/res/layout-w960dp/fragment_remote.xml index 6f584f0..6691ab4 100644 --- a/app/src/main/res/layout-w960dp/fragment_remote.xml +++ b/app/src/main/res/layout-w960dp/fragment_remote.xml @@ -225,6 +225,7 @@ android:layout_marginRight="10dp"> + + --> + + Date: Sat, 21 Dec 2024 21:18:29 -0600 Subject: [PATCH 4/4] MainActivity: switch to last selected tab when activity recreates Kind of hackish: https://stackoverflow.com/a/5317727 and https://stackoverflow.com/a/23363016 So, now that a horizontal layout has been added, when the orientation changes, we retain the selected tab/item. --- .../media/romote/activity/MainActivity.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/wseemann/media/romote/activity/MainActivity.java b/app/src/main/java/wseemann/media/romote/activity/MainActivity.java index b87260e..5bf966e 100644 --- a/app/src/main/java/wseemann/media/romote/activity/MainActivity.java +++ b/app/src/main/java/wseemann/media/romote/activity/MainActivity.java @@ -8,6 +8,7 @@ import android.os.IBinder; import android.os.Bundle; +import android.os.Handler; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; @@ -58,6 +59,14 @@ public class MainActivity extends ConnectivityActivity implements private ChannelFragment mChannelFragment; + @Override + public Object onRetainCustomNonConfigurationInstance() { + if (mViewPager == null) { + return null; + } + return new Integer(mViewPager.getCurrentItem()); + } + @Override public void onCreate(Bundle savedInstanceState) { SplashScreen.installSplashScreen(this); @@ -98,13 +107,23 @@ public void onPageSelected(int position) { } }); - if (!commandHelper.getDeviceURL().equals("")) { - mViewPager.setCurrentItem(1); - } - TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); + Integer lastItem = (Integer) getLastCustomNonConfigurationInstance(); + if (lastItem != null) { + new Handler().post(new Runnable() { + @Override + public void run() { + mViewPager.setCurrentItem(lastItem, false); + } + }); + } else { + if (!commandHelper.getDeviceURL().equals("")) { + mViewPager.setCurrentItem(1, false); + } + } + /*BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation); bottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED); bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {