diff --git a/README.md b/README.md index bf1317f174c..90bee9198cf 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +A mod for more automated downloads. For use with Youtube's "Share" button from a browser, essentially using NewPipe like a downloader "plugin" (a replacement for TubeMate, which is a freaking Adware, if not worse). +Introduces two new "Video and Audio" settings, one for treating all networks as metered, and another for automatically OK'ing the download dialog. +

We are planning to rewrite large chunks of the codebase, to bring about a new, modern and stable NewPipe!

Please do not open pull requests for new features now, only bugfix PRs will be accepted.

diff --git a/app/build.gradle b/app/build.gradle index 5a5a2be1b77..301e0bf6e95 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,7 +17,7 @@ android { defaultConfig { applicationId "org.schabi.newpipe" - resValue "string", "app_name", "NewPipe" + resValue "string", "app_name", "NewPipeAutoDL" minSdk 21 targetSdk 33 if (System.properties.containsKey('versionCodeOverride')) { @@ -49,19 +49,19 @@ android { if (normalizedWorkingBranch.isEmpty() || workingBranch == "master" || workingBranch == "dev") { // default values when branch name could not be determined or is master or dev applicationIdSuffix ".debug" - resValue "string", "app_name", "NewPipe Debug" + resValue "string", "app_name", "NewPipeAutoDLNewPipe Debug" } else { applicationIdSuffix ".debug." + normalizedWorkingBranch - resValue "string", "app_name", "NewPipe " + workingBranch - archivesBaseName = 'NewPipe_' + normalizedWorkingBranch + resValue "string", "app_name", "NewPipeAutoDL " + workingBranch + archivesBaseName = 'NewPipeAutoDL_' + normalizedWorkingBranch } } release { if (System.properties.containsKey('packageSuffix')) { applicationIdSuffix System.getProperty('packageSuffix') - resValue "string", "app_name", "NewPipe " + System.getProperty('packageSuffix') - archivesBaseName = 'NewPipe_' + System.getProperty('packageSuffix') + resValue "string", "app_name", "NewPipeAutoDL " + System.getProperty('packageSuffix') + archivesBaseName = 'NewPipeAutoDL_' + System.getProperty('packageSuffix') } minifyEnabled true shrinkResources false // disabled to fix F-Droid's reproducible build diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index 34a4ba022e2..468ae0cff2a 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -13,6 +13,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Environment; +import android.os.Handler; import android.os.IBinder; import android.provider.Settings; import android.util.Log; @@ -28,6 +29,7 @@ import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult; import androidx.annotation.IdRes; +import androidx.annotation.MainThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; @@ -110,6 +112,8 @@ public class DownloadDialog extends DialogFragment int selectedAudioIndex = 0; // default to the first item @State int selectedSubtitleIndex = 0; // default to the first item + @State + boolean okClicked = false; // guard private StoredDirectoryHelper mainStorageAudio = null; private StoredDirectoryHelper mainStorageVideo = null; @@ -350,13 +354,35 @@ private void initToolbar(final Toolbar toolbar) { toolbar.setOnMenuItemClickListener(item -> { if (item.getItemId() == R.id.okay) { - prepareSelectedDownload(); + if (!this.okClicked) { + this.okClicked = true; + prepareSelectedDownload(); + } return true; } return false; }); } + @MainThread + @Override + public void onStart() { + super.onStart(); + final boolean autoOkDownloadDialog = + PreferenceManager.getDefaultSharedPreferences(requireContext()).getBoolean( + context.getString(R.string.auto_ok_download_dialog_key), false); + if (autoOkDownloadDialog) { + final Handler timerHandler = new Handler(); + final Runnable timerRunnable = new Runnable() { + @Override + public void run() { + okButton.performClick(); + } + }; + timerHandler.postDelayed(timerRunnable, 500); + } + } + @Override public void onDestroy() { super.onDestroy(); diff --git a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java index 282a88b1eaf..79f6b0dc33b 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java @@ -707,9 +707,12 @@ static boolean isLimitingDataUsage(@NonNull final Context context) { */ private static String getResolutionLimit(@NonNull final Context context) { String resolutionLimit = null; - if (isMeteredNetwork(context)) { - final SharedPreferences preferences = - PreferenceManager.getDefaultSharedPreferences(context); + final SharedPreferences preferences = + PreferenceManager.getDefaultSharedPreferences(context); + final boolean treatAllNetworksAsMobileData = + preferences.getBoolean(context.getString(R.string.treat_all_networks_as_mobile_key), + false); + if (isMeteredNetwork(context) || treatAllNetworksAsMobileData) { final String defValue = context.getString(R.string.limit_data_usage_none_key); final String value = preferences.getString( context.getString(R.string.limit_mobile_data_usage_key), defValue); diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 61125c47f95..03c2eec80bb 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -120,6 +120,8 @@ default_resolution 720p60 show_higher_resolutions + treat_all_networks_as_mobile + auto_ok_download_dialog default_popup_resolution 480p best_resolution diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2232ddafff0..2ce54db022e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -46,6 +46,8 @@ Choose download folder for audio files Default resolution Default popup resolution + Treat all networks as mobile + Automatically OK download dialog Show higher resolutions Only some devices can play 2K/4K videos Play with Kodi diff --git a/app/src/main/res/xml/video_audio_settings.xml b/app/src/main/res/xml/video_audio_settings.xml index 727ce4df40a..a7c50188bb1 100644 --- a/app/src/main/res/xml/video_audio_settings.xml +++ b/app/src/main/res/xml/video_audio_settings.xml @@ -33,6 +33,20 @@ app:iconSpaceReserved="false" app:useSimpleSummaryProvider="true" /> + + + +