Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Weblate 2018-01-19 00:17:53 +01:00
commit 43372ff648
37 changed files with 1059 additions and 325 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@
gradle.properties gradle.properties
*~ *~
.weblate .weblate
*.class

170
CheckTranslations.java Normal file
View File

@ -0,0 +1,170 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.*;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.nio.file.Files;
import java.nio.charset.Charset;
public final class CheckTranslations {
private static boolean debug = false;
private static boolean plurals = false;
private static boolean empty = false;
private static boolean remove = false;
private static int checks = 0;
private static int matches = 0;
private static int changes = 0;
private static Pattern p, pb, pe, e, o;
/**
* Search translated strings.xml files for empty item / plural tags
* and remove them.
* @param args directories which contain string.xml files (in any subdirectory)
* -e option to find all empty string tags
* -p option to find all empty plurals and item tags
* -r option to remove all occurrences from the files
* -d option to see more details
*/
public static void main(String[] args) {
if (args.length < 1 || (args[0].equals("-d") && args.length < 2)) {
System.out.println("Not enough arguments");
return;
}
for (int i = 0; i < args.length; i++) {
switch (args[i]) {
case "-d":
debug = true;
break;
case "-p":
plurals = true;
break;
case "-e":
empty = true;
break;
case "-r":
remove = true;
break;
}
}
if (!plurals && !empty) {
plurals = true;
empty = true;
}
p = Pattern.compile("(<item quantity=\")(zero|one|two|three|few|many|other)(\"></item>|\"/>)");
pb = Pattern.compile("(<plurals[\\sa-zA-Z=\"]*>)");
pe = Pattern.compile("(</plurals>)");
e = Pattern.compile("(<string[\\sa-z_\\\"=]*)((><\\/string>|\\/>){1})");
o = Pattern.compile("(<item quantity=\"other\">)[^</>]*(<\\/item>)");
for (int i = 0; i < args.length; i++) {
if (!args[i].equals("-d") && !args[i].equals("-p") && !args[i].equals("-e") && !args[i].equals("-r")) {
File f = new File(args[i]);
if (f.exists() && !f.isDirectory()) {
checkFile(f);
} else if (f.isDirectory()) {
checkFiles(f.listFiles());
} else {
System.out.println("'" + args[i] + "' does not exist!");
}
}
}
System.out.println(checks + " files were checked.");
System.out.println(matches + " corrupt lines detected.");
if (remove) {
System.out.println(matches + " corrupt lines removed and " + changes + " lines fixed.");
}
}
private static void checkFiles(File[] f) {
for (int i = 0; i < f.length; i++) {
if (f[i].exists() && !f[i].isDirectory()) {
if (f[i].toString().contains("strings.xml")) {
checkFile(f[i]);
}
} else if (f[i].isDirectory()) {
checkFiles(f[i].listFiles());
}
}
}
private static void checkFile(File f) {
// Do not check our original English strings to cause no unwanted changes
// Btw. there should not be empty plural/item tags
if (f.toString().contains("values/strings.xml")) {
return;
}
if (debug) System.out.println("Checking " + f.toString());
checks++;
List<String> lines = new ArrayList<String>();
boolean checkFailed = false;
boolean otherDetected = false;
boolean inPlurals = false;
try (BufferedReader br = new BufferedReader(new FileReader(f))) {
String line;
int ln = 0;
while ((line = br.readLine()) != null) {
ln++;
if (plurals && p.matcher(line).find()) {
matches++;
if (debug) System.out.println(" Line " + ln + " was " + ((remove) ? "removed" : "detected") + ": '" + line + "'");
checkFailed = true;
} else if (empty && e.matcher(line).find()) {
matches++;
checkFailed = true;
if (debug) System.out.println(" Line " + ln + " was " + ((remove) ? "removed" : "detected") + ": '" + line + "'");
} else {
if (remove) lines.add(line);
}
}
br.close();
int pluralsLine = 0;
for (int i = 0; i < lines.size(); i++) {
if (o.matcher(lines.get(i)).find()) {
otherDetected = true;
}
if (plurals && pb.matcher(lines.get(i)).find()) {
inPlurals = true;
pluralsLine = i;
} else if (plurals && pe.matcher(lines.get(i)).find()) {
inPlurals = false;
if (!otherDetected) {
boolean b = false;
check: for(int j = pluralsLine; j < i; j++) {
if (lines.get(j).contains("many")) {
b = true;
pluralsLine = j;
break check;
}
}
if (remove && b) {
if (debug) System.out.println(" Line " + (pluralsLine + 1) + " was " + ((remove) ? "changed" : "detected") + ": '" + lines.get(pluralsLine) + "'");
lines.set(pluralsLine, lines.get(pluralsLine).replace("many", "other"));
changes++;
checkFailed = true;
} else if (debug) {
if (debug) System.out.println(" WARNING: Line " + (i + 1) + " - No <item quantity=\"other\"> found!");
}
}
otherDetected = false;
}
}
if (remove && checkFailed) {
Files.write(f.toPath(), lines, Charset.forName("UTF-8"));
}
} catch (IOException e) {
System.out.println(e);
}
}
}

View File

@ -8,8 +8,8 @@ android {
applicationId "org.schabi.newpipe" applicationId "org.schabi.newpipe"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 27 targetSdkVersion 27
versionCode 43 versionCode 45
versionName "0.11.2" versionName "0.11.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
@ -42,8 +42,8 @@ android {
abortOnError false abortOnError false
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_8
} }
} }
@ -55,7 +55,7 @@ dependencies {
exclude module: 'support-annotations' exclude module: 'support-annotations'
} }
implementation 'com.github.TeamNewPipe:NewPipeExtractor:044b8fe32f47e28' implementation 'com.github.TeamNewPipe:NewPipeExtractor:9de63f8c0a170a066'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19' testImplementation 'org.mockito:mockito-core:1.10.19'

View File

@ -18,9 +18,8 @@ public class RouterPopupActivity extends RouterActivity {
@Override @Override
protected void handleUrl(String url) { protected void handleUrl(String url) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M if (!PermissionHelper.isPopupEnabled(this)) {
&& !PermissionHelper.checkSystemAlertWindowPermission(this)) { PermissionHelper.showPopupEnablementToast(this);
Toast.makeText(this, R.string.msg_popup_permission, Toast.LENGTH_LONG).show();
finish(); finish();
return; return;
} }

View File

@ -1,6 +1,7 @@
package org.schabi.newpipe.fragments; package org.schabi.newpipe.fragments;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
@ -18,6 +19,7 @@ import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.ReCaptchaActivity; import org.schabi.newpipe.ReCaptchaActivity;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.ExtractorHelper;
@ -240,4 +242,22 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
ErrorActivity.reportError(getContext(), exception, MainActivity.class, rootView, ErrorActivity.ErrorInfo.make(userAction, serviceName, request, errorId)); ErrorActivity.reportError(getContext(), exception, MainActivity.class, rootView, ErrorActivity.ErrorInfo.make(userAction, serviceName, request, errorId));
} }
/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
protected void openUrlInBrowser(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(Intent.createChooser(intent, activity.getString(R.string.share_dialog_title)));
}
protected void shareUrl(String subject, String url) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, url);
startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title)));
}
} }

View File

@ -505,7 +505,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item)); NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
break; break;
case 1: case 1:
NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(item)); NavigationHelper.enqueueOnPopupPlayer(getActivity(), new SinglePlayQueue(item));
break; break;
default: default:
break; break;
@ -623,24 +623,12 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
if (DEBUG) Log.d(TAG, "setupActionBarHandler() called with: info = [" + info + "]"); if (DEBUG) Log.d(TAG, "setupActionBarHandler() called with: info = [" + info + "]");
sortedStreamVideosList = new ArrayList<>(ListHelper.getSortedStreamVideosList(activity, info.getVideoStreams(), info.getVideoOnlyStreams(), false)); sortedStreamVideosList = new ArrayList<>(ListHelper.getSortedStreamVideosList(activity, info.getVideoStreams(), info.getVideoOnlyStreams(), false));
actionBarHandler.setupStreamList(sortedStreamVideosList, spinnerToolbar); actionBarHandler.setupStreamList(sortedStreamVideosList, spinnerToolbar);
actionBarHandler.setOnShareListener(new ActionBarHandler.OnActionListener() { actionBarHandler.setOnShareListener(selectedStreamId -> shareUrl(info.name, info.url));
@Override
public void onActionSelected(int selectedStreamId) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, info.getUrl());
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, activity.getString(R.string.share_dialog_title)));
}
});
actionBarHandler.setOnOpenInBrowserListener(new ActionBarHandler.OnActionListener() { actionBarHandler.setOnOpenInBrowserListener(new ActionBarHandler.OnActionListener() {
@Override @Override
public void onActionSelected(int selectedStreamId) { public void onActionSelected(int selectedStreamId) {
Intent intent = new Intent(); openUrlInBrowser(info.getUrl());
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(info.getUrl()));
startActivity(Intent.createChooser(intent, activity.getString(R.string.choose_browser)));
} }
}); });
@ -820,11 +808,8 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
} }
private void openPopupPlayer(final boolean append) { private void openPopupPlayer(final boolean append) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !PermissionHelper.checkSystemAlertWindowPermission(activity)) { if (!PermissionHelper.isPopupEnabled(activity)) {
Toast toast = Toast.makeText(activity, R.string.msg_popup_permission, Toast.LENGTH_LONG); PermissionHelper.showPopupEnablementToast(activity);
TextView messageView = toast.getView().findViewById(android.R.id.message);
if (messageView != null) messageView.setGravity(Gravity.CENTER);
toast.show();
return; return;
} }

View File

@ -1,16 +1,21 @@
package org.schabi.newpipe.fragments.list; package org.schabi.newpipe.fragments.list;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log; import android.util.Log;
import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.View; import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
@ -24,6 +29,7 @@ import org.schabi.newpipe.info_list.InfoItemDialog;
import org.schabi.newpipe.info_list.InfoListAdapter; import org.schabi.newpipe.info_list.InfoListAdapter;
import org.schabi.newpipe.playlist.SinglePlayQueue; import org.schabi.newpipe.playlist.SinglePlayQueue;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.StateSaver; import org.schabi.newpipe.util.StateSaver;
import java.util.List; import java.util.List;
@ -192,6 +198,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
protected void showStreamDialog(final StreamInfoItem item) { protected void showStreamDialog(final StreamInfoItem item) {
final Context context = getContext(); final Context context = getContext();
final Activity activity = getActivity();
if (context == null || context.getResources() == null || getActivity() == null) return; if (context == null || context.getResources() == null || getActivity() == null) return;
final String[] commands = new String[]{ final String[] commands = new String[]{
@ -207,7 +214,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item)); NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
break; break;
case 1: case 1:
NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(item)); NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
break; break;
default: default:
break; break;

View File

@ -1,10 +1,10 @@
package org.schabi.newpipe.fragments.list.channel; package org.schabi.newpipe.fragments.list.channel;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -12,7 +12,6 @@ import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -23,7 +22,6 @@ import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.jakewharton.rxbinding2.view.RxView; import com.jakewharton.rxbinding2.view.RxView;
@ -153,6 +151,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
@Override @Override
protected void showStreamDialog(final StreamInfoItem item) { protected void showStreamDialog(final StreamInfoItem item) {
final Activity activity = getActivity();
final Context context = getContext(); final Context context = getContext();
if (context == null || context.getResources() == null || getActivity() == null) return; if (context == null || context.getResources() == null || getActivity() == null) return;
@ -173,7 +172,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item)); NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
break; break;
case 1: case 1:
NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(item)); NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
break; break;
case 2: case 2:
NavigationHelper.playOnMainPlayer(context, getPlayQueue(index)); NavigationHelper.playOnMainPlayer(context, getPlayQueue(index));
@ -182,7 +181,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index)); NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
break; break;
case 4: case 4:
NavigationHelper.playOnPopupPlayer(context, getPlayQueue(index)); NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
break; break;
default: default:
break; break;
@ -222,18 +221,6 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
} }
} }
private void openChannelUriInBrowser() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}
private void shareChannelUri() {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, url);
startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title)));
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
@ -241,10 +228,10 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
openRssFeed(); openRssFeed();
break; break;
case R.id.menu_item_openInBrowser: case R.id.menu_item_openInBrowser:
openChannelUriInBrowser(); openUrlInBrowser(url);
break; break;
case R.id.menu_item_share: { case R.id.menu_item_share: {
shareChannelUri(); shareUrl(name, url);
break; break;
} }
default: default:
@ -466,13 +453,6 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
headerPopupButton.setOnClickListener(new View.OnClickListener() { headerPopupButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !PermissionHelper.checkSystemAlertWindowPermission(activity)) {
Toast toast = Toast.makeText(activity, R.string.msg_popup_permission, Toast.LENGTH_LONG);
TextView messageView = toast.getView().findViewById(android.R.id.message);
if (messageView != null) messageView.setGravity(Gravity.CENTER);
toast.show();
return;
}
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue()); NavigationHelper.playOnPopupPlayer(activity, getPlayQueue());
} }
}); });

View File

@ -58,14 +58,10 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
@State @State
protected String kioskId = ""; protected String kioskId = "";
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Views // Views
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
private View headerRootLayout;
private TextView headerTitleView;
public static KioskFragment getInstance(int serviceId) public static KioskFragment getInstance(int serviceId)
throws ExtractionException { throws ExtractionException {
return getInstance(serviceId, NewPipe.getService(serviceId) return getInstance(serviceId, NewPipe.getService(serviceId)
@ -147,8 +143,8 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
public Single<KioskInfo> loadResult(boolean forceReload) { public Single<KioskInfo> loadResult(boolean forceReload) {
String contentCountry = PreferenceManager String contentCountry = PreferenceManager
.getDefaultSharedPreferences(activity) .getDefaultSharedPreferences(activity)
.getString(getString(R.string.search_language_key), .getString(getString(R.string.content_country_key),
getString(R.string.default_language_value)); getString(R.string.default_country_value));
return ExtractorHelper.getKioskInfo(serviceId, url, contentCountry, forceReload); return ExtractorHelper.getKioskInfo(serviceId, url, contentCountry, forceReload);
} }
@ -156,8 +152,8 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
public Single<ListExtractor.NextItemsResult> loadMoreItemsLogic() { public Single<ListExtractor.NextItemsResult> loadMoreItemsLogic() {
String contentCountry = PreferenceManager String contentCountry = PreferenceManager
.getDefaultSharedPreferences(activity) .getDefaultSharedPreferences(activity)
.getString(getString(R.string.search_language_key), .getString(getString(R.string.content_country_key),
getString(R.string.default_language_value)); getString(R.string.default_country_value));
return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextItemsUrl, contentCountry); return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextItemsUrl, contentCountry);
} }

View File

@ -1,22 +1,21 @@
package org.schabi.newpipe.fragments.list.playlist; package org.schabi.newpipe.fragments.list.playlist;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListExtractor;
@ -32,7 +31,6 @@ import org.schabi.newpipe.playlist.SinglePlayQueue;
import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.ExtractorHelper;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper;
import io.reactivex.Single; import io.reactivex.Single;
@ -98,16 +96,10 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
infoListAdapter.useMiniItemVariants(true); infoListAdapter.useMiniItemVariants(true);
} }
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (DEBUG) Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu + "], inflater = [" + inflater + "]");
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_playlist, menu);
}
@Override @Override
protected void showStreamDialog(final StreamInfoItem item) { protected void showStreamDialog(final StreamInfoItem item) {
final Context context = getContext(); final Context context = getContext();
final Activity activity = getActivity();
if (context == null || context.getResources() == null || getActivity() == null) return; if (context == null || context.getResources() == null || getActivity() == null) return;
final String[] commands = new String[]{ final String[] commands = new String[]{
@ -127,7 +119,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item)); NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
break; break;
case 1: case 1:
NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(item)); NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
break; break;
case 2: case 2:
NavigationHelper.playOnMainPlayer(context, getPlayQueue(index)); NavigationHelper.playOnMainPlayer(context, getPlayQueue(index));
@ -136,7 +128,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index)); NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
break; break;
case 4: case 4:
NavigationHelper.playOnPopupPlayer(context, getPlayQueue(index)); NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
break; break;
default: default:
break; break;
@ -146,6 +138,14 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
new InfoItemDialog(getActivity(), item, commands, actions).show(); new InfoItemDialog(getActivity(), item, commands, actions).show();
} }
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (DEBUG) Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu + "], inflater = [" + inflater + "]");
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_playlist, menu);
}
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Load and handle // Load and handle
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@ -160,6 +160,23 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
return ExtractorHelper.getPlaylistInfo(serviceId, url, forceLoad); return ExtractorHelper.getPlaylistInfo(serviceId, url, forceLoad);
} }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_item_openInBrowser:
openUrlInBrowser(url);
break;
case R.id.menu_item_share: {
shareUrl(name, url);
break;
}
default:
return super.onOptionsItemSelected(item);
}
return true;
}
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Contract // Contract
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@ -211,13 +228,6 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
headerPopupButton.setOnClickListener(new View.OnClickListener() { headerPopupButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !PermissionHelper.checkSystemAlertWindowPermission(activity)) {
Toast toast = Toast.makeText(activity, R.string.msg_popup_permission, Toast.LENGTH_LONG);
TextView messageView = toast.getView().findViewById(android.R.id.message);
if (messageView != null) messageView.setGravity(Gravity.CENTER);
toast.show();
return;
}
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue()); NavigationHelper.playOnPopupPlayer(activity, getPlayQueue());
} }
}); });

View File

@ -111,7 +111,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
private int currentPage = 0; private int currentPage = 0;
private int currentNextPage = 0; private int currentNextPage = 0;
private String searchLanguage; private String contentCountry;
private boolean isSuggestionsEnabled = true; private boolean isSuggestionsEnabled = true;
private boolean isSearchHistoryEnabled = true; private boolean isSearchHistoryEnabled = true;
@ -176,7 +176,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
isSuggestionsEnabled = preferences.getBoolean(getString(R.string.show_search_suggestions_key), true); isSuggestionsEnabled = preferences.getBoolean(getString(R.string.show_search_suggestions_key), true);
searchLanguage = preferences.getString(getString(R.string.search_language_key), getString(R.string.default_language_value)); contentCountry = preferences.getString(getString(R.string.content_country_key), getString(R.string.default_country_value));
} }
@Override @Override
@ -619,7 +619,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
return local.materialize(); return local.materialize();
} }
final Observable<List<SuggestionItem>> network = ExtractorHelper.suggestionsFor(serviceId, query, searchLanguage).toObservable() final Observable<List<SuggestionItem>> network = ExtractorHelper.suggestionsFor(serviceId, query, contentCountry).toObservable()
.map(new Function<List<String>, List<SuggestionItem>>() { .map(new Function<List<String>, List<SuggestionItem>>() {
@Override @Override
public List<SuggestionItem> apply(@io.reactivex.annotations.NonNull List<String> strings) throws Exception { public List<SuggestionItem> apply(@io.reactivex.annotations.NonNull List<String> strings) throws Exception {
@ -731,7 +731,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
super.startLoading(forceLoad); super.startLoading(forceLoad);
if (disposables != null) disposables.clear(); if (disposables != null) disposables.clear();
if (searchDisposable != null) searchDisposable.dispose(); if (searchDisposable != null) searchDisposable.dispose();
searchDisposable = ExtractorHelper.searchFor(serviceId, searchQuery, currentPage, searchLanguage, filter) searchDisposable = ExtractorHelper.searchFor(serviceId, searchQuery, currentPage, contentCountry, filter)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<SearchResult>() { .subscribe(new Consumer<SearchResult>() {
@ -755,7 +755,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
showListFooter(true); showListFooter(true);
if (searchDisposable != null) searchDisposable.dispose(); if (searchDisposable != null) searchDisposable.dispose();
currentNextPage = currentPage + 1; currentNextPage = currentPage + 1;
searchDisposable = ExtractorHelper.getMoreSearchItems(serviceId, searchQuery, currentNextPage, searchLanguage, filter) searchDisposable = ExtractorHelper.getMoreSearchItems(serviceId, searchQuery, currentNextPage, contentCountry, filter)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ListExtractor.NextItemsResult>() { .subscribe(new Consumer<ListExtractor.NextItemsResult>() {

View File

@ -65,7 +65,6 @@ public final class BackgroundPlayer extends Service {
public static final String ACTION_CLOSE = "org.schabi.newpipe.player.BackgroundPlayer.CLOSE"; public static final String ACTION_CLOSE = "org.schabi.newpipe.player.BackgroundPlayer.CLOSE";
public static final String ACTION_PLAY_PAUSE = "org.schabi.newpipe.player.BackgroundPlayer.PLAY_PAUSE"; public static final String ACTION_PLAY_PAUSE = "org.schabi.newpipe.player.BackgroundPlayer.PLAY_PAUSE";
public static final String ACTION_OPEN_CONTROLS = "org.schabi.newpipe.player.BackgroundPlayer.OPEN_CONTROLS";
public static final String ACTION_REPEAT = "org.schabi.newpipe.player.BackgroundPlayer.REPEAT"; public static final String ACTION_REPEAT = "org.schabi.newpipe.player.BackgroundPlayer.REPEAT";
public static final String ACTION_PLAY_NEXT = "org.schabi.newpipe.player.BackgroundPlayer.ACTION_PLAY_NEXT"; public static final String ACTION_PLAY_NEXT = "org.schabi.newpipe.player.BackgroundPlayer.ACTION_PLAY_NEXT";
public static final String ACTION_PLAY_PREVIOUS = "org.schabi.newpipe.player.BackgroundPlayer.ACTION_PLAY_PREVIOUS"; public static final String ACTION_PLAY_PREVIOUS = "org.schabi.newpipe.player.BackgroundPlayer.ACTION_PLAY_PREVIOUS";
@ -195,11 +194,14 @@ public final class BackgroundPlayer extends Service {
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT));
remoteViews.setOnClickPendingIntent(R.id.notificationStop, remoteViews.setOnClickPendingIntent(R.id.notificationStop,
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_CLOSE), PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_CLOSE), PendingIntent.FLAG_UPDATE_CURRENT));
remoteViews.setOnClickPendingIntent(R.id.notificationContent,
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_OPEN_CONTROLS), PendingIntent.FLAG_UPDATE_CURRENT));
remoteViews.setOnClickPendingIntent(R.id.notificationRepeat, remoteViews.setOnClickPendingIntent(R.id.notificationRepeat,
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_REPEAT), PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_REPEAT), PendingIntent.FLAG_UPDATE_CURRENT));
// Starts background player activity -- attempts to unlock lockscreen
final Intent intent = NavigationHelper.getBackgroundPlayerActivityIntent(this);
remoteViews.setOnClickPendingIntent(R.id.notificationContent,
PendingIntent.getActivity(this, NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT));
if (basePlayerImpl.playQueue != null && basePlayerImpl.playQueue.size() > 1) { if (basePlayerImpl.playQueue != null && basePlayerImpl.playQueue.size() > 1) {
remoteViews.setInt(R.id.notificationFRewind, SET_IMAGE_RESOURCE_METHOD, R.drawable.exo_controls_previous); remoteViews.setInt(R.id.notificationFRewind, SET_IMAGE_RESOURCE_METHOD, R.drawable.exo_controls_previous);
remoteViews.setInt(R.id.notificationFForward, SET_IMAGE_RESOURCE_METHOD, R.drawable.exo_controls_next); remoteViews.setInt(R.id.notificationFForward, SET_IMAGE_RESOURCE_METHOD, R.drawable.exo_controls_next);
@ -393,7 +395,7 @@ public final class BackgroundPlayer extends Service {
if (index < 0 || index >= info.audio_streams.size()) return null; if (index < 0 || index >= info.audio_streams.size()) return null;
final AudioStream audio = info.audio_streams.get(index); final AudioStream audio = info.audio_streams.get(index);
return buildMediaSource(audio.getUrl(), MediaFormat.getSuffixById(audio.format)); return buildMediaSource(audio.getUrl(), MediaFormat.getSuffixById(audio.getFormatId()));
} }
@Override @Override
@ -453,7 +455,6 @@ public final class BackgroundPlayer extends Service {
super.setupBroadcastReceiver(intentFilter); super.setupBroadcastReceiver(intentFilter);
intentFilter.addAction(ACTION_CLOSE); intentFilter.addAction(ACTION_CLOSE);
intentFilter.addAction(ACTION_PLAY_PAUSE); intentFilter.addAction(ACTION_PLAY_PAUSE);
intentFilter.addAction(ACTION_OPEN_CONTROLS);
intentFilter.addAction(ACTION_REPEAT); intentFilter.addAction(ACTION_REPEAT);
intentFilter.addAction(ACTION_PLAY_PREVIOUS); intentFilter.addAction(ACTION_PLAY_PREVIOUS);
intentFilter.addAction(ACTION_PLAY_NEXT); intentFilter.addAction(ACTION_PLAY_NEXT);
@ -478,9 +479,6 @@ public final class BackgroundPlayer extends Service {
case ACTION_PLAY_PAUSE: case ACTION_PLAY_PAUSE:
onVideoPlayPause(); onVideoPlayPause();
break; break;
case ACTION_OPEN_CONTROLS:
NavigationHelper.openBackgroundPlayerControl(getApplicationContext());
break;
case ACTION_REPEAT: case ACTION_REPEAT:
onRepeatClicked(); onRepeatClicked();
break; break;

View File

@ -1,9 +1,12 @@
package org.schabi.newpipe.player; package org.schabi.newpipe.player;
import android.content.Intent; import android.content.Intent;
import android.view.MenuItem;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import static org.schabi.newpipe.player.BackgroundPlayer.ACTION_CLOSE;
public final class BackgroundPlayerActivity extends ServicePlayerActivity { public final class BackgroundPlayerActivity extends ServicePlayerActivity {
private static final String TAG = "BackgroundPlayerActivity"; private static final String TAG = "BackgroundPlayerActivity";
@ -36,4 +39,25 @@ public final class BackgroundPlayerActivity extends ServicePlayerActivity {
((BackgroundPlayer.BasePlayerImpl) player).removeActivityListener(this); ((BackgroundPlayer.BasePlayerImpl) player).removeActivityListener(this);
} }
} }
@Override
public int getPlayerOptionMenuResource() {
return R.menu.menu_play_queue_bg;
}
@Override
public boolean onPlayerOptionSelected(MenuItem item) {
if (item.getItemId() == R.id.action_switch_popup) {
this.player.setRecovery();
getApplicationContext().sendBroadcast(getPlayerShutdownIntent());
getApplicationContext().startService(getSwitchIntent(PopupVideoPlayer.class));
return true;
}
return false;
}
@Override
public Intent getPlayerShutdownIntent() {
return new Intent(ACTION_CLOSE);
}
} }

View File

@ -78,6 +78,7 @@ import static org.schabi.newpipe.util.AnimationUtils.animateView;
public final class MainVideoPlayer extends Activity { public final class MainVideoPlayer extends Activity {
private static final String TAG = ".MainVideoPlayer"; private static final String TAG = ".MainVideoPlayer";
private static final boolean DEBUG = BasePlayer.DEBUG; private static final boolean DEBUG = BasePlayer.DEBUG;
private static final String PLAYER_STATE_INTENT = "player_state_intent";
private GestureDetector gestureDetector; private GestureDetector gestureDetector;
@ -99,19 +100,41 @@ public final class MainVideoPlayer extends Activity {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getWindow().setStatusBarColor(Color.BLACK); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getWindow().setStatusBarColor(Color.BLACK);
setVolumeControlStream(AudioManager.STREAM_MUSIC); setVolumeControlStream(AudioManager.STREAM_MUSIC);
if (getIntent() == null) { final Intent intent;
if (savedInstanceState != null && savedInstanceState.getParcelable(PLAYER_STATE_INTENT) != null) {
intent = savedInstanceState.getParcelable(PLAYER_STATE_INTENT);
} else {
intent = getIntent();
}
if (intent == null) {
Toast.makeText(this, R.string.general_error, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.general_error, Toast.LENGTH_SHORT).show();
finish(); finish();
return; return;
} }
showSystemUi(); showSystemUi();
setContentView(R.layout.activity_main_player); setContentView(R.layout.activity_main_player);
playerImpl = new VideoPlayerImpl(this); playerImpl = new VideoPlayerImpl(this);
playerImpl.setup(findViewById(android.R.id.content)); playerImpl.setup(findViewById(android.R.id.content));
playerImpl.handleIntent(getIntent()); playerImpl.handleIntent(intent);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (this.playerImpl == null) return;
final Intent intent = NavigationHelper.getPlayerIntent(
getApplicationContext(),
this.getClass(),
this.playerImpl.getPlayQueue(),
this.playerImpl.getRepeatMode(),
this.playerImpl.getPlaybackSpeed(),
this.playerImpl.getPlaybackPitch(),
this.playerImpl.getPlaybackQuality()
);
outState.putParcelable(PLAYER_STATE_INTENT, intent);
} }
@Override @Override
@ -448,12 +471,9 @@ public final class MainVideoPlayer extends Activity {
if (getCurrentState() != STATE_COMPLETED) { if (getCurrentState() != STATE_COMPLETED) {
getControlsVisibilityHandler().removeCallbacksAndMessages(null); getControlsVisibilityHandler().removeCallbacksAndMessages(null);
animateView(getControlsRoot(), true, 300, 0, new Runnable() { animateView(getControlsRoot(), true, 300, 0, () -> {
@Override if (getCurrentState() == STATE_PLAYING && !isSomePopupMenuVisible()) {
public void run() { hideControls(300, DEFAULT_CONTROLS_HIDE_TIME);
if (getCurrentState() == STATE_PLAYING && !isSomePopupMenuVisible()) {
hideControls(300, DEFAULT_CONTROLS_HIDE_TIME);
}
} }
}); });
} }
@ -506,6 +526,7 @@ public final class MainVideoPlayer extends Activity {
private void onScreenRotationClicked() { private void onScreenRotationClicked() {
if (DEBUG) Log.d(TAG, "onScreenRotationClicked() called"); if (DEBUG) Log.d(TAG, "onScreenRotationClicked() called");
toggleOrientation(); toggleOrientation();
showControlsThenHide();
} }
@Override @Override
@ -561,12 +582,9 @@ public final class MainVideoPlayer extends Activity {
@Override @Override
public void onPlaying() { public void onPlaying() {
super.onPlaying(); super.onPlaying();
animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, new Runnable() { animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, () -> {
@Override playPauseButton.setImageResource(R.drawable.ic_pause_white);
public void run() { animatePlayButtons(true, 200);
playPauseButton.setImageResource(R.drawable.ic_pause_white);
animatePlayButtons(true, 200);
}
}); });
showSystemUi(); showSystemUi();
getRootView().setKeepScreenOn(true); getRootView().setKeepScreenOn(true);
@ -575,12 +593,9 @@ public final class MainVideoPlayer extends Activity {
@Override @Override
public void onPaused() { public void onPaused() {
super.onPaused(); super.onPaused();
animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, new Runnable() { animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, () -> {
@Override playPauseButton.setImageResource(R.drawable.ic_play_arrow_white);
public void run() { animatePlayButtons(true, 200);
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white);
animatePlayButtons(true, 200);
}
}); });
showSystemUi(); showSystemUi();
@ -598,12 +613,9 @@ public final class MainVideoPlayer extends Activity {
@Override @Override
public void onCompleted() { public void onCompleted() {
showSystemUi(); showSystemUi();
animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 0, 0, new Runnable() { animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 0, 0, () -> {
@Override playPauseButton.setImageResource(R.drawable.ic_replay_white);
public void run() { animatePlayButtons(true, 300);
playPauseButton.setImageResource(R.drawable.ic_replay_white);
animatePlayButtons(true, 300);
}
}); });
getRootView().setKeepScreenOn(false); getRootView().setKeepScreenOn(false);
@ -632,17 +644,10 @@ public final class MainVideoPlayer extends Activity {
public void hideControls(final long duration, long delay) { public void hideControls(final long duration, long delay) {
if (DEBUG) Log.d(TAG, "hideControls() called with: delay = [" + delay + "]"); if (DEBUG) Log.d(TAG, "hideControls() called with: delay = [" + delay + "]");
getControlsVisibilityHandler().removeCallbacksAndMessages(null); getControlsVisibilityHandler().removeCallbacksAndMessages(null);
getControlsVisibilityHandler().postDelayed(new Runnable() { getControlsVisibilityHandler().postDelayed(() ->
@Override animateView(getControlsRoot(), false, duration, 0, MainVideoPlayer.this::hideSystemUi),
public void run() { delay
animateView(getControlsRoot(), false, duration, 0, new Runnable() { );
@Override
public void run() {
hideSystemUi();
}
});
}
}, delay);
} }
private void updatePlaybackButtons() { private void updatePlaybackButtons() {
@ -655,22 +660,19 @@ public final class MainVideoPlayer extends Activity {
private void buildMoreOptionsMenu() { private void buildMoreOptionsMenu() {
if (moreOptionsPopupMenu == null) return; if (moreOptionsPopupMenu == null) return;
moreOptionsPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { moreOptionsPopupMenu.setOnMenuItemClickListener(menuItem -> {
@Override switch (menuItem.getItemId()) {
public boolean onMenuItemClick(MenuItem menuItem) { case R.id.toggleOrientation:
switch (menuItem.getItemId()) { onScreenRotationClicked();
case R.id.toggleOrientation: break;
onScreenRotationClicked(); case R.id.switchPopup:
break; onFullScreenButtonClicked();
case R.id.switchPopup: break;
onFullScreenButtonClicked(); case R.id.switchBackground:
break; onPlayBackgroundButtonClicked();
case R.id.switchBackground: break;
onPlayBackgroundButtonClicked();
break;
}
return false;
} }
return false;
}); });
} }
@ -692,12 +694,7 @@ public final class MainVideoPlayer extends Activity {
playQueueAdapter.setSelectedListener(getOnSelectedListener()); playQueueAdapter.setSelectedListener(getOnSelectedListener());
itemsListCloseButton.setOnClickListener(new View.OnClickListener() { itemsListCloseButton.setOnClickListener(view -> onQueueClosed());
@Override
public void onClick(View view) {
onQueueClosed();
}
});
} }
private OnScrollBelowItemsListener getQueueScrollListener() { private OnScrollBelowItemsListener getQueueScrollListener() {

View File

@ -66,9 +66,9 @@ import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.VideoStream; import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.player.event.PlayerEventListener; import org.schabi.newpipe.player.event.PlayerEventListener;
import org.schabi.newpipe.player.helper.LockManager;
import org.schabi.newpipe.player.helper.PlayerHelper; import org.schabi.newpipe.player.helper.PlayerHelper;
import org.schabi.newpipe.player.old.PlayVideoActivity; import org.schabi.newpipe.player.old.PlayVideoActivity;
import org.schabi.newpipe.player.helper.LockManager;
import org.schabi.newpipe.playlist.PlayQueueItem; import org.schabi.newpipe.playlist.PlayQueueItem;
import org.schabi.newpipe.playlist.SinglePlayQueue; import org.schabi.newpipe.playlist.SinglePlayQueue;
import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.ErrorActivity;
@ -84,7 +84,6 @@ import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import static org.schabi.newpipe.player.helper.PlayerHelper.isUsingOldPlayer; import static org.schabi.newpipe.player.helper.PlayerHelper.isUsingOldPlayer;
@ -102,7 +101,6 @@ public final class PopupVideoPlayer extends Service {
private static final int NOTIFICATION_ID = 40028922; private static final int NOTIFICATION_ID = 40028922;
public static final String ACTION_CLOSE = "org.schabi.newpipe.player.PopupVideoPlayer.CLOSE"; public static final String ACTION_CLOSE = "org.schabi.newpipe.player.PopupVideoPlayer.CLOSE";
public static final String ACTION_PLAY_PAUSE = "org.schabi.newpipe.player.PopupVideoPlayer.PLAY_PAUSE"; public static final String ACTION_PLAY_PAUSE = "org.schabi.newpipe.player.PopupVideoPlayer.PLAY_PAUSE";
public static final String ACTION_OPEN_CONTROLS = "org.schabi.newpipe.player.PopupVideoPlayer.OPEN_CONTROLS";
public static final String ACTION_REPEAT = "org.schabi.newpipe.player.PopupVideoPlayer.REPEAT"; public static final String ACTION_REPEAT = "org.schabi.newpipe.player.PopupVideoPlayer.REPEAT";
private static final String POPUP_SAVED_WIDTH = "popup_saved_width"; private static final String POPUP_SAVED_WIDTH = "popup_saved_width";
@ -169,17 +167,7 @@ public final class PopupVideoPlayer extends Service {
currentWorker = ExtractorHelper.getStreamInfo(serviceId,url,false) currentWorker = ExtractorHelper.getStreamInfo(serviceId,url,false)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<StreamInfo>() { .subscribe(fetcherRunnable::onReceive, fetcherRunnable::onError);
@Override
public void accept(@NonNull StreamInfo info) throws Exception {
fetcherRunnable.onReceive(info);
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
fetcherRunnable.onError(throwable);
}
});
} else { } else {
playerImpl.setStartedFromNewPipe(true); playerImpl.setStartedFromNewPipe(true);
playerImpl.handleIntent(intent); playerImpl.handleIntent(intent);
@ -267,11 +255,14 @@ public final class PopupVideoPlayer extends Service {
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT));
notRemoteView.setOnClickPendingIntent(R.id.notificationStop, notRemoteView.setOnClickPendingIntent(R.id.notificationStop,
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_CLOSE), PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_CLOSE), PendingIntent.FLAG_UPDATE_CURRENT));
notRemoteView.setOnClickPendingIntent(R.id.notificationContent,
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_OPEN_CONTROLS), PendingIntent.FLAG_UPDATE_CURRENT));
notRemoteView.setOnClickPendingIntent(R.id.notificationRepeat, notRemoteView.setOnClickPendingIntent(R.id.notificationRepeat,
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_REPEAT), PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_REPEAT), PendingIntent.FLAG_UPDATE_CURRENT));
// Starts popup player activity -- attempts to unlock lockscreen
final Intent intent = NavigationHelper.getPopupPlayerActivityIntent(this);
notRemoteView.setOnClickPendingIntent(R.id.notificationContent,
PendingIntent.getActivity(this, NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT));
setRepeatModeRemote(notRemoteView, playerImpl.getRepeatMode()); setRepeatModeRemote(notRemoteView, playerImpl.getRepeatMode());
return new NotificationCompat.Builder(this, getString(R.string.notification_channel_id)) return new NotificationCompat.Builder(this, getString(R.string.notification_channel_id))
@ -421,12 +412,7 @@ public final class PopupVideoPlayer extends Service {
super.initViews(rootView); super.initViews(rootView);
resizingIndicator = rootView.findViewById(R.id.resizing_indicator); resizingIndicator = rootView.findViewById(R.id.resizing_indicator);
fullScreenButton = rootView.findViewById(R.id.fullScreenButton); fullScreenButton = rootView.findViewById(R.id.fullScreenButton);
fullScreenButton.setOnClickListener(new View.OnClickListener() { fullScreenButton.setOnClickListener(v -> onFullScreenButtonClicked());
@Override
public void onClick(View v) {
onFullScreenButtonClicked();
}
});
} }
@Override @Override
@ -604,7 +590,6 @@ public final class PopupVideoPlayer extends Service {
if (DEBUG) Log.d(TAG, "setupBroadcastReceiver() called with: intentFilter = [" + intentFilter + "]"); if (DEBUG) Log.d(TAG, "setupBroadcastReceiver() called with: intentFilter = [" + intentFilter + "]");
intentFilter.addAction(ACTION_CLOSE); intentFilter.addAction(ACTION_CLOSE);
intentFilter.addAction(ACTION_PLAY_PAUSE); intentFilter.addAction(ACTION_PLAY_PAUSE);
intentFilter.addAction(ACTION_OPEN_CONTROLS);
intentFilter.addAction(ACTION_REPEAT); intentFilter.addAction(ACTION_REPEAT);
intentFilter.addAction(Intent.ACTION_SCREEN_ON); intentFilter.addAction(Intent.ACTION_SCREEN_ON);
@ -623,9 +608,6 @@ public final class PopupVideoPlayer extends Service {
case ACTION_PLAY_PAUSE: case ACTION_PLAY_PAUSE:
onVideoPlayPause(); onVideoPlayPause();
break; break;
case ACTION_OPEN_CONTROLS:
NavigationHelper.openPopupPlayerControl(getApplicationContext());
break;
case ACTION_REPEAT: case ACTION_REPEAT:
onRepeatClicked(); onRepeatClicked();
break; break;
@ -899,37 +881,31 @@ public final class PopupVideoPlayer extends Service {
} }
private void onReceive(final StreamInfo info) { private void onReceive(final StreamInfo info) {
mainHandler.post(new Runnable() { mainHandler.post(() -> {
@Override final Intent intent = NavigationHelper.getPlayerIntent(getApplicationContext(),
public void run() { PopupVideoPlayer.class, new SinglePlayQueue(info));
final Intent intent = NavigationHelper.getPlayerIntent(getApplicationContext(), playerImpl.handleIntent(intent);
PopupVideoPlayer.class, new SinglePlayQueue(info));
playerImpl.handleIntent(intent);
}
}); });
} }
private void onError(final Throwable exception) { private void onError(final Throwable exception) {
if (DEBUG) Log.d(TAG, "onError() called with: exception = [" + exception + "]"); if (DEBUG) Log.d(TAG, "onError() called with: exception = [" + exception + "]");
exception.printStackTrace(); exception.printStackTrace();
mainHandler.post(new Runnable() { mainHandler.post(() -> {
@Override if (exception instanceof ReCaptchaException) {
public void run() { onReCaptchaException();
if (exception instanceof ReCaptchaException) { } else if (exception instanceof IOException) {
onReCaptchaException(); Toast.makeText(context, R.string.network_error, Toast.LENGTH_LONG).show();
} else if (exception instanceof IOException) { } else if (exception instanceof YoutubeStreamExtractor.GemaException) {
Toast.makeText(context, R.string.network_error, Toast.LENGTH_LONG).show(); Toast.makeText(context, R.string.blocked_by_gema, Toast.LENGTH_LONG).show();
} else if (exception instanceof YoutubeStreamExtractor.GemaException) { } else if (exception instanceof YoutubeStreamExtractor.LiveStreamException) {
Toast.makeText(context, R.string.blocked_by_gema, Toast.LENGTH_LONG).show(); Toast.makeText(context, R.string.live_streams_not_supported, Toast.LENGTH_LONG).show();
} else if (exception instanceof YoutubeStreamExtractor.LiveStreamException) { } else if (exception instanceof ContentNotAvailableException) {
Toast.makeText(context, R.string.live_streams_not_supported, Toast.LENGTH_LONG).show(); Toast.makeText(context, R.string.content_not_available, Toast.LENGTH_LONG).show();
} else if (exception instanceof ContentNotAvailableException) { } else {
Toast.makeText(context, R.string.content_not_available, Toast.LENGTH_LONG).show(); int errorId = exception instanceof YoutubeStreamExtractor.DecryptException ? R.string.youtube_signature_decryption_error :
} else { exception instanceof ParsingException ? R.string.parsing_error : R.string.general_error;
int errorId = exception instanceof YoutubeStreamExtractor.DecryptException ? R.string.youtube_signature_decryption_error : ErrorActivity.reportError(mainHandler, context, exception, MainActivity.class, null, ErrorActivity.ErrorInfo.make(UserAction.REQUESTED_STREAM, NewPipe.getNameOfService(serviceId), url, errorId));
exception instanceof ParsingException ? R.string.parsing_error : R.string.general_error;
ErrorActivity.reportError(mainHandler, context, exception, MainActivity.class, null, ErrorActivity.ErrorInfo.make(UserAction.REQUESTED_STREAM, NewPipe.getNameOfService(serviceId), url, errorId));
}
} }
}); });
stopSelf(); stopSelf();

View File

@ -1,9 +1,12 @@
package org.schabi.newpipe.player; package org.schabi.newpipe.player;
import android.content.Intent; import android.content.Intent;
import android.view.MenuItem;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import static org.schabi.newpipe.player.PopupVideoPlayer.ACTION_CLOSE;
public final class PopupVideoPlayerActivity extends ServicePlayerActivity { public final class PopupVideoPlayerActivity extends ServicePlayerActivity {
private static final String TAG = "PopupVideoPlayerActivity"; private static final String TAG = "PopupVideoPlayerActivity";
@ -36,4 +39,25 @@ public final class PopupVideoPlayerActivity extends ServicePlayerActivity {
((PopupVideoPlayer.VideoPlayerImpl) player).removeActivityListener(this); ((PopupVideoPlayer.VideoPlayerImpl) player).removeActivityListener(this);
} }
} }
@Override
public int getPlayerOptionMenuResource() {
return R.menu.menu_play_queue_popup;
}
@Override
public boolean onPlayerOptionSelected(MenuItem item) {
if (item.getItemId() == R.id.action_switch_background) {
this.player.setRecovery();
getApplicationContext().sendBroadcast(getPlayerShutdownIntent());
getApplicationContext().startService(getSwitchIntent(BackgroundPlayer.class));
return true;
}
return false;
}
@Override
public Intent getPlayerShutdownIntent() {
return new Intent(ACTION_CLOSE);
}
} }

View File

@ -100,6 +100,11 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
public abstract void stopPlayerListener(); public abstract void stopPlayerListener();
public abstract int getPlayerOptionMenuResource();
public abstract boolean onPlayerOptionSelected(MenuItem item);
public abstract Intent getPlayerShutdownIntent();
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Activity Lifecycle // Activity Lifecycle
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -134,6 +139,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_play_queue, menu); getMenuInflater().inflate(R.menu.menu_play_queue, menu);
getMenuInflater().inflate(getPlayerOptionMenuResource(), menu);
return true; return true;
} }
@ -153,8 +159,13 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
case R.id.action_system_audio: case R.id.action_system_audio:
startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS)); startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS));
return true; return true;
case R.id.action_switch_main:
this.player.setRecovery();
getApplicationContext().sendBroadcast(getPlayerShutdownIntent());
getApplicationContext().startActivity(getSwitchIntent(MainVideoPlayer.class));
return true;
} }
return super.onOptionsItemSelected(item); return onPlayerOptionSelected(item) || super.onOptionsItemSelected(item);
} }
@Override @Override
@ -163,6 +174,17 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
unbind(); unbind();
} }
protected Intent getSwitchIntent(final Class clazz) {
return NavigationHelper.getPlayerIntent(
getApplicationContext(),
clazz,
this.player.getPlayQueue(),
this.player.getRepeatMode(),
this.player.getPlaybackSpeed(),
this.player.getPlaybackPitch(),
null
);
}
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Service Connection // Service Connection
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -288,14 +310,11 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
final float playbackSpeed = BasePlayer.PLAYBACK_SPEEDS[i]; final float playbackSpeed = BasePlayer.PLAYBACK_SPEEDS[i];
final String formattedSpeed = formatSpeed(playbackSpeed); final String formattedSpeed = formatSpeed(playbackSpeed);
final MenuItem item = playbackSpeedPopupMenu.getMenu().add(PLAYBACK_SPEED_POPUP_MENU_GROUP_ID, i, Menu.NONE, formattedSpeed); final MenuItem item = playbackSpeedPopupMenu.getMenu().add(PLAYBACK_SPEED_POPUP_MENU_GROUP_ID, i, Menu.NONE, formattedSpeed);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(menuItem -> {
@Override if (player == null) return false;
public boolean onMenuItemClick(MenuItem menuItem) {
if (player == null) return false;
player.setPlaybackSpeed(playbackSpeed); player.setPlaybackSpeed(playbackSpeed);
return true; return true;
}
}); });
} }
} }
@ -308,14 +327,11 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
final float playbackPitch = BasePlayer.PLAYBACK_PITCHES[i]; final float playbackPitch = BasePlayer.PLAYBACK_PITCHES[i];
final String formattedPitch = formatPitch(playbackPitch); final String formattedPitch = formatPitch(playbackPitch);
final MenuItem item = playbackPitchPopupMenu.getMenu().add(PLAYBACK_PITCH_POPUP_MENU_GROUP_ID, i, Menu.NONE, formattedPitch); final MenuItem item = playbackPitchPopupMenu.getMenu().add(PLAYBACK_PITCH_POPUP_MENU_GROUP_ID, i, Menu.NONE, formattedPitch);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(menuItem -> {
@Override if (player == null) return false;
public boolean onMenuItemClick(MenuItem menuItem) {
if (player == null) return false;
player.setPlaybackPitch(playbackPitch); player.setPlaybackPitch(playbackPitch);
return true; return true;
}
}); });
} }
} }
@ -323,24 +339,18 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
private void buildItemPopupMenu(final PlayQueueItem item, final View view) { private void buildItemPopupMenu(final PlayQueueItem item, final View view) {
final PopupMenu menu = new PopupMenu(this, view); final PopupMenu menu = new PopupMenu(this, view);
final MenuItem remove = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 0, Menu.NONE, R.string.play_queue_remove); final MenuItem remove = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 0, Menu.NONE, R.string.play_queue_remove);
remove.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { remove.setOnMenuItemClickListener(menuItem -> {
@Override if (player == null) return false;
public boolean onMenuItemClick(MenuItem menuItem) {
if (player == null) return false;
final int index = player.getPlayQueue().indexOf(item); final int index = player.getPlayQueue().indexOf(item);
if (index != -1) player.getPlayQueue().remove(index); if (index != -1) player.getPlayQueue().remove(index);
return true; return true;
}
}); });
final MenuItem detail = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 1, Menu.NONE, R.string.play_queue_stream_detail); final MenuItem detail = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 1, Menu.NONE, R.string.play_queue_stream_detail);
detail.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { detail.setOnMenuItemClickListener(menuItem -> {
@Override onOpenDetail(item.getServiceId(), item.getUrl(), item.getTitle());
public boolean onMenuItemClick(MenuItem menuItem) { return true;
onOpenDetail(item.getServiceId(), item.getUrl(), item.getTitle());
return true;
}
}); });
menu.show(); menu.show();

View File

@ -382,7 +382,7 @@ public class ErrorActivity extends AppCompatActivity {
private String getContentLangString() { private String getContentLangString() {
return PreferenceManager.getDefaultSharedPreferences(this) return PreferenceManager.getDefaultSharedPreferences(this)
.getString(this.getString(R.string.search_language_key), "none"); .getString(this.getString(R.string.content_country_key), "none");
} }
private String getOsString() { private String getOsString() {

View File

@ -57,13 +57,13 @@ public final class ExtractorHelper {
} }
} }
public static Single<SearchResult> searchFor(final int serviceId, final String query, final int pageNumber, final String searchLanguage, final SearchEngine.Filter filter) { public static Single<SearchResult> searchFor(final int serviceId, final String query, final int pageNumber, final String contentCountry, final SearchEngine.Filter filter) {
checkServiceId(serviceId); checkServiceId(serviceId);
return Single.fromCallable(new Callable<SearchResult>() { return Single.fromCallable(new Callable<SearchResult>() {
@Override @Override
public SearchResult call() throws Exception { public SearchResult call() throws Exception {
return SearchResult.getSearchResult(NewPipe.getService(serviceId).getSearchEngine(), return SearchResult.getSearchResult(NewPipe.getService(serviceId).getSearchEngine(),
query, pageNumber, searchLanguage, filter); query, pageNumber, contentCountry, filter);
} }
}); });
} }
@ -79,12 +79,12 @@ public final class ExtractorHelper {
}); });
} }
public static Single<List<String>> suggestionsFor(final int serviceId, final String query, final String searchLanguage) { public static Single<List<String>> suggestionsFor(final int serviceId, final String query, final String contentCountry) {
checkServiceId(serviceId); checkServiceId(serviceId);
return Single.fromCallable(new Callable<List<String>>() { return Single.fromCallable(new Callable<List<String>>() {
@Override @Override
public List<String> call() throws Exception { public List<String> call() throws Exception {
return NewPipe.getService(serviceId).getSuggestionExtractor().suggestionList(query, searchLanguage); return NewPipe.getService(serviceId).getSuggestionExtractor().suggestionList(query, contentCountry);
} }
}); });
} }
@ -143,7 +143,8 @@ public final class ExtractorHelper {
return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<KioskInfo>() { return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<KioskInfo>() {
@Override @Override
public KioskInfo call() throws Exception { public KioskInfo call() throws Exception {
return KioskInfo.getInfo(NewPipe.getService(serviceId), url, toUpperCase(contentCountry)); Log.e("---------", contentCountry);
return KioskInfo.getInfo(NewPipe.getService(serviceId), url, contentCountry);
} }
})); }));
} }
@ -152,7 +153,7 @@ public final class ExtractorHelper {
return Single.fromCallable(new Callable<NextItemsResult>() { return Single.fromCallable(new Callable<NextItemsResult>() {
@Override @Override
public NextItemsResult call() throws Exception { public NextItemsResult call() throws Exception {
return KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextStreamsUrl, toUpperCase(contentCountry)); return KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextStreamsUrl, contentCountry);
} }
}); });
} }
@ -219,16 +220,20 @@ public final class ExtractorHelper {
// as it will cause a infinite loop if it is // as it will cause a infinite loop if it is
Throwable cause, getCause = throwable; Throwable cause, getCause = throwable;
// Check if throwable is a subclass of any of the filtered classes
final Class throwableClass = throwable.getClass();
for (Class<?> causesEl : causesToCheck) { for (Class<?> causesEl : causesToCheck) {
if (throwable.getClass().isAssignableFrom(causesEl)) { if (causesEl.isAssignableFrom(throwableClass)) {
return true; return true;
} }
} }
// Iteratively checks if the root cause of the throwable is a subclass of the filtered class
while ((cause = throwable.getCause()) != null && getCause != cause) { while ((cause = throwable.getCause()) != null && getCause != cause) {
getCause = cause; getCause = cause;
final Class causeClass = cause.getClass();
for (Class<?> causesEl : causesToCheck) { for (Class<?> causesEl : causesToCheck) {
if (cause.getClass().isAssignableFrom(causesEl)) { if (causesEl.isAssignableFrom(causeClass)) {
return true; return true;
} }
} }

View File

@ -1,7 +1,6 @@
package org.schabi.newpipe.util; package org.schabi.newpipe.util;
import android.app.Activity; import android.app.Activity;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -21,9 +20,7 @@ import org.schabi.newpipe.download.DownloadActivity;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.fragments.MainFragment; import org.schabi.newpipe.fragments.MainFragment;
import org.schabi.newpipe.fragments.detail.VideoDetailFragment; import org.schabi.newpipe.fragments.detail.VideoDetailFragment;
import org.schabi.newpipe.fragments.list.channel.ChannelFragment; import org.schabi.newpipe.fragments.list.channel.ChannelFragment;
@ -46,8 +43,6 @@ import org.schabi.newpipe.settings.SettingsActivity;
public class NavigationHelper { public class NavigationHelper {
public static final String MAIN_FRAGMENT_TAG = "main_fragment_tag"; public static final String MAIN_FRAGMENT_TAG = "main_fragment_tag";
public static final int PENDING_INTENT_OPEN_PLAYER_ACTIVITY = 1546;
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Players // Players
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@ -92,9 +87,13 @@ public class NavigationHelper {
context.startActivity(getPlayerIntent(context, MainVideoPlayer.class, queue)); context.startActivity(getPlayerIntent(context, MainVideoPlayer.class, queue));
} }
public static void playOnPopupPlayer(final Context context, final PlayQueue queue) { public static void playOnPopupPlayer(final Activity activity, final PlayQueue queue) {
Toast.makeText(context, R.string.popup_playing_toast, Toast.LENGTH_SHORT).show(); if (!PermissionHelper.isPopupEnabled(activity)) {
context.startService(getPlayerIntent(context, PopupVideoPlayer.class, queue)); PermissionHelper.showPopupEnablementToast(activity);
return;
}
Toast.makeText(activity, R.string.popup_playing_toast, Toast.LENGTH_SHORT).show();
activity.startService(getPlayerIntent(activity, PopupVideoPlayer.class, queue));
} }
public static void playOnBackgroundPlayer(final Context context, final PlayQueue queue) { public static void playOnBackgroundPlayer(final Context context, final PlayQueue queue) {
@ -102,9 +101,13 @@ public class NavigationHelper {
context.startService(getPlayerIntent(context, BackgroundPlayer.class, queue)); context.startService(getPlayerIntent(context, BackgroundPlayer.class, queue));
} }
public static void enqueueOnPopupPlayer(final Context context, final PlayQueue queue) { public static void enqueueOnPopupPlayer(final Activity activity, final PlayQueue queue) {
Toast.makeText(context, R.string.popup_playing_append, Toast.LENGTH_SHORT).show(); if (!PermissionHelper.isPopupEnabled(activity)) {
context.startService(getPlayerEnqueueIntent(context, PopupVideoPlayer.class, queue)); PermissionHelper.showPopupEnablementToast(activity);
return;
}
Toast.makeText(activity, R.string.popup_playing_append, Toast.LENGTH_SHORT).show();
activity.startService(getPlayerEnqueueIntent(activity, PopupVideoPlayer.class, queue));
} }
public static void enqueueOnBackgroundPlayer(final Context context, final PlayQueue queue) { public static void enqueueOnBackgroundPlayer(final Context context, final PlayQueue queue) {
@ -264,34 +267,22 @@ public class NavigationHelper {
return true; return true;
} }
public static void openBackgroundPlayerControl(final Context context) { public static Intent getBackgroundPlayerActivityIntent(final Context context) {
openServicePlayerControl(context, BackgroundPlayerActivity.class); return getServicePlayerActivityIntent(context, BackgroundPlayerActivity.class);
} }
public static void openPopupPlayerControl(final Context context) { public static Intent getPopupPlayerActivityIntent(final Context context) {
openServicePlayerControl(context, PopupVideoPlayerActivity.class); return getServicePlayerActivityIntent(context, PopupVideoPlayerActivity.class);
} }
private static void openServicePlayerControl(final Context context, final Class activityClass) { private static Intent getServicePlayerActivityIntent(final Context context,
Intent intent = getServicePlayerControlIntent(context, activityClass); final Class activityClass) {
context.startActivity(intent); Intent intent = new Intent(context, activityClass);
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}
public static Intent getServicePlayerControlIntent(final Context context, final Class activityClass) {
final Intent intent = new Intent(context, activityClass);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
} }
return intent; return intent;
} }
public static PendingIntent getServicePlayerControlPendingIntent(final Context context, final Class activityClass) {
Intent intent = getServicePlayerControlIntent(context, activityClass);
PendingIntent pIntent = PendingIntent.getActivity(context, PENDING_INTENT_OPEN_PLAYER_ACTIVITY, intent, 0);
return pIntent;
}
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Link handling // Link handling
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/

View File

@ -11,6 +11,11 @@ import android.provider.Settings;
import android.support.annotation.RequiresApi; import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.widget.TextView;
import android.widget.Toast;
import org.schabi.newpipe.R;
public class PermissionHelper { public class PermissionHelper {
public static final int PERMISSION_WRITE_STORAGE = 778; public static final int PERMISSION_WRITE_STORAGE = 778;
@ -92,4 +97,16 @@ public class PermissionHelper {
return false; return false;
}else return true; }else return true;
} }
public static boolean isPopupEnabled(Activity activity) {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M ||
PermissionHelper.checkSystemAlertWindowPermission(activity);
}
public static void showPopupEnablementToast(Context context) {
Toast toast = Toast.makeText(context, R.string.msg_popup_permission, Toast.LENGTH_LONG);
TextView messageView = toast.getView().findViewById(android.R.id.message);
if (messageView != null) messageView.setGravity(Gravity.CENTER);
toast.show();
}
} }

View File

@ -31,10 +31,14 @@
android:layout_below="@+id/itemTitleView" android:layout_below="@+id/itemTitleView"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true" android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/video_item_search_uploader_text_size" android:textSize="@dimen/video_item_search_uploader_text_size"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" tools:visibility="visible"
tools:text="TYPE" /> tools:text="UPLOADER" />
</RelativeLayout> </RelativeLayout>

View File

@ -17,4 +17,9 @@
android:orderInCategory="996" android:orderInCategory="996"
android:title="@string/play_queue_audio_settings" android:title="@string/play_queue_audio_settings"
app:showAsAction="never"/> app:showAsAction="never"/>
<item android:id="@+id/action_switch_main"
android:orderInCategory="999"
android:title="@string/switch_to_main"
app:showAsAction="never"/>
</menu> </menu>

View File

@ -0,0 +1,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.schabi.newpipe.history.HistoryActivity">
<item android:id="@+id/action_switch_popup"
android:orderInCategory="1999"
android:title="@string/switch_to_popup"
app:showAsAction="never"/>
</menu>

View File

@ -0,0 +1,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.schabi.newpipe.history.HistoryActivity">
<item android:id="@+id/action_switch_background"
android:orderInCategory="1999"
android:title="@string/switch_to_background"
app:showAsAction="never"/>
</menu>

View File

@ -6,16 +6,16 @@
<item <item
android:icon="@drawable/ic_screen_rotation_white" android:icon="@drawable/ic_screen_rotation_white"
android:id="@+id/toggleOrientation" android:id="@+id/toggleOrientation"
android:title="Toggle orientation" android:title="@string/toggle_orientation"
app:showAsAction="always|withText" /> app:showAsAction="always|withText" />
<item <item
android:icon="@drawable/ic_fullscreen_exit_white" android:icon="@drawable/ic_fullscreen_exit_white"
android:id="@+id/switchPopup" android:id="@+id/switchPopup"
android:title="Switch to popup" android:title="@string/switch_to_popup"
app:showAsAction="always|withText" /> app:showAsAction="always|withText" />
<item android:icon="?audio" <item android:icon="?audio"
android:id="@+id/switchBackground" android:id="@+id/switchBackground"
android:title="Switch to background" android:title="@string/switch_to_background"
app:showAsAction="always|withText" /> app:showAsAction="always|withText" />
</menu> </menu>

View File

@ -176,13 +176,13 @@
<string name="no_subscribers">صفر لا تقم با الإختيار (في بعض اللغات) لأنها ليست \"حالة خاصة\" للأندرويد</string> <string name="no_subscribers">صفر لا تقم با الإختيار (في بعض اللغات) لأنها ليست \"حالة خاصة\" للأندرويد</string>
<plurals name="subscribers"> <plurals name="subscribers">
<item quantity="zero">صفر</item> <item quantity="zero">صفر</item>
<item quantity="one">واحد</item> <item quantity="one">واحد</item>
<item quantity="two">اثنان</item> <item quantity="two">اثنان</item>
<item quantity="few">قليل</item> <item quantity="few">قليل</item>
<item quantity="many">كثير</item> <item quantity="many">كثير</item>
<item quantity="other">أخرى</item> <item quantity="other">أخرى</item>
</plurals> </plurals>
<string name="no_views">لاتوجد مشاهدات</string> <string name="no_views">لاتوجد مشاهدات</string>
<string name="no_videos">لاتوجد فديوهات</string> <string name="no_videos">لاتوجد فديوهات</string>
@ -292,4 +292,4 @@
<string name="enqueue_on_background">إدراج بقائمة الانتظار على خلفية</string> <string name="enqueue_on_background">إدراج بقائمة الانتظار على خلفية</string>
<string name="enqueue_on_popup">إدراج بقائمة الانتظار على المنبثقة</string> <string name="enqueue_on_popup">إدراج بقائمة الانتظار على المنبثقة</string>
<string name="start_here_on_background">ابدأ هنا على خلفية المصدر</string> <string name="start_here_on_background">ابدأ هنا على خلفية المصدر</string>
</resources> </resources>

View File

@ -204,8 +204,7 @@ otevření ve vyskakovacím okně</string>
<plurals name="subscribers"> <plurals name="subscribers">
<item quantity="one">%s odběratel</item> <item quantity="one">%s odběratel</item>
<item quantity="few">%s odběratelé</item> <item quantity="few">%s odběratelé</item>
<item quantity="many">%s odběratelů</item> <item quantity="other">%s odběratelů</item>
<item quantity="other"/>
</plurals> </plurals>
<string name="no_views">Žádná zhlédnutí</string> <string name="no_views">Žádná zhlédnutí</string>
@ -219,8 +218,7 @@ otevření ve vyskakovacím okně</string>
<plurals name="videos"> <plurals name="videos">
<item quantity="one">%s video</item> <item quantity="one">%s video</item>
<item quantity="few">%s videa</item> <item quantity="few">%s videa</item>
<item quantity="many">%s videí</item> <item quantity="other">%s videí</item>
<item quantity="other"/>
</plurals> </plurals>
<string name="settings_category_downloads_title">Stahování</string> <string name="settings_category_downloads_title">Stahování</string>

View File

@ -178,24 +178,18 @@
<plurals name="subscribers"> <plurals name="subscribers">
<item quantity="one">%s עוקב</item> <item quantity="one">%s עוקב</item>
<item quantity="two">%s עוקבים</item> <item quantity="two">%s עוקבים</item>
<item quantity="many"></item>
<item quantity="other"></item>
</plurals> </plurals>
<string name="no_views">אין תצוגות</string> <string name="no_views">אין תצוגות</string>
<plurals name="views"> <plurals name="views">
<item quantity="one">תצוגה %s</item> <item quantity="one">תצוגה %s</item>
<item quantity="two">%s תצוגות</item> <item quantity="two">%s תצוגות</item>
<item quantity="many"></item>
<item quantity="other"></item>
</plurals> </plurals>
<string name="no_videos">אין סרטונים</string> <string name="no_videos">אין סרטונים</string>
<plurals name="videos"> <plurals name="videos">
<item quantity="one">סרטון %s</item> <item quantity="one">סרטון %s</item>
<item quantity="two">%s סרטונים</item> <item quantity="two">%s סרטונים</item>
<item quantity="many"></item>
<item quantity="other"></item>
</plurals> </plurals>
<string name="start">התחל</string> <string name="start">התחל</string>

View File

@ -128,15 +128,10 @@
<plurals name="subscribers"> <plurals name="subscribers">
<item quantity="one">%s prenumeratorius</item> <item quantity="one">%s prenumeratorius</item>
<item quantity="few">%s prenumeratoriai</item> <item quantity="few">%s prenumeratoriai</item>
<item quantity="many"/>
<item quantity="other"/>
</plurals> </plurals>
<plurals name="videos"> <plurals name="videos">
<item quantity="one">Vaizdo įrašai</item> <item quantity="one">Vaizdo įrašai</item>
<item quantity="few"/>
<item quantity="many"/>
<item quantity="other"/>
</plurals> </plurals>
<string name="start">Pradėti</string> <string name="start">Pradėti</string>
@ -214,9 +209,6 @@
<string name="no_views">Nėra peržiūrų</string> <string name="no_views">Nėra peržiūrų</string>
<plurals name="views"> <plurals name="views">
<item quantity="one">%a peržiūra</item> <item quantity="one">%a peržiūra</item>
<item quantity="few"></item>
<item quantity="many"></item>
<item quantity="other"></item>
</plurals> </plurals>
<string name="no_videos">Nėra vaizdo įrašų</string> <string name="no_videos">Nėra vaizdo įrašų</string>

View File

@ -247,23 +247,18 @@
<plurals name="subscribers"> <plurals name="subscribers">
<item quantity="one">%s subskrybent</item> <item quantity="one">%s subskrybent</item>
<item quantity="few">%s subskrybentów</item> <item quantity="few">%s subskrybentów</item>
<item quantity="many">%s subskrybentów</item> <item quantity="other">%s subskrybentów</item>
<item quantity="other"/>
</plurals> </plurals>
<plurals name="views"> <plurals name="views">
<item quantity="one">%s odtworzenie</item> <item quantity="one">%s odtworzenie</item>
<item quantity="few"/> <item quantity="other">%s odtworzeń</item>
<item quantity="many">%s odtworzeń</item>
<item quantity="other"/>
</plurals> </plurals>
<string name="no_videos">Brak filmów</string> <string name="no_videos">Brak filmów</string>
<plurals name="videos"> <plurals name="videos">
<item quantity="one">%s film</item> <item quantity="one">%s film</item>
<item quantity="few">%s filmów</item> <item quantity="few">%s filmów</item>
<item quantity="many"/>
<item quantity="other"/>
</plurals> </plurals>
<string name="charset_most_special_characters">Większość znaków specjalnych</string> <string name="charset_most_special_characters">Większość znaków specjalnych</string>

View File

@ -236,24 +236,21 @@
<plurals name="subscribers"> <plurals name="subscribers">
<item quantity="one">%s подписчик</item> <item quantity="one">%s подписчик</item>
<item quantity="few">%s подписчика</item> <item quantity="few">%s подписчика</item>
<item quantity="many">%s подписчиков</item> <item quantity="other">%s подписчиков</item>
<item quantity="other"/>
</plurals> </plurals>
<string name="no_views">Нет просмотров</string> <string name="no_views">Нет просмотров</string>
<plurals name="views"> <plurals name="views">
<item quantity="one">%s просмотр</item> <item quantity="one">%s просмотр</item>
<item quantity="few">%s просмотра</item> <item quantity="few">%s просмотра</item>
<item quantity="many">%s просмотров</item> <item quantity="other">%s просмотров</item>
<item quantity="other"/>
</plurals> </plurals>
<string name="no_videos">Нет видео</string> <string name="no_videos">Нет видео</string>
<plurals name="videos"> <plurals name="videos">
<item quantity="one">%s видео</item> <item quantity="one">%s видео</item>
<item quantity="few">%s видео</item> <item quantity="few">%s видео</item>
<item quantity="many">%s видео</item> <item quantity="other">%s видео</item>
<item quantity="other"/>
</plurals> </plurals>
<string name="item_deleted">Элемент удалён</string> <string name="item_deleted">Элемент удалён</string>

View File

@ -247,24 +247,21 @@ otvorenie okna na popredí</string>
<plurals name="subscribers"> <plurals name="subscribers">
<item quantity="one">%s odberateľ</item> <item quantity="one">%s odberateľ</item>
<item quantity="few">%s odberatelia</item> <item quantity="few">%s odberatelia</item>
<item quantity="many">%s odberateľov</item> <item quantity="other">%s odberateľov</item>
<item quantity="other"/>
</plurals> </plurals>
<string name="no_views">Žiadne zobrazenia</string> <string name="no_views">Žiadne zobrazenia</string>
<plurals name="views"> <plurals name="views">
<item quantity="one">%s zobrazenie</item> <item quantity="one">%s zobrazenie</item>
<item quantity="few">%s zobrazenia</item> <item quantity="few">%s zobrazenia</item>
<item quantity="many">%s zobrazení</item> <item quantity="other">%s zobrazení</item>
<item quantity="other"/>
</plurals> </plurals>
<string name="no_videos">Žiadne videá</string> <string name="no_videos">Žiadne videá</string>
<plurals name="videos"> <plurals name="videos">
<item quantity="one">%s video</item> <item quantity="one">%s video</item>
<item quantity="few">%s videá</item> <item quantity="few">%s videá</item>
<item quantity="many">%s videí</item> <item quantity="other">%s videí</item>
<item quantity="other"/>
</plurals> </plurals>
<string name="item_deleted">Položka bola odstránená</string> <string name="item_deleted">Položka bola odstránená</string>

View File

@ -100,7 +100,9 @@
<string name="show_next_video_key" translatable="false">show_next_video</string> <string name="show_next_video_key" translatable="false">show_next_video</string>
<string name="show_hold_to_append_key" translatable="false">show_hold_to_append</string> <string name="show_hold_to_append_key" translatable="false">show_hold_to_append</string>
<string name="default_language_value">en</string> <string name="default_language_value">en</string>
<string name="default_country_value">GB</string>
<string name="search_language_key" translatable="false">search_language</string> <string name="search_language_key" translatable="false">search_language</string>
<string name="content_country_key" translatable="false">content_country</string>
<string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string> <string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string>
<string name="use_tor_key" translatable="false">use_tor</string> <string name="use_tor_key" translatable="false">use_tor</string>
<string name="enable_search_history_key" translatable="false">enable_search_history</string> <string name="enable_search_history_key" translatable="false">enable_search_history</string>
@ -140,7 +142,6 @@
<string name="default_file_charset_value" translatable="false">@string/charset_most_special_characters_value</string> <string name="default_file_charset_value" translatable="false">@string/charset_most_special_characters_value</string>
<!-- TODO: scrape these programmatically, then store in a local cache -->
<!-- alternatively, load these from some local android data store --> <!-- alternatively, load these from some local android data store -->
<string-array name="language_codes" translatable="false"> <string-array name="language_codes" translatable="false">
<item>af</item> <item>af</item>
@ -300,4 +301,505 @@
<item>日本語</item> <item>日本語</item>
<item>한국어</item> <item>한국어</item>
</string-array> </string-array>
<string-array name="country_names" translatable="false">
<item>Afghanistan</item>
<item>Aland Islands</item>
<item>Albania</item>
<item>Algeria</item>
<item>American Samoa</item>
<item>Andorra</item>
<item>Angola</item>
<item>Anguilla</item>
<item>Antarctica</item>
<item>Antiguaand Barbuda</item>
<item>Argentina</item>
<item>Armenia</item>
<item>Aruba</item>
<item>Australia</item>
<item>Austria</item>
<item>Azerbaijan</item>
<item>Bahamas</item>
<item>Bahrain</item>
<item>Bangladesh</item>
<item>Barbados</item>
<item>Belarus</item>
<item>Belgium</item>
<item>Belize</item>
<item>Benin</item>
<item>Bermuda</item>
<item>Bhutan</item>
<item>Bolivia</item>
<item>Bosniaand Herzegovina</item>
<item>Botswana</item>
<item>BouvetIsland</item>
<item>Brazil</item>
<item>British Virgin Islands</item>
<item>British Indian Ocean Territory</item>
<item>Brunei Darussalam</item>
<item>Bulgaria</item>
<item>Burkina Faso</item>
<item>Burundi</item>
<item>Cambodia</item>
<item>Cameroon</item>
<item>Canada</item>
<item>CapeVerde</item>
<item>Cayman Islands</item>
<item>Central African Republic</item>
<item>Chad</item>
<item>Chile</item>
<item>China</item>
<item>HongKong, China</item>
<item>Macao,China</item>
<item>Christmas Island</item>
<item>Cocos(Keeling) Islands</item>
<item>Colombia</item>
<item>Comoros</item>
<item>Congo(Brazzaville)</item>
<item>Congo, (Kinshasa)</item>
<item>Cook Islands</item>
<item>CostaRica</item>
<item>Côted'Ivoire</item>
<item>Croatia</item>
<item>Cuba</item>
<item>Cyprus</item>
<item>Czech Republic</item>
<item>Denmark</item>
<item>Djibouti</item>
<item>Dominica</item>
<item>Dominican Republic</item>
<item>Ecuador</item>
<item>Egypt</item>
<item>ElSalvador</item>
<item>EquatorialGuinea</item>
<item>Eritrea</item>
<item>Estonia</item>
<item>Ethiopia</item>
<item>Falkland Islands (Malvinas)</item>
<item>Faroe Islands</item>
<item>Fiji</item>
<item>Finland</item>
<item>France</item>
<item>French Guiana</item>
<item>French Polynesia</item>
<item>French Southern Territories</item>
<item>Gabon</item>
<item>Gambia</item>
<item>Georgia</item>
<item>Germany</item>
<item>Ghana</item>
<item>Gibraltar</item>
<item>Greece</item>
<item>Greenland</item>
<item>Grenada</item>
<item>Guadeloupe</item>
<item>Guam</item>
<item>Guatemala</item>
<item>Guernsey</item>
<item>Guinea</item>
<item>Guinea-Bissau</item>
<item>Guyana</item>
<item>Haiti</item>
<item>Heardand Mcdonald Islands</item>
<item>HolySee (Vatican City State)</item>
<item>Honduras</item>
<item>Hungary</item>
<item>Iceland</item>
<item>India</item>
<item>Indonesia</item>
<item>Iran</item>
<item>Iraq</item>
<item>Ireland</item>
<item>Isleof Man</item>
<item>Israel</item>
<item>Italy</item>
<item>Jamaica</item>
<item>Japan</item>
<item>Jersey</item>
<item>Jordan</item>
<item>Kazakhstan</item>
<item>Kenya</item>
<item>Kiribati</item>
<item>Korea(North)</item>
<item>Korea(South)</item>
<item>Kuwait</item>
<item>Kyrgyzstan</item>
<item>Lao</item>
<item>Latvia</item>
<item>Lebanon</item>
<item>Lesotho</item>
<item>Liberia</item>
<item>Libya</item>
<item>Liechtenstein</item>
<item>Lithuania</item>
<item>Luxembourg</item>
<item>Macedonia</item>
<item>Madagascar</item>
<item>Malawi</item>
<item>Malaysia</item>
<item>Maldives</item>
<item>Mali</item>
<item>Malta</item>
<item>MarshallIslands</item>
<item>Martinique</item>
<item>Mauritania</item>
<item>Mauritius</item>
<item>Mayotte</item>
<item>Mexico</item>
<item>Micronesia</item>
<item>Moldova</item>
<item>Monaco</item>
<item>Mongolia</item>
<item>Montenegro</item>
<item>Montserrat</item>
<item>Morocco</item>
<item>Mozambique</item>
<item>Myanmar</item>
<item>Namibia</item>
<item>Nauru</item>
<item>Nepal</item>
<item>Netherlands</item>
<item>Netherlands Antilles</item>
<item>New Caledonia</item>
<item>New Zealand</item>
<item>Nicaragua</item>
<item>Niger</item>
<item>Nigeria</item>
<item>Niue</item>
<item>Norfolk Island</item>
<item>Northern Mariana Islands</item>
<item>Norway</item>
<item>Oman</item>
<item>Pakistan</item>
<item>Palau</item>
<item>Palestinian Territory</item>
<item>Panama</item>
<item>Papua New Guinea</item>
<item>Paraguay</item>
<item>Peru</item>
<item>Philippines</item>
<item>Pitcairn</item>
<item>Poland</item>
<item>Portugal</item>
<item>PuertoRico</item>
<item>Qatar</item>
<item>Réunion</item>
<item>Romania</item>
<item>Russian Federation</item>
<item>Rwanda</item>
<item>Saint-Barthélemy</item>
<item>Saint Helena</item>
<item>Saint KittsandNevis</item>
<item>SaintLucia</item>
<item>Saint-Martin(Frenchpart)</item>
<item>SaintPierreandMiquelon</item>
<item>Saint Vincentand Grenadines</item>
<item>Samoa</item>
<item>San Marino</item>
<item>Sao Tomeand Principe</item>
<item>SaudiArabia</item>
<item>Senegal</item>
<item>Serbia</item>
<item>Seychelles</item>
<item>SierraLeone</item>
<item>Singapore</item>
<item>Slovakia</item>
<item>Slovenia</item>
<item>SolomonIslands</item>
<item>Somalia</item>
<item>SouthAfrica</item>
<item>South Georgiaandthe South Sandwich Islands</item>
<item>South Sudan</item>
<item>Spain</item>
<item>Sri Lanka</item>
<item>Sudan</item>
<item>Suriname</item>
<item>Svalbardand Jan Mayen Islands</item>
<item>Swaziland</item>
<item>Sweden</item>
<item>Switzerland</item>
<item>Syrian ArabRepublic(Syria)</item>
<item>Taiwan, Republicof China</item>
<item>Tajikistan</item>
<item>Tanzania</item>
<item>Thailand</item>
<item>Timor-Leste</item>
<item>Togo</item>
<item>Tokelau</item>
<item>Tonga</item>
<item>Trinidadand Tobago</item>
<item>Tunisia</item>
<item>Turkey</item>
<item>Turkmenistan</item>
<item>Turksand Caicos Islands</item>
<item>Tuvalu</item>
<item>Uganda</item>
<item>Ukraine</item>
<item>United Arab Emirates</item>
<item>United Kingdom</item>
<item>USA</item>
<item>Minor Outlying Islands</item>
<item>Uruguay</item>
<item>Uzbekistan</item>
<item>Vanuatu</item>
<item>Venezuela (BolivarianRepublic)</item>
<item>VietNam</item>
<item>Virgin Islands,</item>
<item>Wallisand Futuna Islands</item>
<item>Western Sahara</item>
<item>Yemen</item>
<item>Zambia</item>
<item>Zimbabwe</item>
</string-array>
<string-array name="country_codes" translatable="false">
<item>AF</item>
<item>AX</item>
<item>AL</item>
<item>DZ</item>
<item>AS</item>
<item>AD</item>
<item>AO</item>
<item>AI</item>
<item>AQ</item>
<item>AG</item>
<item>AR</item>
<item>AM</item>
<item>AW</item>
<item>AU</item>
<item>AT</item>
<item>AZ</item>
<item>BS</item>
<item>BH</item>
<item>BD</item>
<item>BB</item>
<item>BY</item>
<item>BE</item>
<item>BZ</item>
<item>BJ</item>
<item>BM</item>
<item>BT</item>
<item>BO</item>
<item>BA</item>
<item>BW</item>
<item>BV</item>
<item>BR</item>
<item>VG</item>
<item>IO</item>
<item>BN</item>
<item>BG</item>
<item>BF</item>
<item>BI</item>
<item>KH</item>
<item>CM</item>
<item>CA</item>
<item>CV</item>
<item>KY</item>
<item>CF</item>
<item>TD</item>
<item>CL</item>
<item>CN</item>
<item>HK</item>
<item>MO</item>
<item>CX</item>
<item>CC</item>
<item>CO</item>
<item>KM</item>
<item>CG</item>
<item>CD</item>
<item>CK</item>
<item>CR</item>
<item>CI</item>
<item>HR</item>
<item>CU</item>
<item>CY</item>
<item>CZ</item>
<item>DK</item>
<item>DJ</item>
<item>DM</item>
<item>DO</item>
<item>EC</item>
<item>EG</item>
<item>SV</item>
<item>GQ</item>
<item>ER</item>
<item>EE</item>
<item>ET</item>
<item>FK</item>
<item>FO</item>
<item>FJ</item>
<item>FI</item>
<item>FR</item>
<item>GF</item>
<item>PF</item>
<item>TF</item>
<item>GA</item>
<item>GM</item>
<item>GE</item>
<item>DE</item>
<item>GH</item>
<item>GI</item>
<item>GR</item>
<item>GL</item>
<item>GD</item>
<item>GP</item>
<item>GU</item>
<item>GT</item>
<item>GG</item>
<item>GN</item>
<item>GW</item>
<item>GY</item>
<item>HT</item>
<item>HM</item>
<item>VA</item>
<item>HN</item>
<item>HU</item>
<item>IS</item>
<item>IN</item>
<item>ID</item>
<item>IR</item>
<item>IQ</item>
<item>IE</item>
<item>IM</item>
<item>IL</item>
<item>IT</item>
<item>JM</item>
<item>JP</item>
<item>JE</item>
<item>JO</item>
<item>KZ</item>
<item>KE</item>
<item>KI</item>
<item>KP</item>
<item>KR</item>
<item>KW</item>
<item>KG</item>
<item>LA</item>
<item>LV</item>
<item>LB</item>
<item>LS</item>
<item>LR</item>
<item>LY</item>
<item>LI</item>
<item>LT</item>
<item>LU</item>
<item>MK</item>
<item>MG</item>
<item>MW</item>
<item>MY</item>
<item>MV</item>
<item>ML</item>
<item>MT</item>
<item>MH</item>
<item>MQ</item>
<item>MR</item>
<item>MU</item>
<item>YT</item>
<item>MX</item>
<item>FM</item>
<item>MD</item>
<item>MC</item>
<item>MN</item>
<item>ME</item>
<item>MS</item>
<item>MA</item>
<item>MZ</item>
<item>MM</item>
<item>NA</item>
<item>NR</item>
<item>NP</item>
<item>NL</item>
<item>AN</item>
<item>NC</item>
<item>NZ</item>
<item>NI</item>
<item>NE</item>
<item>NG</item>
<item>NU</item>
<item>NF</item>
<item>MP</item>
<item>NO</item>
<item>OM</item>
<item>PK</item>
<item>PW</item>
<item>PS</item>
<item>PA</item>
<item>PG</item>
<item>PY</item>
<item>PE</item>
<item>PH</item>
<item>PN</item>
<item>PL</item>
<item>PT</item>
<item>PR</item>
<item>QA</item>
<item>RE</item>
<item>RO</item>
<item>RU</item>
<item>RW</item>
<item>BL</item>
<item>SH</item>
<item>KN</item>
<item>LC</item>
<item>MF</item>
<item>PM</item>
<item>VC</item>
<item>WS</item>
<item>SM</item>
<item>ST</item>
<item>SA</item>
<item>SN</item>
<item>RS</item>
<item>SC</item>
<item>SL</item>
<item>SG</item>
<item>SK</item>
<item>SI</item>
<item>SB</item>
<item>SO</item>
<item>ZA</item>
<item>GS</item>
<item>SS</item>
<item>ES</item>
<item>LK</item>
<item>SD</item>
<item>SR</item>
<item>SJ</item>
<item>SZ</item>
<item>SE</item>
<item>CH</item>
<item>SY</item>
<item>TW</item>
<item>TJ</item>
<item>TZ</item>
<item>TH</item>
<item>TL</item>
<item>TG</item>
<item>TK</item>
<item>TO</item>
<item>TT</item>
<item>TN</item>
<item>TR</item>
<item>TM</item>
<item>TC</item>
<item>TV</item>
<item>UG</item>
<item>UA</item>
<item>AE</item>
<item>GB</item>
<item>US</item>
<item>UM</item>
<item>UY</item>
<item>UZ</item>
<item>VU</item>
<item>VE</item>
<item>VN</item>
<item>VI</item>
<item>WF</item>
<item>EH</item>
<item>YE</item>
<item>ZM</item>
<item>ZW</item>
</string-array>
</resources> </resources>

View File

@ -83,6 +83,7 @@
<string name="show_hold_to_append_title">Show Hold to Append Tip</string> <string name="show_hold_to_append_title">Show Hold to Append Tip</string>
<string name="show_hold_to_append_summary">Show tip when background or popup button is pressed on video details page</string> <string name="show_hold_to_append_summary">Show tip when background or popup button is pressed on video details page</string>
<string name="url_not_supported_toast">URL not supported</string> <string name="url_not_supported_toast">URL not supported</string>
<string name="default_content_country_title">Default content country</string>
<string name="search_language_title">Default content language</string> <string name="search_language_title">Default content language</string>
<string name="settings_category_player_title">Player</string> <string name="settings_category_player_title">Player</string>
<string name="settings_category_player_behavior_title">Behavior</string> <string name="settings_category_player_behavior_title">Behavior</string>
@ -124,6 +125,11 @@
<string name="unknown_content">[Unknown]</string> <string name="unknown_content">[Unknown]</string>
<string name="toggle_orientation">Toggle Orientation</string>
<string name="switch_to_background">Switch to Background</string>
<string name="switch_to_popup">Switch to Popup</string>
<string name="switch_to_main">Switch to Main</string>
<!-- error strings --> <!-- error strings -->
<string name="general_error">Error</string> <string name="general_error">Error</string>
<string name="network_error">Network error</string> <string name="network_error">Network error</string>

View File

@ -3,6 +3,15 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/content"> android:title="@string/content">
<ListPreference
android:defaultValue="@string/default_country_value"
android:entries="@array/country_names"
android:entryValues="@array/country_codes"
android:key="@string/content_country_key"
android:summary="%s"
android:title="@string/default_content_country_title"/>
<!-- TODO: add support for this within code
<ListPreference <ListPreference
android:defaultValue="@string/default_language_value" android:defaultValue="@string/default_language_value"
android:entries="@array/language_names" android:entries="@array/language_names"
@ -10,6 +19,7 @@
android:key="@string/search_language_key" android:key="@string/search_language_key"
android:summary="%s" android:summary="%s"
android:title="@string/search_language_title"/> android:title="@string/search_language_title"/>
-->
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"

4
fixplurals.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
javac CheckTranslations.java
find app/src -name "*.xml" | grep values | xargs java CheckTranslations -d -r