Skip to content

Commit aaf3374

Browse files
committed
Merge branch 'refactor' into pr11282
2 parents d56eef6 + 79a0eda commit aaf3374

36 files changed

Lines changed: 667 additions & 392 deletions

app/build.gradle

Lines changed: 95 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import com.android.tools.profgen.DexFile
44
import com.mikepenz.aboutlibraries.plugin.DuplicateMode
55

66
plugins {
7-
id "com.android.application"
8-
id "kotlin-android"
9-
id "kotlin-kapt"
10-
id "kotlin-parcelize"
11-
id "checkstyle"
12-
id "org.sonarqube" version "4.0.0.2929"
13-
id "org.jetbrains.kotlin.plugin.compose" version "${kotlin_version}"
14-
id 'com.google.dagger.hilt.android'
15-
id 'com.mikepenz.aboutlibraries.plugin'
7+
alias libs.plugins.android.application
8+
alias libs.plugins.kotlin.android
9+
alias libs.plugins.kotlin.compose
10+
alias libs.plugins.kotlin.kapt
11+
alias libs.plugins.kotlin.parcelize
12+
alias libs.plugins.checkstyle
13+
alias libs.plugins.sonarqube
14+
alias libs.plugins.hilt
15+
alias libs.plugins.aboutlibraries
1616
}
1717

1818
android {
@@ -111,25 +111,6 @@ android {
111111
}
112112
}
113113

114-
ext {
115-
checkstyleVersion = '10.12.1'
116-
117-
androidxLifecycleVersion = '2.6.2'
118-
androidxRoomVersion = '2.6.1'
119-
androidxWorkVersion = '2.8.1'
120-
121-
stateSaverVersion = '1.4.1'
122-
exoPlayerVersion = '2.18.7'
123-
googleAutoServiceVersion = '1.1.1'
124-
groupieVersion = '2.10.1'
125-
markwonVersion = '4.6.2'
126-
127-
leakCanaryVersion = '2.12'
128-
stethoVersion = '1.6.0'
129-
130-
coilVersion = '3.0.3'
131-
}
132-
133114
configurations {
134115
checkstyle
135116
ktlint
@@ -139,7 +120,7 @@ checkstyle {
139120
getConfigDirectory().set(rootProject.file("checkstyle"))
140121
ignoreFailures false
141122
showViolations true
142-
toolVersion = checkstyleVersion
123+
toolVersion = libs.versions.checkstyle.get()
143124
}
144125

145126
tasks.register('runCheckstyle', Checkstyle) {
@@ -181,11 +162,13 @@ tasks.register('formatKtlint', JavaExec) {
181162
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
182163
}
183164

165+
apply from: 'check-dependencies.gradle'
166+
184167
afterEvaluate {
185168
if (!System.properties.containsKey('skipFormatKtlint')) {
186169
preDebugBuild.dependsOn formatKtlint
187170
}
188-
preDebugBuild.dependsOn runCheckstyle, runKtlint
171+
preDebugBuild.dependsOn runCheckstyle, runKtlint, checkDependenciesOrder
189172
}
190173

191174
sonar {
@@ -209,146 +192,143 @@ aboutLibraries {
209192

210193
dependencies {
211194
/** Desugaring **/
212-
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.4'
195+
coreLibraryDesugaring libs.desugar.jdk.libs.nio
213196

214197
/** NewPipe libraries **/
215-
// You can use a local version by uncommenting a few lines in settings.gradle
216-
// Or you can use a commit you pushed to GitHub by just replacing TeamNewPipe with your GitHub
217-
// name and the commit hash with the commit hash of the (pushed) commit you want to test
218-
// This works thanks to JitPack: https://jitpack.io/
219-
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
220-
// WORKAROUND: v0.24.2 can't be resolved by jitpack -> use git commit hash instead
221-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:d3d5f2b3f03a5f2b479b9f6fdf1c2555cbb9de0e'
222-
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
198+
implementation libs.teamnewpipe.nanojson
199+
implementation libs.teamnewpipe.newpipe.extractor
200+
implementation libs.teamnewpipe.nononsense.filepicker
223201

224202
/** Checkstyle **/
225-
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
226-
ktlint 'com.pinterest:ktlint:0.45.2'
203+
checkstyle libs.tools.checkstyle
204+
ktlint libs.tools.ktlint
227205

228206
/** Kotlin **/
229-
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
207+
implementation libs.kotlin.stdlib
230208

231209
/** AndroidX **/
232-
implementation 'androidx.appcompat:appcompat:1.6.1'
233-
implementation 'androidx.cardview:cardview:1.0.0'
234-
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
235-
implementation 'androidx.core:core-ktx:1.12.0'
236-
implementation 'androidx.documentfile:documentfile:1.0.1'
237-
implementation 'androidx.fragment:fragment-compose:1.8.2'
238-
implementation "androidx.lifecycle:lifecycle-livedata-ktx:${androidxLifecycleVersion}"
239-
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${androidxLifecycleVersion}"
240-
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
241-
implementation 'androidx.media:media:1.7.0'
242-
implementation 'androidx.preference:preference:1.2.1'
243-
implementation 'androidx.recyclerview:recyclerview:1.3.2'
244-
implementation "androidx.room:room-runtime:${androidxRoomVersion}"
245-
implementation "androidx.room:room-rxjava3:${androidxRoomVersion}"
246-
kapt "androidx.room:room-compiler:${androidxRoomVersion}"
247-
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
248-
implementation "androidx.work:work-runtime-ktx:${androidxWorkVersion}"
249-
implementation "androidx.work:work-rxjava3:${androidxWorkVersion}"
250-
implementation 'com.google.android.material:material:1.11.0'
210+
implementation libs.androidx.appcompat
211+
implementation libs.androidx.cardview
212+
implementation libs.androidx.constraintlayout
213+
implementation libs.androidx.core.ktx
214+
implementation libs.androidx.documentfile
215+
implementation libs.androidx.fragment.compose
216+
implementation libs.androidx.lifecycle.livedata
217+
implementation libs.androidx.lifecycle.viewmodel
218+
implementation libs.androidx.localbroadcastmanager
219+
implementation libs.androidx.media
220+
implementation libs.androidx.preference
221+
implementation libs.androidx.recyclerview
222+
implementation libs.androidx.room.runtime
223+
implementation libs.androidx.room.rxjava3
224+
kapt libs.androidx.room.compiler
225+
implementation libs.androidx.swiperefreshlayout
226+
// Newer version specified to prevent accessibility regressions with RecyclerView, see:
227+
// https://developer.android.com/jetpack/androidx/releases/viewpager2#1.1.0-alpha01
228+
implementation libs.androidx.viewpager2
229+
implementation libs.androidx.work.runtime
230+
implementation libs.androidx.work.rxjava3
231+
implementation libs.androidx.material
251232

252233
/** Third-party libraries **/
253234
// Instance state boilerplate elimination
254-
implementation 'com.github.livefront:bridge:v2.0.2'
255-
implementation "com.evernote:android-state:$stateSaverVersion"
256-
kapt "com.evernote:android-state-processor:$stateSaverVersion"
235+
implementation libs.livefront.bridge
236+
implementation libs.android.state
237+
kapt libs.android.state.processor
257238

258239
// HTML parser
259-
implementation "org.jsoup:jsoup:1.17.2"
240+
implementation libs.jsoup
260241

261242
// HTTP client
262-
implementation "com.squareup.okhttp3:okhttp:4.12.0"
243+
implementation libs.okhttp
263244

264245
// Media player
265-
implementation "com.google.android.exoplayer:exoplayer-core:${exoPlayerVersion}"
266-
implementation "com.google.android.exoplayer:exoplayer-dash:${exoPlayerVersion}"
267-
implementation "com.google.android.exoplayer:exoplayer-database:${exoPlayerVersion}"
268-
implementation "com.google.android.exoplayer:exoplayer-datasource:${exoPlayerVersion}"
269-
implementation "com.google.android.exoplayer:exoplayer-hls:${exoPlayerVersion}"
270-
implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:${exoPlayerVersion}"
271-
implementation "com.google.android.exoplayer:exoplayer-ui:${exoPlayerVersion}"
272-
implementation "com.google.android.exoplayer:extension-mediasession:${exoPlayerVersion}"
246+
implementation libs.exoplayer.core
247+
implementation libs.exoplayer.dash
248+
implementation libs.exoplayer.database
249+
implementation libs.exoplayer.datasource
250+
implementation libs.exoplayer.hls
251+
implementation libs.exoplayer.smoothstreaming
252+
implementation libs.exoplayer.ui
253+
implementation libs.extension.mediasession
273254

274255
// Metadata generator for service descriptors
275-
compileOnly "com.google.auto.service:auto-service-annotations:${googleAutoServiceVersion}"
276-
kapt "com.google.auto.service:auto-service:${googleAutoServiceVersion}"
256+
compileOnly libs.auto.service
257+
kapt libs.auto.service.kapt
277258

278259
// Manager for complex RecyclerView layouts
279-
implementation "com.github.lisawray.groupie:groupie:${groupieVersion}"
280-
implementation "com.github.lisawray.groupie:groupie-viewbinding:${groupieVersion}"
260+
implementation libs.lisawray.groupie
261+
implementation libs.lisawray.groupie.viewbinding
281262

282263
// Image loading
283-
implementation "io.coil-kt.coil3:coil-compose:${coilVersion}"
284-
implementation "io.coil-kt.coil3:coil-network-okhttp:${coilVersion}"
264+
implementation libs.coil.compose
285265

286266
// Markdown library for Android
287-
implementation "io.noties.markwon:core:${markwonVersion}"
288-
implementation "io.noties.markwon:linkify:${markwonVersion}"
267+
implementation libs.markwon.core
268+
implementation libs.markwon.linkify
289269

290270
// Crash reporting
291-
implementation "ch.acra:acra-core:5.11.3"
271+
implementation libs.acra.core
292272

293273
// Properly restarting
294-
implementation 'com.jakewharton:process-phoenix:2.1.2'
274+
implementation libs.process.phoenix
295275

296276
// Reactive extensions for Java VM
297-
implementation "io.reactivex.rxjava3:rxjava:3.1.8"
298-
implementation "io.reactivex.rxjava3:rxandroid:3.0.2"
277+
implementation libs.rxjava3.rxjava
278+
implementation libs.rxjava3.rxandroid
299279
// RxJava binding APIs for Android UI widgets
300-
implementation "com.jakewharton.rxbinding4:rxbinding:4.0.0"
280+
implementation libs.rxbinding4.rxbinding
301281

302282
// Date and time formatting
303-
implementation "org.ocpsoft.prettytime:prettytime:5.0.8.Final"
283+
implementation libs.prettytime
304284

305285
// Jetpack Compose
306-
implementation(platform('androidx.compose:compose-bom:2024.11.00'))
307-
implementation 'androidx.compose.material3:material3'
308-
implementation 'androidx.compose.material3.adaptive:adaptive'
309-
implementation 'androidx.activity:activity-compose'
310-
implementation 'androidx.compose.ui:ui-tooling-preview'
311-
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose'
312-
implementation 'androidx.compose.ui:ui-text' // Needed for parsing HTML to AnnotatedString
313-
implementation 'androidx.compose.material:material-icons-extended'
286+
implementation(platform(libs.androidx.compose.bom))
287+
implementation libs.androidx.compose.material3
288+
implementation libs.androidx.compose.adaptive
289+
implementation libs.androidx.activity.compose
290+
implementation libs.androidx.compose.ui.tooling.preview
291+
implementation libs.androidx.lifecycle.viewmodel.compose
292+
implementation libs.androidx.compose.ui.text // Needed for parsing HTML to AnnotatedString
293+
implementation libs.androidx.compose.material.icons.extended
314294

315295
// Jetpack Compose related dependencies
316-
implementation 'androidx.paging:paging-compose:3.3.2'
317-
implementation "androidx.navigation:navigation-compose:2.8.3"
296+
implementation libs.androidx.paging.compose
297+
implementation libs.androidx.navigation.compose
318298

319299
// Coroutines interop
320-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-rx3:1.8.1'
300+
implementation libs.kotlinx.coroutines.rx3
321301

322302
// Library loading for About screen
323-
implementation "com.mikepenz:aboutlibraries-compose-m3:$about_libs"
303+
implementation libs.aboutlibraries.compose.m3
324304

325305
// Hilt
326-
implementation("com.google.dagger:hilt-android:2.51.1")
327-
kapt("com.google.dagger:hilt-compiler:2.51.1")
306+
implementation libs.hilt.android
307+
kapt(libs.hilt.compiler)
328308

329309
// Scroll
330-
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:2.2.0'
310+
implementation libs.lazycolumnscrollbar
331311

332312
/** Debugging **/
333313
// Memory leak detection
334-
debugImplementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}"
335-
debugImplementation "com.squareup.leakcanary:plumber-android:${leakCanaryVersion}"
336-
debugImplementation "com.squareup.leakcanary:leakcanary-android-core:${leakCanaryVersion}"
314+
debugImplementation libs.leakcanary.object.watcher
315+
debugImplementation libs.leakcanary.plumber.android
316+
debugImplementation libs.leakcanary.android.core
337317
// Debug bridge for Android
338-
debugImplementation "com.facebook.stetho:stetho:${stethoVersion}"
339-
debugImplementation "com.facebook.stetho:stetho-okhttp3:${stethoVersion}"
318+
debugImplementation libs.stetho
319+
debugImplementation libs.stetho.okhttp3
340320

341321
// Jetpack Compose
342-
debugImplementation 'androidx.compose.ui:ui-tooling'
322+
debugImplementation libs.androidx.compose.ui.tooling
343323

344324
/** Testing **/
345-
testImplementation 'junit:junit:4.13.2'
346-
testImplementation 'org.mockito:mockito-core:5.6.0'
325+
testImplementation libs.junit
326+
testImplementation libs.mockito.core
347327

348-
androidTestImplementation "androidx.test.ext:junit:1.1.5"
349-
androidTestImplementation "androidx.test:runner:1.5.2"
350-
androidTestImplementation "androidx.room:room-testing:${androidxRoomVersion}"
351-
androidTestImplementation "org.assertj:assertj-core:3.24.2"
328+
androidTestImplementation libs.androidx.junit
329+
androidTestImplementation libs.androidx.runner
330+
androidTestImplementation libs.androidx.room.testing
331+
androidTestImplementation libs.assertj.core
352332
}
353333

354334
static String getGitWorkingBranch() {

app/check-dependencies.gradle

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
tasks.register('checkDependenciesOrder') {
2+
group = 'verification'
3+
description = 'Checks that each section in libs.versions.toml is sorted alphabetically'
4+
5+
def tomlFile = file('../gradle/libs.versions.toml')
6+
7+
doLast {
8+
if (!tomlFile.exists()) {
9+
throw new GradleException('TOML file not found')
10+
}
11+
12+
def lines = tomlFile.readLines()
13+
def nonSortedBlocks = []
14+
def currentBlock = []
15+
def prevLine = ''
16+
def prevIndex = 0
17+
18+
lines.eachWithIndex { line, lineIndex ->
19+
if (line.trim() && !line.startsWith('#')) {
20+
if (line.startsWith('[')) {
21+
prevLine = ''
22+
} else {
23+
def currIndex = lineIndex + 1
24+
if (prevLine > line) {
25+
if (currentBlock && currentBlock[-1] == "${prevIndex}: ${prevLine}") {
26+
currentBlock.add("${currIndex}: ${line}")
27+
} else {
28+
if (!currentBlock.isEmpty()) {
29+
nonSortedBlocks.add(currentBlock)
30+
currentBlock = []
31+
}
32+
currentBlock.add("${prevIndex}: ${prevLine}")
33+
currentBlock.add("${currIndex}: ${line}")
34+
}
35+
}
36+
prevLine = line
37+
prevIndex = lineIndex + 1
38+
}
39+
}
40+
}
41+
42+
if (!currentBlock.isEmpty()) {
43+
nonSortedBlocks.add(currentBlock)
44+
throw new GradleException("The following lines were not sorted:\n" +
45+
nonSortedBlocks.collect { it.join("\n") }.join("\n\n"))
46+
}
47+
}
48+
}

app/src/main/java/org/schabi/newpipe/fragments/EmptyFragment.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import android.view.ViewGroup;
77

88
import androidx.annotation.Nullable;
9+
import androidx.compose.ui.platform.ComposeView;
910

1011
import org.schabi.newpipe.BaseFragment;
1112
import org.schabi.newpipe.R;
13+
import org.schabi.newpipe.ui.emptystate.EmptyStateUtil;
1214

1315
public class EmptyFragment extends BaseFragment {
1416
private static final String SHOW_MESSAGE = "SHOW_MESSAGE";
@@ -26,8 +28,10 @@ public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGrou
2628
final Bundle savedInstanceState) {
2729
final boolean showMessage = getArguments().getBoolean(SHOW_MESSAGE);
2830
final View view = inflater.inflate(R.layout.fragment_empty, container, false);
29-
view.findViewById(R.id.empty_state_view).setVisibility(
30-
showMessage ? View.VISIBLE : View.GONE);
31+
32+
final ComposeView composeView = view.findViewById(R.id.empty_state_view);
33+
EmptyStateUtil.setEmptyStateComposable(composeView);
34+
composeView.setVisibility(showMessage ? View.VISIBLE : View.GONE);
3135
return view;
3236
}
3337
}

0 commit comments

Comments
 (0)