Skip to content

Commit 676c62a

Browse files
committed
feat: add full local mode option to instance settings
1 parent 7db8212 commit 676c62a

5 files changed

Lines changed: 67 additions & 46 deletions

File tree

app/src/main/java/com/github/libretube/api/MediaServiceRepository.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ interface MediaServiceRepository {
3939
suspend fun getPlaylistNextPage(playlistId: String, nextPage: String): Playlist
4040

4141
companion object {
42-
val instance by lazy {
43-
if (PlayerHelper.disablePipedProxy && PlayerHelper.localStreamExtraction) {
44-
// TODO: LocalStreamsExtractionPipedMediaServiceRepository()
45-
NewPipeMediaServiceRepository()
46-
} else {
47-
PipedMediaServiceRepository()
42+
val instance: MediaServiceRepository
43+
get() = when {
44+
PlayerHelper.fullLocalMode -> NewPipeMediaServiceRepository()
45+
PlayerHelper.localStreamExtraction -> LocalStreamsExtractionPipedMediaServiceRepository()
46+
else -> PipedMediaServiceRepository()
4847
}
49-
}
5048
}
5149
}

app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ object PreferenceKeys {
133133
const val MAX_CONCURRENT_DOWNLOADS = "max_parallel_downloads"
134134
const val EXTERNAL_DOWNLOAD_PROVIDER = "external_download_provider"
135135
const val DISABLE_VIDEO_IMAGE_PROXY = "disable_video_image_proxy"
136+
const val FULL_LOCAL_MODE = "full_local_mode"
136137
const val LOCAL_RYD = "local_return_youtube_dislikes"
137138
const val LOCAL_STREAM_EXTRACTION = "local_stream_extraction"
138139

app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ object PlayerHelper {
357357
false
358358
)
359359

360+
val fullLocalMode: Boolean
361+
get() = PreferenceHelper.getBoolean(
362+
PreferenceKeys.FULL_LOCAL_MODE,
363+
false
364+
)
365+
360366
val localStreamExtraction: Boolean
361367
get() = PreferenceHelper.getBoolean(
362368
PreferenceKeys.LOCAL_STREAM_EXTRACTION,

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@
472472
<string name="crashlog">Crashlog</string>
473473
<string name="never_show_again">Never show this again</string>
474474
<string name="update_information">Update information</string>
475+
<string name="mode_of_operation">Mode of operation</string>
475476

476477
<!-- Backup & Restore Settings -->
477478
<string name="import_subscriptions_from">Import subscriptions from</string>
@@ -532,6 +533,9 @@
532533
<string name="local_feed_extraction_summary">Directly fetch the feed from YouTube. This may be significantly slower.</string>
533534
<string name="show_upcoming_videos">Show upcoming videos</string>
534535
<string name="updating_feed">Updating feed …</string>
536+
<string name="full_local_mode">Full local mode</string>
537+
<string name="full_local_mode_desc">Directly fetch everything from YouTube, without using Piped.</string>
538+
<string name="authentication">Authentication</string>
535539

536540
<!-- Notification channel strings -->
537541
<string name="download_channel_name">Download Service</string>

app/src/main/res/xml/instance_settings.xml

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto">
44

5+
<PreferenceCategory app:title="@string/mode_of_operation">
6+
7+
<SwitchPreferenceCompat
8+
android:icon="@drawable/ic_region"
9+
android:defaultValue="false"
10+
android:title="@string/full_local_mode"
11+
android:key="full_local_mode"
12+
android:disableDependentsState="true"
13+
android:summary="@string/full_local_mode_desc" />
14+
15+
<SwitchPreferenceCompat
16+
android:defaultValue="true"
17+
android:icon="@drawable/ic_region"
18+
android:dependency="full_local_mode"
19+
android:summary="@string/local_stream_extraction_summary"
20+
android:title="@string/local_stream_extraction"
21+
app:key="local_stream_extraction" />
22+
23+
</PreferenceCategory>
24+
525
<PreferenceCategory app:title="@string/instance">
626

727
<ListPreference
@@ -10,19 +30,41 @@
1030
app:entries="@array/instances"
1131
app:entryValues="@array/instancesValue"
1232
app:key="selectInstance"
33+
android:dependency="full_local_mode"
1334
app:title="@string/instances" />
1435

1536
<Preference
1637
android:icon="@drawable/ic_add_instance"
1738
app:key="customInstance"
39+
android:dependency="full_local_mode"
1840
app:summary="@string/customInstance_summary"
1941
app:title="@string/customInstance" />
2042

2143
<Preference
2244
android:icon="@drawable/ic_trash"
2345
app:key="clearCustomInstances"
46+
android:dependency="full_local_mode"
2447
app:title="@string/clear_customInstances" />
2548

49+
<SwitchPreferenceCompat
50+
android:defaultValue="false"
51+
android:icon="@drawable/ic_server"
52+
android:dependency="full_local_mode"
53+
android:summary="@string/disable_proxy_summary"
54+
android:title="@string/disable_proxy"
55+
app:key="disable_video_image_proxy" />
56+
57+
</PreferenceCategory>
58+
59+
<PreferenceCategory android:title="@string/authentication">
60+
61+
<SwitchPreferenceCompat
62+
android:defaultValue="false"
63+
android:icon="@drawable/ic_region"
64+
android:summary="@string/local_feed_extraction_summary"
65+
android:title="@string/local_feed_extraction"
66+
app:key="local_feed_extraction" />
67+
2668
<SwitchPreferenceCompat
2769
android:defaultValue="false"
2870
android:icon="@drawable/ic_auth"
@@ -39,21 +81,6 @@
3981
app:key="selectAuthInstance"
4082
app:title="@string/auth_instances" />
4183

42-
</PreferenceCategory>
43-
44-
<PreferenceCategory app:title="@string/audio_video">
45-
46-
<SwitchPreferenceCompat
47-
android:defaultValue="false"
48-
android:icon="@drawable/ic_list"
49-
android:summary="@string/hls_instead_of_dash_summary"
50-
android:title="@string/hls_instead_of_dash"
51-
app:key="use_hls" />
52-
53-
</PreferenceCategory>
54-
55-
<PreferenceCategory app:title="@string/account">
56-
5784
<Preference
5885
android:icon="@drawable/ic_login_filled"
5986
android:summary="@string/notgmail"
@@ -75,42 +102,27 @@
75102

76103
</PreferenceCategory>
77104

78-
<PreferenceCategory app:title="@string/proxy">
105+
<PreferenceCategory app:title="@string/audio_video">
79106

80107
<SwitchPreferenceCompat
81108
android:defaultValue="false"
82-
android:icon="@drawable/ic_server"
83-
android:summary="@string/disable_proxy_summary"
84-
android:title="@string/disable_proxy"
85-
app:key="disable_video_image_proxy" />
109+
android:icon="@drawable/ic_list"
110+
android:summary="@string/hls_instead_of_dash_summary"
111+
android:title="@string/hls_instead_of_dash"
112+
app:key="use_hls" />
86113

87-
<SwitchPreferenceCompat
88-
android:defaultValue="true"
89-
android:icon="@drawable/ic_region"
90-
android:summary="@string/local_stream_extraction_summary"
91-
android:title="@string/local_stream_extraction"
92-
android:dependency="disable_video_image_proxy"
93-
app:key="local_stream_extraction" />
114+
</PreferenceCategory>
115+
116+
<PreferenceCategory app:title="@string/misc">
94117

95118
<SwitchPreferenceCompat
96119
android:defaultValue="true"
97120
android:icon="@drawable/ic_dislike"
121+
android:dependency="local_stream_extraction"
98122
android:summary="@string/local_ryd_summary"
99123
android:title="@string/local_ryd"
100-
android:dependency="local_stream_extraction"
101124
app:key="local_return_youtube_dislikes" />
102125

103126
</PreferenceCategory>
104127

105-
<PreferenceCategory app:title="@string/subscriptions">
106-
107-
<SwitchPreferenceCompat
108-
android:defaultValue="false"
109-
android:icon="@drawable/ic_region"
110-
android:summary="@string/local_feed_extraction_summary"
111-
android:title="@string/local_feed_extraction"
112-
app:key="local_feed_extraction" />
113-
114-
</PreferenceCategory>
115-
116128
</PreferenceScreen>

0 commit comments

Comments
 (0)