Skip to content

Commit 501f4cc

Browse files
authored
Merge branch 'refactor' into Create_CommentSection_ErrorPanel
2 parents 36aac1c + d81b571 commit 501f4cc

101 files changed

Lines changed: 2022 additions & 1631 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.

.github/workflows/image-minimizer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ module.exports = async ({github, context}) => {
3333

3434
// Regex for finding images (simple variant) ![ALT_TEXT](https://*.githubusercontent.com/<number>/<variousHexStringsAnd->.<fileExtension>)
3535
const REGEX_USER_CONTENT_IMAGE_LOOKUP = /\!\[([^\]]*)\]\((https:\/\/[-a-z0-9]+\.githubusercontent\.com\/\d+\/[-0-9a-f]{32,512}\.(jpg|gif|png))\)/gm;
36-
const REGEX_ASSETS_IMAGE_LOCKUP = /\!\[([^\]]*)\]\((https:\/\/github\.com\/[-\w\d]+\/[-\w\d]+\/assets\/\d+\/[\-0-9a-f]{32,512})\)/gm;
36+
const REGEX_ASSETS_IMAGE_LOOKUP = /\!\[([^\]]*)\]\((https:\/\/github\.com\/(?:user-attachments\/assets|[-\w\d]+\/[-\w\d]+\/assets\/\d+)\/[\-0-9a-f]{32,512})\)/gm;
3737

3838
// Check if we found something
3939
let foundSimpleImages = REGEX_USER_CONTENT_IMAGE_LOOKUP.test(initialBody)
40-
|| REGEX_ASSETS_IMAGE_LOCKUP.test(initialBody);
40+
|| REGEX_ASSETS_IMAGE_LOOKUP.test(initialBody);
4141
if (!foundSimpleImages) {
4242
console.log('Found no simple images to process');
4343
return;
@@ -52,7 +52,7 @@ module.exports = async ({github, context}) => {
5252

5353
// Try to find and replace the images with minimized ones
5454
let newBody = await replaceAsync(initialBody, REGEX_USER_CONTENT_IMAGE_LOOKUP, minimizeAsync);
55-
newBody = await replaceAsync(newBody, REGEX_ASSETS_IMAGE_LOCKUP, minimizeAsync);
55+
newBody = await replaceAsync(newBody, REGEX_ASSETS_IMAGE_LOOKUP, minimizeAsync);
5656

5757
if (!wasMatchModified) {
5858
console.log('Nothing was modified. Skipping update');

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@
88
<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>
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">
13+
<img src="https://img.shields.io/github/release/TeamNewPipe/NewPipe-nightly.svg?labelColor=purple&label=dev%20nightly" >
14+
</a>
15+
<a href="https://github.com/TeamNewPipe/NewPipe-refactor-nightly/releases" alt="GitHub NewPipe refactor nightly releases">
16+
<img src="https://img.shields.io/github/release/TeamNewPipe/NewPipe-refactor-nightly.svg?labelColor=purple&label=refactor%20nightly" >
17+
</a>
1218
<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>
19+
<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>
1420
<a href="https://hosted.weblate.org/engage/newpipe/" alt="Translation Status"><img src="https://hosted.weblate.org/widgets/newpipe/-/svg-badge.svg"></a>
21+
</p>
22+
23+
<p align="center">
1524
<a href="https://web.libera.chat/#newpipe" alt="IRC channel: #newpipe"><img src="https://img.shields.io/badge/IRC%20chat-%23newpipe-brightgreen.svg"></a>
1625
<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>
1726
</p>
27+
1828
<hr>
1929
<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>
2030
<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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ plugins {
99
alias libs.plugins.kotlin.compose
1010
alias libs.plugins.kotlin.kapt
1111
alias libs.plugins.kotlin.parcelize
12+
alias libs.plugins.kotlinx.serialization
1213
alias libs.plugins.checkstyle
1314
alias libs.plugins.sonarqube
1415
alias libs.plugins.hilt
1516
alias libs.plugins.aboutlibraries
1617
}
1718

1819
android {
19-
compileSdk 34
20+
compileSdk 35
2021
namespace 'org.schabi.newpipe'
2122

2223
defaultConfig {
@@ -27,9 +28,9 @@ android {
2728
if (System.properties.containsKey('versionCodeOverride')) {
2829
versionCode System.getProperty('versionCodeOverride') as Integer
2930
} else {
30-
versionCode 1003
31+
versionCode 1004
3132
}
32-
versionName "0.27.6"
33+
versionName "0.27.7"
3334
if (System.properties.containsKey('versionNameSuffix')) {
3435
versionNameSuffix System.getProperty('versionNameSuffix')
3536
}
@@ -226,7 +227,6 @@ dependencies {
226227
implementation libs.androidx.fragment.compose
227228
implementation libs.androidx.lifecycle.livedata
228229
implementation libs.androidx.lifecycle.viewmodel
229-
implementation libs.androidx.localbroadcastmanager
230230
implementation libs.androidx.media
231231
implementation libs.androidx.preference
232232
implementation libs.androidx.recyclerview
@@ -319,6 +319,9 @@ dependencies {
319319
// Scroll
320320
implementation libs.lazycolumnscrollbar
321321

322+
// Kotlinx Serialization
323+
implementation libs.kotlinx.serialization.json
324+
322325
/** Debugging **/
323326
// Memory leak detection
324327
debugImplementation libs.leakcanary.object.watcher

app/proguard-rules.pro

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,18 @@
3434

3535
## For some reason NotificationModeConfigFragment wasn't kept (only referenced in a preference xml)
3636
-keep class org.schabi.newpipe.settings.notifications.** { *; }
37+
38+
## Keep Kotlinx Serialization classes
39+
-keepclassmembers class kotlinx.serialization.json.** {
40+
*** Companion;
41+
}
42+
-keepclasseswithmembers class kotlinx.serialization.json.** {
43+
kotlinx.serialization.KSerializer serializer(...);
44+
}
45+
-keep,includedescriptorclasses class org.schabi.newpipe.**$$serializer { *; }
46+
-keepclassmembers class org.schabi.newpipe.** {
47+
*** Companion;
48+
}
49+
-keepclasseswithmembers class org.schabi.newpipe.** {
50+
kotlinx.serialization.KSerializer serializer(...);
51+
}

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1010
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
1111
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
12+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
1213
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
1314

1415
<!-- We need to be able to open links in the browser on API 30+ -->
@@ -90,8 +91,10 @@
9091
android:exported="false"
9192
android:label="@string/title_activity_about" />
9293

93-
<service android:name=".local.subscription.services.SubscriptionsImportService" />
94-
<service android:name=".local.subscription.services.SubscriptionsExportService" />
94+
<service
95+
android:name="androidx.work.impl.foreground.SystemForegroundService"
96+
android:foregroundServiceType="dataSync"
97+
tools:node="merge" />
9598
<service android:name=".local.feed.service.FeedLoadService" />
9699

97100
<activity

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
//////////////////////////////////////////////////////////////////////////*/
@@ -152,6 +155,8 @@ protected void onCreate(final Bundle savedInstanceState) {
152155

153156
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;
@@ -195,16 +200,29 @@ 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

@@ -504,21 +522,19 @@ protected void onResume() {
504522
ErrorUtil.showUiErrorSnackbar(this, "Setting up service toggle", e);
505523
}
506524

507-
final SharedPreferences sharedPreferences =
508-
PreferenceManager.getDefaultSharedPreferences(this);
509525
if (sharedPreferences.getBoolean(Constants.KEY_THEME_CHANGE, false)) {
510526
if (DEBUG) {
511527
Log.d(TAG, "Theme has changed, recreating activity...");
512528
}
513-
sharedPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, false).apply();
529+
sharedPrefEditor.putBoolean(Constants.KEY_THEME_CHANGE, false).apply();
514530
ActivityCompat.recreate(this);
515531
}
516532

517533
if (sharedPreferences.getBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false)) {
518534
if (DEBUG) {
519535
Log.d(TAG, "main page has changed, recreating main fragment...");
520536
}
521-
sharedPreferences.edit().putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false).apply();
537+
sharedPrefEditor.putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false).apply();
522538
NavigationHelper.openMainActivity(this);
523539
}
524540

app/src/main/java/org/schabi/newpipe/database/subscription/SubscriptionDAO.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ abstract class SubscriptionDAO : BasicDAO<SubscriptionEntity> {
9090
internal abstract fun silentInsertAllInternal(entities: List<SubscriptionEntity>): List<Long>
9191

9292
@Transaction
93-
open fun upsertAll(entities: List<SubscriptionEntity>): List<SubscriptionEntity> {
93+
open fun upsertAll(entities: List<SubscriptionEntity>) {
9494
val insertUidList = silentInsertAllInternal(entities)
9595

9696
insertUidList.forEachIndexed { index: Int, uidFromInsert: Long ->
@@ -106,7 +106,5 @@ abstract class SubscriptionDAO : BasicDAO<SubscriptionEntity> {
106106
update(entity)
107107
}
108108
}
109-
110-
return entities
111109
}
112110
}

app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import androidx.core.app.NotificationCompat
1111
import androidx.core.app.NotificationManagerCompat
1212
import androidx.core.app.PendingIntentCompat
1313
import androidx.fragment.app.Fragment
14+
import androidx.preference.PreferenceManager
1415
import com.google.android.material.snackbar.Snackbar
16+
import org.schabi.newpipe.MainActivity
1517
import org.schabi.newpipe.R
1618

1719
/**
@@ -35,12 +37,20 @@ class ErrorUtil {
3537
* activity (since the workflow would be interrupted anyway in that case). So never use this
3638
* for background services.
3739
*
40+
* If the crashed occurred while the app was in the background open a notification instead
41+
*
3842
* @param context the context to use to start the new activity
3943
* @param errorInfo the error info to be reported
4044
*/
4145
@JvmStatic
4246
fun openActivity(context: Context, errorInfo: ErrorInfo) {
43-
context.startActivity(getErrorActivityIntent(context, errorInfo))
47+
if (PreferenceManager.getDefaultSharedPreferences(context)
48+
.getBoolean(MainActivity.KEY_IS_IN_BACKGROUND, true)
49+
) {
50+
createNotification(context, errorInfo)
51+
} else {
52+
context.startActivity(getErrorActivityIntent(context, errorInfo))
53+
}
4454
}
4555

4656
/**

0 commit comments

Comments
 (0)