mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-30 23:03:00 +00:00 
			
		
		
		
	Fix persistent hover overlay when mouse connected
This commit is contained in:
		| @@ -639,19 +639,7 @@ public final class VideoDetailFragment | |||||||
|                         ? View.VISIBLE |                         ? View.VISIBLE | ||||||
|                         : View.GONE |                         : View.GONE | ||||||
|         ); |         ); | ||||||
|  |         accommodateForTvAndDesktopMode(); | ||||||
|         if (DeviceUtils.isTv(getContext())) { |  | ||||||
|             // remove ripple effects from detail controls |  | ||||||
|             final int transparent = ContextCompat.getColor(requireContext(), |  | ||||||
|                     R.color.transparent_background_color); |  | ||||||
|             binding.detailControlsPlaylistAppend.setBackgroundColor(transparent); |  | ||||||
|             binding.detailControlsBackground.setBackgroundColor(transparent); |  | ||||||
|             binding.detailControlsPopup.setBackgroundColor(transparent); |  | ||||||
|             binding.detailControlsDownload.setBackgroundColor(transparent); |  | ||||||
|             binding.detailControlsShare.setBackgroundColor(transparent); |  | ||||||
|             binding.detailControlsOpenInBrowser.setBackgroundColor(transparent); |  | ||||||
|             binding.detailControlsPlayWithKodi.setBackgroundColor(transparent); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -2106,6 +2094,30 @@ public final class VideoDetailFragment | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Make changes to the UI to accommodate for better usability on bigger screens such as TVs | ||||||
|  |      * or in Android's desktop mode (DeX etc.) | ||||||
|  |      */ | ||||||
|  |     private void accommodateForTvAndDesktopMode() { | ||||||
|  |         if (DeviceUtils.isTv(getContext())) { | ||||||
|  |             // remove ripple effects from detail controls | ||||||
|  |             final int transparent = ContextCompat.getColor(requireContext(), | ||||||
|  |                     R.color.transparent_background_color); | ||||||
|  |             binding.detailControlsPlaylistAppend.setBackgroundColor(transparent); | ||||||
|  |             binding.detailControlsBackground.setBackgroundColor(transparent); | ||||||
|  |             binding.detailControlsPopup.setBackgroundColor(transparent); | ||||||
|  |             binding.detailControlsDownload.setBackgroundColor(transparent); | ||||||
|  |             binding.detailControlsShare.setBackgroundColor(transparent); | ||||||
|  |             binding.detailControlsOpenInBrowser.setBackgroundColor(transparent); | ||||||
|  |             binding.detailControlsPlayWithKodi.setBackgroundColor(transparent); | ||||||
|  |         } | ||||||
|  |         if (DeviceUtils.isDesktopMode(getContext())) { | ||||||
|  |             // Remove the "hover" overlay (since it is visible on all mouse events and interferes | ||||||
|  |             // with the video content being played) | ||||||
|  |             binding.detailThumbnailRootLayout.setForeground(null); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     private void checkLandscape() { |     private void checkLandscape() { | ||||||
|         if ((!player.isPlaying() && player.getPlayQueue() != playQueue) |         if ((!player.isPlaying() && player.getPlayQueue() != playQueue) | ||||||
|                 || player.getPlayQueue() == null) { |                 || player.getPlayQueue() == null) { | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| package org.schabi.newpipe.util; | package org.schabi.newpipe.util; | ||||||
|  |  | ||||||
|  | import android.annotation.SuppressLint; | ||||||
| import android.app.UiModeManager; | import android.app.UiModeManager; | ||||||
| import android.content.Context; | import android.content.Context; | ||||||
| import android.content.pm.PackageManager; | import android.content.pm.PackageManager; | ||||||
| @@ -22,6 +23,9 @@ import androidx.preference.PreferenceManager; | |||||||
| import org.schabi.newpipe.App; | import org.schabi.newpipe.App; | ||||||
| import org.schabi.newpipe.R; | import org.schabi.newpipe.R; | ||||||
|  |  | ||||||
|  | import java.lang.reflect.InvocationTargetException; | ||||||
|  | import java.lang.reflect.Method; | ||||||
|  |  | ||||||
| public final class DeviceUtils { | public final class DeviceUtils { | ||||||
|  |  | ||||||
|     private static final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv"; |     private static final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv"; | ||||||
| @@ -84,6 +88,50 @@ public final class DeviceUtils { | |||||||
|         return DeviceUtils.isTV; |         return DeviceUtils.isTV; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static boolean isDesktopMode(final Context context) { | ||||||
|  |         final boolean isDesktopMode = ContextCompat.getSystemService(context, UiModeManager.class) | ||||||
|  |                 .getCurrentModeType() == Configuration.UI_MODE_TYPE_DESK; | ||||||
|  |  | ||||||
|  |         // DeX check for standalone and multi-window mode | ||||||
|  |         boolean isDeXMode = false; | ||||||
|  |         try { | ||||||
|  |             final Configuration config = context.getResources().getConfiguration(); | ||||||
|  |             final Class<?> configClass = config.getClass(); | ||||||
|  |             final int semDesktopModeEnabledConst = | ||||||
|  |                     configClass.getField("SEM_DESKTOP_MODE_ENABLED").getInt(configClass); | ||||||
|  |             final int currentMode = | ||||||
|  |                     configClass.getField("semDesktopModeEnabled").getInt(config); | ||||||
|  |             if (semDesktopModeEnabledConst == currentMode) { | ||||||
|  |                 isDeXMode = true; | ||||||
|  |             } | ||||||
|  |         } catch (final NoSuchFieldException | IllegalAccessException e) { | ||||||
|  |             // empty | ||||||
|  |         } | ||||||
|  |         @SuppressLint("WrongConstant") final Object desktopModeManager = context | ||||||
|  |                 .getApplicationContext() | ||||||
|  |                 .getSystemService("desktopmode"); | ||||||
|  |         if (desktopModeManager != null) { | ||||||
|  |             try { | ||||||
|  |                 final Method getDesktopModeStateMethod = desktopModeManager.getClass() | ||||||
|  |                         .getDeclaredMethod("getDesktopModeState"); | ||||||
|  |                 final Object desktopModeState = getDesktopModeStateMethod | ||||||
|  |                         .invoke(desktopModeManager); | ||||||
|  |                 final Class<?> desktopModeStateClass = desktopModeState.getClass(); | ||||||
|  |                 final Method getEnabledMethod = desktopModeStateClass | ||||||
|  |                         .getDeclaredMethod("getEnabled"); | ||||||
|  |                 final int enabled = (int) getEnabledMethod.invoke(desktopModeState); | ||||||
|  |                 final boolean isEnabled = enabled == desktopModeStateClass | ||||||
|  |                         .getDeclaredField("ENABLED").getInt(desktopModeStateClass); | ||||||
|  |  | ||||||
|  |                 isDeXMode = isEnabled; | ||||||
|  |             } catch (NoSuchFieldException | NoSuchMethodException | ||||||
|  |                     | IllegalAccessException | InvocationTargetException e) { | ||||||
|  |                 // Device does not support DeX 3.0 | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return isDesktopMode || isDeXMode; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public static boolean isTablet(@NonNull final Context context) { |     public static boolean isTablet(@NonNull final Context context) { | ||||||
|         final String tabletModeSetting = PreferenceManager.getDefaultSharedPreferences(context) |         final String tabletModeSetting = PreferenceManager.getDefaultSharedPreferences(context) | ||||||
|                 .getString(context.getString(R.string.tablet_mode_key), ""); |                 .getString(context.getString(R.string.tablet_mode_key), ""); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Hanif Shersy
					Hanif Shersy