3838import android .view .MenuItem ;
3939import android .view .View ;
4040import android .view .ViewGroup ;
41+ import android .webkit .WebView ;
4142import android .widget .AdapterView ;
4243import android .widget .ArrayAdapter ;
4344import android .widget .FrameLayout ;
@@ -136,6 +137,19 @@ protected void onCreate(final Bundle savedInstanceState) {
136137 ThemeHelper .setDayNightMode (this );
137138 ThemeHelper .setTheme (this , ServiceHelper .getSelectedServiceId (this ));
138139
140+ // Fixes text color turning black in dark/black mode:
141+ // https://github.com/TeamNewPipe/NewPipe/issues/12016
142+ // For further reference see: https://issuetracker.google.com/issues/37124582
143+ if (DeviceUtils .supportsWebView ()) {
144+ try {
145+ new WebView (this );
146+ } catch (final Throwable e ) {
147+ if (DEBUG ) {
148+ Log .e (TAG , "Failed to create WebView" , e );
149+ }
150+ }
151+ }
152+
139153 assureCorrectAppLanguage (this );
140154 super .onCreate (savedInstanceState );
141155
@@ -172,6 +186,8 @@ protected void onCreate(final Bundle savedInstanceState) {
172186 && ReleaseVersionUtil .INSTANCE .isReleaseApk ()) {
173187 UpdateSettingsFragment .askForConsentToUpdateChecks (this );
174188 }
189+
190+ Localization .migrateAppLanguageSettingIfNecessary (getApplicationContext ());
175191 }
176192
177193 @ Override
@@ -578,8 +594,8 @@ public void onBackPressed() {
578594 if (player instanceof BackPressable backPressable && !backPressable .onBackPressed ()) {
579595 BottomSheetBehavior .from (mainBinding .fragmentPlayerHolder )
580596 .setState (BottomSheetBehavior .STATE_COLLAPSED );
581- return ;
582597 }
598+ return ;
583599 }
584600
585601 if (fragmentManager .getBackStackEntryCount () == 1 ) {
@@ -826,7 +842,8 @@ private void openMiniPlayerUponPlayerStarted() {
826842 @ Override
827843 public void onReceive (final Context context , final Intent intent ) {
828844 if (Objects .equals (intent .getAction (),
829- VideoDetailFragment .ACTION_PLAYER_STARTED )) {
845+ VideoDetailFragment .ACTION_PLAYER_STARTED )
846+ && PlayerHolder .getInstance ().isPlayerOpen ()) {
830847 openMiniPlayerIfMissing ();
831848 // At this point the player is added 100%, we can unregister. Other actions
832849 // are useless since the fragment will not be removed after that.
@@ -838,6 +855,10 @@ public void onReceive(final Context context, final Intent intent) {
838855 final IntentFilter intentFilter = new IntentFilter ();
839856 intentFilter .addAction (VideoDetailFragment .ACTION_PLAYER_STARTED );
840857 registerReceiver (broadcastReceiver , intentFilter );
858+
859+ // If the PlayerHolder is not bound yet, but the service is running, try to bind to it.
860+ // Once the connection is established, the ACTION_PLAYER_STARTED will be sent.
861+ PlayerHolder .getInstance ().tryBindIfNeeded (this );
841862 }
842863 }
843864
0 commit comments