-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature|fix] Support configuring whether to auto seed after the down…
…load is completed; support opening the downloaded video by other apps; fix the abnormal behavior of TopBar in the download task page
- Loading branch information
Showing
13 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...c/main/java/com/skyd/anivu/model/preference/transmission/SeedingWhenCompletePreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.skyd.anivu.model.preference.transmission | ||
|
||
import android.content.Context | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.booleanPreferencesKey | ||
import com.skyd.anivu.base.BasePreference | ||
import com.skyd.anivu.ext.dataStore | ||
import com.skyd.anivu.ext.put | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
|
||
object SeedingWhenCompletePreference : BasePreference<Boolean> { | ||
private const val SEEDING_WHEN_COMPLETE = "seedingWhenComplete" | ||
override val default = true | ||
|
||
val key = booleanPreferencesKey(SEEDING_WHEN_COMPLETE) | ||
|
||
fun put(context: Context, scope: CoroutineScope, value: Boolean) { | ||
scope.launch(Dispatchers.IO) { | ||
context.dataStore.put(key, value) | ||
} | ||
} | ||
|
||
override fun fromPreferences(preferences: Preferences): Boolean = preferences[key] ?: default | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/src/main/java/com/skyd/anivu/ui/fragment/settings/transmission/TransmissionFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.skyd.anivu.ui.fragment.settings.transmission | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.preference.PreferenceCategory | ||
import androidx.preference.PreferenceScreen | ||
import androidx.preference.SwitchPreferenceCompat | ||
import com.skyd.anivu.R | ||
import com.skyd.anivu.base.BasePreferenceFragmentCompat | ||
import com.skyd.anivu.ext.dataStore | ||
import com.skyd.anivu.ext.getOrDefault | ||
import com.skyd.anivu.model.preference.transmission.SeedingWhenCompletePreference | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
|
||
@AndroidEntryPoint | ||
class TransmissionFragment : BasePreferenceFragmentCompat() { | ||
override val title by lazy { resources.getString(R.string.transmission_fragment_name) } | ||
override fun Context.onAddPreferences( | ||
savedInstanceState: Bundle?, | ||
rootKey: String?, | ||
screen: PreferenceScreen | ||
) { | ||
val transmissionBehaviorCategory = PreferenceCategory(this).apply { | ||
key = "transmissionBehaviorCategory" | ||
title = getString(R.string.transmission_fragment_transmission_behavior_category) | ||
screen.addPreference(this) | ||
} | ||
|
||
SwitchPreferenceCompat(this).apply { | ||
key = "seedingWhenComplete" | ||
title = getString(R.string.transmission_fragment_seeding_when_complete) | ||
summary = getString(R.string.transmission_fragment_seeding_when_complete_description) | ||
setIcon(R.drawable.ic_cloud_upload_24) | ||
isChecked = requireContext().dataStore.getOrDefault(SeedingWhenCompletePreference) | ||
setOnPreferenceChangeListener { _, newValue -> | ||
SeedingWhenCompletePreference.put( | ||
context = requireContext(), | ||
scope = lifecycleScope, | ||
value = newValue as Boolean, | ||
) | ||
true | ||
} | ||
transmissionBehaviorCategory.addPreference(this) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:tint="?attr/colorControlNormal" | ||
android:viewportWidth="960" | ||
android:viewportHeight="960"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,200Q120,167 143.5,143.5Q167,120 200,120L440,120Q457,120 468.5,131.5Q480,143 480,160Q480,177 468.5,188.5Q457,200 440,200L200,200Q200,200 200,200Q200,200 200,200L200,760Q200,760 200,760Q200,760 200,760L760,760Q760,760 760,760Q760,760 760,760L760,520Q760,503 771.5,491.5Q783,480 800,480Q817,480 828.5,491.5Q840,503 840,520L840,760Q840,793 816.5,816.5Q793,840 760,840L200,840ZM760,256L416,600Q405,611 388,611Q371,611 360,600Q349,589 349,572Q349,555 360,544L704,200L600,200Q583,200 571.5,188.5Q560,177 560,160Q560,143 571.5,131.5Q583,120 600,120L840,120L840,360Q840,377 828.5,388.5Q817,400 800,400Q783,400 771.5,388.5Q760,377 760,360L760,256Z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:tint="?attr/colorControlNormal" | ||
android:viewportWidth="960" | ||
android:viewportHeight="960"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M360,520Q343,520 331.5,508.5Q320,497 320,480L320,233L245,308Q234,319 217.5,319Q201,319 189,308Q177,296 177,279.5Q177,263 189,251L332,108Q338,102 345,99.5Q352,97 360,97Q368,97 375,99.5Q382,102 388,108L532,252Q544,264 543.5,280Q543,296 531,308Q519,319 503,319.5Q487,320 475,308L400,233L400,480Q400,497 388.5,508.5Q377,520 360,520ZM600,863Q592,863 585,860.5Q578,858 572,852L428,708Q416,696 416.5,680Q417,664 429,652Q441,641 457,640.5Q473,640 485,652L560,727L560,480Q560,463 571.5,451.5Q583,440 600,440Q617,440 628.5,451.5Q640,463 640,480L640,727L715,652Q726,641 742.5,641Q759,641 771,652Q783,664 783,680.5Q783,697 771,709L628,852Q622,858 615,860.5Q608,863 600,863Z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters