Skip to content

Commit bac9f7e

Browse files
committed
Merge branch 'refactor' into pr11060
2 parents 3177ca6 + 8ada566 commit bac9f7e

57 files changed

Lines changed: 639 additions & 181 deletions

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

app/build.gradle

Lines changed: 24 additions & 6 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 **/
@@ -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,18 +294,28 @@ dependencies {
286294
implementation "org.ocpsoft.prettytime:prettytime:5.0.8.Final"
287295

288296
// Jetpack Compose
289-
implementation(platform('androidx.compose:compose-bom:2024.09.00'))
297+
implementation(platform('androidx.compose:compose-bom:2024.09.03'))
290298
implementation 'androidx.compose.material3:material3'
291299
implementation 'androidx.compose.material3.adaptive:adaptive'
292300
implementation 'androidx.activity:activity-compose'
293301
implementation 'androidx.compose.ui:ui-tooling-preview'
294302
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose'
303+
implementation 'androidx.compose.ui:ui-text' // Needed for parsing HTML to AnnotatedString
304+
305+
// Jetpack Compose related dependencies
295306
implementation 'androidx.paging:paging-compose:3.3.2'
296-
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:2.2.0'
307+
implementation "androidx.navigation:navigation-compose"
297308

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

312+
// Hilt
313+
implementation("com.google.dagger:hilt-android:2.51.1")
314+
kapt("com.google.dagger:hilt-compiler:2.51.1")
315+
316+
// Scroll
317+
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:2.2.0'
318+
301319
/** Debugging **/
302320
// Memory leak detection
303321
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) {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
import androidx.lifecycle.LifecycleOwner;
4242
import androidx.preference.PreferenceManager;
4343

44+
import com.evernote.android.state.State;
45+
import com.livefront.bridge.Bridge;
46+
4447
import org.schabi.newpipe.database.stream.model.StreamEntity;
4548
import org.schabi.newpipe.databinding.ListRadioIconItemBinding;
4649
import org.schabi.newpipe.databinding.SingleChoiceDialogViewBinding;
@@ -98,8 +101,6 @@
98101
import java.util.Optional;
99102
import java.util.function.Consumer;
100103

101-
import icepick.Icepick;
102-
import icepick.State;
103104
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
104105
import io.reactivex.rxjava3.core.Observable;
105106
import io.reactivex.rxjava3.core.Single;
@@ -152,7 +153,7 @@ protected void onCreate(final Bundle savedInstanceState) {
152153
getWindow().setAttributes(params);
153154

154155
super.onCreate(savedInstanceState);
155-
Icepick.restoreInstanceState(this, savedInstanceState);
156+
Bridge.restoreInstanceState(this, savedInstanceState);
156157

157158
// FragmentManager will take care to recreate (Playlist|Download)Dialog when screen rotates
158159
// We used to .setOnDismissListener(dialog -> finish()); when creating these DialogFragments
@@ -197,7 +198,7 @@ protected void onStop() {
197198
@Override
198199
protected void onSaveInstanceState(@NonNull final Bundle outState) {
199200
super.onSaveInstanceState(outState);
200-
Icepick.saveInstanceState(this, outState);
201+
Bridge.saveInstanceState(this, outState);
201202
}
202203

203204
@Override

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,12 @@ class AboutActivity : AppCompatActivity() {
138138
"https://github.com/lisawray/groupie", StandardLicenses.MIT
139139
),
140140
SoftwareComponent(
141-
"Icepick", "2015", "Frankie Sardo",
142-
"https://github.com/frankiesardo/icepick", StandardLicenses.EPL1
141+
"Android-State", "2018", "Evernote",
142+
"https://github.com/Evernote/android-state", StandardLicenses.EPL1
143+
),
144+
SoftwareComponent(
145+
"Bridge", "2021", "Livefront",
146+
"https://github.com/livefront/bridge", StandardLicenses.APACHE2
143147
),
144148
SoftwareComponent(
145149
"Jsoup", "2009 - 2020", "Jonathan Hedley",

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import androidx.fragment.app.DialogFragment;
4040
import androidx.preference.PreferenceManager;
4141

42+
import com.evernote.android.state.State;
43+
import com.livefront.bridge.Bridge;
4244
import com.nononsenseapps.filepicker.Utils;
4345

4446
import org.schabi.newpipe.MainActivity;
@@ -59,6 +61,8 @@
5961
import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard;
6062
import org.schabi.newpipe.streams.io.StoredDirectoryHelper;
6163
import org.schabi.newpipe.streams.io.StoredFileHelper;
64+
import org.schabi.newpipe.util.AudioTrackAdapter;
65+
import org.schabi.newpipe.util.AudioTrackAdapter.AudioTracksWrapper;
6266
import org.schabi.newpipe.util.FilePickerActivityHelper;
6367
import org.schabi.newpipe.util.FilenameUtils;
6468
import org.schabi.newpipe.util.ListHelper;
@@ -67,8 +71,6 @@
6771
import org.schabi.newpipe.util.SimpleOnSeekBarChangeListener;
6872
import org.schabi.newpipe.util.StreamItemAdapter;
6973
import org.schabi.newpipe.util.StreamItemAdapter.StreamInfoWrapper;
70-
import org.schabi.newpipe.util.AudioTrackAdapter;
71-
import org.schabi.newpipe.util.AudioTrackAdapter.AudioTracksWrapper;
7274
import org.schabi.newpipe.util.ThemeHelper;
7375

7476
import java.io.File;
@@ -79,8 +81,6 @@
7981
import java.util.Objects;
8082
import java.util.Optional;
8183

82-
import icepick.Icepick;
83-
import icepick.State;
8484
import io.reactivex.rxjava3.disposables.CompositeDisposable;
8585
import us.shandian.giga.get.MissionRecoveryInfo;
8686
import us.shandian.giga.postprocessing.Postprocessing;
@@ -214,7 +214,7 @@ public void onCreate(@Nullable final Bundle savedInstanceState) {
214214
context = getContext();
215215

216216
setStyle(STYLE_NO_TITLE, ThemeHelper.getDialogTheme(context));
217-
Icepick.restoreInstanceState(this, savedInstanceState);
217+
Bridge.restoreInstanceState(this, savedInstanceState);
218218

219219
this.audioTrackAdapter = new AudioTrackAdapter(wrappedAudioTracks);
220220
this.subtitleStreamsAdapter = new StreamItemAdapter<>(wrappedSubtitleStreams);
@@ -372,7 +372,7 @@ public void onDestroyView() {
372372
@Override
373373
public void onSaveInstanceState(@NonNull final Bundle outState) {
374374
super.onSaveInstanceState(outState);
375-
Icepick.saveInstanceState(this, outState);
375+
Bridge.saveInstanceState(this, outState);
376376
}
377377

378378

0 commit comments

Comments
 (0)