From 8b092280e1718b1a286ddcd9a3575505fdef5d04 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 22 Aug 2022 19:14:48 +0200 Subject: [PATCH] feat: setting for downloader package name --- .../integrations/settings/SettingsEnum.java | 3 ++- .../integrations/videoplayer/DownloadButton.java | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index fa872883..0be5e8fd 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -14,7 +14,8 @@ import app.revanced.integrations.utils.SharedPrefHelper; public enum SettingsEnum { //Download Settings // TODO: DOWNLOAD_PATH("revanced_download_path", Environment.getExternalStorageDirectory().getPath() + "/Download", ReturnType.STRING), - DOWNLOAD_BUTTON_SHOWN("revanced_downloads", true, ReturnType.BOOLEAN), + DOWNLOADS_BUTTON_SHOWN("revanced_downloads", true, ReturnType.BOOLEAN), + DOWNLOADS_PACKAGE_NAME("revanced_downloads_package_name", "org.schabi.newpipe" /* NewPipe */, ReturnType.STRING), //Video Settings OLD_STYLE_QUALITY_SETTINGS("revanced_use_old_style_quality_settings", true, ReturnType.BOOLEAN), diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/DownloadButton.java b/app/src/main/java/app/revanced/integrations/videoplayer/DownloadButton.java index e77f402f..b1ed0b4b 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/DownloadButton.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/DownloadButton.java @@ -1,6 +1,5 @@ package app.revanced.integrations.videoplayer; -import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -48,20 +47,19 @@ public class DownloadButton { LogHelper.debug(DownloadButton.class, "Download button clicked"); final var context = view.getContext(); - final var powerTubePackageName = "ussr.razar.youtube_dl"; + var downloaderPackageName = SettingsEnum.DOWNLOADS_PACKAGE_NAME.getString(); boolean packageEnabled = false; try { assert context != null; - packageEnabled = context.getPackageManager().getApplicationInfo(powerTubePackageName, 0).enabled; + packageEnabled = context.getPackageManager().getApplicationInfo(downloaderPackageName, 0).enabled; } catch (PackageManager.NameNotFoundException error) { - LogHelper.debug(DownloadButton.class, "PowerTube could not be found: " + error); + LogHelper.debug(DownloadButton.class, "Downloader could not be found: " + error); } // If the package is not installed, show the toast if (!packageEnabled) { - Toast.makeText(context, StringRef.str("powertube_not_installed_warning"), Toast.LENGTH_SHORT).show(); - Toast.makeText(context, StringRef.str("powertube_not_installed_notice"), Toast.LENGTH_LONG).show(); + Toast.makeText(context, downloaderPackageName + " " + StringRef.str("downloader_not_installed_warning"), Toast.LENGTH_LONG).show(); return; } @@ -71,7 +69,7 @@ public class DownloadButton { Intent intent = new Intent("android.intent.action.SEND"); intent.setType("text/plain"); - intent.setPackage(powerTubePackageName); + intent.setPackage(downloaderPackageName); intent.putExtra("android.intent.extra.TEXT", content); context.startActivity(intent); @@ -129,7 +127,7 @@ public class DownloadButton { } private static boolean shouldBeShown() { - if (!SettingsEnum.DOWNLOAD_BUTTON_SHOWN.getBoolean()) { + if (!SettingsEnum.DOWNLOADS_BUTTON_SHOWN.getBoolean()) { return false; }