From 5533f6ba86a4c8b51b20469e03cece12aef48e63 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 1 Jan 2016 22:09:36 +0100 Subject: [PATCH 01/11] use the standard "Movies" folder for downloads On all of the devices that I've checked, there is a folder called "Movies" on the SD Card by default. NewPipe should use that standard location since it is always downloading movies :). People can always change that via the preferences. Also, this makes the defaults the same when creating the dir and when setting the destination URL. --- .../java/org/schabi/newpipe/DownloadDialog.java | 14 ++++++-------- .../org/schabi/newpipe/SettingsActivity.java | 17 ----------------- .../schabi/newpipe/VideoItemListActivity.java | 3 ++- app/src/main/res/xml/settings_screen.xml | 5 ++--- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/DownloadDialog.java index 903251e58..a943ad423 100644 --- a/app/src/main/java/org/schabi/newpipe/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/DownloadDialog.java @@ -57,7 +57,7 @@ public class DownloadDialog extends DialogFragment { @Override public void onClick(DialogInterface dialog, int which) { Context context = getActivity(); - SharedPreferences defaultPreferences = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String suffix = ""; String title = arguments.getString(TITLE); String url = ""; @@ -73,10 +73,10 @@ public class DownloadDialog extends DialogFragment { default: Log.d(TAG, "lolz"); } - //to avoid hard-coded string like "/storage/emulated/0/NewPipe" - final File dir = new File(defaultPreferences.getString( - "download_path_preference", - Environment.getExternalStorageDirectory().getAbsolutePath() + "/NewPipe")); + //to avoid hard-coded string like "/storage/emulated/0/Movies" + String downloadPath = prefs.getString(getString(R.string.downloadPathPreference), + Environment.getExternalStorageDirectory().getAbsolutePath() + "/Movies"); + final File dir = new File(downloadPath); if(!dir.exists()) { boolean mkdir = dir.mkdir(); //attempt to create directory if(!mkdir && !dir.isDirectory()) { @@ -87,9 +87,7 @@ public class DownloadDialog extends DialogFragment { DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request( Uri.parse(url)); - request.setDestinationUri(Uri.fromFile(new File( - defaultPreferences.getString("download_path_preference", "/storage/emulated/0/NewPipe") - + "/" + title + suffix))); + request.setDestinationUri(Uri.fromFile(new File(dir + "/" + title + suffix))); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); try { dm.enqueue(request); diff --git a/app/src/main/java/org/schabi/newpipe/SettingsActivity.java b/app/src/main/java/org/schabi/newpipe/SettingsActivity.java index b434b53d8..c8a548ab6 100644 --- a/app/src/main/java/org/schabi/newpipe/SettingsActivity.java +++ b/app/src/main/java/org/schabi/newpipe/SettingsActivity.java @@ -1,13 +1,9 @@ package org.schabi.newpipe; -import android.content.Context; -import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; -import android.os.Environment; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; -import android.preference.PreferenceManager; import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.v7.app.ActionBar; @@ -148,17 +144,4 @@ public class SettingsActivity extends PreferenceActivity { } return true; } - - public static void initSettings(Context context) { - PreferenceManager.setDefaultValues(context, R.xml.settings_screen, false); - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - if(sp.getString(context.getString(R.string.downloadPathPreference), "").isEmpty()){ - SharedPreferences.Editor spEditor = sp.edit(); - String newPipeDownloadStorage = - Environment.getExternalStorageDirectory().getAbsolutePath() + "/NewPipe"; - spEditor.putString(context.getString(R.string.downloadPathPreference) - , newPipeDownloadStorage); - spEditor.apply(); - } - } } diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java index 6aaf10d41..d15709b23 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java @@ -3,6 +3,7 @@ package org.schabi.newpipe; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v4.app.NavUtils; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; @@ -171,7 +172,7 @@ public class VideoItemListActivity extends AppCompatActivity } } - SettingsActivity.initSettings(this); + PreferenceManager.setDefaultValues(this, R.xml.settings_screen, false); } /** diff --git a/app/src/main/res/xml/settings_screen.xml b/app/src/main/res/xml/settings_screen.xml index 98399f778..d4b21426f 100644 --- a/app/src/main/res/xml/settings_screen.xml +++ b/app/src/main/res/xml/settings_screen.xml @@ -64,8 +64,7 @@ android:key="@string/downloadPathPreference" android:title="@string/downloadLocation" android:summary="@string/downloadLocationSummary" - android:dialogTitle="@string/downloadLocationDialogTitle" - android:defaultValue=""/> + android:dialogTitle="@string/downloadLocationDialogTitle" /> - \ No newline at end of file + From b31490c4e34e7256bf270cb255ec2ffc51f5701a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 1 Jan 2016 22:23:00 +0100 Subject: [PATCH 02/11] make all strings translatable --- app/src/main/AndroidManifest.xml | 6 ++---- app/src/main/res/layout/paginate_footer.xml | 2 +- app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ae3f5f056..8f562698d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -74,12 +74,10 @@ android:parentActivityName=".VideoItemDetailActivity" tools:ignore="UnusedAttribute"> - - + android:label="@string/background_player_name" + android:exported="false" /> diff --git a/app/src/main/res/layout/paginate_footer.xml b/app/src/main/res/layout/paginate_footer.xml index 8e5d7571d..b3757c1af 100644 --- a/app/src/main/res/layout/paginate_footer.xml +++ b/app/src/main/res/layout/paginate_footer.xml @@ -8,7 +8,7 @@ NewPipe + NewPipe Background Player NewPipe %1$s views Uploaded on %1$s @@ -10,6 +11,7 @@ https://f-droid.org/repository/browse/?fdfilter=vlc&fdid=org.videolan.vlc Open in browser Share + Loading Download Search Settings From 4fe3cb2bca146aa35848a7530641b4273b73c107 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 1 Jan 2016 22:26:25 +0100 Subject: [PATCH 03/11] use symlinks to provide alternate folders for Hebrew and Indonesian These two languages must be included twice (iw/he and id/in) For a full discussion of why, see: https://gitlab.com/fdroid/fdroidclient/issues/139 https://stackoverflow.com/questions/5074769/cyanogenmod-translate-a-project/8470980#8470980 https://stackoverflow.com/questions/8393771/android-not-using-finding-my-hebrew-localization I included a blank placeholder file for Indonesian, it can be simply replaced by the real one, whenever that comes along. --- app/src/main/res/values-id | 1 + app/src/main/res/values-in/strings.xml | 3 +++ app/src/main/res/values-iw | 1 + 3 files changed, 5 insertions(+) create mode 120000 app/src/main/res/values-id create mode 100644 app/src/main/res/values-in/strings.xml create mode 120000 app/src/main/res/values-iw diff --git a/app/src/main/res/values-id b/app/src/main/res/values-id new file mode 120000 index 000000000..9ea8dda4b --- /dev/null +++ b/app/src/main/res/values-id @@ -0,0 +1 @@ +values-in \ No newline at end of file diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml new file mode 100644 index 000000000..9c5ad89af --- /dev/null +++ b/app/src/main/res/values-in/strings.xml @@ -0,0 +1,3 @@ + + + diff --git a/app/src/main/res/values-iw b/app/src/main/res/values-iw new file mode 120000 index 000000000..57bf91954 --- /dev/null +++ b/app/src/main/res/values-iw @@ -0,0 +1 @@ +values-he \ No newline at end of file From 3c1e64d8dc35e22b5327fbd1e2664c7826067c8c Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 1 Jan 2016 23:17:39 +0100 Subject: [PATCH 04/11] simplify youtube URL IntentFilters Each elements applies to the whole IntentFilter, so there is no need to declare the host, scheme, etc. multiple times within a single IntentFilter. Also, pathPrefix="/" will match all paths, so it is unnecessary. --- app/src/main/AndroidManifest.xml | 53 ++++++++++++-------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8f562698d..ab3ceaf9b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,43 +29,30 @@ + - + + - - - - - - - - + + + + + + + + + + + + + + + + + Date: Fri, 1 Jan 2016 23:29:50 +0100 Subject: [PATCH 05/11] support another youtube URL format: https://www.youtube.com/v/mS1gstS6YS8 https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/YouTubeLinks/YouTubeLinks.html --- app/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ab3ceaf9b..3cd85adec 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -41,6 +41,7 @@ + From 2a93e9bd2e15ca33ef11ea89e414c99604e676fc Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 1 Jan 2016 23:32:09 +0100 Subject: [PATCH 06/11] precisely target these URLs https://www.youtube.com/watch?v=mS1gstS6YS8 These URLs have a Path that always starts with "/watch" so no need for a pattern. Also, everything after the "?" is considered the "Query String", not the Path. Anything after a "#" is the "Feature String". The path matching in IntentFilters only see the Path, and nothing from the "Query String" or "Feature String". these are the available kinds of URLs: https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/YouTubeLinks/YouTubeLinks.html --- app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3cd85adec..861f773ff 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -42,7 +42,7 @@ - + From efe5de4c7526bbc50c79f09c5522f10bd8dc7502 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 1 Jan 2016 23:51:34 +0100 Subject: [PATCH 07/11] support youtube's custom URL schemes (vnd.youtube: and vnd.youtube.launch:) --- app/src/main/AndroidManifest.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 861f773ff..54894f679 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -55,6 +55,15 @@ + + + + + + + + + Date: Fri, 1 Jan 2016 23:52:22 +0100 Subject: [PATCH 08/11] youtube URLs can also come from media searches and NFC sends --- app/src/main/AndroidManifest.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 54894f679..d028886b1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,6 +32,8 @@ + + @@ -46,6 +48,8 @@ + + @@ -57,6 +61,8 @@ + + From d715eae0d1fc2893aed4a7c057a01d3a6409b08a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 2 Jan 2016 01:33:08 +0100 Subject: [PATCH 09/11] route video downloads to "Movies" and audio to "Music" use the standard Android folders when downloading files. --- app/src/main/java/org/schabi/newpipe/DownloadDialog.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/DownloadDialog.java index a943ad423..3001455f9 100644 --- a/app/src/main/java/org/schabi/newpipe/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/DownloadDialog.java @@ -61,21 +61,24 @@ public class DownloadDialog extends DialogFragment { String suffix = ""; String title = arguments.getString(TITLE); String url = ""; + String downloadFolder = "Download"; switch(which) { case 0: // Video suffix = arguments.getString(FILE_SUFFIX_VIDEO); url = arguments.getString(VIDEO_URL); + downloadFolder = "Movies"; break; case 1: suffix = arguments.getString(FILE_SUFFIX_AUDIO); url = arguments.getString(AUDIO_URL); + downloadFolder = "Music"; break; default: Log.d(TAG, "lolz"); } //to avoid hard-coded string like "/storage/emulated/0/Movies" String downloadPath = prefs.getString(getString(R.string.downloadPathPreference), - Environment.getExternalStorageDirectory().getAbsolutePath() + "/Movies"); + Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + downloadFolder); final File dir = new File(downloadPath); if(!dir.exists()) { boolean mkdir = dir.mkdir(); //attempt to create directory From 966ac0673c07c3fa6ef178f9f63f085890d8ac01 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 2 Jan 2016 01:29:31 +0100 Subject: [PATCH 10/11] gradle.properties is only commented out defaults, so remove from git For anyone who tweaks this file for local settings, it becomes painful to have it committed in git because those changes which are only relevant to the local setup will show up in git as changed. --- .gitignore | 1 + gradle.properties | 18 ------------------ 2 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 gradle.properties diff --git a/.gitignore b/.gitignore index 42caadb93..2b3c40d66 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /app/app.iml /.idea /*.iml +gradle.properties diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 1d3591c8a..000000000 --- a/gradle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html - -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m -# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file From 7cbb135f286727adf02e77b0114cdf541c1eda87 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 2 Jan 2016 11:59:28 +0100 Subject: [PATCH 11/11] include Tibetan as a language option The Tibetan alphabet was only recently included on Android, so the language name needs to also have the English there. Otherwise it'll appear blank on devices without Tibetan. --- app/src/main/res/values/settings_keys.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 8d33b8cbe..0ff359a46 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -71,6 +71,7 @@ sl fi sv + bo vi tr bg @@ -149,6 +150,7 @@ Slovenščina Suomi Svenska + Tibetan བོད་སྐད། Tiếng Việt Türkçe Български