Skip to content

Commit 3641698

Browse files
Merge branch 'refs/heads/refactor' into Comments-Compose
# Conflicts: # app/build.gradle
2 parents 294b9cf + 2836191 commit 3641698

25 files changed

Lines changed: 927 additions & 390 deletions

app/build.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,19 @@ dependencies {
286286
implementation "org.ocpsoft.prettytime:prettytime:5.0.8.Final"
287287

288288
// Jetpack Compose
289-
implementation(platform('androidx.compose:compose-bom:2024.06.00'))
290-
implementation 'androidx.compose.material3:material3:1.3.0-beta05'
289+
implementation(platform('androidx.compose:compose-bom:2024.08.00'))
290+
implementation 'androidx.compose.material3:material3:1.3.0-rc01'
291+
implementation 'androidx.compose.material3.adaptive:adaptive:1.0.0-rc01'
291292
implementation 'androidx.activity:activity-compose'
292293
implementation 'androidx.compose.ui:ui-tooling-preview'
293-
implementation 'androidx.compose.ui:ui-text:1.7.0-beta06' // Needed for parsing HTML to AnnotatedString
294+
implementation 'androidx.compose.ui:ui-text:1.7.0-rc01' // Needed for parsing HTML to AnnotatedString
294295
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose'
295-
implementation 'androidx.paging:paging-compose:3.3.1'
296+
implementation 'androidx.paging:paging-compose:3.3.2'
296297
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:2.2.0'
297298

299+
// Coroutines interop
300+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-rx3:1.8.1'
301+
298302
/** Debugging **/
299303
// Memory leak detection
300304
debugImplementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}"

app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamDAO.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.room.Query
88
import androidx.room.Transaction
99
import io.reactivex.rxjava3.core.Completable
1010
import io.reactivex.rxjava3.core.Flowable
11+
import io.reactivex.rxjava3.core.Maybe
1112
import org.schabi.newpipe.database.BasicDAO
1213
import org.schabi.newpipe.database.stream.model.StreamEntity
1314
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_ID
@@ -27,7 +28,7 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
2728
abstract override fun listByService(serviceId: Int): Flowable<List<StreamEntity>>
2829

2930
@Query("SELECT * FROM streams WHERE url = :url AND service_id = :serviceId")
30-
abstract fun getStream(serviceId: Long, url: String): Flowable<List<StreamEntity>>
31+
abstract fun getStream(serviceId: Long, url: String): Maybe<StreamEntity>
3132

3233
@Query("UPDATE streams SET uploader_url = :uploaderUrl WHERE url = :url AND service_id = :serviceId")
3334
abstract fun setUploaderUrl(serviceId: Long, url: String, uploaderUrl: String): Completable

app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamStateDAO.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.schabi.newpipe.database.stream.dao;
22

3+
import static org.schabi.newpipe.database.stream.model.StreamStateEntity.JOIN_STREAM_ID;
4+
import static org.schabi.newpipe.database.stream.model.StreamStateEntity.STREAM_STATE_TABLE;
5+
36
import androidx.room.Dao;
47
import androidx.room.Insert;
58
import androidx.room.OnConflictStrategy;
@@ -12,9 +15,7 @@
1215
import java.util.List;
1316

1417
import io.reactivex.rxjava3.core.Flowable;
15-
16-
import static org.schabi.newpipe.database.stream.model.StreamStateEntity.JOIN_STREAM_ID;
17-
import static org.schabi.newpipe.database.stream.model.StreamStateEntity.STREAM_STATE_TABLE;
18+
import io.reactivex.rxjava3.core.Maybe;
1819

1920
@Dao
2021
public interface StreamStateDAO extends BasicDAO<StreamStateEntity> {
@@ -32,7 +33,7 @@ default Flowable<List<StreamStateEntity>> listByService(final int serviceId) {
3233
}
3334

3435
@Query("SELECT * FROM " + STREAM_STATE_TABLE + " WHERE " + JOIN_STREAM_ID + " = :streamId")
35-
Flowable<List<StreamStateEntity>> getState(long streamId);
36+
Maybe<StreamStateEntity> getState(long streamId);
3637

3738
@Query("DELETE FROM " + STREAM_STATE_TABLE + " WHERE " + JOIN_STREAM_ID + " = :streamId")
3839
int deleteState(long streamId);

app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java

Lines changed: 0 additions & 176 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.schabi.newpipe.fragments.list.videos
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.compose.material3.MaterialTheme
8+
import androidx.compose.material3.Surface
9+
import androidx.compose.ui.platform.ComposeView
10+
import androidx.compose.ui.platform.ViewCompositionStrategy
11+
import androidx.core.os.bundleOf
12+
import androidx.fragment.app.Fragment
13+
import org.schabi.newpipe.extractor.stream.StreamInfo
14+
import org.schabi.newpipe.ktx.serializable
15+
import org.schabi.newpipe.ui.components.video.RelatedItems
16+
import org.schabi.newpipe.ui.theme.AppTheme
17+
import org.schabi.newpipe.util.KEY_INFO
18+
19+
class RelatedItemsFragment : Fragment() {
20+
override fun onCreateView(
21+
inflater: LayoutInflater,
22+
container: ViewGroup?,
23+
savedInstanceState: Bundle?
24+
): View {
25+
return ComposeView(requireContext()).apply {
26+
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
27+
setContent {
28+
AppTheme {
29+
Surface(color = MaterialTheme.colorScheme.background) {
30+
RelatedItems(requireArguments().serializable<StreamInfo>(KEY_INFO)!!)
31+
}
32+
}
33+
}
34+
}
35+
}
36+
37+
companion object {
38+
@JvmStatic
39+
fun getInstance(info: StreamInfo) = RelatedItemsFragment().apply {
40+
arguments = bundleOf(KEY_INFO to info)
41+
}
42+
}
43+
}

app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsInfo.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@
4141
* </p>
4242
*/
4343
public enum StreamDialogDefaultEntry {
44-
SHOW_CHANNEL_DETAILS(R.string.show_channel_details, (fragment, item) ->
45-
fetchUploaderUrlIfSparse(fragment.requireContext(), item.getServiceId(), item.getUrl(),
46-
item.getUploaderUrl(), url -> openChannelFragment(fragment, item, url))
47-
),
44+
SHOW_CHANNEL_DETAILS(R.string.show_channel_details, (fragment, item) -> {
45+
final var activity = fragment.requireActivity();
46+
fetchUploaderUrlIfSparse(activity, item.getServiceId(), item.getUrl(),
47+
item.getUploaderUrl(), url -> openChannelFragment(activity, item, url));
48+
}),
4849

4950
/**
5051
* Enqueues the stream automatically to the current PlayerType.

app/src/main/java/org/schabi/newpipe/info_list/holder/StreamMiniInfoItemHolder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ public void updateFromItem(final InfoItem infoItem,
6464
StreamStateEntity state2 = null;
6565
if (DependentPreferenceHelper
6666
.getPositionsInListsEnabled(itemProgressView.getContext())) {
67-
state2 = historyRecordManager.loadStreamState(infoItem)
68-
.blockingGet()[0];
67+
state2 = historyRecordManager.loadStreamState(infoItem).blockingGet();
6968
}
7069
if (state2 != null) {
7170
itemProgressView.setVisibility(View.VISIBLE);
@@ -120,7 +119,7 @@ public void updateState(final InfoItem infoItem,
120119
if (DependentPreferenceHelper.getPositionsInListsEnabled(itemProgressView.getContext())) {
121120
state = historyRecordManager
122121
.loadStreamState(infoItem)
123-
.blockingGet()[0];
122+
.blockingGet();
124123
}
125124
if (state != null && item.getDuration() > 0
126125
&& !StreamTypeUtil.isLiveStream(item.getStreamType())) {

app/src/main/java/org/schabi/newpipe/ktx/Bundle.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ package org.schabi.newpipe.ktx
33
import android.os.Bundle
44
import android.os.Parcelable
55
import androidx.core.os.BundleCompat
6+
import java.io.Serializable
67

78
inline fun <reified T : Parcelable> Bundle.parcelableArrayList(key: String?): ArrayList<T>? {
89
return BundleCompat.getParcelableArrayList(this, key, T::class.java)
910
}
11+
12+
inline fun <reified T : Serializable> Bundle.serializable(key: String?): T? {
13+
return BundleCompat.getSerializable(this, key, T::class.java)
14+
}

0 commit comments

Comments
 (0)