From afa9d3cbb12f8abd9a7f1beb74e454fee6e4b0a7 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 29 Oct 2022 03:03:04 +0200 Subject: [PATCH] feat(youtube/microg-support): handle availability of Vanced MicroG --- .../integrations/patches/MicroGSupport.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java diff --git a/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java b/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java new file mode 100644 index 00000000..cd8e3f1e --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java @@ -0,0 +1,33 @@ +package app.revanced.integrations.patches; + +import static app.revanced.integrations.sponsorblock.StringRef.str; + +import android.content.Intent; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.widget.Toast; + +import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; + +public class MicroGSupport { + private static final String MICROG_VENDOR = "com.mgoogle"; + private static final String MICROG_PACKAGE_NAME = "com.mgoogle.android.gms"; + private static final String VANCED_MICROG_DOWNLOAD_LINK = "https://github.com/TeamVanced/VancedMicroG/releases/latest"; + + public static void checkAvailability() { + var context = ReVancedUtils.getContext(); + assert context != null; + try { + context.getPackageManager().getPackageInfo(MICROG_PACKAGE_NAME, PackageManager.GET_ACTIVITIES); + LogHelper.debug(ReVancedUtils.class, "MicroG is installed on the device"); + } catch (PackageManager.NameNotFoundException exception) { + LogHelper.printException(ReVancedUtils.class, "MicroG was not found", exception); + Toast.makeText(context, str("microg_not_installed_warning"), Toast.LENGTH_LONG).show(); + + var intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(VANCED_MICROG_DOWNLOAD_LINK)); + context.startActivity(intent); + } + } +}