Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
3f461792e5 | |||
4738c317cc | |||
3997b38120 | |||
a1deaa844c | |||
4de1408ba6 | |||
48eec0dc88 | |||
4bbeb284da |
@ -1,4 +1,3 @@
|
||||
|
||||
plugins {
|
||||
id "com.android.application"
|
||||
id "kotlin-android"
|
||||
@ -7,11 +6,11 @@ plugins {
|
||||
android {
|
||||
defaultConfig {
|
||||
applicationId "org.libre.agosto.p2play"
|
||||
compileSdk 34
|
||||
compileSdk 35
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 32
|
||||
versionCode 10
|
||||
versionName "0.7.0"
|
||||
versionCode 14
|
||||
versionName "0.8.3"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
@ -25,14 +24,17 @@ android {
|
||||
viewBinding = true
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
sourceCompatibility JavaVersion.VERSION_18
|
||||
targetCompatibility JavaVersion.VERSION_18
|
||||
}
|
||||
namespace 'org.libre.agosto.p2play'
|
||||
lint {
|
||||
abortOnError false
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '18'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -66,11 +66,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
binding.content.mini.miniPlayerAuthor.setOnClickListener { this.resumeVideo() }
|
||||
// binding.content.mini.setOnClickListener { this.resumeVideo() }
|
||||
binding.content.mini.miniPlayPause.setOnClickListener { this.playPausePlayer() }
|
||||
|
||||
Handler().postDelayed({
|
||||
// Title for nav_bar
|
||||
binding.navView.getHeaderView(0).findViewById<TextView>(R.id.side_emailTxt).text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
// Generic function for set data to RecyclerView
|
||||
@ -374,10 +369,10 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
}
|
||||
|
||||
private fun setSideData() {
|
||||
val headerView = binding.navView.getHeaderView(0)
|
||||
if (ManagerSingleton.user.status == 1) {
|
||||
binding.navView.menu.findItem(R.id.ml).isVisible = true
|
||||
|
||||
val headerView = binding.navView.getHeaderView(0)
|
||||
headerView.findViewById<TextView>(R.id.side_usernameTxt).text = ManagerSingleton.user.username
|
||||
headerView.findViewById<TextView>(R.id.side_emailTxt).text = ManagerSingleton.user.email
|
||||
if (ManagerSingleton.user.avatar != "" && headerView.findViewById<ImageView>(R.id.side_imageView) != null) {
|
||||
@ -394,6 +389,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
}
|
||||
} else {
|
||||
binding.navView.menu.findItem(R.id.ml).isVisible = false
|
||||
headerView.findViewById<TextView>(R.id.side_emailTxt).text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import android.net.Uri
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.webkit.WebChromeClient
|
||||
@ -129,7 +130,7 @@ class ReproductorActivity : AppCompatActivity() {
|
||||
binding.reportLayout.setOnClickListener { reportIntent() }
|
||||
fullscreenButton.setOnClickListener { toggleFullscreen() }
|
||||
fullscreenButton2.setOnClickListener { toggleFullscreen() }
|
||||
binding.downloadLayout!!.setOnClickListener { downloadVideo() }
|
||||
binding.downloadLayout.setOnClickListener { downloadVideo() }
|
||||
|
||||
|
||||
binding.userImg.setOnClickListener {
|
||||
@ -139,7 +140,7 @@ class ReproductorActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
AsyncTask.execute {
|
||||
videoPlayback = this.clientVideo.getVideo(this.video.uuid)
|
||||
videoPlayback = this.clientVideo.getVideo(this.video.uuid, ManagerSingleton.token.token)
|
||||
// TODO: Make this configurable
|
||||
// val bufferSize = 1024 * 1024 // 1mb
|
||||
// val allocator = DefaultAllocator(true, bufferSize)
|
||||
@ -149,7 +150,7 @@ class ReproductorActivity : AppCompatActivity() {
|
||||
|
||||
runOnUiThread {
|
||||
try {
|
||||
if (PlaybackSingleton.player == null || !PlaybackSingleton.player!!.playWhenReady) {
|
||||
if (PlaybackSingleton.player == null || !PlaybackSingleton.player!!.isPlaying) {
|
||||
PlaybackSingleton.player = ExoPlayer.Builder(this)
|
||||
//.setSeekBackIncrementMs(10000)
|
||||
//.setSeekForwardIncrementMs(10000)
|
||||
@ -160,7 +161,6 @@ class ReproductorActivity : AppCompatActivity() {
|
||||
player = PlaybackSingleton.player!!
|
||||
binding.exoPlayer.player = player
|
||||
|
||||
binding.exoPlayer
|
||||
player.addListener(
|
||||
object : Player.Listener {
|
||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||
@ -175,9 +175,6 @@ class ReproductorActivity : AppCompatActivity() {
|
||||
}
|
||||
)
|
||||
|
||||
println("----- video --------")
|
||||
println(videoPlayback.streamingData?.playlistUrl)
|
||||
|
||||
if (!isResume) {
|
||||
val mediaItem = MediaItem.Builder()
|
||||
.setUri(videoPlayback.streamingData?.playlistUrl!!)
|
||||
@ -192,7 +189,7 @@ class ReproductorActivity : AppCompatActivity() {
|
||||
}
|
||||
// Start the playback.
|
||||
// TODO: Setting for autoplay
|
||||
// player.play()
|
||||
player.playWhenReady = true
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
}
|
||||
@ -359,6 +356,10 @@ class ReproductorActivity : AppCompatActivity() {
|
||||
} else {
|
||||
binding.commentBox.commentaryLayout.visibility = View.GONE
|
||||
}
|
||||
|
||||
if (::player.isInitialized && !player.isPlaying) {
|
||||
binding.exoPlayer.onResume()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDescription() {
|
||||
|
@ -10,6 +10,8 @@ import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.preference.PreferenceManager
|
||||
import org.libre.agosto.p2play.ajax.Auth
|
||||
import org.libre.agosto.p2play.helpers.TaskManager
|
||||
import org.libre.agosto.p2play.models.TokenModel
|
||||
import java.lang.Exception
|
||||
|
||||
class SplashActivity : AppCompatActivity() {
|
||||
@ -31,55 +33,50 @@ class SplashActivity : AppCompatActivity() {
|
||||
val lastHost = settings.getString("last_host", "")
|
||||
if (host != "") {
|
||||
if (lastHost != host) {
|
||||
Handler().postDelayed({
|
||||
Thread.sleep(2000)
|
||||
startHostActivity()
|
||||
}, 2000)
|
||||
} else {
|
||||
ManagerSingleton.url = host
|
||||
checkUser()
|
||||
}
|
||||
} else {
|
||||
Handler().postDelayed({
|
||||
Thread.sleep(2000)
|
||||
startHostActivity()
|
||||
}, 2000)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkUser() {
|
||||
Log.d("was", "Checked")
|
||||
try {
|
||||
val token = db.getToken()
|
||||
val user = db.getUser()
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
if (token.status == 1 && user.status == 1) {
|
||||
val clientId = settings.getString("client_id", "")!!
|
||||
val clientSecret = settings.getString("client_secret", "")!!
|
||||
val task = TaskManager<TokenModel>()
|
||||
|
||||
val newToken = client.refreshToken(token, clientId, clientSecret)
|
||||
|
||||
when (token.status.toString()) {
|
||||
task.runTask(
|
||||
{
|
||||
client.refreshToken(token, clientId, clientSecret)
|
||||
}, {
|
||||
when (it.status.toString()) {
|
||||
"1" -> {
|
||||
db.newToken(newToken)
|
||||
ManagerSingleton.token = newToken
|
||||
db.newToken(it)
|
||||
ManagerSingleton.token = it
|
||||
ManagerSingleton.user = user
|
||||
}
|
||||
else -> ManagerSingleton.logout()
|
||||
}
|
||||
startApp()
|
||||
})
|
||||
} else {
|
||||
ManagerSingleton.logout()
|
||||
}
|
||||
|
||||
startApp()
|
||||
}
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
Handler().postDelayed({
|
||||
startApp()
|
||||
}, 2000)
|
||||
Thread.sleep(2000)
|
||||
startHostActivity()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,7 @@ class Auth : Client() {
|
||||
token.status = 1
|
||||
} else {
|
||||
Log.d("Status", con.responseMessage)
|
||||
token.status = 0
|
||||
}
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
|
@ -9,7 +9,7 @@ import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
|
||||
open class Client {
|
||||
protected fun newCon(uri: String, method: String, token: String = ""): HttpURLConnection {
|
||||
protected fun newCon(uri: String, method: String, token: String? = null): HttpURLConnection {
|
||||
val url = URL("https://${ManagerSingleton.url}/api/v1/$uri")
|
||||
val con = url.openConnection() as HttpURLConnection
|
||||
|
||||
@ -17,7 +17,7 @@ open class Client {
|
||||
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
|
||||
con.setRequestProperty("Accept", "*/*")
|
||||
|
||||
if (token != "") {
|
||||
if (token !== null) {
|
||||
con.setRequestProperty("Authorization", "Bearer $token")
|
||||
}
|
||||
|
||||
|
@ -201,8 +201,8 @@ class Videos : Client() {
|
||||
return this.getVideos(start, "-likes")
|
||||
}
|
||||
|
||||
fun getVideo(uuid: String): VideoModel {
|
||||
val con = this.newCon("videos/$uuid", "GET")
|
||||
fun getVideo(uuid: String, token: String? = null): VideoModel {
|
||||
val con = this.newCon("videos/$uuid", "GET", token)
|
||||
val video = VideoModel()
|
||||
try {
|
||||
if (con.responseCode == 200) {
|
||||
|
@ -0,0 +1,22 @@
|
||||
package org.libre.agosto.p2play.helpers
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class TaskManager<T> : ViewModel() {
|
||||
val result = MutableLiveData<T>()
|
||||
|
||||
fun runTask(task: () -> T, callback: (T) -> Unit) {
|
||||
viewModelScope.launch {
|
||||
val data = withContext(Dispatchers.IO) {
|
||||
task()
|
||||
}
|
||||
result.postValue(data)
|
||||
callback(data)
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ package org.libre.agosto.p2play.services
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.session.MediaSession
|
||||
import androidx.media3.session.MediaSessionService
|
||||
import org.libre.agosto.p2play.ReproductorActivity
|
||||
@ -11,6 +13,7 @@ class PlaybackService : MediaSessionService() {
|
||||
private var mediaSession: MediaSession? = null
|
||||
|
||||
// Create your Player and MediaSession in the onCreate lifecycle event
|
||||
@OptIn(UnstableApi::class)
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
val player = PlaybackSingleton.player!!
|
||||
@ -24,7 +27,8 @@ class PlaybackService : MediaSessionService() {
|
||||
contentIntent,
|
||||
PendingIntent.FLAG_MUTABLE,
|
||||
)
|
||||
mediaSession!!.setSessionActivity(pendingIntent)
|
||||
|
||||
mediaSession?.setSessionActivity(pendingIntent)
|
||||
}
|
||||
|
||||
// Remember to release the player and media session in onDestroy
|
||||
|
@ -170,6 +170,35 @@
|
||||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/downloadLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/downloadImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:adjustViewBounds="false"
|
||||
android:contentDescription="@string/reportBtn"
|
||||
android:cropToPadding="false"
|
||||
android:visibility="visible"
|
||||
app:srcCompat="@drawable/ic_outline_cloud_download_24"
|
||||
app:tint="#585858" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/downloadText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/downloadText"
|
||||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/reportLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -7,7 +7,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.3.2'
|
||||
classpath 'com.android.tools.build:gradle:8.8.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Mon Mar 18 13:17:32 CST 2024
|
||||
#Fri Jan 24 15:00:50 CST 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
Reference in New Issue
Block a user