Skip to content

Commit ed2c8e9

Browse files
Merge branch 'refactor' into Video-description-compose
# Conflicts: # app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java # app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java # app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelAboutFragment.java
2 parents ef29fb6 + 2915ab6 commit ed2c8e9

File tree

205 files changed

+5709
-4503
lines changed

Some content is hidden

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

205 files changed

+5709
-4503
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ jobs:
7272
- api-level: 21
7373
target: default
7474
arch: x86
75-
- api-level: 33
76-
target: google_apis # emulator API 33 only exists with Google APIs
75+
- api-level: 35
76+
target: default
7777
arch: x86_64
7878

7979
permissions:
@@ -111,6 +111,7 @@ jobs:
111111
path: app/build/reports/androidTests/connected/**
112112

113113
sonar:
114+
if: ${{ false }} # the key has expired and needs to be regenerated by the sonar admins
114115
runs-on: ubuntu-latest
115116

116117
permissions:

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
<h3 align="center">We are planning to <i>rewrite</i> large chunks of the codebase, to bring about <a href="https://github.com/TeamNewPipe/NewPipe/discussions/10118">a new, modern and stable NewPipe</a>!</h3>
2-
<h4 align="center">Please do <b>not</b> open pull requests for <i>new features</i> now, only bugfix PRs will be accepted.</h4>
1+
<h3 align="center">We are <i>rewriting</i> large chunks of the codebase, to bring about <a href="https://newpipe.net/blog/pinned/announcement/newpipe-0.27.6-rewrite-team-states/#the-refactor">a modern and stable NewPipe</a>! You can download nightly builds <a href="https://github.com/TeamNewPipe/NewPipe-refactor-nightly/releases">here</a>.</h3>
2+
<h4 align="center">Please work on the <code>refactor</code> branch if you want to contribute <i>new features</i>. The current codebase is in maintenance mode and will only receive <i>bugfixes</i>.</h4>
33

44
<p align="center"><a href="https://newpipe.net"><img src="assets/new_pipe_icon_5.png" width="150"></a></p>
55
<h2 align="center"><b>NewPipe</b></h2>
66
<h4 align="center">A libre lightweight streaming front-end for Android.</h4>
77

8-
<p align="center"><a href="https://f-droid.org/packages/org.schabi.newpipe/"><img src="https://fdroid.gitlab.io/artwork/badge/get-it-on-en.svg" alt="Get it on F-Droid" height=80/></a></p>
8+
<p align="center"><a href="https://f-droid.org/packages/org.schabi.newpipe/"><img src="https://fdroid.gitlab.io/artwork/badge/get-it-on-en.svg" alt="Get it on F-Droid" width=206/></a></p>
99

1010
<p align="center">
11-
<a href="https://github.com/TeamNewPipe/NewPipe/releases" alt="GitHub release"><img src="https://img.shields.io/github/release/TeamNewPipe/NewPipe.svg" ></a>
11+
<a href="https://github.com/TeamNewPipe/NewPipe/releases" alt="GitHub NewPipe releases"><img src="https://img.shields.io/github/release/TeamNewPipe/NewPipe.svg" ></a>
12+
<a href="https://github.com/TeamNewPipe/NewPipe-nightly/releases" alt="GitHub NewPipe nightly releases"><img src="https://img.shields.io/github/release/TeamNewPipe/NewPipe-nightly.svg?labelColor=purple&label=dev%20nightly"></a>
13+
<a href="https://github.com/TeamNewPipe/NewPipe-refactor-nightly/releases" alt="GitHub NewPipe refactor nightly releases"><img src="https://img.shields.io/github/release/TeamNewPipe/NewPipe-refactor-nightly.svg?labelColor=purple&label=refactor%20nightly"></a>
1214
<a href="https://www.gnu.org/licenses/gpl-3.0" alt="License: GPLv3"><img src="https://img.shields.io/badge/License-GPL%20v3-blue.svg"></a>
13-
<a href="https://github.com/TeamNewPipe/NewPipe/actions" alt="Build Status"><img src="https://github.com/TeamNewPipe/NewPipe/workflows/CI/badge.svg?branch=dev&event=push"></a>
15+
<a href="https://github.com/TeamNewPipe/NewPipe/actions" alt="Build Status"><img src="https://github.com/TeamNewPipe/NewPipe/actions/workflows/ci.yml/badge.svg?branch=dev&event=push"></a>
1416
<a href="https://hosted.weblate.org/engage/newpipe/" alt="Translation Status"><img src="https://hosted.weblate.org/widgets/newpipe/-/svg-badge.svg"></a>
17+
</p>
18+
19+
<p align="center">
1520
<a href="https://web.libera.chat/#newpipe" alt="IRC channel: #newpipe"><img src="https://img.shields.io/badge/IRC%20chat-%23newpipe-brightgreen.svg"></a>
1621
<a href="https://matrix.to/#/#newpipe:matrix.newpipe-ev.de" alt="Matrix channel: #newpipe"><img src="https://img.shields.io/badge/Matrix%20chat-%23newpipe-blue"></a>
1722
</p>
23+
1824
<hr>
1925
<p align="center"><a href="#screenshots">Screenshots</a> &bull; <a href="#supported-services">Supported Services</a> &bull; <a href="#description">Description</a> &bull; <a href="#features">Features</a> &bull; <a href="#installation-and-updates">Installation and updates</a> &bull; <a href="#contribution">Contribution</a> &bull; <a href="#donate">Donate</a> &bull; <a href="#license">License</a></p>
2026
<p align="center"><a href="https://newpipe.net">Website</a> &bull; <a href="https://newpipe.net/blog/">Blog</a> &bull; <a href="https://newpipe.net/FAQ/">FAQ</a> &bull; <a href="https://newpipe.net/press/">Press</a></p>

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ plugins {
1717
}
1818

1919
android {
20-
compileSdk 35
20+
compileSdk 36
2121
namespace 'org.schabi.newpipe'
2222

2323
defaultConfig {
2424
applicationId "org.schabi.newpipe"
2525
resValue "string", "app_name", "NewPipe"
2626
minSdk 21
27-
targetSdk 33
27+
targetSdk 35
2828
if (System.properties.containsKey('versionCodeOverride')) {
2929
versionCode System.getProperty('versionCodeOverride') as Integer
3030
} else {

app/src/main/AndroidManifest.xml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
1111
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
1212
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
13+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
1314
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
1415

1516
<!-- We need to be able to open links in the browser on API 30+ -->
@@ -58,6 +59,15 @@
5859
</intent-filter>
5960
</receiver>
6061

62+
<service
63+
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
64+
android:enabled="false"
65+
android:exported="false">
66+
<meta-data
67+
android:name="autoStoreLocales"
68+
android:value="true" />
69+
</service>
70+
6171
<service
6272
android:name=".player.PlayerService"
6373
android:exported="true"
@@ -95,7 +105,10 @@
95105
android:name="androidx.work.impl.foreground.SystemForegroundService"
96106
android:foregroundServiceType="dataSync"
97107
tools:node="merge" />
98-
<service android:name=".local.feed.service.FeedLoadService" />
108+
109+
<service
110+
android:name=".local.feed.service.FeedLoadService"
111+
android:foregroundServiceType="dataSync" />
99112

100113
<activity
101114
android:name=".PanicResponderActivity"
@@ -127,7 +140,9 @@
127140
android:label="@string/app_name"
128141
android:launchMode="singleTask" />
129142

130-
<service android:name="us.shandian.giga.service.DownloadManagerService" />
143+
<service
144+
android:name="us.shandian.giga.service.DownloadManagerService"
145+
android:foregroundServiceType="dataSync" />
131146

132147
<activity
133148
android:name=".util.FilePickerActivityHelper"

app/src/main/java/org/schabi/newpipe/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ open class App :
9797
Localization.getPreferredLocalization(this),
9898
Localization.getPreferredContentCountry(this),
9999
)
100-
Localization.initPrettyTime(Localization.resolvePrettyTime(this))
100+
Localization.initPrettyTime(Localization.resolvePrettyTime())
101101

102102
BridgeStateSaverInitializer.init(this)
103103
StateSaver.init(this)

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

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
package org.schabi.newpipe;
2222

23-
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
24-
2523
import android.content.BroadcastReceiver;
2624
import android.content.Context;
2725
import android.content.Intent;
@@ -49,6 +47,7 @@
4947
import androidx.appcompat.app.ActionBarDrawerToggle;
5048
import androidx.appcompat.app.AppCompatActivity;
5149
import androidx.core.app.ActivityCompat;
50+
import androidx.core.content.ContextCompat;
5251
import androidx.core.view.GravityCompat;
5352
import androidx.drawerlayout.widget.DrawerLayout;
5453
import androidx.fragment.app.Fragment;
@@ -76,6 +75,7 @@
7675
import org.schabi.newpipe.player.event.OnKeyDownListener;
7776
import org.schabi.newpipe.player.helper.PlayerHolder;
7877
import org.schabi.newpipe.player.playqueue.PlayQueue;
78+
import org.schabi.newpipe.settings.SettingMigrations;
7979
import org.schabi.newpipe.settings.UpdateSettingsFragment;
8080
import org.schabi.newpipe.util.Constants;
8181
import org.schabi.newpipe.util.DeviceUtils;
@@ -122,7 +122,10 @@ public class MainActivity extends AppCompatActivity {
122122
private static final int ITEM_ID_ABOUT = 2;
123123

124124
private static final int ORDER = 0;
125+
public static final String KEY_IS_IN_BACKGROUND = "is_in_background";
125126

127+
private SharedPreferences sharedPreferences;
128+
private SharedPreferences.Editor sharedPrefEditor;
126129
/*//////////////////////////////////////////////////////////////////////////
127130
// Activity's LifeCycle
128131
//////////////////////////////////////////////////////////////////////////*/
@@ -134,6 +137,7 @@ protected void onCreate(final Bundle savedInstanceState) {
134137
+ "savedInstanceState = [" + savedInstanceState + "]");
135138
}
136139

140+
Localization.migrateAppLanguageSettingIfNecessary(getApplicationContext());
137141
ThemeHelper.setDayNightMode(this);
138142
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
139143

@@ -150,8 +154,9 @@ protected void onCreate(final Bundle savedInstanceState) {
150154
}
151155
}
152156

153-
assureCorrectAppLanguage(this);
154157
super.onCreate(savedInstanceState);
158+
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
159+
sharedPrefEditor = sharedPreferences.edit();
155160

156161
mainBinding = ActivityMainBinding.inflate(getLayoutInflater());
157162
drawerLayoutBinding = mainBinding.drawerLayout;
@@ -187,24 +192,37 @@ protected void onCreate(final Bundle savedInstanceState) {
187192
UpdateSettingsFragment.askForConsentToUpdateChecks(this);
188193
}
189194

190-
Localization.migrateAppLanguageSettingIfNecessary(getApplicationContext());
195+
SettingMigrations.showUserInfoIfPresent(this);
191196
}
192197

193198
@Override
194199
protected void onPostCreate(final Bundle savedInstanceState) {
195200
super.onPostCreate(savedInstanceState);
196201

197202
final App app = App.getInstance();
198-
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(app);
199203

200-
if (prefs.getBoolean(app.getString(R.string.update_app_key), false)
201-
&& prefs.getBoolean(app.getString(R.string.update_check_consent_key), false)) {
204+
if (sharedPreferences.getBoolean(app.getString(R.string.update_app_key), false)
205+
&& sharedPreferences
206+
.getBoolean(app.getString(R.string.update_check_consent_key), false)) {
202207
// Start the worker which is checking all conditions
203208
// and eventually searching for a new version.
204209
NewVersionWorker.enqueueNewVersionCheckingWork(app, false);
205210
}
206211
}
207212

213+
@Override
214+
protected void onStart() {
215+
super.onStart();
216+
sharedPrefEditor.putBoolean(KEY_IS_IN_BACKGROUND, false).apply();
217+
Log.d(TAG, "App moved to foreground");
218+
}
219+
220+
@Override
221+
protected void onStop() {
222+
super.onStop();
223+
sharedPrefEditor.putBoolean(KEY_IS_IN_BACKGROUND, true).apply();
224+
Log.d(TAG, "App moved to background");
225+
}
208226
private void setupDrawer() throws ExtractionException {
209227
addDrawerMenuForCurrentService();
210228

@@ -480,9 +498,8 @@ protected void onDestroy() {
480498

481499
@Override
482500
protected void onResume() {
483-
assureCorrectAppLanguage(this);
484501
// Change the date format to match the selected language on resume
485-
Localization.initPrettyTime(Localization.resolvePrettyTime(getApplicationContext()));
502+
Localization.initPrettyTime(Localization.resolvePrettyTime());
486503
super.onResume();
487504

488505
// Close drawer on return, and don't show animation,
@@ -504,21 +521,19 @@ protected void onResume() {
504521
ErrorUtil.showUiErrorSnackbar(this, "Setting up service toggle", e);
505522
}
506523

507-
final SharedPreferences sharedPreferences =
508-
PreferenceManager.getDefaultSharedPreferences(this);
509524
if (sharedPreferences.getBoolean(Constants.KEY_THEME_CHANGE, false)) {
510525
if (DEBUG) {
511526
Log.d(TAG, "Theme has changed, recreating activity...");
512527
}
513-
sharedPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, false).apply();
528+
sharedPrefEditor.putBoolean(Constants.KEY_THEME_CHANGE, false).apply();
514529
ActivityCompat.recreate(this);
515530
}
516531

517532
if (sharedPreferences.getBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false)) {
518533
if (DEBUG) {
519534
Log.d(TAG, "main page has changed, recreating main fragment...");
520535
}
521-
sharedPreferences.edit().putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false).apply();
536+
sharedPrefEditor.putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false).apply();
522537
NavigationHelper.openMainActivity(this);
523538
}
524539

@@ -833,7 +848,7 @@ private void openMiniPlayerUponPlayerStarted() {
833848
return;
834849
}
835850

836-
if (PlayerHolder.getInstance().isPlayerOpen()) {
851+
if (PlayerHolder.INSTANCE.isPlayerOpen()) {
837852
// if the player is already open, no need for a broadcast receiver
838853
openMiniPlayerIfMissing();
839854
} else {
@@ -843,7 +858,7 @@ private void openMiniPlayerUponPlayerStarted() {
843858
public void onReceive(final Context context, final Intent intent) {
844859
if (Objects.equals(intent.getAction(),
845860
VideoDetailFragment.ACTION_PLAYER_STARTED)
846-
&& PlayerHolder.getInstance().isPlayerOpen()) {
861+
&& PlayerHolder.INSTANCE.isPlayerOpen()) {
847862
openMiniPlayerIfMissing();
848863
// At this point the player is added 100%, we can unregister. Other actions
849864
// are useless since the fragment will not be removed after that.
@@ -854,11 +869,12 @@ public void onReceive(final Context context, final Intent intent) {
854869
};
855870
final IntentFilter intentFilter = new IntentFilter();
856871
intentFilter.addAction(VideoDetailFragment.ACTION_PLAYER_STARTED);
857-
registerReceiver(broadcastReceiver, intentFilter);
872+
ContextCompat.registerReceiver(this, broadcastReceiver, intentFilter,
873+
ContextCompat.RECEIVER_EXPORTED);
858874

859875
// If the PlayerHolder is not bound yet, but the service is running, try to bind to it.
860876
// Once the connection is established, the ACTION_PLAYER_STARTED will be sent.
861-
PlayerHolder.getInstance().tryBindIfNeeded(this);
877+
PlayerHolder.INSTANCE.tryBindIfNeeded(this);
862878
}
863879
}
864880

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
import org.schabi.newpipe.util.Constants;
8585
import org.schabi.newpipe.util.DeviceUtils;
8686
import org.schabi.newpipe.util.ExtractorHelper;
87-
import org.schabi.newpipe.util.Localization;
8887
import org.schabi.newpipe.util.NavigationHelper;
8988
import org.schabi.newpipe.util.PermissionHelper;
9089
import org.schabi.newpipe.util.ThemeHelper;
@@ -132,7 +131,6 @@ protected void onCreate(final Bundle savedInstanceState) {
132131
ThemeHelper.setDayNightMode(this);
133132
setTheme(ThemeHelper.isLightThemeSelected(this)
134133
? R.style.RouterActivityThemeLight : R.style.RouterActivityThemeDark);
135-
Localization.assureCorrectAppLanguage(this);
136134

137135
// Pass-through touch events to background activities
138136
// so that our transparent window won't lock UI in the mean time
@@ -701,7 +699,7 @@ private boolean canHandleChoiceLikeShowInfo(final String selectedChoiceKey) {
701699
}
702700

703701
// ...the player is not running or in normal Video-mode/type
704-
final PlayerType playerType = PlayerHolder.getInstance().getType();
702+
final PlayerType playerType = PlayerHolder.INSTANCE.getType();
705703
return playerType == null || playerType == PlayerType.MAIN;
706704
}
707705

app/src/main/java/org/schabi/newpipe/about/AboutActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import org.schabi.newpipe.R
99
import org.schabi.newpipe.ui.components.common.ScaffoldWithToolbar
1010
import org.schabi.newpipe.ui.screens.AboutScreen
1111
import org.schabi.newpipe.ui.theme.AppTheme
12-
import org.schabi.newpipe.util.Localization
1312

1413
class AboutActivity : AppCompatActivity() {
1514
override fun onCreate(savedInstanceState: Bundle?) {
16-
Localization.assureCorrectAppLanguage(this)
1715
enableEdgeToEdge()
1816
super.onCreate(savedInstanceState)
1917

app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import us.shandian.giga.service.DownloadManagerService;
2121
import us.shandian.giga.ui.fragment.MissionsFragment;
2222

23-
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
24-
2523
public class DownloadActivity extends AppCompatActivity {
2624

2725
private static final String MISSIONS_FRAGMENT_TAG = "fragment_tag";
@@ -33,7 +31,6 @@ protected void onCreate(final Bundle savedInstanceState) {
3331
i.setClass(this, DownloadManagerService.class);
3432
startService(i);
3533

36-
assureCorrectAppLanguage(this);
3734
ThemeHelper.setTheme(this);
3835

3936
super.onCreate(savedInstanceState);

app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static org.schabi.newpipe.extractor.stream.DeliveryMethod.PROGRESSIVE_HTTP;
44
import static org.schabi.newpipe.util.ListHelper.getStreamsOfSpecifiedDelivery;
5-
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
65

76
import android.app.Activity;
87
import android.content.ComponentName;
@@ -751,7 +750,6 @@ private String getNameEditText() {
751750
}
752751

753752
private void showFailedDialog(@StringRes final int msg) {
754-
assureCorrectAppLanguage(requireContext());
755753
new AlertDialog.Builder(context)
756754
.setTitle(R.string.general_error)
757755
.setMessage(msg)

0 commit comments

Comments
 (0)