Merge pull request #134 from eighthave/intent-filters-and-other-fixes

Intent filters and other fixes
This commit is contained in:
Christian Schabesberger 2016-01-02 16:18:56 +01:00
commit 592eee7d3d
13 changed files with 62 additions and 85 deletions

1
.gitignore vendored
View file

@ -7,3 +7,4 @@
/app/app.iml /app/app.iml
/.idea /.idea
/*.iml /*.iml
gradle.properties

View file

@ -29,43 +29,46 @@
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".VideoItemListActivity" /> android:value=".VideoItemListActivity" />
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data <data android:scheme="http" />
android:host="youtube.com" <data android:scheme="https" />
android:scheme="http" <data android:host="youtube.com" />
android:pathPattern="/?*#*/*watch"/> <data android:host="m.youtube.com" />
<data <data android:host="www.youtube.com" />
android:host="youtube.com" <data android:pathPrefix="/v/" />
android:scheme="https" <data android:pathPrefix="/watch" />
android:pathPattern="/?*#*/*watch"/> </intent-filter>
<data <intent-filter>
android:host="www.youtube.com" <action android:name="android.intent.action.VIEW" />
android:scheme="http" <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
android:pathPattern="/?*#*/*watch"/> <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<data
android:host="www.youtube.com" <category android:name="android.intent.category.DEFAULT" />
android:scheme="https" <category android:name="android.intent.category.BROWSABLE" />
android:pathPattern="/?*#*/*watch"/>
<data <data android:scheme="http" />
android:host="m.youtube.com" <data android:scheme="https" />
android:scheme="http" <data android:host="youtu.be" />
android:pathPattern="/?*#*/*watch"/> <data android:pathPrefix="/" />
<data </intent-filter>
android:host="m.youtube.com" <intent-filter>
android:scheme="https" <action android:name="android.intent.action.VIEW" />
android:pathPattern="/?*#*/*watch"/> <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<data <action android:name="android.nfc.action.NDEF_DISCOVERED" />
android:host="youtu.be"
android:scheme="https" <category android:name="android.intent.category.DEFAULT" />
android:pathPrefix="/"/> <category android:name="android.intent.category.BROWSABLE" />
<data
android:host="youtu.be" <data android:scheme="vnd.youtube" />
android:scheme="http" <data android:scheme="vnd.youtube.launch" />
android:pathPrefix="/"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".PlayVideoActivity" <activity android:name=".PlayVideoActivity"
@ -74,12 +77,10 @@
android:parentActivityName=".VideoItemDetailActivity" android:parentActivityName=".VideoItemDetailActivity"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
</activity> </activity>
<!--TODO: make label a translatable string -->
<service <service
android:name=".BackgroundPlayer" android:name=".BackgroundPlayer"
android:label="NewPipe Background Player" android:label="@string/background_player_name"
android:exported="false" > android:exported="false" />
</service>
<activity <activity
android:name=".SettingsActivity" android:name=".SettingsActivity"
android:label="@string/title_activity_settings" > android:label="@string/title_activity_settings" >

View file

@ -57,26 +57,29 @@ public class DownloadDialog extends DialogFragment {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Context context = getActivity(); Context context = getActivity();
SharedPreferences defaultPreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String suffix = ""; String suffix = "";
String title = arguments.getString(TITLE); String title = arguments.getString(TITLE);
String url = ""; String url = "";
String downloadFolder = "Download";
switch(which) { switch(which) {
case 0: // Video case 0: // Video
suffix = arguments.getString(FILE_SUFFIX_VIDEO); suffix = arguments.getString(FILE_SUFFIX_VIDEO);
url = arguments.getString(VIDEO_URL); url = arguments.getString(VIDEO_URL);
downloadFolder = "Movies";
break; break;
case 1: case 1:
suffix = arguments.getString(FILE_SUFFIX_AUDIO); suffix = arguments.getString(FILE_SUFFIX_AUDIO);
url = arguments.getString(AUDIO_URL); url = arguments.getString(AUDIO_URL);
downloadFolder = "Music";
break; break;
default: default:
Log.d(TAG, "lolz"); Log.d(TAG, "lolz");
} }
//to avoid hard-coded string like "/storage/emulated/0/NewPipe" //to avoid hard-coded string like "/storage/emulated/0/Movies"
final File dir = new File(defaultPreferences.getString( String downloadPath = prefs.getString(getString(R.string.downloadPathPreference),
"download_path_preference", Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + downloadFolder);
Environment.getExternalStorageDirectory().getAbsolutePath() + "/NewPipe")); final File dir = new File(downloadPath);
if(!dir.exists()) { if(!dir.exists()) {
boolean mkdir = dir.mkdir(); //attempt to create directory boolean mkdir = dir.mkdir(); //attempt to create directory
if(!mkdir && !dir.isDirectory()) { if(!mkdir && !dir.isDirectory()) {
@ -87,9 +90,7 @@ public class DownloadDialog extends DialogFragment {
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request( DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(url)); Uri.parse(url));
request.setDestinationUri(Uri.fromFile(new File( request.setDestinationUri(Uri.fromFile(new File(dir + "/" + title + suffix)));
defaultPreferences.getString("download_path_preference", "/storage/emulated/0/NewPipe")
+ "/" + title + suffix)));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
try { try {
dm.enqueue(request); dm.enqueue(request);

View file

@ -1,13 +1,9 @@
package org.schabi.newpipe; package org.schabi.newpipe;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
@ -148,17 +144,4 @@ public class SettingsActivity extends PreferenceActivity {
} }
return true; 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();
}
}
} }

View file

@ -3,6 +3,7 @@ package org.schabi.newpipe;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.NavUtils; import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView; 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);
} }
/** /**

View file

@ -8,7 +8,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Loading" android:text="@string/loading"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<ProgressBar <ProgressBar

1
app/src/main/res/values-id Symbolic link
View file

@ -0,0 +1 @@
values-in

View file

@ -0,0 +1,3 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
</resources>

1
app/src/main/res/values-iw Symbolic link
View file

@ -0,0 +1 @@
values-he

View file

@ -71,6 +71,7 @@
<item>sl</item> <item>sl</item>
<item>fi</item> <item>fi</item>
<item>sv</item> <item>sv</item>
<item>bo</item>
<item>vi</item> <item>vi</item>
<item>tr</item> <item>tr</item>
<item>bg</item> <item>bg</item>
@ -149,6 +150,7 @@
<item>Slovenščina</item> <item>Slovenščina</item>
<item>Suomi</item> <item>Suomi</item>
<item>Svenska</item> <item>Svenska</item>
<item>Tibetan བོད་སྐད།</item>
<item>Tiếng Việt</item> <item>Tiếng Việt</item>
<item>Türkçe</item> <item>Türkçe</item>
<item>Български</item> <item>Български</item>

View file

@ -1,6 +1,7 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<resources> <resources>
<string name="app_name" translatable="false">NewPipe</string> <string name="app_name" translatable="false">NewPipe</string>
<string name="background_player_name">NewPipe Background Player</string>
<string name="title_videoitem_detail" translatable="false">NewPipe</string> <string name="title_videoitem_detail" translatable="false">NewPipe</string>
<string name="viewCountText">%1$s views</string> <string name="viewCountText">%1$s views</string>
<string name="uploadDateText">Uploaded on %1$s</string> <string name="uploadDateText">Uploaded on %1$s</string>
@ -10,6 +11,7 @@
<string name="fdroidVLCurl" translatable="false">https://f-droid.org/repository/browse/?fdfilter=vlc&amp;fdid=org.videolan.vlc</string> <string name="fdroidVLCurl" translatable="false">https://f-droid.org/repository/browse/?fdfilter=vlc&amp;fdid=org.videolan.vlc</string>
<string name="open_in_browser">Open in browser</string> <string name="open_in_browser">Open in browser</string>
<string name="share">Share</string> <string name="share">Share</string>
<string name="loading">Loading</string>
<string name="download">Download</string> <string name="download">Download</string>
<string name="search">Search</string> <string name="search">Search</string>
<string name="settings">Settings</string> <string name="settings">Settings</string>

View file

@ -64,8 +64,7 @@
android:key="@string/downloadPathPreference" android:key="@string/downloadPathPreference"
android:title="@string/downloadLocation" android:title="@string/downloadLocation"
android:summary="@string/downloadLocationSummary" android:summary="@string/downloadLocationSummary"
android:dialogTitle="@string/downloadLocationDialogTitle" android:dialogTitle="@string/downloadLocationDialogTitle" />
android:defaultValue=""/>
<CheckBoxPreference <CheckBoxPreference
android:key="@string/autoPlayThroughIntent" android:key="@string/autoPlayThroughIntent"

View file

@ -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