Skip to content

Commit 985811a

Browse files
committed
AppDialog: Android 8 opaque fallback
1 parent 1669751 commit 985811a

6 files changed

Lines changed: 33 additions & 12 deletions

File tree

smarttubetv/src/main/AndroidManifest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@
142142
android:screenOrientation="unspecified"
143143
android:theme="@style/App.Theme.Leanback.Preferences"/>
144144

145+
<!-- Android 8 fallback -->
146+
<activity android:name="com.liskovsoft.smartyoutubetv2.tv.ui.dialogs.AppDialogActivityOpaque"
147+
android:noHistory="true"
148+
android:excludeFromRecents="true"
149+
android:launchMode="singleInstance"
150+
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|layoutDirection"
151+
android:screenOrientation="unspecified"
152+
android:theme="@style/App.Theme.Leanback.Preferences.Opaque"/>
153+
145154
<activity
146155
android:name="com.liskovsoft.smartyoutubetv2.tv.ui.browse.BrowseActivity"
147156
android:launchMode="singleInstance"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.liskovsoft.smartyoutubetv2.tv.ui.dialogs;
2+
3+
// Android 8 fallback
4+
public class AppDialogActivityOpaque extends AppDialogActivity {
5+
}

smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/main/MainApplication.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.liskovsoft.smartyoutubetv2.tv.ui.main;
22

3+
import android.os.Build.VERSION;
4+
35
import androidx.multidex.MultiDexApplication;
46

57
import com.liskovsoft.sharedutils.helpers.Helpers;
@@ -25,6 +27,7 @@
2527
import com.liskovsoft.smartyoutubetv2.tv.ui.channel.ChannelActivity;
2628
import com.liskovsoft.smartyoutubetv2.tv.ui.channeluploads.ChannelUploadsActivity;
2729
import com.liskovsoft.smartyoutubetv2.tv.ui.dialogs.AppDialogActivity;
30+
import com.liskovsoft.smartyoutubetv2.tv.ui.dialogs.AppDialogActivityOpaque;
2831
import com.liskovsoft.smartyoutubetv2.tv.ui.playback.PlaybackActivity;
2932
import com.liskovsoft.smartyoutubetv2.tv.ui.search.tags.SearchTagsActivity;
3033
import com.liskovsoft.smartyoutubetv2.tv.ui.signin.SignInActivity;
@@ -74,11 +77,21 @@ public void onCreate() {
7477
private void setupViewManager() {
7578
ViewManager viewManager = ViewManager.instance(this);
7679

80+
Class<? extends AppDialogActivity> dialogClazz;
81+
82+
if (VERSION.SDK_INT == 26
83+
&& Helpers.equalsAny(Helpers.getCrashlyticsDeviceName(), "4S806_Z51S1 (Panasonic)")) {
84+
// The fix: Only fullscreen opaque activities can request orientation
85+
dialogClazz = AppDialogActivityOpaque.class;
86+
} else {
87+
dialogClazz = AppDialogActivity.class;
88+
}
89+
7790
viewManager.setRoot(BrowseActivity.class);
7891
viewManager.register(SplashView.class, SplashActivity.class); // no parent, because it's root activity
7992
viewManager.register(BrowseView.class, BrowseActivity.class); // no parent, because it's root activity
8093
viewManager.register(PlaybackView.class, PlaybackActivity.class, BrowseActivity.class);
81-
viewManager.register(AppDialogView.class, AppDialogActivity.class, BrowseActivity.class);
94+
viewManager.register(AppDialogView.class, dialogClazz, BrowseActivity.class);
8295
viewManager.register(SearchView.class, SearchTagsActivity.class, BrowseActivity.class);
8396
viewManager.register(SignInView.class, SignInActivity.class, BrowseActivity.class);
8497
viewManager.register(AddDeviceView.class, AddDeviceActivity.class, BrowseActivity.class);

smarttubetv/src/main/res/values-v26/styles.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

smarttubetv/src/main/res/values-v27/styles.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

smarttubetv/src/main/res/values/styles.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
</style>
9898
<!-- Give ability to override style for different api -->
9999
<style name="App.Theme.Leanback.Preferences" parent="App.Theme.Leanback.Preferences.Base" />
100+
<!-- Android 8 fallback -->
101+
<style name="App.Theme.Leanback.Preferences.Opaque" parent="App.Theme.Leanback.Preferences.Base">
102+
<!-- IllegalStateException: Only fullscreen opaque activities can request orientation -->
103+
<item name="android:windowIsTranslucent">false</item>
104+
</style>
100105
<!-- End Color scheme: Teal (Default) -->
101106

102107
<!-- Color scheme: Dark Grey -->

0 commit comments

Comments
 (0)