Merge pull request #796 from Bnyro/master

add data saver mode, history preference category
This commit is contained in:
Bnyro 2022-07-15 22:27:30 +02:00 committed by GitHub
commit a36fde0cf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 254 additions and 122 deletions

View File

@ -1,7 +1,16 @@
package com.github.libretube
/**
* Global variables can be stored here
*/
object Globals {
// for the player fragment
var isFullScreen = false
var isMiniPlayerVisible = false
// for the settings
var isCurrentViewMainSettings = true
// for the data saver mode
var dataSaverModeEnabled = false
}

View File

@ -75,6 +75,13 @@ class MainActivity : AppCompatActivity() {
RetrofitInstance.url
}
// save whether the data saver mode is enabled
Globals.dataSaverModeEnabled = PreferenceHelper.getBoolean(
this,
"data_saver_mode",
false
)
// show noInternet Activity if no internet available on app startup
if (!ConnectionHelper.isNetworkAvailable(this)) {
val noInternetIntent = Intent(this, NoInternetActivity::class.java)
@ -268,7 +275,8 @@ class MainActivity : AppCompatActivity() {
minimizePlayer()
} catch (e: Exception) {
if (navController.currentDestination?.id == startFragmentId) {
super.onBackPressed()
// close app
moveTaskToBack(true)
} else {
navController.popBackStack()
}

View File

@ -3,9 +3,10 @@ package com.github.libretube.activities
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.github.libretube.Globals
import com.github.libretube.R
import com.github.libretube.databinding.ActivitySettingsBinding
import com.github.libretube.preferences.AboutFragment
import com.github.libretube.preferences.CommunityFragment
import com.github.libretube.preferences.MainSettings
import com.github.libretube.util.ThemeHelper
@ -22,6 +23,8 @@ class SettingsActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
binding = ActivitySettingsBinding.inflate(layoutInflater)
// animate the layout transition
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
overridePendingTransition(50, 50)
}
@ -43,16 +46,24 @@ class SettingsActivity : AppCompatActivity() {
}
override fun onBackPressed() {
if (Globals.isCurrentViewMainSettings) {
super.onBackPressed()
finishAndRemoveTask()
} else {
Globals.isCurrentViewMainSettings = true
supportFragmentManager
.beginTransaction()
.replace(R.id.settings, MainSettings())
.commit()
changeTopBarText(getString(R.string.settings))
when (supportFragmentManager.findFragmentById(R.id.settings)) {
is MainSettings -> {
super.onBackPressed()
finishAndRemoveTask()
}
is CommunityFragment -> {
supportFragmentManager
.beginTransaction()
.replace(R.id.settings, AboutFragment())
.commit()
}
else -> {
supportFragmentManager
.beginTransaction()
.replace(R.id.settings, MainSettings())
.commit()
changeTopBarText(getString(R.string.settings))
}
}
}

View File

@ -12,8 +12,8 @@ import com.github.libretube.databinding.VideoChannelRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.StreamItem
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.formatShort
import com.squareup.picasso.Picasso
class ChannelAdapter(
private val videoFeed: MutableList<StreamItem>,
@ -45,7 +45,7 @@ class ChannelAdapter(
DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
channelDuration.text =
DateUtils.formatElapsedTime(trending.duration!!)
Picasso.get().load(trending.thumbnail).into(channelThumbnail)
ConnectionHelper.loadImage(trending.thumbnail, channelThumbnail)
root.setOnClickListener {
var bundle = Bundle()
bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))

View File

@ -5,8 +5,8 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.databinding.ChapterColumnBinding
import com.github.libretube.obj.ChapterSegment
import com.github.libretube.util.ConnectionHelper
import com.google.android.exoplayer2.ExoPlayer
import com.squareup.picasso.Picasso
class ChaptersAdapter(
private val chapters: List<ChapterSegment>,
@ -23,7 +23,7 @@ class ChaptersAdapter(
override fun onBindViewHolder(holder: ChaptersViewHolder, position: Int) {
val chapter = chapters[position]
holder.binding.apply {
Picasso.get().load(chapter.image).fit().centerCrop().into(chapterImage)
ConnectionHelper.loadImage(chapter.image, chapterImage)
chapterTitle.text = chapter.title
root.setOnClickListener {

View File

@ -14,9 +14,9 @@ import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.CommentsRowBinding
import com.github.libretube.obj.Comment
import com.github.libretube.obj.CommentsPage
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.formatShort
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -53,7 +53,7 @@ class CommentsAdapter(
"" + comment.commentedTime.toString()
commentText.text =
comment.commentText.toString()
Picasso.get().load(comment.thumbnail).fit().centerCrop().into(commentorImage)
ConnectionHelper.loadImage(comment.thumbnail, commentorImage)
likesTextView.text =
comment.likeCount?.toLong().formatShort()
if (comment.verified == true) {

View File

@ -17,8 +17,8 @@ import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.PlaylistId
import com.github.libretube.obj.StreamItem
import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.RetrofitInstance
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -55,7 +55,7 @@ class PlaylistAdapter(
playlistTitle.text = streamItem.title
playlistDescription.text = streamItem.uploaderName
playlistDuration.text = DateUtils.formatElapsedTime(streamItem.duration!!)
Picasso.get().load(streamItem.thumbnail).into(playlistThumbnail)
ConnectionHelper.loadImage(streamItem.thumbnail, playlistThumbnail)
root.setOnClickListener {
var bundle = Bundle()
bundle.putString("videoId", streamItem.url!!.replace("/watch?v=", ""))

View File

@ -12,9 +12,9 @@ import com.github.libretube.databinding.PlaylistsRowBinding
import com.github.libretube.obj.PlaylistId
import com.github.libretube.obj.Playlists
import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.RetrofitInstance
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -45,7 +45,7 @@ class PlaylistsAdapter(
override fun onBindViewHolder(holder: PlaylistsViewHolder, position: Int) {
val playlist = playlists[position]
holder.binding.apply {
Picasso.get().load(playlist.thumbnail).into(playlistThumbnail)
ConnectionHelper.loadImage(playlist.thumbnail, playlistThumbnail)
// set imageview drawable as empty playlist if imageview empty
if (playlistThumbnail.drawable == null) {
playlistThumbnail.setImageResource(R.drawable.ic_empty_playlist)

View File

@ -10,8 +10,8 @@ import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.RepliesRowBinding
import com.github.libretube.obj.Comment
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.formatShort
import com.squareup.picasso.Picasso
class RepliesAdapter(
private val replies: MutableList<Comment>
@ -44,7 +44,7 @@ class RepliesAdapter(
"" + reply.commentedTime.toString()
commentText.text =
reply.commentText.toString()
Picasso.get().load(reply.thumbnail).fit().centerCrop().into(commentorImage)
ConnectionHelper.loadImage(reply.thumbnail, commentorImage)
likesTextView.text =
reply.likeCount?.toLong().formatShort()
if (reply.verified == true) {

View File

@ -20,9 +20,9 @@ import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.SearchItem
import com.github.libretube.obj.Subscribe
import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.formatShort
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -84,14 +84,14 @@ class SearchAdapter(
private fun bindWatch(item: SearchItem, binding: VideoSearchRowBinding) {
binding.apply {
Picasso.get().load(item.thumbnail).fit().centerCrop().into(searchThumbnail)
ConnectionHelper.loadImage(item.thumbnail, searchThumbnail)
if (item.duration != -1L) {
searchThumbnailDuration.text = DateUtils.formatElapsedTime(item.duration!!)
} else {
searchThumbnailDuration.text = root.context.getString(R.string.live)
searchThumbnailDuration.setBackgroundColor(R.attr.colorPrimaryDark)
}
Picasso.get().load(item.uploaderAvatar).fit().centerCrop().into(searchChannelImage)
ConnectionHelper.loadImage(item.uploaderAvatar, searchChannelImage)
searchDescription.text = item.title
val viewsString = if (item.views?.toInt() != -1) item.views.formatShort() else ""
val uploadDate = if (item.uploadedDate != null) item.uploadedDate else ""
@ -131,7 +131,7 @@ class SearchAdapter(
private fun bindChannel(item: SearchItem, binding: ChannelSearchRowBinding) {
binding.apply {
Picasso.get().load(item.thumbnail).fit().centerCrop().into(searchChannelImage)
ConnectionHelper.loadImage(item.thumbnail, searchChannelImage)
searchChannelName.text = item.name
searchViews.text = root.context.getString(
R.string.subscribers,
@ -219,7 +219,7 @@ class SearchAdapter(
private fun bindPlaylist(item: SearchItem, binding: PlaylistSearchRowBinding) {
binding.apply {
Picasso.get().load(item.thumbnail).fit().centerCrop().into(searchThumbnail)
ConnectionHelper.loadImage(item.thumbnail, searchThumbnail)
if (item.videos?.toInt() != -1) searchPlaylistNumber.text = item.videos.toString()
searchDescription.text = item.name
searchName.text = item.uploaderName

View File

@ -15,8 +15,8 @@ import com.github.libretube.databinding.TrendingRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.StreamItem
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.formatShort
import com.squareup.picasso.Picasso
class SubscriptionAdapter(
private val videoFeed: List<StreamItem>,
@ -72,8 +72,8 @@ class SubscriptionAdapter(
} catch (e: Exception) {
}
}
Picasso.get().load(trending.thumbnail).into(thumbnail)
Picasso.get().load(trending.uploaderAvatar).into(channelImage)
ConnectionHelper.loadImage(trending.thumbnail, thumbnail)
ConnectionHelper.loadImage(trending.uploaderAvatar, channelImage)
root.setOnClickListener {
val bundle = Bundle()
bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))

View File

@ -12,8 +12,8 @@ import com.github.libretube.databinding.ChannelSubscriptionRowBinding
import com.github.libretube.obj.Subscribe
import com.github.libretube.obj.Subscription
import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.RetrofitInstance
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -40,7 +40,7 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
val subscription = subscriptions[position]
holder.binding.apply {
subscriptionChannelName.text = subscription.name
Picasso.get().load(subscription.avatar).into(subscriptionChannelImage)
ConnectionHelper.loadImage(subscription.avatar, subscriptionChannelImage)
root.setOnClickListener {
val activity = root.context as MainActivity
val bundle = bundleOf("channel_id" to subscription.url)

View File

@ -15,8 +15,8 @@ import com.github.libretube.databinding.TrendingRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.StreamItem
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.formatShort
import com.squareup.picasso.Picasso
class TrendingAdapter(
private val videoFeed: List<StreamItem>,
@ -63,12 +63,8 @@ class TrendingAdapter(
} catch (e: Exception) {
}
}
if (trending.thumbnail!!.isNotEmpty()) {
Picasso.get().load(trending.thumbnail).into(thumbnail)
}
if (trending.uploaderAvatar!!.isNotEmpty()) {
Picasso.get().load(trending.uploaderAvatar).into(channelImage)
}
ConnectionHelper.loadImage(trending.thumbnail, thumbnail)
ConnectionHelper.loadImage(trending.uploaderAvatar, channelImage)
root.setOnClickListener {
var bundle = Bundle()

View File

@ -15,7 +15,7 @@ import com.github.libretube.databinding.WatchHistoryRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.WatchHistoryItem
import com.squareup.picasso.Picasso
import com.github.libretube.util.ConnectionHelper
class WatchHistoryAdapter(
private val watchHistory: MutableList<WatchHistoryItem>,
@ -43,8 +43,8 @@ class WatchHistoryAdapter(
channelName.text = video.uploader
uploadDate.text = video.uploadDate
thumbnailDuration.text = DateUtils.formatElapsedTime(video.duration?.toLong()!!)
Picasso.get().load(video.thumbnailUrl).into(thumbnail)
Picasso.get().load(video.uploaderAvatar).into(channelImage)
ConnectionHelper.loadImage(video.thumbnailUrl, thumbnail)
ConnectionHelper.loadImage(video.uploaderAvatar, channelImage)
channelImage.setOnClickListener {
val activity = root.context as MainActivity

View File

@ -14,9 +14,9 @@ import com.github.libretube.adapters.ChannelAdapter
import com.github.libretube.databinding.FragmentChannelBinding
import com.github.libretube.obj.Subscribe
import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.formatShort
import com.squareup.picasso.Picasso
import retrofit2.HttpException
import java.io.IOException
@ -194,8 +194,8 @@ class ChannelFragment : Fragment() {
binding.channelDescription.text = response.description?.trim()
}
Picasso.get().load(response.bannerUrl).into(binding.channelBanner)
Picasso.get().load(response.avatarUrl).into(binding.channelImage)
ConnectionHelper.loadImage(response.bannerUrl, binding.channelBanner)
ConnectionHelper.loadImage(response.avatarUrl, binding.channelImage)
channelAdapter = ChannelAdapter(
response.relatedStreams!!.toMutableList(),
childFragmentManager

View File

@ -57,6 +57,7 @@ import com.github.libretube.obj.Subscribe
import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.services.IS_DOWNLOAD_RUNNING
import com.github.libretube.util.BackgroundMode
import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.CronetHelper
import com.github.libretube.util.DescriptionAdapter
import com.github.libretube.util.RetrofitInstance
@ -87,7 +88,6 @@ import com.google.android.exoplayer2.util.RepeatModeUtil
import com.google.android.exoplayer2.video.VideoSize
import com.google.android.material.button.MaterialButton
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -739,17 +739,19 @@ class PlayerFragment : Fragment() {
}
private fun initializePlayerView(view: View, response: Streams) {
binding.playerViewsInfo.text =
context?.getString(R.string.views, response.views.formatShort()) +
"" + response.uploadDate
binding.textLike.text = response.likes.formatShort()
binding.textDislike.text = response.dislikes.formatShort()
Picasso.get().load(response.uploaderAvatar).into(binding.playerChannelImage)
binding.playerChannelName.text = response.uploader
binding.apply {
playerViewsInfo.text =
context?.getString(R.string.views, response.views.formatShort()) +
"" + response.uploadDate
textLike.text = response.likes.formatShort()
textDislike.text = response.dislikes.formatShort()
ConnectionHelper.loadImage(response.uploaderAvatar, binding.playerChannelImage)
playerChannelName.text = response.uploader
binding.titleTextView.text = response.title
binding.playerTitle.text = response.title
binding.playerDescription.text = response.description
titleTextView.text = response.title
playerTitle.text = response.title
playerDescription.text = response.description
}
playerBinding.exoTitle.text = response.title

View File

@ -81,6 +81,13 @@ class AboutFragment : Fragment() {
showSnackBar(text)
true
}
binding.community.setOnClickListener {
val communityFragment = CommunityFragment()
parentFragmentManager.beginTransaction()
.replace(R.id.settings, communityFragment)
.commitNow()
}
}
private fun openLinkFromHref(link: String) {

View File

@ -3,6 +3,7 @@ package com.github.libretube.preferences
import android.os.Bundle
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
import com.github.libretube.dialogs.RequireRestartDialog
@ -17,18 +18,10 @@ class AdvancedSettings : PreferenceFragmentCompat() {
val settingsActivity = activity as SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.advanced))
// clear search history
val clearHistory = findPreference<Preference>("clear_history")
clearHistory?.setOnPreferenceClickListener {
PreferenceHelper.removePreference(requireContext(), "search_history")
true
}
// clear watch history and positions
val clearWatchHistory = findPreference<Preference>("clear_watch_history")
clearWatchHistory?.setOnPreferenceClickListener {
PreferenceHelper.removePreference(requireContext(), "watch_history")
PreferenceHelper.removePreference(requireContext(), "watch_positions")
val dataSaverMode = findPreference<SwitchPreferenceCompat>("data_saver_mode")
dataSaverMode?.setOnPreferenceChangeListener { _, _ ->
val restartDialog = RequireRestartDialog()
restartDialog.show(childFragmentManager, "RequireRestartDialog")
true
}

View File

@ -0,0 +1,38 @@
package com.github.libretube.preferences
import android.os.Bundle
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
class HistorySettings : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.history_settings, rootKey)
val settingsActivity = activity as SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.history))
// clear search history
val clearHistory = findPreference<Preference>("clear_history")
clearHistory?.setOnPreferenceClickListener {
PreferenceHelper.removePreference(requireContext(), "search_history")
true
}
// clear watch history and positions
val clearWatchHistory = findPreference<Preference>("clear_watch_history")
clearWatchHistory?.setOnPreferenceClickListener {
PreferenceHelper.removePreference(requireContext(), "watch_history")
true
}
// clear watch positions
val clearWatchPositions = findPreference<Preference>("clear_watch_positions")
clearWatchPositions?.setOnPreferenceClickListener {
PreferenceHelper.removePreference(requireContext(), "watch_positions")
true
}
}
}

View File

@ -64,6 +64,13 @@ class MainSettings : PreferenceFragmentCompat() {
true
}
val history = findPreference<Preference>("history")
history?.setOnPreferenceClickListener {
val newFragment = HistorySettings()
navigateToSettingsFragment(newFragment)
true
}
val advanced = findPreference<Preference>("advanced")
advanced?.setOnPreferenceClickListener {
val newFragment = AdvancedSettings()
@ -84,13 +91,6 @@ class MainSettings : PreferenceFragmentCompat() {
navigateToSettingsFragment(newFragment)
true
}
val community = findPreference<Preference>("community")
community?.setOnPreferenceClickListener {
val newFragment = CommunityFragment()
navigateToSettingsFragment(newFragment)
true
}
}
private fun navigateToSettingsFragment(newFragment: Fragment) {

View File

@ -2,6 +2,9 @@ package com.github.libretube.util
import android.content.Context
import android.net.ConnectivityManager
import android.widget.ImageView
import com.github.libretube.Globals
import com.squareup.picasso.Picasso
object ConnectionHelper {
fun isNetworkAvailable(context: Context): Boolean {
@ -33,4 +36,12 @@ object ConnectionHelper {
return connectivityManager.activeNetworkInfo?.isConnected ?: false
}
// load an image from a url into an imageView
fun loadImage(url: String?, target: ImageView) {
// only load the image if the data saver mode is disabled
if (!Globals.dataSaverModeEnabled) {
Picasso.get().load(url).fit().centerCrop().into(target)
}
}
}

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#FF000000"
android:pathData="M22.55,31.45L22.55,25.4L16.5,25.4v-3h6.05v-6.05h3v6.05h6v3h-6v6.05ZM42.15,32.55 L37.75,30.1q0.6,-1.55 0.9,-3.075 0.3,-1.525 0.3,-3.025 0,-5.8 -3.825,-10.05Q31.3,9.7 25.6,9.2L25.6,4.1q7.85,0.55 13.15,6.225Q44.05,16 44.05,23.8q0,2.25 -0.475,4.425T42.15,32.55ZM24.05,44q-4.1,0 -7.75,-1.575 -3.65,-1.575 -6.375,-4.275t-4.3,-6.35Q4.05,28.15 4.05,24.05q0,-7.9 5.325,-13.6Q14.7,4.75 22.6,4.15v5.1q-5.75,0.55 -9.6,4.775Q9.15,18.25 9.15,24.05q0,6.2 4.35,10.525T24.05,38.9q3.6,0 6.8,-1.625 3.2,-1.625 5.45,-4.575l4.4,2.55q-2.9,4.15 -7.275,6.45T24.05,44Z" />
</vector>

View File

@ -117,6 +117,24 @@
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/community"
style="@style/AboutCard">
<LinearLayout style="@style/AboutItem">
<ImageView
style="@style/AboutImageView"
android:src="@drawable/ic_community" />
<TextView
style="@style/AboutTextView"
android:text="@string/community" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</ScrollView>

View File

@ -23,8 +23,7 @@
<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher" />
android:layout_height="match_parent" />
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"

View File

@ -145,7 +145,7 @@
<string name="advanced">Advanced</string>
<string name="player">Player</string>
<string name="appearance_summary">Adjust the app to your liking.</string>
<string name="advanced_summary">Downloads, history</string>
<string name="advanced_summary">Downloads, reset</string>
<string name="live">Live</string>
<string name="no_replies">This comment has no replies.</string>
<string name="authors">Authors</string>
@ -209,7 +209,7 @@
<string name="restore">Restore</string>
<string name="watch_history">Watch History</string>
<string name="watch_positions">Remember position</string>
<string name="watch_positions_summary">Remember the watch position and automatically seek to it.</string>
<string name="watch_positions_summary">Restore last watch position</string>
<string name="auth_instance">Authentication instance</string>
<string name="auth_instance_summary">Use a different instance for authenticated calls.</string>
<string name="auth_instances">Choose an auth instance</string>
@ -242,4 +242,11 @@
<string name="pure_theme">Pure theme</string>
<string name="pure_theme_summary">Pure white/black theme</string>
<string name="no_player_found">No external player found. Please make sure you have one installed.</string>
<string name="data_saver_mode">Data saver mode</string>
<string name="data_saver_mode_summary">Don\'t load thumbnails and other images to save data.</string>
<string name="search_history_summary">Store the search queries locally</string>
<string name="watch_history_summary">Keep track of watched videos locally</string>
<string name="history_summary">Watch and search history</string>
<string name="watch_positions_title">Watch positions</string>
<string name="reset_watch_positions">Reset watch positions</string>
</resources>

View File

@ -31,44 +31,13 @@
</PreferenceCategory>
<PreferenceCategory app:title="@string/search_history">
<PreferenceCategory app:title="@string/advanced">
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_history_filled"
app:key="search_history_toggle"
app:title="@string/search_history" />
<Preference
android:icon="@drawable/ic_trash"
app:key="clear_history"
app:title="@string/clear_history" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/watch_history">
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_time_outlined"
app:key="watch_history_toggle"
app:title="@string/watch_history" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_play_filled"
app:key="watch_position_toggle"
app:summary="@string/watch_positions_summary"
app:title="@string/watch_positions" />
<Preference
android:icon="@drawable/ic_trash"
app:key="clear_watch_history"
app:title="@string/clear_history" />
</PreferenceCategory>
<PreferenceCategory>
android:icon="@drawable/ic_data_saver"
android:summary="@string/data_saver_mode_summary"
app:key="data_saver_mode"
app:title="@string/data_saver_mode" />
<Preference
android:icon="@drawable/ic_reset"

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:title="@string/search_history">
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_history_filled"
android:summary="@string/search_history_summary"
app:key="search_history_toggle"
app:title="@string/search_history" />
<Preference
android:icon="@drawable/ic_trash"
app:key="clear_history"
app:title="@string/clear_history" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/watch_history">
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_time_outlined"
android:summary="@string/watch_history_summary"
app:key="watch_history_toggle"
app:title="@string/watch_history" />
<Preference
android:icon="@drawable/ic_trash"
app:key="clear_watch_history"
app:title="@string/clear_history" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/watch_positions_title">
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_play_filled"
app:key="watch_position_toggle"
app:summary="@string/watch_positions_summary"
app:title="@string/watch_positions" />
<Preference
app:title="@string/reset_watch_positions"
android:icon="@drawable/ic_reset"
app:key="reset_watch_positions" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -50,6 +50,12 @@
app:summary="@string/player_summary"
app:title="@string/audio_video" />
<Preference
android:icon="@drawable/ic_history_filled"
android:summary="@string/history_summary"
app:key="history"
app:title="@string/history" />
<Preference
android:icon="@drawable/ic_list"
app:key="advanced"
@ -71,11 +77,6 @@
app:key="about"
app:title="@string/about" />
<Preference
android:icon="@drawable/ic_community"
app:key="community"
app:title="@string/community" />
</PreferenceCategory>
</PreferenceScreen>