forked from ReVanced/revanced-integrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(youtube/microg-support): handle availability of Vanced MicroG
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |