feat(YouTube): Add Override 'Open in YouTube Music' button patch
Co-authored-by: ILoveOpenSourceApplications <117499019+iloveopensourceapplications@users.noreply.github.com>
This commit is contained in:
parent
bc08ecf785
commit
8c2445f92f
6 changed files with 230 additions and 4 deletions
|
|
@ -373,6 +373,29 @@ public class Utils {
|
|||
return getContext().getResources().getStringArray(getResourceIdentifierOrThrow(ResourceType.ARRAY, resourceIdentifierName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a specific app package is installed and enabled on the device.
|
||||
*
|
||||
* @param packageName The application package name to check (e.g., "app.morphe.android.apps.youtube.music").
|
||||
* @return True if the package is installed and enabled, false otherwise.
|
||||
*/
|
||||
public static boolean isPackageEnabled(String packageName) {
|
||||
Context context = getContext();
|
||||
if (context == null || !isNotEmpty(packageName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
return pm.getApplicationInfo(packageName, PackageManager.ApplicationInfoFlags.of(0)).enabled;
|
||||
} else {
|
||||
return pm.getApplicationInfo(packageName, 0).enabled;
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public interface MatchFilter<T> {
|
||||
boolean matches(T object);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue