mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
commit
aaabcfe701
@ -33,6 +33,7 @@ object PreferenceKeys {
|
|||||||
const val APP_ICON = "icon_change"
|
const val APP_ICON = "icon_change"
|
||||||
const val LEGACY_SUBSCRIPTIONS = "legacy_subscriptions"
|
const val LEGACY_SUBSCRIPTIONS = "legacy_subscriptions"
|
||||||
const val LEGACY_SUBSCRIPTIONS_COLUMNS = "legacy_subscriptions_columns"
|
const val LEGACY_SUBSCRIPTIONS_COLUMNS = "legacy_subscriptions_columns"
|
||||||
|
const val ALTERNATIVE_TRENDING_LAYOUT = "trending_layout"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance
|
* Instance
|
||||||
@ -77,12 +78,6 @@ object PreferenceKeys {
|
|||||||
*/
|
*/
|
||||||
const val BACKGROUND_PLAYBACK_SPEED = "background_playback_speed"
|
const val BACKGROUND_PLAYBACK_SPEED = "background_playback_speed"
|
||||||
|
|
||||||
/**
|
|
||||||
* Download
|
|
||||||
*/
|
|
||||||
const val DOWNLOAD_LOCATION = "download_location"
|
|
||||||
const val DOWNLOAD_FOLDER = "download_folder"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifications
|
* Notifications
|
||||||
*/
|
*/
|
||||||
|
@ -8,7 +8,9 @@ import android.view.ViewGroup
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
|
import com.github.libretube.adapters.ChannelAdapter
|
||||||
import com.github.libretube.adapters.TrendingAdapter
|
import com.github.libretube.adapters.TrendingAdapter
|
||||||
import com.github.libretube.api.RetrofitInstance
|
import com.github.libretube.api.RetrofitInstance
|
||||||
import com.github.libretube.constants.PreferenceKeys
|
import com.github.libretube.constants.PreferenceKeys
|
||||||
@ -41,11 +43,6 @@ class HomeFragment : BaseFragment() {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
val grid = PreferenceHelper.getString(
|
|
||||||
PreferenceKeys.GRID_COLUMNS,
|
|
||||||
resources.getInteger(R.integer.grid_items).toString()
|
|
||||||
)
|
|
||||||
|
|
||||||
val regionPref = PreferenceHelper.getString(PreferenceKeys.REGION, "sys")
|
val regionPref = PreferenceHelper.getString(PreferenceKeys.REGION, "sys")
|
||||||
|
|
||||||
// get the system default country if auto region selected
|
// get the system default country if auto region selected
|
||||||
@ -57,15 +54,14 @@ class HomeFragment : BaseFragment() {
|
|||||||
regionPref
|
regionPref
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.recview.layoutManager = GridLayoutManager(view.context, grid.toInt())
|
fetchTrending()
|
||||||
fetchJson()
|
|
||||||
binding.homeRefresh.isEnabled = true
|
binding.homeRefresh.isEnabled = true
|
||||||
binding.homeRefresh.setOnRefreshListener {
|
binding.homeRefresh.setOnRefreshListener {
|
||||||
fetchJson()
|
fetchTrending()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchJson() {
|
private fun fetchTrending() {
|
||||||
fun run() {
|
fun run() {
|
||||||
lifecycleScope.launchWhenCreated {
|
lifecycleScope.launchWhenCreated {
|
||||||
val response = try {
|
val response = try {
|
||||||
@ -84,7 +80,29 @@ class HomeFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
binding.recview.adapter = TrendingAdapter(response, childFragmentManager)
|
if (
|
||||||
|
PreferenceHelper.getBoolean(
|
||||||
|
PreferenceKeys.ALTERNATIVE_TRENDING_LAYOUT,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
binding.recview.layoutManager = LinearLayoutManager(context)
|
||||||
|
|
||||||
|
binding.recview.adapter = ChannelAdapter(
|
||||||
|
response.toMutableList(),
|
||||||
|
childFragmentManager
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
binding.recview.layoutManager = GridLayoutManager(
|
||||||
|
context,
|
||||||
|
PreferenceHelper.getString(
|
||||||
|
PreferenceKeys.GRID_COLUMNS,
|
||||||
|
resources.getInteger(R.integer.grid_items).toString()
|
||||||
|
).toInt()
|
||||||
|
)
|
||||||
|
|
||||||
|
binding.recview.adapter = TrendingAdapter(response, childFragmentManager)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -641,19 +641,6 @@
|
|||||||
<item>.mkv</item>
|
<item>.mkv</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="downloadLocation">
|
|
||||||
<item>@string/downloads_directory</item>
|
|
||||||
<item>@string/music_directory</item>
|
|
||||||
<item>@string/movies_directory</item>
|
|
||||||
<item>@string/sdcard</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="downloadLocationValues">
|
|
||||||
<item>downloads</item>
|
|
||||||
<item>music</item>
|
|
||||||
<item>movies</item>
|
|
||||||
<item>sdcard</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="bufferingGoal">
|
<string-array name="bufferingGoal">
|
||||||
<item>50s</item>
|
<item>50s</item>
|
||||||
<item>100s</item>
|
<item>100s</item>
|
||||||
|
@ -315,4 +315,5 @@
|
|||||||
<string name="device_info">Device Info</string>
|
<string name="device_info">Device Info</string>
|
||||||
<string name="audio_video_summary">Quality and format</string>
|
<string name="audio_video_summary">Quality and format</string>
|
||||||
<string name="delete">Delete</string>
|
<string name="delete">Delete</string>
|
||||||
|
<string name="trending_layout">Alternative trending layout</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -2,38 +2,6 @@
|
|||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<!--
|
|
||||||
<PreferenceCategory app:title="@string/downloads">
|
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:defaultValue="downloads"
|
|
||||||
android:entries="@array/downloadLocation"
|
|
||||||
android:entryValues="@array/downloadLocationValues"
|
|
||||||
app:icon="@drawable/ic_download_filled"
|
|
||||||
app:key="download_location"
|
|
||||||
app:summary="@string/download_directory_summary"
|
|
||||||
app:title="@string/download_directory" />
|
|
||||||
|
|
||||||
<EditTextPreference
|
|
||||||
android:defaultValue="LibreTube"
|
|
||||||
app:icon="@drawable/ic_folder"
|
|
||||||
app:key="download_folder"
|
|
||||||
app:summary="@string/download_folder_summary"
|
|
||||||
app:title="@string/download_folder" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/share">
|
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
|
||||||
app:defaultValue="true"
|
|
||||||
app:icon="@drawable/ic_time"
|
|
||||||
app:key="share_with_time_code"
|
|
||||||
app:title="@string/share_with_time" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/advanced">
|
<PreferenceCategory app:title="@string/advanced">
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
|
@ -94,6 +94,12 @@
|
|||||||
app:key="legacy_subscriptions_columns"
|
app:key="legacy_subscriptions_columns"
|
||||||
app:title="@string/grid" />
|
app:title="@string/grid" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:icon="@drawable/ic_trending"
|
||||||
|
app:defaultValue="false"
|
||||||
|
app:key="trending_layout"
|
||||||
|
app:title="@string/trending_layout" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user