Skip to content

Commit 49c3299

Browse files
Merge branch 'dev' into Core-i18n
# Conflicts: # app/src/main/res/values-ar-rLY/strings.xml # app/src/main/res/values-ar/strings.xml # app/src/main/res/values-be/strings.xml # app/src/main/res/values-ber/strings.xml # app/src/main/res/values-bg/strings.xml # app/src/main/res/values-bn/strings.xml # app/src/main/res/values-ckb/strings.xml # app/src/main/res/values-cs/strings.xml # app/src/main/res/values-da/strings.xml # app/src/main/res/values-el/strings.xml # app/src/main/res/values-eo/strings.xml # app/src/main/res/values-et/strings.xml # app/src/main/res/values-fa/strings.xml # app/src/main/res/values-fi/strings.xml # app/src/main/res/values-gl/strings.xml # app/src/main/res/values-he/strings.xml # app/src/main/res/values-hi/strings.xml # app/src/main/res/values-hu/strings.xml # app/src/main/res/values-is/strings.xml # app/src/main/res/values-ko/strings.xml # app/src/main/res/values-ku/strings.xml # app/src/main/res/values-lt/strings.xml # app/src/main/res/values-mk/strings.xml # app/src/main/res/values-ms/strings.xml # app/src/main/res/values-ne/strings.xml # app/src/main/res/values-nl-rBE/strings.xml # app/src/main/res/values-or/strings.xml # app/src/main/res/values-pa/strings.xml # app/src/main/res/values-sat/strings.xml # app/src/main/res/values-sv/strings.xml # app/src/main/res/values-te/strings.xml # app/src/main/res/values-th/strings.xml # app/src/main/res/values-ur/strings.xml # app/src/main/res/values-zh-rCN/strings.xml
2 parents 2a99cfe + ff3526b commit 49c3299

115 files changed

Lines changed: 825 additions & 481 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ android {
2323
if (System.properties.containsKey('versionCodeOverride')) {
2424
versionCode System.getProperty('versionCodeOverride') as Integer
2525
} else {
26-
versionCode 1004
26+
versionCode 1005
2727
}
28-
versionName "0.27.7"
28+
versionName "0.28.0"
2929
if (System.properties.containsKey('versionNameSuffix')) {
3030
versionNameSuffix System.getProperty('versionNameSuffix')
3131
}
@@ -214,7 +214,7 @@ dependencies {
214214
// the corresponding commit hash, since JitPack sometimes deletes artifacts.
215215
// If there’s already a git hash, just add more of it to the end (or remove a letter)
216216
// to cause jitpack to regenerate the artifact.
217-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:7adbc48a0aa872c016b8ec089e278d5e12772054'
217+
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.24.8'
218218
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
219219

220220
/** Checkstyle **/

app/src/main/java/org/schabi/newpipe/DownloaderImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
public final class DownloaderImpl extends Downloader {
3131
public static final String USER_AGENT =
32-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0";
32+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0";
3333
public static final String YOUTUBE_RESTRICTED_MODE_COOKIE_KEY =
3434
"youtube_restricted_mode_key";
3535
public static final String YOUTUBE_RESTRICTED_MODE_COOKIE = "PREF=f2=8000000";

app/src/main/java/org/schabi/newpipe/MainActivity.java

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
import org.schabi.newpipe.player.event.OnKeyDownListener;
8080
import org.schabi.newpipe.player.helper.PlayerHolder;
8181
import org.schabi.newpipe.player.playqueue.PlayQueue;
82-
import org.schabi.newpipe.settings.SettingMigrations;
8382
import org.schabi.newpipe.settings.UpdateSettingsFragment;
83+
import org.schabi.newpipe.settings.migration.MigrationManager;
8484
import org.schabi.newpipe.util.Constants;
8585
import org.schabi.newpipe.util.DeviceUtils;
8686
import org.schabi.newpipe.util.KioskTranslator;
@@ -196,7 +196,7 @@ protected void onCreate(final Bundle savedInstanceState) {
196196
UpdateSettingsFragment.askForConsentToUpdateChecks(this);
197197
}
198198

199-
SettingMigrations.showUserInfoIfPresent(this);
199+
MigrationManager.showUserInfoIfPresent(this);
200200
}
201201

202202
@Override
@@ -264,19 +264,6 @@ public void onDrawerClosed(final View drawerView) {
264264
*/
265265
private void addDrawerMenuForCurrentService() throws ExtractionException {
266266
//Tabs
267-
final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
268-
final StreamingService service = NewPipe.getService(currentServiceId);
269-
270-
int kioskMenuItemId = 0;
271-
272-
for (final String ks : service.getKioskList().getAvailableKiosks()) {
273-
drawerLayoutBinding.navigation.getMenu()
274-
.add(R.id.menu_tabs_group, kioskMenuItemId, 0, KioskTranslator
275-
.getTranslatedKioskName(ks, this))
276-
.setIcon(KioskTranslator.getKioskIcon(ks));
277-
kioskMenuItemId++;
278-
}
279-
280267
drawerLayoutBinding.navigation.getMenu()
281268
.add(R.id.menu_tabs_group, ITEM_ID_SUBSCRIPTIONS, ORDER,
282269
R.string.tab_subscriptions)
@@ -294,6 +281,20 @@ private void addDrawerMenuForCurrentService() throws ExtractionException {
294281
.add(R.id.menu_tabs_group, ITEM_ID_HISTORY, ORDER, R.string.action_history)
295282
.setIcon(R.drawable.ic_history);
296283

284+
//Kiosks
285+
final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
286+
final StreamingService service = NewPipe.getService(currentServiceId);
287+
288+
int kioskMenuItemId = 0;
289+
290+
for (final String ks : service.getKioskList().getAvailableKiosks()) {
291+
drawerLayoutBinding.navigation.getMenu()
292+
.add(R.id.menu_kiosks_group, kioskMenuItemId, 0, KioskTranslator
293+
.getTranslatedKioskName(ks, this))
294+
.setIcon(KioskTranslator.getKioskIcon(ks));
295+
kioskMenuItemId++;
296+
}
297+
297298
//Settings and About
298299
drawerLayoutBinding.navigation.getMenu()
299300
.add(R.id.menu_options_about_group, ITEM_ID_SETTINGS, ORDER, R.string.settings)
@@ -313,10 +314,13 @@ private boolean drawerItemSelected(final MenuItem item) {
313314
changeService(item);
314315
break;
315316
case R.id.menu_tabs_group:
317+
tabSelected(item);
318+
break;
319+
case R.id.menu_kiosks_group:
316320
try {
317-
tabSelected(item);
321+
kioskSelected(item);
318322
} catch (final Exception e) {
319-
ErrorUtil.showUiErrorSnackbar(this, "Selecting main page tab", e);
323+
ErrorUtil.showUiErrorSnackbar(this, "Selecting drawer kiosk", e);
320324
}
321325
break;
322326
case R.id.menu_options_about_group:
@@ -340,7 +344,7 @@ private void changeService(final MenuItem item) {
340344
.setChecked(true);
341345
}
342346

343-
private void tabSelected(final MenuItem item) throws ExtractionException {
347+
private void tabSelected(final MenuItem item) {
344348
switch (item.getItemId()) {
345349
case ITEM_ID_SUBSCRIPTIONS:
346350
NavigationHelper.openSubscriptionFragment(getSupportFragmentManager());
@@ -357,18 +361,19 @@ private void tabSelected(final MenuItem item) throws ExtractionException {
357361
case ITEM_ID_HISTORY:
358362
NavigationHelper.openStatisticFragment(getSupportFragmentManager());
359363
break;
360-
default:
361-
final StreamingService currentService = ServiceHelper.getSelectedService(this);
362-
int kioskMenuItemId = 0;
363-
for (final String kioskId : currentService.getKioskList().getAvailableKiosks()) {
364-
if (kioskMenuItemId == item.getItemId()) {
365-
NavigationHelper.openKioskFragment(getSupportFragmentManager(),
366-
currentService.getServiceId(), kioskId);
367-
break;
368-
}
369-
kioskMenuItemId++;
370-
}
364+
}
365+
}
366+
367+
private void kioskSelected(final MenuItem item) throws ExtractionException {
368+
final StreamingService currentService = ServiceHelper.getSelectedService(this);
369+
int kioskMenuItemId = 0;
370+
for (final String kioskId : currentService.getKioskList().getAvailableKiosks()) {
371+
if (kioskMenuItemId == item.getItemId()) {
372+
NavigationHelper.openKioskFragment(getSupportFragmentManager(),
373+
currentService.getServiceId(), kioskId);
371374
break;
375+
}
376+
kioskMenuItemId++;
372377
}
373378
}
374379

@@ -409,6 +414,7 @@ private void toggleServices() {
409414

410415
drawerLayoutBinding.navigation.getMenu().removeGroup(R.id.menu_services_group);
411416
drawerLayoutBinding.navigation.getMenu().removeGroup(R.id.menu_tabs_group);
417+
drawerLayoutBinding.navigation.getMenu().removeGroup(R.id.menu_kiosks_group);
412418
drawerLayoutBinding.navigation.getMenu().removeGroup(R.id.menu_options_about_group);
413419

414420
// Show up or down arrow

app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,15 +1089,25 @@ private void handleSearchSuggestion() {
10891089
public void handleNextItems(final ListExtractor.InfoItemsPage<?> result) {
10901090
showListFooter(false);
10911091
infoListAdapter.addInfoItemList(result.getItems());
1092-
nextPage = result.getNextPage();
10931092

1094-
if (!result.getErrors().isEmpty() && nextPage != null) {
1095-
showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED,
1096-
"\"" + searchString + "\" → pageUrl: " + nextPage.getUrl() + ", "
1097-
+ "pageIds: " + nextPage.getIds() + ", "
1098-
+ "pageCookies: " + nextPage.getCookies(),
1099-
serviceId));
1093+
if (!result.getErrors().isEmpty()) {
1094+
// nextPage should be non-null at this point, because it refers to the page
1095+
// whose results are handled here, but let's check it anyway
1096+
if (nextPage == null) {
1097+
showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED,
1098+
"\"" + searchString + "\" → nextPage == null", serviceId));
1099+
} else {
1100+
showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED,
1101+
"\"" + searchString + "\" → pageUrl: " + nextPage.getUrl() + ", "
1102+
+ "pageIds: " + nextPage.getIds() + ", "
1103+
+ "pageCookies: " + nextPage.getCookies(),
1104+
serviceId));
1105+
}
11001106
}
1107+
1108+
// keep the reassignment of nextPage after the error handling to ensure that nextPage
1109+
// still holds the correct value during the error handling
1110+
nextPage = result.getNextPage();
11011111
super.handleNextItems(result);
11021112
}
11031113

app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java

Lines changed: 63 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
3434
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode;
3535
import com.google.android.exoplayer2.ui.CaptionStyleCompat;
36-
import com.google.android.exoplayer2.util.MimeTypes;
3736

3837
import org.schabi.newpipe.R;
3938
import org.schabi.newpipe.extractor.InfoItem;
40-
import org.schabi.newpipe.extractor.MediaFormat;
4139
import org.schabi.newpipe.extractor.stream.StreamInfo;
4240
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
4341
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
@@ -47,13 +45,14 @@
4745
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
4846
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
4947
import org.schabi.newpipe.util.ListHelper;
48+
import org.schabi.newpipe.util.Localization;
5049

5150
import java.lang.annotation.Retention;
5251
import java.text.DecimalFormat;
52+
import java.text.DecimalFormatSymbols;
5353
import java.text.NumberFormat;
5454
import java.util.ArrayList;
5555
import java.util.Collections;
56-
import java.util.Formatter;
5756
import java.util.HashSet;
5857
import java.util.List;
5958
import java.util.Locale;
@@ -62,11 +61,7 @@
6261
import java.util.concurrent.TimeUnit;
6362

6463
public final class PlayerHelper {
65-
private static final StringBuilder STRING_BUILDER = new StringBuilder();
66-
private static final Formatter STRING_FORMATTER =
67-
new Formatter(STRING_BUILDER, Locale.getDefault());
68-
private static final NumberFormat SPEED_FORMATTER = new DecimalFormat("0.##x");
69-
private static final NumberFormat PITCH_FORMATTER = new DecimalFormat("##%");
64+
private static final FormattersProvider FORMATTERS_PROVIDER = new FormattersProvider();
7065

7166
@Retention(SOURCE)
7267
@IntDef({AUTOPLAY_TYPE_ALWAYS, AUTOPLAY_TYPE_WIFI,
@@ -89,9 +84,11 @@ public final class PlayerHelper {
8984
private PlayerHelper() {
9085
}
9186

92-
////////////////////////////////////////////////////////////////////////////
93-
// Exposed helpers
94-
////////////////////////////////////////////////////////////////////////////
87+
// region Exposed helpers
88+
89+
public static void resetFormat() {
90+
FORMATTERS_PROVIDER.reset();
91+
}
9592

9693
@NonNull
9794
public static String getTimeString(final int milliSeconds) {
@@ -100,35 +97,24 @@ public static String getTimeString(final int milliSeconds) {
10097
final int hours = (milliSeconds % 86400000) / 3600000;
10198
final int days = (milliSeconds % (86400000 * 7)) / 86400000;
10299

103-
STRING_BUILDER.setLength(0);
104-
return (days > 0
105-
? STRING_FORMATTER.format("%d:%02d:%02d:%02d", days, hours, minutes, seconds)
106-
: hours > 0
107-
? STRING_FORMATTER.format("%d:%02d:%02d", hours, minutes, seconds)
108-
: STRING_FORMATTER.format("%02d:%02d", minutes, seconds)
109-
).toString();
100+
final Formatters formatters = FORMATTERS_PROVIDER.formatters();
101+
if (days > 0) {
102+
return formatters.stringFormat("%d:%02d:%02d:%02d", days, hours, minutes, seconds);
103+
}
104+
105+
return hours > 0
106+
? formatters.stringFormat("%d:%02d:%02d", hours, minutes, seconds)
107+
: formatters.stringFormat("%02d:%02d", minutes, seconds);
110108
}
111109

112110
@NonNull
113111
public static String formatSpeed(final double speed) {
114-
return SPEED_FORMATTER.format(speed);
112+
return FORMATTERS_PROVIDER.formatters().speed().format(speed);
115113
}
116114

117115
@NonNull
118116
public static String formatPitch(final double pitch) {
119-
return PITCH_FORMATTER.format(pitch);
120-
}
121-
122-
@NonNull
123-
public static String subtitleMimeTypesOf(@NonNull final MediaFormat format) {
124-
switch (format) {
125-
case VTT:
126-
return MimeTypes.TEXT_VTT;
127-
case TTML:
128-
return MimeTypes.APPLICATION_TTML;
129-
default:
130-
throw new IllegalArgumentException("Unrecognized mime type: " + format.name());
131-
}
117+
return FORMATTERS_PROVIDER.formatters().pitch().format(pitch);
132118
}
133119

134120
@NonNull
@@ -219,9 +205,8 @@ public static PlayQueue autoQueueOf(@NonNull final StreamInfo info,
219205
? null : getAutoQueuedSinglePlayQueue(autoQueueItems.get(0));
220206
}
221207

222-
////////////////////////////////////////////////////////////////////////////
223-
// Settings Resolution
224-
////////////////////////////////////////////////////////////////////////////
208+
// endregion
209+
// region Resolution
225210

226211
public static boolean isResumeAfterAudioFocusGain(@NonNull final Context context) {
227212
return getPreferences(context)
@@ -405,9 +390,8 @@ public static int getProgressiveLoadIntervalBytes(@NonNull final Context context
405390
return Integer.parseInt(preferredIntervalBytes) * 1024;
406391
}
407392

408-
////////////////////////////////////////////////////////////////////////////
409-
// Private helpers
410-
////////////////////////////////////////////////////////////////////////////
393+
// endregion
394+
// region Private helpers
411395

412396
@NonNull
413397
private static SharedPreferences getPreferences(@NonNull final Context context) {
@@ -427,9 +411,8 @@ private static SinglePlayQueue getAutoQueuedSinglePlayQueue(
427411
}
428412

429413

430-
////////////////////////////////////////////////////////////////////////////
431-
// Utils used by player
432-
////////////////////////////////////////////////////////////////////////////
414+
// endregion
415+
// region Utils used by player
433416

434417
@RepeatMode
435418
public static int nextRepeatMode(@RepeatMode final int repeatMode) {
@@ -503,4 +486,43 @@ public static int retrieveSeekDurationFromPreferences(final Player player) {
503486
player.getContext().getString(R.string.seek_duration_key),
504487
player.getContext().getString(R.string.seek_duration_default_value))));
505488
}
489+
490+
// endregion
491+
// region Format
492+
493+
static class FormattersProvider {
494+
private Formatters formatters;
495+
496+
public Formatters formatters() {
497+
if (formatters == null) {
498+
formatters = Formatters.create();
499+
}
500+
return formatters;
501+
}
502+
503+
public void reset() {
504+
formatters = null;
505+
}
506+
}
507+
508+
record Formatters(
509+
Locale locale,
510+
NumberFormat speed,
511+
NumberFormat pitch) {
512+
513+
static Formatters create() {
514+
final Locale locale = Localization.getAppLocale();
515+
final DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale);
516+
return new Formatters(
517+
locale,
518+
new DecimalFormat("0.##x", dfs),
519+
new DecimalFormat("##%", dfs));
520+
}
521+
522+
String stringFormat(final String format, final Object... args) {
523+
return String.format(locale, format, args);
524+
}
525+
}
526+
527+
// endregion
506528
}

app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.schabi.newpipe.DownloaderImpl;
1717
import org.schabi.newpipe.R;
1818
import org.schabi.newpipe.extractor.NewPipe;
19+
import org.schabi.newpipe.player.helper.PlayerHelper;
1920
import org.schabi.newpipe.util.Localization;
2021
import org.schabi.newpipe.util.image.ImageStrategy;
2122
import org.schabi.newpipe.util.image.PicassoHelper;
@@ -107,5 +108,6 @@ public void onDestroy() {
107108
NewPipe.setupLocalization(
108109
Localization.getPreferredLocalization(context),
109110
Localization.getPreferredContentCountry(context));
111+
PlayerHelper.resetFormat();
110112
}
111113
}

0 commit comments

Comments
 (0)