Merge pull request #7325 from Bnyro/master

refactor: enable full local mode by default
This commit is contained in:
Bnyro 2025-04-23 11:52:39 +02:00 committed by GitHub
commit 5bb969fe2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 26 deletions

View File

@ -348,7 +348,7 @@ object PlayerHelper {
val fullLocalMode: Boolean val fullLocalMode: Boolean
get() = PreferenceHelper.getBoolean( get() = PreferenceHelper.getBoolean(
PreferenceKeys.FULL_LOCAL_MODE, PreferenceKeys.FULL_LOCAL_MODE,
false true
) )
val localStreamExtraction: Boolean val localStreamExtraction: Boolean

View File

@ -19,6 +19,7 @@ import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.obj.PipedInstance import com.github.libretube.api.obj.PipedInstance
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.helpers.BackupHelper import com.github.libretube.helpers.BackupHelper
import com.github.libretube.helpers.PlayerHelper
import com.github.libretube.helpers.PreferenceHelper import com.github.libretube.helpers.PreferenceHelper
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
@ -69,6 +70,7 @@ class WelcomeViewModel(
PreferenceKeys.FETCH_INSTANCE, PreferenceKeys.FETCH_INSTANCE,
_uiState.value.instances[selectedInstanceIndex].apiUrl _uiState.value.instances[selectedInstanceIndex].apiUrl
) )
PreferenceHelper.putBoolean(PreferenceKeys.FULL_LOCAL_MODE, false)
refreshAndNavigate() refreshAndNavigate()
} }
} }
@ -79,7 +81,7 @@ class WelcomeViewModel(
// only skip the welcome activity if the restored backup contains an instance // only skip the welcome activity if the restored backup contains an instance
val instancePref = PreferenceHelper.getString(PreferenceKeys.FETCH_INSTANCE, "") val instancePref = PreferenceHelper.getString(PreferenceKeys.FETCH_INSTANCE, "")
if (instancePref.isNotEmpty()) { if (instancePref.isNotEmpty() || PlayerHelper.fullLocalMode) {
refreshAndNavigate() refreshAndNavigate()
} }
} }
@ -101,7 +103,7 @@ class WelcomeViewModel(
@Parcelize @Parcelize
data class UiState( data class UiState(
val fullLocalMode: Boolean = false, val fullLocalMode: Boolean = true,
val selectedInstanceIndex: Int? = null, val selectedInstanceIndex: Int? = null,
val instances: List<PipedInstance> = emptyList(), val instances: List<PipedInstance> = emptyList(),
@StringRes val error: Int? = null, @StringRes val error: Int? = null,

View File

@ -45,19 +45,12 @@
android:id="@+id/operation_mode_group" android:id="@+id/operation_mode_group"
app:selectionRequired="true" app:selectionRequired="true"
app:singleSelection="true" app:singleSelection="true"
app:checkedButton="@+id/piped_toggle_group_button" app:checkedButton="@+id/full_local_mode_toggle_group_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginBottom="10dp"> android:layout_marginBottom="10dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/piped_toggle_group_button"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/piped" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/full_local_mode_toggle_group_button" android:id="@+id/full_local_mode_toggle_group_button"
style="?attr/materialButtonOutlinedStyle" style="?attr/materialButtonOutlinedStyle"
@ -65,9 +58,31 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/full_local_mode" /> android:text="@string/full_local_mode" />
<com.google.android.material.button.MaterialButton
android:id="@+id/piped_toggle_group_button"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/piped" />
</com.google.android.material.button.MaterialButtonToggleGroup> </com.google.android.material.button.MaterialButtonToggleGroup>
<LinearLayout <LinearLayout
android:id="@+id/local_mode_info_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/full_local_mode_desc" />
</LinearLayout>
<LinearLayout
tools:visibility="gone"
android:id="@+id/instances_container" android:id="@+id/instances_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -93,21 +108,6 @@
tools:listitem="@layout/instance_row" /> tools:listitem="@layout/instance_row" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:visibility="gone"
android:id="@+id/local_mode_info_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/full_local_mode_desc" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<FrameLayout <FrameLayout