Merge branch 'dev' of github.com:teamnewpipe/NewPipe into dev
This commit is contained in:
commit
6dde524d2c
6 changed files with 49 additions and 13 deletions
|
@ -17,7 +17,8 @@ public final class CheckTranslations {
|
||||||
private static boolean remove = false;
|
private static boolean remove = false;
|
||||||
private static int checks = 0;
|
private static int checks = 0;
|
||||||
private static int matches = 0;
|
private static int matches = 0;
|
||||||
private static Pattern p, e;
|
private static int changes = 0;
|
||||||
|
private static Pattern p, pb, pe, e, o;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search translated strings.xml files for empty item / plural tags
|
* Search translated strings.xml files for empty item / plural tags
|
||||||
|
@ -56,7 +57,10 @@ public final class CheckTranslations {
|
||||||
}
|
}
|
||||||
|
|
||||||
p = Pattern.compile("(<item quantity=\")(zero|one|two|three|few|many|other)(\"></item>|\"/>)");
|
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})");
|
e = Pattern.compile("(<string[\\sa-z_\\\"=]*)((><\\/string>|\\/>){1})");
|
||||||
|
o = Pattern.compile("(<item quantity=\"other\">)[^</>]*(<\\/item>)");
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
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")) {
|
if (!args[i].equals("-d") && !args[i].equals("-p") && !args[i].equals("-e") && !args[i].equals("-r")) {
|
||||||
|
@ -73,7 +77,9 @@ public final class CheckTranslations {
|
||||||
|
|
||||||
System.out.println(checks + " files were checked.");
|
System.out.println(checks + " files were checked.");
|
||||||
System.out.println(matches + " corrupt lines detected.");
|
System.out.println(matches + " corrupt lines detected.");
|
||||||
if (remove) System.out.println(matches + " corrupt lines removed.");
|
if (remove) {
|
||||||
|
System.out.println(matches + " corrupt lines removed and " + changes + " lines fixed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +107,8 @@ public final class CheckTranslations {
|
||||||
|
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<String>();
|
||||||
boolean checkFailed = false;
|
boolean checkFailed = false;
|
||||||
|
boolean otherDetected = false;
|
||||||
|
boolean inPlurals = false;
|
||||||
try (BufferedReader br = new BufferedReader(new FileReader(f))) {
|
try (BufferedReader br = new BufferedReader(new FileReader(f))) {
|
||||||
String line;
|
String line;
|
||||||
int ln = 0;
|
int ln = 0;
|
||||||
|
@ -120,6 +127,38 @@ public final class CheckTranslations {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
br.close();
|
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) {
|
if (remove && checkFailed) {
|
||||||
Files.write(f.toPath(), lines, Charset.forName("UTF-8"));
|
Files.write(f.toPath(), lines, Charset.forName("UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,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;
|
||||||
|
@ -252,9 +253,10 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
|
||||||
startActivity(Intent.createChooser(intent, activity.getString(R.string.share_dialog_title)));
|
startActivity(Intent.createChooser(intent, activity.getString(R.string.share_dialog_title)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void shareUrl(String url) {
|
protected void shareUrl(String subject, String url) {
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
|
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, url);
|
intent.putExtra(Intent.EXTRA_TEXT, url);
|
||||||
startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title)));
|
startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -623,12 +623,7 @@ 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) {
|
|
||||||
shareUrl(info.getUrl());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
actionBarHandler.setOnOpenInBrowserListener(new ActionBarHandler.OnActionListener() {
|
actionBarHandler.setOnOpenInBrowserListener(new ActionBarHandler.OnActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -231,7 +231,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
|
||||||
openUrlInBrowser(url);
|
openUrlInBrowser(url);
|
||||||
break;
|
break;
|
||||||
case R.id.menu_item_share: {
|
case R.id.menu_item_share: {
|
||||||
shareUrl(url);
|
shareUrl(name, url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -167,7 +167,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
||||||
openUrlInBrowser(url);
|
openUrlInBrowser(url);
|
||||||
break;
|
break;
|
||||||
case R.id.menu_item_share: {
|
case R.id.menu_item_share: {
|
||||||
shareUrl(url);
|
shareUrl(name, url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
javac CheckTranslations.java
|
javac CheckTranslations.java
|
||||||
find app/src -name "*.xml" | grep values | xargs java CheckTranslations -r
|
find app/src -name "*.xml" | grep values | xargs java CheckTranslations -d -r
|
||||||
|
|
Loading…
Reference in a new issue