mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
minor fixes
This commit is contained in:
parent
072f31a1e8
commit
ddac0ebfd3
@ -62,7 +62,7 @@ class ChannelAdapter(
|
|||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
val videoId = trending.url!!.replace("/watch?v=", "")
|
val videoId = trending.url!!.replace("/watch?v=", "")
|
||||||
VideoOptionsDialog(videoId, root.context)
|
VideoOptionsDialog(videoId, root.context)
|
||||||
.show(childFragmentManager, VideoOptionsDialog.TAG)
|
.show(childFragmentManager, "VideoOptionsDialog")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ class PlaylistAdapter(
|
|||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
val videoId = streamItem.url!!.replace("/watch?v=", "")
|
val videoId = streamItem.url!!.replace("/watch?v=", "")
|
||||||
VideoOptionsDialog(videoId, root.context)
|
VideoOptionsDialog(videoId, root.context)
|
||||||
.show(childFragmentManager, VideoOptionsDialog.TAG)
|
.show(childFragmentManager, "VideoOptionsDialog")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ class SearchAdapter(
|
|||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
val videoId = item.url!!.replace("/watch?v=", "")
|
val videoId = item.url!!.replace("/watch?v=", "")
|
||||||
VideoOptionsDialog(videoId, root.context)
|
VideoOptionsDialog(videoId, root.context)
|
||||||
.show(childFragmentManager, VideoOptionsDialog.TAG)
|
.show(childFragmentManager, "VideoOptionsDialog")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
searchChannelImage.setOnClickListener {
|
searchChannelImage.setOnClickListener {
|
||||||
|
@ -90,7 +90,7 @@ class SubscriptionAdapter(
|
|||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
val videoId = trending.url!!.replace("/watch?v=", "")
|
val videoId = trending.url!!.replace("/watch?v=", "")
|
||||||
VideoOptionsDialog(videoId, root.context)
|
VideoOptionsDialog(videoId, root.context)
|
||||||
.show(childFragmentManager, VideoOptionsDialog.TAG)
|
.show(childFragmentManager, "VideoOptionsDialog")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ class TrendingAdapter(
|
|||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
val videoId = trending.url!!.replace("/watch?v=", "")
|
val videoId = trending.url!!.replace("/watch?v=", "")
|
||||||
VideoOptionsDialog(videoId, root.context)
|
VideoOptionsDialog(videoId, root.context)
|
||||||
.show(childFragmentManager, VideoOptionsDialog.TAG)
|
.show(childFragmentManager, "VideoOptionsDialog")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class WatchHistoryAdapter(
|
|||||||
}
|
}
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
VideoOptionsDialog(video.videoId!!, root.context)
|
VideoOptionsDialog(video.videoId!!, root.context)
|
||||||
.show(childFragmentManager, VideoOptionsDialog.TAG)
|
.show(childFragmentManager, "VideoOptionsDialog")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,12 @@ import android.net.Uri
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.services.UpdateService
|
import com.github.libretube.services.UpdateService
|
||||||
import com.github.libretube.update.UpdateInfo
|
import com.github.libretube.update.UpdateInfo
|
||||||
|
import com.github.libretube.util.PermissionHelper
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
||||||
class UpdateDialog(
|
class UpdateDialog(
|
||||||
@ -28,6 +30,7 @@ class UpdateDialog(
|
|||||||
val downloadUrl = getDownloadUrl(updateInfo)
|
val downloadUrl = getDownloadUrl(updateInfo)
|
||||||
Log.i("downloadUrl", downloadUrl.toString())
|
Log.i("downloadUrl", downloadUrl.toString())
|
||||||
if (downloadUrl != null) {
|
if (downloadUrl != null) {
|
||||||
|
PermissionHelper.requestReadWrite(activity as AppCompatActivity)
|
||||||
val intent = Intent(context, UpdateService::class.java)
|
val intent = Intent(context, UpdateService::class.java)
|
||||||
intent.putExtra("downloadUrl", downloadUrl)
|
intent.putExtra("downloadUrl", downloadUrl)
|
||||||
context?.startService(intent)
|
context?.startService(intent)
|
||||||
@ -44,8 +47,8 @@ class UpdateDialog(
|
|||||||
private fun getDownloadUrl(updateInfo: UpdateInfo): String? {
|
private fun getDownloadUrl(updateInfo: UpdateInfo): String? {
|
||||||
val supportedArchitectures = Build.SUPPORTED_ABIS
|
val supportedArchitectures = Build.SUPPORTED_ABIS
|
||||||
supportedArchitectures.forEach { arch ->
|
supportedArchitectures.forEach { arch ->
|
||||||
updateInfo.assets.forEach {
|
updateInfo.assets.forEach { asset ->
|
||||||
if (it.browser_download_url.contains(arch)) return it.browser_download_url
|
if (asset.name.contains(arch)) return asset.browser_download_url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
@ -17,6 +17,8 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||||||
* Needs the [videoId] to load the content from the right video.
|
* Needs the [videoId] to load the content from the right video.
|
||||||
*/
|
*/
|
||||||
class VideoOptionsDialog(private val videoId: String, context: Context) : DialogFragment() {
|
class VideoOptionsDialog(private val videoId: String, context: Context) : DialogFragment() {
|
||||||
|
private val TAG = "VideoOptionsDialog"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List that stores the different menu options. In the future could be add more options here.
|
* List that stores the different menu options. In the future could be add more options here.
|
||||||
*/
|
*/
|
||||||
@ -71,8 +73,4 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog
|
|||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val TAG = "VideoOptionsDialog"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package com.github.libretube.fragments
|
package com.github.libretube.fragments
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
@ -62,6 +62,10 @@ class ChannelFragment : Fragment() {
|
|||||||
fetchChannel()
|
fetchChannel()
|
||||||
if (PreferenceHelper.getToken() != "") {
|
if (PreferenceHelper.getToken() != "") {
|
||||||
isSubscribed()
|
isSubscribed()
|
||||||
|
} else {
|
||||||
|
binding.channelSubscribe.setOnClickListener {
|
||||||
|
Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refreshChannel()
|
refreshChannel()
|
||||||
@ -85,7 +89,6 @@ class ChannelFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isSubscribed() {
|
private fun isSubscribed() {
|
||||||
@SuppressLint("ResourceAsColor")
|
|
||||||
fun run() {
|
fun run() {
|
||||||
lifecycleScope.launchWhenCreated {
|
lifecycleScope.launchWhenCreated {
|
||||||
val response = try {
|
val response = try {
|
||||||
@ -104,10 +107,10 @@ class ChannelFragment : Fragment() {
|
|||||||
isSubscribed = true
|
isSubscribed = true
|
||||||
binding.channelSubscribe.text = getString(R.string.unsubscribe)
|
binding.channelSubscribe.text = getString(R.string.unsubscribe)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.channelSubscribe.setOnClickListener {
|
||||||
if (response.subscribed != null) {
|
if (response.subscribed != null) {
|
||||||
binding.channelSubscribe.apply {
|
binding.channelSubscribe.text = if (isSubscribed) {
|
||||||
setOnClickListener {
|
|
||||||
text = if (isSubscribed) {
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
getString(R.string.subscribe)
|
getString(R.string.subscribe)
|
||||||
} else {
|
} else {
|
||||||
@ -119,7 +122,6 @@ class ChannelFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
run()
|
run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.github.libretube.fragments
|
package com.github.libretube.fragments
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.PictureInPictureParams
|
import android.app.PictureInPictureParams
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@ -1526,7 +1525,6 @@ class PlayerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isSubscribed(button: MaterialButton, channel_id: String) {
|
private fun isSubscribed(button: MaterialButton, channel_id: String) {
|
||||||
@SuppressLint("ResourceAsColor")
|
|
||||||
fun run() {
|
fun run() {
|
||||||
lifecycleScope.launchWhenCreated {
|
lifecycleScope.launchWhenCreated {
|
||||||
val response = try {
|
val response = try {
|
||||||
|
@ -93,7 +93,7 @@ class MainSettings : PreferenceFragmentCompat() {
|
|||||||
update?.setOnPreferenceClickListener {
|
update?.setOnPreferenceClickListener {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
// check for update
|
// check for update
|
||||||
val updateInfo = UpdateChecker.checkUpdate()
|
val updateInfo = UpdateChecker.getLatestReleaseInfo()
|
||||||
if (updateInfo?.name != "" && BuildConfig.VERSION_NAME != updateInfo?.name) {
|
if (updateInfo?.name != "" && BuildConfig.VERSION_NAME != updateInfo?.name) {
|
||||||
// show the UpdateAvailableDialog if there's an update available
|
// show the UpdateAvailableDialog if there's an update available
|
||||||
val updateAvailableDialog = UpdateDialog(updateInfo!!)
|
val updateAvailableDialog = UpdateDialog(updateInfo!!)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.github.libretube.update
|
package com.github.libretube.update
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
data class Asset(
|
data class Asset(
|
||||||
val browser_download_url: String,
|
val browser_download_url: String,
|
||||||
val content_type: String,
|
val content_type: String,
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.github.libretube.update
|
package com.github.libretube.update
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
data class Author(
|
data class Author(
|
||||||
val avatar_url: String,
|
val avatar_url: String,
|
||||||
val events_url: String,
|
val events_url: String,
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.github.libretube.update
|
package com.github.libretube.update
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
data class Reactions(
|
data class Reactions(
|
||||||
val confused: Int,
|
val confused: Int,
|
||||||
val eyes: Int,
|
val eyes: Int,
|
||||||
|
@ -2,13 +2,10 @@ package com.github.libretube.update
|
|||||||
|
|
||||||
import com.github.libretube.GITHUB_API_URL
|
import com.github.libretube.GITHUB_API_URL
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import java.io.BufferedReader
|
|
||||||
import java.io.InputStreamReader
|
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import javax.net.ssl.HttpsURLConnection
|
|
||||||
|
|
||||||
object UpdateChecker {
|
object UpdateChecker {
|
||||||
fun checkUpdate(): UpdateInfo? {
|
fun getLatestReleaseInfo(): UpdateInfo? {
|
||||||
var versionInfo: UpdateInfo? = null
|
var versionInfo: UpdateInfo? = null
|
||||||
// run http request as thread to make it async
|
// run http request as thread to make it async
|
||||||
val thread = Thread {
|
val thread = Thread {
|
||||||
@ -26,19 +23,13 @@ object UpdateChecker {
|
|||||||
return versionInfo
|
return versionInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUpdateInfo(): UpdateInfo? {
|
private fun getUpdateInfo(): UpdateInfo? {
|
||||||
val latest = URL(GITHUB_API_URL)
|
// get the github API response
|
||||||
val json = StringBuilder()
|
val latestVersionApiUrl = URL(GITHUB_API_URL)
|
||||||
val urlConnection: HttpsURLConnection?
|
val json = latestVersionApiUrl.readText()
|
||||||
urlConnection = latest.openConnection() as HttpsURLConnection
|
|
||||||
|
|
||||||
// read json
|
|
||||||
val br = BufferedReader(InputStreamReader(urlConnection.inputStream))
|
|
||||||
var line: String?
|
|
||||||
while (br.readLine().also { line = it } != null) json.append(line)
|
|
||||||
|
|
||||||
// Parse and return the json data
|
// Parse and return the json data
|
||||||
val gson = Gson()
|
val gson = Gson()
|
||||||
return gson.fromJson(json.toString(), UpdateInfo::class.java)
|
return gson.fromJson(json, UpdateInfo::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.github.libretube.update
|
package com.github.libretube.update
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
data class UpdateInfo(
|
data class UpdateInfo(
|
||||||
val assets: List<Asset>,
|
val assets: List<Asset>,
|
||||||
val assets_url: String,
|
val assets_url: String,
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.github.libretube.update
|
package com.github.libretube.update
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
data class Uploader(
|
data class Uploader(
|
||||||
val avatar_url: String,
|
val avatar_url: String,
|
||||||
val events_url: String,
|
val events_url: String,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user