feat(youtube/microg-support): handle availability of Vanced MicroG

This commit is contained in:
oSumAtrIX 2022-10-29 03:03:04 +02:00
parent 6762ea4178
commit afa9d3cbb1
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -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);
}
}
}