Skip to content

Commit a56debf

Browse files
Merge branch 'refs/heads/refactor' into Compose-theme-improvements
# Conflicts: # app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.kt # app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt
2 parents c0388d9 + 13585ca commit a56debf

91 files changed

Lines changed: 1809 additions & 1282 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/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ jobs:
4747
BRANCH: ${{ github.head_ref }}
4848
run: git checkout -B "$BRANCH"
4949

50-
- name: set up JDK 17
50+
- name: set up JDK
5151
uses: actions/setup-java@v4
5252
with:
53-
java-version: 17
53+
java-version: 21
5454
distribution: "temurin"
5555
cache: 'gradle'
5656

@@ -88,10 +88,10 @@ jobs:
8888
sudo udevadm control --reload-rules
8989
sudo udevadm trigger --name-match=kvm
9090
91-
- name: set up JDK 17
91+
- name: set up JDK
9292
uses: actions/setup-java@v4
9393
with:
94-
java-version: 17
94+
java-version: 21
9595
distribution: "temurin"
9696
cache: 'gradle'
9797

@@ -121,10 +121,10 @@ jobs:
121121
with:
122122
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
123123

124-
- name: Set up JDK 17
124+
- name: Set up JDK
125125
uses: actions/setup-java@v4
126126
with:
127-
java-version: 17
127+
java-version: 21
128128
distribution: "temurin"
129129
cache: 'gradle'
130130

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ captures/
1010
*.class
1111
app/debug/
1212
app/release/
13+
.kotlin/
1314

1415
# vscode / eclipse files
1516
*.classpath

app/build.gradle

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ plugins {
1010
id "checkstyle"
1111
id "org.sonarqube" version "4.0.0.2929"
1212
id "org.jetbrains.kotlin.plugin.compose" version "${kotlin_version}"
13+
id 'com.google.dagger.hilt.android'
1314
}
1415

1516
android {
@@ -94,6 +95,7 @@ android {
9495
buildFeatures {
9596
viewBinding true
9697
compose true
98+
buildConfig true
9799
}
98100

99101
packagingOptions {
@@ -114,7 +116,7 @@ ext {
114116
androidxRoomVersion = '2.6.1'
115117
androidxWorkVersion = '2.8.1'
116118

117-
icepickVersion = '3.2.0'
119+
stateSaverVersion = '1.4.1'
118120
exoPlayerVersion = '2.18.7'
119121
googleAutoServiceVersion = '1.1.1'
120122
groupieVersion = '2.10.1'
@@ -190,6 +192,10 @@ sonar {
190192
}
191193
}
192194

195+
kapt {
196+
correctErrorTypes true
197+
}
198+
193199
dependencies {
194200
/** Desugaring **/
195201
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.4'
@@ -200,7 +206,8 @@ dependencies {
200206
// name and the commit hash with the commit hash of the (pushed) commit you want to test
201207
// This works thanks to JitPack: https://jitpack.io/
202208
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
203-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.24.2'
209+
// WORKAROUND: v0.24.2 can't be resolved by jitpack -> use git commit hash instead
210+
implementation 'com.github.TeamNewPipe:NewPipeExtractor:176da72cb4c3ec4679211339b0e59f6b01bf2f52'
204211
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
205212

206213
/** Checkstyle **/
@@ -216,7 +223,7 @@ dependencies {
216223
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
217224
implementation 'androidx.core:core-ktx:1.12.0'
218225
implementation 'androidx.documentfile:documentfile:1.0.1'
219-
implementation 'androidx.fragment:fragment-ktx:1.6.2'
226+
implementation 'androidx.fragment:fragment-compose:1.8.2'
220227
implementation "androidx.lifecycle:lifecycle-livedata-ktx:${androidxLifecycleVersion}"
221228
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${androidxLifecycleVersion}"
222229
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
@@ -236,8 +243,9 @@ dependencies {
236243

237244
/** Third-party libraries **/
238245
// Instance state boilerplate elimination
239-
implementation "frankiesardo:icepick:${icepickVersion}"
240-
kapt "frankiesardo:icepick-processor:${icepickVersion}"
246+
implementation 'com.github.livefront:bridge:v2.0.2'
247+
implementation "com.evernote:android-state:$stateSaverVersion"
248+
kapt "com.evernote:android-state-processor:$stateSaverVersion"
241249

242250
// HTML parser
243251
implementation "org.jsoup:jsoup:1.17.2"
@@ -286,19 +294,29 @@ dependencies {
286294
implementation "org.ocpsoft.prettytime:prettytime:5.0.8.Final"
287295

288296
// Jetpack Compose
289-
implementation(platform('androidx.compose:compose-bom:2024.06.00'))
290-
implementation 'androidx.compose.material3:material3:1.3.0-beta05'
291-
implementation 'androidx.compose.material3.adaptive:adaptive:1.0.0-beta04'
297+
implementation(platform('androidx.compose:compose-bom:2024.10.01'))
298+
implementation 'androidx.compose.material3:material3'
299+
implementation 'androidx.compose.material3.adaptive:adaptive'
292300
implementation 'androidx.activity:activity-compose'
293301
implementation 'androidx.compose.ui:ui-tooling-preview'
294-
implementation 'androidx.compose.ui:ui-text:1.7.0-beta07' // Needed for parsing HTML to AnnotatedString
295302
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose'
303+
implementation 'androidx.compose.ui:ui-text' // Needed for parsing HTML to AnnotatedString
304+
implementation 'androidx.compose.material:material-icons-extended'
305+
306+
// Jetpack Compose related dependencies
296307
implementation 'androidx.paging:paging-compose:3.3.2'
297-
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:2.2.0'
308+
implementation "androidx.navigation:navigation-compose:2.8.3"
298309

299310
// Coroutines interop
300311
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-rx3:1.8.1'
301312

313+
// Hilt
314+
implementation("com.google.dagger:hilt-android:2.51.1")
315+
kapt("com.google.dagger:hilt-compiler:2.51.1")
316+
317+
// Scroll
318+
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:2.2.0'
319+
302320
/** Debugging **/
303321
// Memory leak detection
304322
debugImplementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}"

app/proguard-rules.pro

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313
## Rules for ExoPlayer
1414
-keep class com.google.android.exoplayer2.** { *; }
1515

16-
## Rules for Icepick. Copy pasted from https://github.com/frankiesardo/icepick
17-
-dontwarn icepick.**
18-
-keep class icepick.** { *; }
19-
-keep class **$$Icepick { *; }
20-
-keepclasseswithmembernames class * {
21-
@icepick.* <fields>;
22-
}
23-
-keepnames class * { @icepick.State *;}
24-
2516
## Rules for OkHttp. Copy pasted from https://github.com/square/okhttp
2617
-dontwarn okhttp3.**
2718
-dontwarn okio.**

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
android:exported="false"
7878
android:label="@string/settings" />
7979

80+
<activity
81+
android:name=".settings.SettingsV2Activity"
82+
android:exported="true"
83+
android:label="@string/settings" />
84+
8085
<activity
8186
android:name=".about.AboutActivity"
8287
android:exported="false"

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.schabi.newpipe.extractor.downloader.Downloader;
2222
import org.schabi.newpipe.ktx.ExceptionUtils;
2323
import org.schabi.newpipe.settings.NewPipeSettings;
24+
import org.schabi.newpipe.util.BridgeStateSaverInitializer;
2425
import org.schabi.newpipe.util.Localization;
2526
import org.schabi.newpipe.util.ServiceHelper;
2627
import org.schabi.newpipe.util.StateSaver;
@@ -36,6 +37,7 @@
3637
import coil.ImageLoader;
3738
import coil.ImageLoaderFactory;
3839
import coil.util.DebugLogger;
40+
import dagger.hilt.android.HiltAndroidApp;
3941
import io.reactivex.rxjava3.exceptions.CompositeException;
4042
import io.reactivex.rxjava3.exceptions.MissingBackpressureException;
4143
import io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException;
@@ -61,6 +63,7 @@
6163
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
6264
*/
6365

66+
@HiltAndroidApp
6467
public class App extends Application implements ImageLoaderFactory {
6568
public static final String PACKAGE_NAME = BuildConfig.APPLICATION_ID;
6669
private static final String TAG = App.class.toString();
@@ -105,6 +108,7 @@ public void onCreate() {
105108
Localization.getPreferredContentCountry(this));
106109
Localization.initPrettyTime(Localization.resolvePrettyTime(getApplicationContext()));
107110

111+
BridgeStateSaverInitializer.init(this);
108112
StateSaver.init(this);
109113
initNotificationChannels();
110114

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.schabi.newpipe
2+
3+
import android.content.Context
4+
import android.content.SharedPreferences
5+
import androidx.preference.PreferenceManager
6+
import dagger.Module
7+
import dagger.Provides
8+
import dagger.hilt.InstallIn
9+
import dagger.hilt.android.qualifiers.ApplicationContext
10+
import dagger.hilt.components.SingletonComponent
11+
import javax.inject.Singleton
12+
13+
@Module
14+
@InstallIn(SingletonComponent::class)
15+
class AppModule {
16+
17+
@Provides
18+
@Singleton
19+
fun providesSharedPreference(@ApplicationContext context: Context): SharedPreferences {
20+
return PreferenceManager.getDefaultSharedPreferences(context)
21+
}
22+
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
import androidx.fragment.app.Fragment;
1111
import androidx.fragment.app.FragmentManager;
1212

13-
import icepick.Icepick;
14-
import icepick.State;
13+
import com.evernote.android.state.State;
14+
import com.livefront.bridge.Bridge;
15+
1516

1617
public abstract class BaseFragment extends Fragment {
1718
protected final String TAG = getClass().getSimpleName() + "@" + Integer.toHexString(hashCode());
@@ -48,7 +49,7 @@ public void onCreate(final Bundle savedInstanceState) {
4849
+ "savedInstanceState = [" + savedInstanceState + "]");
4950
}
5051
super.onCreate(savedInstanceState);
51-
Icepick.restoreInstanceState(this, savedInstanceState);
52+
Bridge.restoreInstanceState(this, savedInstanceState);
5253
if (savedInstanceState != null) {
5354
onRestoreInstanceState(savedInstanceState);
5455
}
@@ -70,7 +71,7 @@ public void onViewCreated(@NonNull final View rootView, final Bundle savedInstan
7071
@Override
7172
public void onSaveInstanceState(@NonNull final Bundle outState) {
7273
super.onSaveInstanceState(outState);
73-
Icepick.saveInstanceState(this, outState);
74+
Bridge.saveInstanceState(this, outState);
7475
}
7576

7677
protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) {

0 commit comments

Comments
 (0)