Merge branch 'feature/removve-kotlin-extensions' into 'master'

Feature/removve kotlin extensions

See merge request agosto182/p2play!17
This commit is contained in:
Ivan Agosto 2024-05-26 21:47:25 +00:00
commit 7d865cd181
25 changed files with 469 additions and 744 deletions

View File

@ -2,13 +2,12 @@
plugins { plugins {
id "com.android.application" id "com.android.application"
id "kotlin-android" id "kotlin-android"
id "kotlin-android-extensions"
} }
android { android {
compileSdkVersion 34
defaultConfig { defaultConfig {
applicationId "org.libre.agosto.p2play" applicationId "org.libre.agosto.p2play"
compileSdk 34
minSdkVersion 26 minSdkVersion 26
targetSdkVersion 32 targetSdkVersion 32
versionCode 10 versionCode 10
@ -22,9 +21,12 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
buildFeatures {
viewBinding = true
}
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_17
} }
namespace 'org.libre.agosto.p2play' namespace 'org.libre.agosto.p2play'
lint { lint {
@ -41,14 +43,14 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.material:material:1.6.0' implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.preference:preference:1.2.1' implementation 'androidx.preference:preference-ktx:1.2.1'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.5.2' androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'androidx.media3:media3-exoplayer:1.1.1' implementation 'androidx.media3:media3-exoplayer:1.3.1'
implementation 'androidx.media3:media3-exoplayer-dash:1.1.1' implementation 'androidx.media3:media3-exoplayer-dash:1.3.1'
implementation 'androidx.media3:media3-ui:1.1.1' implementation 'androidx.media3:media3-ui:1.3.1'
implementation 'androidx.media3:media3-exoplayer-hls:1.1.1' implementation 'androidx.media3:media3-exoplayer-hls:1.3.1'
implementation "androidx.media3:media3-session:1.1.1" implementation "androidx.media3:media3-session:1.3.1"
} }

View File

@ -59,11 +59,6 @@
<activity <activity
android:name=".AboutActivity" android:name=".AboutActivity"
android:exported="false" /> android:exported="false" />
<activity
android:name=".SettingsActivity"
android:exported="false"
android:label="@string/title_activity_settings"
android:theme="@style/Theme.P2play" />
<service <service
android:name=".services.PlaybackService" android:name=".services.PlaybackService"

View File

@ -2,16 +2,18 @@ package org.libre.agosto.p2play
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_about.* import org.libre.agosto.p2play.databinding.ActivityAboutBinding
class AboutActivity : AppCompatActivity() { class AboutActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_about) val binding = ActivityAboutBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
aboutUrl.text = "https://" + ManagerSingleton.url + "/about/instance" binding.aboutUrl.text = "https://" + ManagerSingleton.url + "/about/instance"
aboutLabel.text = aboutLabel.text.toString() + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName binding.aboutLabel.text = binding.aboutLabel.text.toString() + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName
} }
} }

View File

@ -1,90 +0,0 @@
package org.libre.agosto.p2play
import android.content.res.Configuration
import android.os.Bundle
import android.preference.PreferenceActivity
import android.view.MenuInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.widget.Toolbar
/**
* A [android.preference.PreferenceActivity] which implements and proxies the necessary calls
* to be used with AppCompat.
*/
abstract class AppCompatPreferenceActivity : PreferenceActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
delegate.installViewFactory()
delegate.onCreate(savedInstanceState)
super.onCreate(savedInstanceState)
}
override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
delegate.onPostCreate(savedInstanceState)
}
val supportActionBar: ActionBar?
get() = delegate.supportActionBar
fun setSupportActionBar(toolbar: Toolbar?) {
delegate.setSupportActionBar(toolbar)
}
override fun getMenuInflater(): MenuInflater {
return delegate.menuInflater
}
override fun setContentView(@LayoutRes layoutResID: Int) {
delegate.setContentView(layoutResID)
}
override fun setContentView(view: View) {
delegate.setContentView(view)
}
override fun setContentView(view: View, params: ViewGroup.LayoutParams) {
delegate.setContentView(view, params)
}
override fun addContentView(view: View, params: ViewGroup.LayoutParams) {
delegate.addContentView(view, params)
}
override fun onPostResume() {
super.onPostResume()
delegate.onPostResume()
}
override fun onTitleChanged(title: CharSequence, color: Int) {
super.onTitleChanged(title, color)
delegate.setTitle(title)
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
delegate.onConfigurationChanged(newConfig)
}
override fun onStop() {
super.onStop()
delegate.onStop()
}
override fun onDestroy() {
super.onDestroy()
delegate.onDestroy()
}
override fun invalidateOptionsMenu() {
delegate.invalidateOptionsMenu()
}
private val delegate: AppCompatDelegate by lazy {
AppCompatDelegate.create(this, null)
}
}

View File

@ -4,14 +4,13 @@ import android.os.AsyncTask
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_channel.*
import org.libre.agosto.p2play.adapters.VideosAdapter import org.libre.agosto.p2play.adapters.VideosAdapter
import org.libre.agosto.p2play.ajax.Actions import org.libre.agosto.p2play.ajax.Actions
import org.libre.agosto.p2play.ajax.Channels import org.libre.agosto.p2play.ajax.Channels
import org.libre.agosto.p2play.ajax.Videos import org.libre.agosto.p2play.ajax.Videos
import org.libre.agosto.p2play.databinding.ActivityChannelBinding
import org.libre.agosto.p2play.helpers.getViewManager import org.libre.agosto.p2play.helpers.getViewManager
import org.libre.agosto.p2play.models.ChannelModel import org.libre.agosto.p2play.models.ChannelModel
import org.libre.agosto.p2play.models.VideoModel import org.libre.agosto.p2play.models.VideoModel
@ -27,15 +26,19 @@ class ChannelActivity : AppCompatActivity() {
private lateinit var viewAdapter: RecyclerView.Adapter<VideosAdapter.ViewHolder> private lateinit var viewAdapter: RecyclerView.Adapter<VideosAdapter.ViewHolder>
private lateinit var viewManager: RecyclerView.LayoutManager private lateinit var viewManager: RecyclerView.LayoutManager
private lateinit var binding: ActivityChannelBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_channel) binding = ActivityChannelBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
channelId = this.intent.extras?.getString("channel")!! channelId = this.intent.extras?.getString("channel")!!
viewManager = getViewManager(this, resources) viewManager = getViewManager(this, resources)
subcriptionBtn.setOnClickListener { binding.subcriptionBtn.setOnClickListener {
subscribeAction() subscribeAction()
} }
} }
@ -48,7 +51,7 @@ class ChannelActivity : AppCompatActivity() {
getVideos() getVideos()
if (ManagerSingleton.user.status == 1) { if (ManagerSingleton.user.status == 1) {
subcriptionBtn.visibility = View.VISIBLE binding.subcriptionBtn.visibility = View.VISIBLE
getSubscription() getSubscription()
} }
} }
@ -57,11 +60,11 @@ class ChannelActivity : AppCompatActivity() {
AsyncTask.execute { AsyncTask.execute {
channel = channelService.getChannelInfo(channelId) channel = channelService.getChannelInfo(channelId)
runOnUiThread { runOnUiThread {
usernameProfile.text = channel.name binding.usernameProfile.text = channel.name
hostTxt.text = channel.host binding.hostTxt.text = channel.host
subcriptionsTxt.text = channel.followers.toString() binding.subcriptionsTxt.text = channel.followers.toString()
if (channel.channelImg != "") { if (channel.channelImg != "") {
Picasso.get().load("https://${ManagerSingleton.url}${channel.channelImg}").into(channelImg) Picasso.get().load("https://${ManagerSingleton.url}${channel.channelImg}").into(binding.channelImg)
} }
} }
} }
@ -72,7 +75,7 @@ class ChannelActivity : AppCompatActivity() {
val res = actionsService.subscribe(ManagerSingleton.token.token, channel.getAccount()) val res = actionsService.subscribe(ManagerSingleton.token.token, channel.getAccount())
runOnUiThread { runOnUiThread {
if (res == 1) { if (res == 1) {
subcriptionBtn.text = getString(R.string.unSubscribeBtn) binding.subcriptionBtn.text = getString(R.string.unSubscribeBtn)
ManagerSingleton.toast(getString(R.string.subscribeMsg), this) ManagerSingleton.toast(getString(R.string.subscribeMsg), this)
getSubscription() getSubscription()
} else { } else {
@ -87,7 +90,7 @@ class ChannelActivity : AppCompatActivity() {
val res = actionsService.unSubscribe(ManagerSingleton.token.token, channel.getAccount()) val res = actionsService.unSubscribe(ManagerSingleton.token.token, channel.getAccount())
runOnUiThread { runOnUiThread {
if (res == 1) { if (res == 1) {
subcriptionBtn.text = getString(R.string.subscribeBtn) binding.subcriptionBtn.text = getString(R.string.subscribeBtn)
ManagerSingleton.toast(getString(R.string.unSubscribeMsg), this) ManagerSingleton.toast(getString(R.string.unSubscribeMsg), this)
getSubscription() getSubscription()
} else { } else {
@ -110,9 +113,9 @@ class ChannelActivity : AppCompatActivity() {
isSubcribed = actionsService.getSubscription(ManagerSingleton.token.token, channel.getAccount()) isSubcribed = actionsService.getSubscription(ManagerSingleton.token.token, channel.getAccount())
runOnUiThread { runOnUiThread {
if (isSubcribed) { if (isSubcribed) {
subcriptionBtn.text = getText(R.string.unSubscribeBtn) binding.subcriptionBtn.text = getText(R.string.unSubscribeBtn)
} else { } else {
subcriptionBtn.text = getText(R.string.subscribeBtn) binding.subcriptionBtn.text = getText(R.string.subscribeBtn)
} }
} }
} }

View File

@ -7,8 +7,8 @@ import android.os.Bundle
import android.os.Looper import android.os.Looper
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import kotlinx.android.synthetic.main.activity_host.*
import org.libre.agosto.p2play.ajax.Auth import org.libre.agosto.p2play.ajax.Auth
import org.libre.agosto.p2play.databinding.ActivityHostBinding
class HostActivity : AppCompatActivity() { class HostActivity : AppCompatActivity() {
lateinit var settings: SharedPreferences lateinit var settings: SharedPreferences
@ -16,15 +16,19 @@ class HostActivity : AppCompatActivity() {
val client: Auth = Auth() val client: Auth = Auth()
private val db = Database(this) private val db = Database(this)
private lateinit var binding: ActivityHostBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_host) binding = ActivityHostBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
settings = PreferenceManager.getDefaultSharedPreferences(this) settings = PreferenceManager.getDefaultSharedPreferences(this)
editor = settings.edit() editor = settings.edit()
button.setOnClickListener { binding.button.setOnClickListener {
getKeys(hostText.text.toString()) getKeys(binding.hostText.text.toString())
} }
val host = settings.getString("hostP2play", "") val host = settings.getString("hostP2play", "")
@ -51,7 +55,7 @@ class HostActivity : AppCompatActivity() {
} }
private fun getKeys(hostText: String) { private fun getKeys(hostText: String) {
button.isEnabled = false binding.button.isEnabled = false
var host = hostText.toString() var host = hostText.toString()
host = host.replace("http://", "") host = host.replace("http://", "")
host = host.replace("https://", "") host = host.replace("https://", "")
@ -71,7 +75,7 @@ class HostActivity : AppCompatActivity() {
} else { } else {
runOnUiThread { runOnUiThread {
ManagerSingleton.toast(getString(R.string.errorMsg), this) ManagerSingleton.toast(getString(R.string.errorMsg), this)
button.isEnabled = true binding.button.isEnabled = true
} }
} }
} }

View File

@ -9,8 +9,8 @@ import android.widget.EditText
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import kotlinx.android.synthetic.main.activity_login.*
import org.libre.agosto.p2play.ajax.Auth import org.libre.agosto.p2play.ajax.Auth
import org.libre.agosto.p2play.databinding.ActivityLoginBinding
class LoginActivity : AppCompatActivity() { class LoginActivity : AppCompatActivity() {
private val auth = Auth() private val auth = Auth()
@ -20,9 +20,13 @@ class LoginActivity : AppCompatActivity() {
private lateinit var db: Database private lateinit var db: Database
private var optCode: String? = null private var optCode: String? = null
private lateinit var binding: ActivityLoginBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login) binding = ActivityLoginBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
setTitle(R.string.action_login) setTitle(R.string.action_login)
db = Database(this) db = Database(this)
@ -30,14 +34,14 @@ class LoginActivity : AppCompatActivity() {
clientId = settings.getString("client_id", "")!! clientId = settings.getString("client_id", "")!!
clientSecret = settings.getString("client_secret", "")!! clientSecret = settings.getString("client_secret", "")!!
registerActionBtn.setOnClickListener { startActivity(Intent(this, RegisterActivity::class.java)) } binding.registerActionBtn.setOnClickListener { startActivity(Intent(this, RegisterActivity::class.java)) }
loginBtn.setOnClickListener { tryLogin() } binding.loginBtn.setOnClickListener { tryLogin() }
} }
fun tryLogin() { fun tryLogin() {
loginBtn.isEnabled = false binding.loginBtn.isEnabled = false
val username = userText.text.toString() val username = binding.userText.text.toString()
val password = passwordText.text.toString() val password = binding.passwordText.text.toString()
AsyncTask.execute { AsyncTask.execute {
if (Looper.myLooper() == null) { if (Looper.myLooper() == null) {
@ -62,7 +66,7 @@ class LoginActivity : AppCompatActivity() {
} }
"-1" -> { "-1" -> {
runOnUiThread { runOnUiThread {
loginBtn.isEnabled = true binding.loginBtn.isEnabled = true
ManagerSingleton.toast(getString(R.string.loginFailed_msg), this) ManagerSingleton.toast(getString(R.string.loginFailed_msg), this)
} }
} }
@ -84,7 +88,7 @@ class LoginActivity : AppCompatActivity() {
} }
.setNegativeButton("Cancel") { d, _ -> .setNegativeButton("Cancel") { d, _ ->
dialog.run { d.cancel() } dialog.run { d.cancel() }
loginBtn.isEnabled = true binding.loginBtn.isEnabled = true
} }
val alertDialog = builder.create() val alertDialog = builder.create()
alertDialog.show() alertDialog.show()

View File

@ -1,34 +1,24 @@
package org.libre.agosto.p2play package org.libre.agosto.p2play
import android.content.Intent import android.content.Intent
import android.content.res.Configuration
import android.os.AsyncTask import android.os.AsyncTask
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.navigation.NavigationView import com.google.android.material.navigation.NavigationView
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_main.drawer_layout
import kotlinx.android.synthetic.main.activity_main.nav_view
import kotlinx.android.synthetic.main.app_bar_main.toolbar
import kotlinx.android.synthetic.main.content_main.mini
import kotlinx.android.synthetic.main.content_main.swipeContainer
import kotlinx.android.synthetic.main.mini_player.mini_play_pause
import kotlinx.android.synthetic.main.mini_player.mini_player_author
import kotlinx.android.synthetic.main.mini_player.mini_player_image
import kotlinx.android.synthetic.main.mini_player.mini_player_title
import kotlinx.android.synthetic.main.nav_header_main.*
import org.libre.agosto.p2play.adapters.VideosAdapter import org.libre.agosto.p2play.adapters.VideosAdapter
import org.libre.agosto.p2play.ajax.Videos import org.libre.agosto.p2play.ajax.Videos
import org.libre.agosto.p2play.databinding.ActivityMainBinding
import org.libre.agosto.p2play.helpers.getViewManager import org.libre.agosto.p2play.helpers.getViewManager
import org.libre.agosto.p2play.models.VideoModel import org.libre.agosto.p2play.models.VideoModel
import org.libre.agosto.p2play.singletons.PlaybackSingleton import org.libre.agosto.p2play.singletons.PlaybackSingleton
@ -44,16 +34,20 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
var section: String = "" var section: String = ""
var searchVal: String = "" var searchVal: String = ""
var pagination = 0 var pagination = 0
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) binding = ActivityMainBinding.inflate(layoutInflater)
setSupportActionBar(toolbar) val view = binding.root
setContentView(view)
setSupportActionBar(binding.toolbar)
val toggle = ActionBarDrawerToggle(this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) val toggle = ActionBarDrawerToggle(this, binding.drawerLayout, binding.toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close)
drawer_layout.addDrawerListener(toggle) binding.drawerLayout.addDrawerListener(toggle)
toggle.syncState() toggle.syncState()
nav_view.setNavigationItemSelectedListener(this) binding.navView.setNavigationItemSelectedListener(this)
viewManager = getViewManager(this, resources) viewManager = getViewManager(this, resources)
@ -62,19 +56,20 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
this.getTrengindVideos() this.getTrengindVideos()
swipeContainer.setOnRefreshListener { binding.content.swipeContainer.setOnRefreshListener {
this.refresh() this.refresh()
} }
mini_player_image.setOnClickListener { this.resumeVideo() }
mini_player_title.setOnClickListener { this.resumeVideo() } binding.content.mini.miniPlayerImage.setOnClickListener { this.resumeVideo() }
mini_player_author.setOnClickListener { this.resumeVideo() } binding.content.mini.miniPlayerTitle.setOnClickListener { this.resumeVideo() }
mini.setOnClickListener { this.resumeVideo() } binding.content.mini.miniPlayerAuthor.setOnClickListener { this.resumeVideo() }
mini_play_pause.setOnClickListener { this.playPausePlayer() } // binding.content.mini.setOnClickListener { this.resumeVideo() }
binding.content.mini.miniPlayPause.setOnClickListener { this.playPausePlayer() }
Handler().postDelayed({ Handler().postDelayed({
// Title for nav_bar // Title for nav_bar
side_emailTxt?.text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName 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) }, 2000)
} }
@ -99,7 +94,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
super.onScrolled(recyclerView, dx, dy) super.onScrolled(recyclerView, dx, dy)
// super.onScrolled(recyclerView!!, dx, dy) // super.onScrolled(recyclerView!!, dx, dy)
if (!swipeContainer.isRefreshing) { if (!binding.content.swipeContainer.isRefreshing) {
if (!canScrollVertically(1)) { if (!canScrollVertically(1)) {
loadMore() loadMore()
} }
@ -107,11 +102,11 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
} }
}) })
} }
swipeContainer.isRefreshing = false binding.content.swipeContainer.isRefreshing = false
} }
private fun addVideos(videos: ArrayList<VideoModel>) { private fun addVideos(videos: ArrayList<VideoModel>) {
this.swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
try { try {
if (this.pagination == 0) { if (this.pagination == 0) {
@ -125,11 +120,11 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
ManagerSingleton.toast(getString(R.string.errorMsg), this) ManagerSingleton.toast(getString(R.string.errorMsg), this)
} }
this.swipeContainer.isRefreshing = false binding.content.swipeContainer.isRefreshing = false
} }
private fun refresh() { private fun refresh() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
this.pagination = 0 this.pagination = 0
when (section) { when (section) {
"local" -> this.getLocalVideos() "local" -> this.getLocalVideos()
@ -154,7 +149,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
startActivity(Intent(this, LoginActivity::class.java)) startActivity(Intent(this, LoginActivity::class.java))
return return
} }
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
section = "sub" section = "sub"
setTitle(R.string.title_subscriptions) setTitle(R.string.title_subscriptions)
AsyncTask.execute { AsyncTask.execute {
@ -167,7 +162,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Last videos // Last videos
private fun getLastVideos() { private fun getLastVideos() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
section = "last" section = "last"
setTitle(R.string.title_recent) setTitle(R.string.title_recent)
AsyncTask.execute { AsyncTask.execute {
@ -180,7 +175,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Popular videos // Popular videos
private fun getPopularVideos() { private fun getPopularVideos() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
section = "popular" section = "popular"
setTitle(R.string.title_popular) setTitle(R.string.title_popular)
AsyncTask.execute { AsyncTask.execute {
@ -193,7 +188,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Trending videos // Trending videos
private fun getTrengindVideos() { private fun getTrengindVideos() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
section = "trending" section = "trending"
setTitle(R.string.title_trending) setTitle(R.string.title_trending)
AsyncTask.execute { AsyncTask.execute {
@ -206,7 +201,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Local videos // Local videos
private fun getLocalVideos() { private fun getLocalVideos() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
section = "local" section = "local"
setTitle(R.string.title_local) setTitle(R.string.title_local)
AsyncTask.execute { AsyncTask.execute {
@ -219,7 +214,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Videos of user // Videos of user
private fun getMyVideos() { private fun getMyVideos() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
section = "my_videos" section = "my_videos"
setTitle(R.string.title_myVideos) setTitle(R.string.title_myVideos)
AsyncTask.execute { AsyncTask.execute {
@ -232,7 +227,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Videos history of user // Videos history of user
private fun getHistory() { private fun getHistory() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
section = "my_videos" section = "my_videos"
setTitle(R.string.nav_history) setTitle(R.string.nav_history)
AsyncTask.execute { AsyncTask.execute {
@ -245,7 +240,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Most liked // Most liked
private fun getMostLiked() { private fun getMostLiked() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
section = "liked" section = "liked"
setTitle(R.string.nav_likes) setTitle(R.string.nav_likes)
AsyncTask.execute { AsyncTask.execute {
@ -257,8 +252,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
} }
override fun onBackPressed() { override fun onBackPressed() {
if (drawer_layout.isDrawerOpen(GravityCompat.START)) { if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawer_layout.closeDrawer(GravityCompat.START) binding.drawerLayout.closeDrawer(GravityCompat.START)
} else if (!section.equals("trending")) { } else if (!section.equals("trending")) {
// Hot fix // Hot fix
pagination = 0 pagination = 0
@ -350,7 +345,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
R.id.nav_likes -> getMostLiked() R.id.nav_likes -> getMostLiked()
} }
drawer_layout.closeDrawer(GravityCompat.START) binding.drawerLayout.closeDrawer(GravityCompat.START)
return true return true
} }
@ -360,13 +355,14 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
if (PlaybackSingleton.player != null && PlaybackSingleton.player!!.isPlaying) { if (PlaybackSingleton.player != null && PlaybackSingleton.player!!.isPlaying) {
PlaybackSingleton.runMediaSession(this) PlaybackSingleton.runMediaSession(this)
mini_player_title.text = PlaybackSingleton.video!!.name
mini_player_author.text = PlaybackSingleton.video!!.username binding.content.mini.miniPlayerTitle.text = PlaybackSingleton.video!!.name
Picasso.get().load("https://${ManagerSingleton.url}${PlaybackSingleton.video!!.thumbUrl}").into(mini_player_image) binding.content.mini.miniPlayerAuthor.text = PlaybackSingleton.video!!.username
mini_play_pause.setImageResource(R.drawable.ic_pause_24) Picasso.get().load("https://${ManagerSingleton.url}${PlaybackSingleton.video!!.thumbUrl}").into(binding.content.mini.miniPlayerImage)
mini.visibility = View.VISIBLE binding.content.mini.miniPlayPause.setImageResource(R.drawable.ic_pause_24)
binding.content.mini.miniPlayer.visibility = View.VISIBLE
} else { } else {
mini.visibility = View.GONE binding.content.mini.miniPlayer.visibility = View.GONE
} }
} }
@ -379,24 +375,25 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
private fun setSideData() { private fun setSideData() {
if (ManagerSingleton.user.status == 1) { if (ManagerSingleton.user.status == 1) {
nav_view.menu.findItem(R.id.ml).isVisible = true binding.navView.menu.findItem(R.id.ml).isVisible = true
side_usernameTxt?.text = ManagerSingleton.user.username val headerView = binding.navView.getHeaderView(0)
side_emailTxt?.text = ManagerSingleton.user.email headerView.findViewById<TextView>(R.id.side_usernameTxt).text = ManagerSingleton.user.username
if (ManagerSingleton.user.avatar != "" && side_imageView != null) { headerView.findViewById<TextView>(R.id.side_emailTxt).text = ManagerSingleton.user.email
Picasso.get().load("https://" + ManagerSingleton.url + ManagerSingleton.user.avatar).into(side_imageView) if (ManagerSingleton.user.avatar != "" && headerView.findViewById<ImageView>(R.id.side_imageView) != null) {
Picasso.get().load("https://" + ManagerSingleton.url + ManagerSingleton.user.avatar).into(headerView.findViewById<ImageView>(R.id.side_imageView))
} }
side_imageView?.setOnClickListener { headerView.findViewById<ImageView>(R.id.side_imageView).setOnClickListener {
pagination = 0 pagination = 0
getMyVideos() getMyVideos()
drawer_layout.closeDrawer(GravityCompat.START) binding.drawerLayout.closeDrawer(GravityCompat.START)
} }
if (::myMenu.isInitialized) { if (::myMenu.isInitialized) {
myMenu.findItem(R.id.action_login).isVisible = false myMenu.findItem(R.id.action_login).isVisible = false
myMenu.findItem(R.id.action_logout).isVisible = true myMenu.findItem(R.id.action_logout).isVisible = true
} }
} else { } else {
nav_view.menu.findItem(R.id.ml).isVisible = false binding.navView.menu.findItem(R.id.ml).isVisible = false
} }
} }
@ -405,11 +402,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
myMenu.findItem(R.id.action_login).isVisible = true myMenu.findItem(R.id.action_login).isVisible = true
myMenu.findItem(R.id.action_logout).isVisible = false myMenu.findItem(R.id.action_logout).isVisible = false
} }
// nav_view.menu.findItem(R.id.ml).isVisible = false val headerView = binding.navView.getHeaderView(0)
side_usernameTxt?.text = getString(R.string.nav_header_title) binding.navView.menu.findItem(R.id.ml).isVisible = false
side_emailTxt?.text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName headerView.findViewById<TextView>(R.id.side_usernameTxt).text = getString(R.string.nav_header_title)
side_imageView?.setImageResource(R.drawable.default_avatar) headerView.findViewById<TextView>(R.id.side_emailTxt).text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName
side_imageView?.setOnClickListener { } headerView.findViewById<ImageView>(R.id.side_imageView).setImageResource(R.drawable.default_avatar)
headerView.findViewById<ImageView>(R.id.side_imageView).setOnClickListener { }
db.logout() db.logout()
ManagerSingleton.logout() ManagerSingleton.logout()
@ -419,7 +417,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
} }
private fun loadMore() { private fun loadMore() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
this.pagination += ManagerSingleton.videosCount this.pagination += ManagerSingleton.videosCount
when (section) { when (section) {
@ -441,7 +439,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
} }
private fun searchVideos() { private fun searchVideos() {
swipeContainer.isRefreshing = true binding.content.swipeContainer.isRefreshing = true
section = "search" section = "search"
this.title = this.searchVal this.title = this.searchVal
AsyncTask.execute { AsyncTask.execute {
@ -462,10 +460,10 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
PlaybackSingleton.player?.let { PlaybackSingleton.player?.let {
if (it.isPlaying) { if (it.isPlaying) {
it.pause() it.pause()
mini_play_pause.setImageResource(R.drawable.ic_play_arrow_24) binding.content.mini.miniPlayPause.setImageResource(R.drawable.ic_play_arrow_24)
} else { } else {
it.play() it.play()
mini_play_pause.setImageResource(R.drawable.ic_pause_24) binding.content.mini.miniPlayPause.setImageResource(R.drawable.ic_pause_24)
} }
} }
} }

View File

@ -7,8 +7,8 @@ import android.os.Looper
import android.util.Log import android.util.Log
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import kotlinx.android.synthetic.main.activity_register.*
import org.libre.agosto.p2play.ajax.Auth import org.libre.agosto.p2play.ajax.Auth
import org.libre.agosto.p2play.databinding.ActivityRegisterBinding
class RegisterActivity : AppCompatActivity() { class RegisterActivity : AppCompatActivity() {
private val auth = Auth() private val auth = Auth()
@ -16,23 +16,27 @@ class RegisterActivity : AppCompatActivity() {
lateinit var clientId: String lateinit var clientId: String
lateinit var clientSecret: String lateinit var clientSecret: String
private lateinit var binding: ActivityRegisterBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_register) binding = ActivityRegisterBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
setTitle(R.string.registerActionBtn) setTitle(R.string.registerActionBtn)
settings = PreferenceManager.getDefaultSharedPreferences(this) settings = PreferenceManager.getDefaultSharedPreferences(this)
clientId = settings.getString("client_id", "")!! clientId = settings.getString("client_id", "")!!
clientSecret = settings.getString("client_secret", "")!! clientSecret = settings.getString("client_secret", "")!!
registerBtn.setOnClickListener { registerUser() } binding.registerBtn.setOnClickListener { registerUser() }
} }
private fun registerUser() { private fun registerUser() {
registerBtn.isEnabled = false binding.registerBtn.isEnabled = false
val username = userText2.text.toString() val username = binding.userText2.text.toString()
val password = passwordText2.text.toString() val password = binding.passwordText2.text.toString()
val email = emailText.text.toString() val email = binding.emailText.text.toString()
AsyncTask.execute { AsyncTask.execute {
if (Looper.myLooper() == null) { if (Looper.myLooper() == null) {
Looper.prepare() Looper.prepare()
@ -49,7 +53,7 @@ class RegisterActivity : AppCompatActivity() {
0 -> ManagerSingleton.toast(getString(R.string.registerFailed_msg), this) 0 -> ManagerSingleton.toast(getString(R.string.registerFailed_msg), this)
-1 -> ManagerSingleton.toast(getString(R.string.registerError_msg), this) -1 -> ManagerSingleton.toast(getString(R.string.registerError_msg), this)
} }
registerBtn.isEnabled = true binding.registerBtn.isEnabled = true
} }
} }
} }

View File

@ -15,35 +15,28 @@ import android.webkit.WebChromeClient
import android.widget.EditText import android.widget.EditText
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.media3.common.MediaItem import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata import androidx.media3.common.MediaMetadata
import androidx.media3.common.Player import androidx.media3.common.Player
import androidx.media3.exoplayer.DefaultLoadControl
import androidx.media3.exoplayer.ExoPlayer import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.upstream.DefaultAllocator
import androidx.media3.session.MediaController import androidx.media3.session.MediaController
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_reproductor.*
import kotlinx.android.synthetic.main.comment_component.commentaryBtn
import kotlinx.android.synthetic.main.comment_component.commentaryLayout
import kotlinx.android.synthetic.main.comment_component.commentaryText
import kotlinx.android.synthetic.main.comment_component.userImgCom
import kotlinx.android.synthetic.main.custom_player_controls.view.exo_controls
import org.libre.agosto.p2play.adapters.CommentariesAdapter import org.libre.agosto.p2play.adapters.CommentariesAdapter
import org.libre.agosto.p2play.ajax.Actions import org.libre.agosto.p2play.ajax.Actions
import org.libre.agosto.p2play.ajax.Comments import org.libre.agosto.p2play.ajax.Comments
import org.libre.agosto.p2play.ajax.Videos import org.libre.agosto.p2play.ajax.Videos
import org.libre.agosto.p2play.databinding.ActivityReproductorBinding
import org.libre.agosto.p2play.helpers.setFullscreen import org.libre.agosto.p2play.helpers.setFullscreen
import org.libre.agosto.p2play.models.CommentaryModel import org.libre.agosto.p2play.models.CommentaryModel
import org.libre.agosto.p2play.models.VideoModel import org.libre.agosto.p2play.models.VideoModel
import org.libre.agosto.p2play.singletons.PlaybackSingleton import org.libre.agosto.p2play.singletons.PlaybackSingleton
@Suppress("NAME_SHADOWING")
class ReproductorActivity : AppCompatActivity() { class ReproductorActivity : AppCompatActivity() {
private val clientVideo: Videos = Videos() private val clientVideo: Videos = Videos()
lateinit var video: VideoModel lateinit var video: VideoModel
@ -68,14 +61,19 @@ class ReproductorActivity : AppCompatActivity() {
// Resume info // Resume info
private var isResume = false private var isResume = false
private lateinit var binding: ActivityReproductorBinding
@SuppressLint("SetJavaScriptEnabled", "SetTextI18n") @SuppressLint("SetJavaScriptEnabled", "SetTextI18n")
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_reproductor) binding = ActivityReproductorBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
val fullscreenButton: ImageView = exoPlayer.findViewById(R.id.exo_fullscreen_custom) val fullscreenButton = binding.exoPlayer.findViewById<ImageView>(R.id.exo_fullscreen_custom)
val fullscreenButton2 = fullscreenPlayer.findViewById<ImageView>(R.id.exo_fullscreen_custom) val fullscreenButton2 = binding.fullscreenPlayer.findViewById<ImageView>(R.id.exo_fullscreen_custom)
val videoView = binding.videoView
videoView.webChromeClient = WebClient() videoView.webChromeClient = WebClient()
videoView.settings.javaScriptEnabled = true videoView.settings.javaScriptEnabled = true
videoView.settings.allowContentAccess = true videoView.settings.allowContentAccess = true
@ -95,19 +93,19 @@ class ReproductorActivity : AppCompatActivity() {
isResume = true isResume = true
} }
tittleVideoTxt.text = this.video.name binding.tittleVideoTxt.text = this.video.name
viewsTxt.text = "${this.video.views} ${getString(R.string.view_text)}" binding.viewsTxt.text = "${this.video.views} ${getString(R.string.view_text)}"
userTxt.text = this.video.username binding.userTxt.text = this.video.username
descriptionVideoTxt.text = this.video.description binding.descriptionVideoTxt.text = this.video.description
val haveDescription = this.video.description.endsWith("...") val haveDescription = this.video.description.endsWith("...")
if (haveDescription) { if (haveDescription) {
showMoreBtn.visibility = View.VISIBLE binding.showMoreBtn.visibility = View.VISIBLE
} }
hostTxt.text = this.video.userHost binding.hostTxt.text = this.video.userHost
// Check if user had profile image // Check if user had profile image
if (this.video.userImageUrl != "") { if (this.video.userImageUrl != "") {
Picasso.get().load("https://" + ManagerSingleton.url + this.video.userImageUrl).into(userImg) Picasso.get().load("https://" + ManagerSingleton.url + this.video.userImageUrl).into(binding.userImg)
} }
// Load the video // Load the video
videoView.loadUrl("https://" + ManagerSingleton.url + this.video.embedUrl) videoView.loadUrl("https://" + ManagerSingleton.url + this.video.embedUrl)
@ -120,17 +118,17 @@ class ReproductorActivity : AppCompatActivity() {
this.getComments() this.getComments()
subscribeBtn.setOnClickListener { subscribe() } binding.subscribeBtn.setOnClickListener { subscribe() }
likeLayout.setOnClickListener { rate("like") } binding.likeLayout.setOnClickListener { rate("like") }
dislikeLayout.setOnClickListener { rate("dislike") } binding.dislikeLayout.setOnClickListener { rate("dislike") }
commentaryBtn.setOnClickListener { makeComment() } binding.commentBox.commentaryBtn.setOnClickListener { makeComment() }
showMoreBtn.setOnClickListener { getDescription() } binding.showMoreBtn.setOnClickListener { getDescription() }
shareLayout.setOnClickListener { shareIntent() } binding.shareLayout.setOnClickListener { shareIntent() }
reportLayout.setOnClickListener { reportIntent() } binding.reportLayout.setOnClickListener { reportIntent() }
fullscreenButton.setOnClickListener { toggleFullscreen() } fullscreenButton.setOnClickListener { toggleFullscreen() }
fullscreenButton2.setOnClickListener { toggleFullscreen() } fullscreenButton2.setOnClickListener { toggleFullscreen() }
userImg.setOnClickListener { binding.userImg.setOnClickListener {
val intent = Intent(this, ChannelActivity::class.java) val intent = Intent(this, ChannelActivity::class.java)
intent.putExtra("channel", video.getChannel()) intent.putExtra("channel", video.getChannel())
startActivity(intent) startActivity(intent)
@ -139,32 +137,35 @@ class ReproductorActivity : AppCompatActivity() {
AsyncTask.execute { AsyncTask.execute {
videoPlayback = this.clientVideo.getVideo(this.video.uuid) videoPlayback = this.clientVideo.getVideo(this.video.uuid)
// TODO: Make this configurable // TODO: Make this configurable
val bufferSize = 1024 * 1024 // 1mb // val bufferSize = 1024 * 1024 // 1mb
val allocator = DefaultAllocator(true, bufferSize) // val allocator = DefaultAllocator(true, bufferSize)
val loadControl = DefaultLoadControl.Builder() // val loadControl = DefaultLoadControl.Builder()
.setAllocator(allocator) // .setAllocator(allocator)
.build() // .build()
runOnUiThread { runOnUiThread {
try { try {
if (PlaybackSingleton.player == null || !PlaybackSingleton.player!!.playWhenReady) { if (PlaybackSingleton.player == null || !PlaybackSingleton.player!!.playWhenReady) {
PlaybackSingleton.player = ExoPlayer.Builder(this.baseContext) PlaybackSingleton.player = ExoPlayer.Builder(this)
.setSeekBackIncrementMs(10000) //.setSeekBackIncrementMs(10000)
.setSeekForwardIncrementMs(10000) //.setSeekForwardIncrementMs(10000)
.setLoadControl(loadControl).build() //.setLoadControl(loadControl)
.build()
} }
player = PlaybackSingleton.player!! player = PlaybackSingleton.player!!
exoPlayer.player = player binding.exoPlayer.player = player
binding.exoPlayer
player.addListener( player.addListener(
object : Player.Listener { object : Player.Listener {
override fun onPlaybackStateChanged(playbackState: Int) { override fun onPlaybackStateChanged(playbackState: Int) {
super.onPlaybackStateChanged(playbackState) super.onPlaybackStateChanged(playbackState)
val controls = binding.exoPlayer.findViewById<LinearLayout>(R.id.exo_center_controls)
if (playbackState == Player.STATE_BUFFERING || playbackState == Player.STATE_IDLE) { if (playbackState == Player.STATE_BUFFERING || playbackState == Player.STATE_IDLE) {
exoPlayer.exo_controls.visibility = View.INVISIBLE controls.visibility = View.INVISIBLE
} else if (playbackState == Player.STATE_READY) { } else if (playbackState == Player.STATE_READY) {
exoPlayer.exo_controls.visibility = View.VISIBLE controls.visibility = View.VISIBLE
} }
} }
} }
@ -186,6 +187,7 @@ class ReproductorActivity : AppCompatActivity() {
PlaybackSingleton.setData(mediaItem, video) PlaybackSingleton.setData(mediaItem, video)
} }
// Start the playback. // Start the playback.
// TODO: Setting for autoplay
// player.play() // player.play()
} catch (err: Exception) { } catch (err: Exception) {
err.printStackTrace() err.printStackTrace()
@ -234,11 +236,11 @@ class ReproductorActivity : AppCompatActivity() {
runOnUiThread { runOnUiThread {
ManagerSingleton.toast(getString(R.string.rateMsg), this) ManagerSingleton.toast(getString(R.string.rateMsg), this)
if (rate == "like") { if (rate == "like") {
textViewLike.setTextColor(ContextCompat.getColor(this, R.color.colorLike)) binding.textViewLike.setTextColor(ContextCompat.getColor(this, R.color.colorLike))
textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light)) binding.textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light))
} else if (rate == "dislike") { } else if (rate == "dislike") {
textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.colorDislike)) binding.textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.colorDislike))
textViewLike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light)) binding.textViewLike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light))
} }
} }
} }
@ -254,16 +256,16 @@ class ReproductorActivity : AppCompatActivity() {
runOnUiThread { runOnUiThread {
when (rate) { when (rate) {
"like" -> { "like" -> {
textViewLike.setTextColor(ContextCompat.getColor(this, R.color.colorLike)) binding.textViewLike.setTextColor(ContextCompat.getColor(this, R.color.colorLike))
textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light)) binding.textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light))
} }
"dislike" -> { "dislike" -> {
textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.colorDislike)) binding.textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.colorDislike))
textViewLike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light)) binding.textViewLike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light))
} }
else -> { else -> {
textViewLike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light)) binding.textViewLike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light))
textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light)) binding.textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light))
} }
} }
} }
@ -285,11 +287,11 @@ class ReproductorActivity : AppCompatActivity() {
private fun changeSubscribeBtn(subscribed: Boolean) { private fun changeSubscribeBtn(subscribed: Boolean) {
if (subscribed) { if (subscribed) {
subscribeBtn.text = getText(R.string.unSubscribeBtn) binding.subscribeBtn.text = getText(R.string.unSubscribeBtn)
subscribeBtn.setOnClickListener { this.unSubscribe() } binding.subscribeBtn.setOnClickListener { this.unSubscribe() }
} else { } else {
subscribeBtn.text = getText(R.string.subscribeBtn) binding.subscribeBtn.text = getText(R.string.subscribeBtn)
subscribeBtn.setOnClickListener { this.subscribe() } binding.subscribeBtn.setOnClickListener { this.subscribe() }
} }
} }
@ -320,17 +322,17 @@ class ReproductorActivity : AppCompatActivity() {
} }
private fun makeComment() { private fun makeComment() {
if (commentaryText.text.toString() == "") { if (binding.commentBox.commentaryText.text.toString() == "") {
ManagerSingleton.toast(getString(R.string.emptyCommentaryMsg), this) ManagerSingleton.toast(getString(R.string.emptyCommentaryMsg), this)
return return
} }
val text = commentaryText.text.toString() val text = binding.commentBox.commentaryText.text.toString()
AsyncTask.execute { AsyncTask.execute {
val res = this.client.makeCommentary(ManagerSingleton.token.token, this.video.id, text) val res = this.client.makeCommentary(ManagerSingleton.token.token, this.video.id, text)
runOnUiThread { runOnUiThread {
if (res) { if (res) {
ManagerSingleton.toast(getString(R.string.makedCommentaryMsg), this) ManagerSingleton.toast(getString(R.string.makedCommentaryMsg), this)
commentaryText.text?.clear() binding.commentBox.commentaryText.text?.clear()
this.getComments() this.getComments()
} else { } else {
ManagerSingleton.toast(getString(R.string.errorCommentaryMsg), this) ManagerSingleton.toast(getString(R.string.errorCommentaryMsg), this)
@ -344,14 +346,14 @@ class ReproductorActivity : AppCompatActivity() {
if (ManagerSingleton.user.status == 1) { if (ManagerSingleton.user.status == 1) {
this.getRate() this.getRate()
this.getSubscription() this.getSubscription()
actionsLayout.visibility = View.VISIBLE binding.actionsLayout.visibility = View.VISIBLE
subscribeBtn.visibility = View.VISIBLE binding.subscribeBtn.visibility = View.VISIBLE
commentaryLayout.visibility = View.VISIBLE binding.commentBox.commentaryLayout.visibility = View.VISIBLE
if (ManagerSingleton.user.avatar != "") { if (ManagerSingleton.user.avatar != "") {
Picasso.get().load("https://" + ManagerSingleton.url + ManagerSingleton.user.avatar).into(userImgCom) Picasso.get().load("https://" + ManagerSingleton.url + ManagerSingleton.user.avatar).into(binding.commentBox.userImgCom)
} }
} else { } else {
commentaryLayout.visibility = View.GONE binding.commentBox.commentaryLayout.visibility = View.GONE
} }
} }
@ -359,8 +361,8 @@ class ReproductorActivity : AppCompatActivity() {
AsyncTask.execute { AsyncTask.execute {
val fullDescription = this.videos.fullDescription(this.video.id) val fullDescription = this.videos.fullDescription(this.video.id)
runOnUiThread { runOnUiThread {
descriptionVideoTxt.text = fullDescription binding.descriptionVideoTxt.text = fullDescription
showMoreBtn.visibility = View.GONE binding.showMoreBtn.visibility = View.GONE
} }
} }
} }
@ -413,10 +415,10 @@ class ReproductorActivity : AppCompatActivity() {
private fun toggleFullscreen() { private fun toggleFullscreen() {
if (isFullscreen) { if (isFullscreen) {
nonFullScreen.visibility = View.VISIBLE binding.nonFullScreen.visibility = View.VISIBLE
fullScreenExo.visibility = View.GONE binding.fullScreenExo.visibility = View.GONE
exoPlayer.player = player binding.exoPlayer.player = player
fullscreenPlayer.player = null binding.fullscreenPlayer.player = null
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
val attrs = window.attributes val attrs = window.attributes
@ -429,11 +431,11 @@ class ReproductorActivity : AppCompatActivity() {
} else { } else {
val matchParent = WindowManager.LayoutParams.MATCH_PARENT val matchParent = WindowManager.LayoutParams.MATCH_PARENT
nonFullScreen.visibility = View.GONE binding.nonFullScreen.visibility = View.GONE
fullScreenExo.visibility = View.VISIBLE binding.fullScreenExo.visibility = View.VISIBLE
exoPlayer.player = null binding.exoPlayer.player = null
fullscreenPlayer.player = player binding.fullscreenPlayer.player = player
setFullscreen(window) setFullscreen(window)
@ -469,9 +471,9 @@ class ReproductorActivity : AppCompatActivity() {
override fun onHideCustomView() { override fun onHideCustomView() {
try { try {
this@ReproductorActivity.nonFullScreen.visibility = View.VISIBLE this@ReproductorActivity.binding.nonFullScreen.visibility = View.VISIBLE
this@ReproductorActivity.fullScreen.visibility = View.GONE this@ReproductorActivity.binding.fullScreen.visibility = View.GONE
this@ReproductorActivity.fullScreen.removeView(this.mCustomView) this@ReproductorActivity.binding.fullScreen.removeView(this.mCustomView)
this.mCustomView = null this.mCustomView = null
this.mCustomViewCallback!!.onCustomViewHidden() this.mCustomViewCallback!!.onCustomViewHidden()
@ -502,10 +504,10 @@ class ReproductorActivity : AppCompatActivity() {
this.mCustomViewCallback = paramCustomViewCallback this.mCustomViewCallback = paramCustomViewCallback
val matchParent = WindowManager.LayoutParams.MATCH_PARENT val matchParent = WindowManager.LayoutParams.MATCH_PARENT
this@ReproductorActivity.nonFullScreen.visibility = View.GONE this@ReproductorActivity.binding.nonFullScreen.visibility = View.GONE
this@ReproductorActivity.fullScreen.visibility = View.VISIBLE this@ReproductorActivity.binding.fullScreen.visibility = View.VISIBLE
this@ReproductorActivity.fullScreen.addView(paramView, FrameLayout.LayoutParams(matchParent, matchParent)) this@ReproductorActivity.binding.fullScreen.addView(paramView, FrameLayout.LayoutParams(matchParent, matchParent))
setFullscreen(this@ReproductorActivity.window) setFullscreen(this@ReproductorActivity.window)

View File

@ -1,159 +0,0 @@
package org.libre.agosto.p2play
import android.annotation.TargetApi
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.preference.ListPreference
import android.preference.Preference
import android.preference.PreferenceActivity
import android.preference.PreferenceFragment
import android.preference.PreferenceManager
import android.view.MenuItem
/**
* A [PreferenceActivity] that presents a set of application settings. On
* handset devices, settings are presented as a single list. On tablets,
* settings are split by category, with category headers shown to the left of
* the list of settings.
*
* See [Android Design: Settings](http://developer.android.com/design/patterns/settings.html)
* for design guidelines and the [Settings API Guide](http://developer.android.com/guide/topics/ui/settings.html)
* for more information on developing a Settings UI.
*/
class SettingsActivity : AppCompatPreferenceActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupActionBar()
}
override fun onBackPressed() {
super.onBackPressed()
ManagerSingleton.toast(getString(R.string.pref_message_exit), this)
}
/**
* Set up the [android.app.ActionBar], if the API is available.
*/
private fun setupActionBar() {
supportActionBar?.setDisplayHomeAsUpEnabled(false)
}
/**
* {@inheritDoc}
*/
override fun onIsMultiPane(): Boolean {
return isXLargeTablet(this)
}
/**
* {@inheritDoc}
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
override fun onBuildHeaders(target: List<PreferenceActivity.Header>) {
loadHeadersFromResource(R.xml.pref_headers, target)
}
/**
* This method stops fragment injection in malicious applications.
* Make sure to deny any unknown fragments here.
*/
override fun isValidFragment(fragmentName: String): Boolean {
return PreferenceFragment::class.java.name == fragmentName ||
GeneralPreferenceFragment::class.java.name == fragmentName
}
/**
* This fragment shows general preferences only. It is used when the
* activity is showing a two-pane settings UI.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class GeneralPreferenceFragment : PreferenceFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
addPreferencesFromResource(R.xml.pref_general)
setHasOptionsMenu(true)
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
// to their values. When their values change, their summaries are
// updated to reflect the new value, per the Android Design
// guidelines.
bindPreferenceSummaryToValue(findPreference("hostP2play"))
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val id = item.itemId
if (id == android.R.id.home) {
startActivity(Intent(activity, SettingsActivity::class.java))
return true
}
return super.onOptionsItemSelected(item)
}
}
companion object {
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private val sBindPreferenceSummaryToValueListener = Preference.OnPreferenceChangeListener { preference, value ->
val stringValue = value.toString()
if (preference is ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
val listPreference = preference
val index = listPreference.findIndexOfValue(stringValue)
// Set the summary to reflect the new value.
preference.setSummary(
if (index >= 0) {
listPreference.entries[index]
} else {
null
},
)
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.summary = stringValue
}
true
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private fun isXLargeTablet(context: Context): Boolean {
return context.resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK >= Configuration.SCREENLAYOUT_SIZE_XLARGE
}
/**
* Binds a preference's summary to its value. More specifically, when the
* preference's value is changed, its summary (line of text below the
* preference title) is updated to reflect the value. The summary is also
* immediately updated upon calling this method. The exact display format is
* dependent on the type of preference.
* @see .sBindPreferenceSummaryToValueListener
*/
private fun bindPreferenceSummaryToValue(preference: Preference) {
// Set the listener to watch for value changes.
preference.onPreferenceChangeListener = sBindPreferenceSummaryToValueListener
// Trigger the listener immediately with the preference's
// current value.
sBindPreferenceSummaryToValueListener.onPreferenceChange(
preference,
PreferenceManager
.getDefaultSharedPreferences(preference.context)
.getString(preference.key, ""),
)
}
}
}

View File

@ -12,22 +12,11 @@ import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.comment_component.commentaryLayout
import kotlinx.android.synthetic.main.comment_component.commentaryText
import kotlinx.android.synthetic.main.comment_component.userImgCom
import kotlinx.android.synthetic.main.comment_component.view.commentaryBtn
import kotlinx.android.synthetic.main.comment_component.view.commentaryLayout
import kotlinx.android.synthetic.main.comment_component.view.commentaryText
import kotlinx.android.synthetic.main.comment_component.view.userImgCom
import kotlinx.android.synthetic.main.dialog_thread.view.materialToolbar
import kotlinx.android.synthetic.main.view_commentary.view.replyBtn
import kotlinx.android.synthetic.main.view_commentary.view.userCommentImg
import kotlinx.android.synthetic.main.view_commentary.view.userCommentary
import kotlinx.android.synthetic.main.view_commentary.view.userTxt
import org.libre.agosto.p2play.ManagerSingleton import org.libre.agosto.p2play.ManagerSingleton
import org.libre.agosto.p2play.R import org.libre.agosto.p2play.R
import org.libre.agosto.p2play.adapters.CommentariesAdapter import org.libre.agosto.p2play.adapters.CommentariesAdapter
import org.libre.agosto.p2play.ajax.Comments import org.libre.agosto.p2play.ajax.Comments
import org.libre.agosto.p2play.databinding.DialogThreadBinding
import org.libre.agosto.p2play.models.CommentaryModel import org.libre.agosto.p2play.models.CommentaryModel
class ThreadDialog : DialogFragment() { class ThreadDialog : DialogFragment() {
@ -35,6 +24,12 @@ class ThreadDialog : DialogFragment() {
lateinit var fragmentManager2: FragmentManager lateinit var fragmentManager2: FragmentManager
private val client: Comments = Comments() private val client: Comments = Comments()
private var _binding: DialogThreadBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
// The system calls this to get the DialogFragment's layout, regardless of // The system calls this to get the DialogFragment's layout, regardless of
// whether it's being displayed as a dialog or an embedded fragment. // whether it's being displayed as a dialog or an embedded fragment.
override fun onCreateView( override fun onCreateView(
@ -43,29 +38,30 @@ class ThreadDialog : DialogFragment() {
savedInstanceState: Bundle?, savedInstanceState: Bundle?,
): View { ): View {
// Inflate the layout to use as a dialog or embedded fragment. // Inflate the layout to use as a dialog or embedded fragment.
val view = inflater.inflate(R.layout.dialog_thread, container, false) _binding = DialogThreadBinding.inflate(inflater, container, false)
val view = binding.root
comment = arguments?.getSerializable("comment") as CommentaryModel comment = arguments?.getSerializable("comment") as CommentaryModel
view.userTxt.text = comment.username binding.commentThread?.userTxt?.text = comment.username
view.userCommentary.text = comment.commentary binding.commentThread?.userCommentary?.text = comment.commentary
Picasso.get().load("https://${ManagerSingleton.url}${comment.userImageUrl}").into(view.userCommentImg) Picasso.get().load("https://${ManagerSingleton.url}${comment.userImageUrl}").into(binding.commentThread?.userCommentImg)
view.replyBtn.visibility = View.GONE binding.commentThread?.replyBtn?.visibility = View.GONE
if (ManagerSingleton.user.status == 1) { if (ManagerSingleton.user.status == 1) {
view.commentaryText.setText("${comment.username}@${comment.userHost} ") binding.commentBox?.commentaryText?.setText("${comment.nameChannel}@${comment.userHost} ")
if (ManagerSingleton.user.avatar != "") { if (ManagerSingleton.user.avatar != "") {
Picasso.get().load("https://${ManagerSingleton.url}${ManagerSingleton.user.avatar}").into(view.userImgCom) Picasso.get().load("https://${ManagerSingleton.url}${ManagerSingleton.user.avatar}").into(binding.commentBox?.userImgCom)
} }
view.commentaryText.requestFocus() binding.commentBox?.commentaryText?.requestFocus()
view.commentaryBtn.setOnClickListener { this.replyThread() } binding.commentBox?.commentaryBtn?.setOnClickListener { this.replyThread() }
} else { } else {
view.commentaryLayout.visibility = View.GONE binding.commentBox?.commentaryLayout?.visibility = View.GONE
} }
view.materialToolbar.setTitle("Thread") binding.materialToolbar.setTitle("Thread")
view.materialToolbar.setNavigationIcon(R.drawable.baseline_arrow_back_24) binding.materialToolbar.setNavigationIcon(R.drawable.baseline_arrow_back_24)
view.materialToolbar.setNavigationOnClickListener { binding.materialToolbar.setNavigationOnClickListener {
dismiss() dismiss()
this.fragmentManager2.popBackStack() this.fragmentManager2.popBackStack()
} }
@ -109,7 +105,7 @@ class ThreadDialog : DialogFragment() {
} }
private fun replyThread() { private fun replyThread() {
val commentary = view?.commentaryText?.text.toString() val commentary = binding.commentBox?.commentaryText?.text.toString()
if (commentary == "") { if (commentary == "") {
ManagerSingleton.toast(getString(R.string.emptyCommentaryMsg), requireActivity()) ManagerSingleton.toast(getString(R.string.emptyCommentaryMsg), requireActivity())
@ -121,7 +117,7 @@ class ThreadDialog : DialogFragment() {
activity?.runOnUiThread { activity?.runOnUiThread {
if (res) { if (res) {
ManagerSingleton.toast(getString(R.string.makedCommentaryMsg), requireActivity()) ManagerSingleton.toast(getString(R.string.makedCommentaryMsg), requireActivity())
commentaryText.text?.clear() binding.commentBox?.commentaryText?.text?.clear()
this.getComments() this.getComments()
} else { } else {
ManagerSingleton.toast(getString(R.string.errorCommentaryMsg), requireActivity()) ManagerSingleton.toast(getString(R.string.errorCommentaryMsg), requireActivity())

View File

@ -1,4 +1,4 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#fff" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="48dp" android:tint="#fff" android:viewportHeight="24" android:viewportWidth="24" android:width="48dp">
<path android:fillColor="@android:color/white" android:pathData="M7,14L5,14v5h5v-2L7,17v-3zM5,10h2L7,7h3L10,5L5,5v5zM17,17h-3v2h5v-5h-2v3zM14,5v2h3v3h2L19,5h-5z"/> <path android:fillColor="@android:color/white" android:pathData="M7,14L5,14v5h5v-2L7,17v-3zM5,10h2L7,7h3L10,5L5,5v5zM17,17h-3v2h5v-5h-2v3zM14,5v2h3v3h2L19,5h-5z"/>

View File

@ -84,12 +84,9 @@
android:id="@+id/exoPlayer" android:id="@+id/exoPlayer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="500dp" android:layout_height="500dp"
app:auto_show="true"
app:controller_layout_id="@layout/custom_player_controls"
app:repeat_toggle_modes="none"
app:show_buffering="always" app:show_buffering="always"
app:surface_type="surface_view" app:use_controller="true"
app:use_controller="true" /> app:controller_layout_id="@layout/custom_player_controls"/>
<TextView <TextView
android:id="@+id/tittleVideoTxt" android:id="@+id/tittleVideoTxt"
@ -337,7 +334,9 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<include layout="@layout/comment_component" /> <include
android:id="@+id/commentBox"
layout="@layout/comment_component" />
<TextView <TextView
android:id="@+id/commentariesTxt" android:id="@+id/commentariesTxt"

View File

@ -1,110 +1,113 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <!-- Copyright 2020 The Android Open Source Project
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/exo_controls"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#44000000">
<ImageView Licensed under the Apache License, Version 2.0 (the "License");
android:id="@+id/exo_settings" you may not use this file except in compliance with the License.
android:layout_width="30dp" You may obtain a copy of the License at
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_weight="0"
android:alpha="0.5"
android:src="@drawable/ic_baseline_settings_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout http://www.apache.org/licenses/LICENSE-2.0
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView Unless required by applicable law or agreed to in writing, software
android:id="@+id/exo_rew" distributed under the License is distributed on an "AS IS" BASIS,
android:layout_width="60dp" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
android:layout_height="60dp" See the License for the specific language governing permissions and
android:src="@drawable/ic_replay_10_24" /> limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView <!-- 0dp dimensions are used to prevent this view from influencing the size of
android:id="@+id/exo_play_pause" the parent view if it uses "wrap_content". It is expanded to occupy the
android:layout_width="100dp" entirety of the parent in code, after the parent's size has been
android:layout_height="100dp" determined. See: https://github.com/google/ExoPlayer/issues/8726.
android:layout_marginHorizontal="30dp" /> -->
<View android:id="@id/exo_controls_background"
<ImageView android:layout_width="0dp"
android:id="@+id/exo_ffwd"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/ic_forward_10_24" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.media3.ui.DefaultTimeBar
android:id="@+id/exo_progress"
android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" /> android:background="@color/exo_black_opacity_60"/>
<FrameLayout
android:id="@id/exo_bottom_bar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:layout_marginTop="@dimen/exo_styled_bottom_bar_margin_top"
android:background="@color/exo_bottom_bar_background"
android:layoutDirection="ltr">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:id="@id/exo_time"
android:layout_height="60dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/exo_position"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="#fff" android:layout_gravity="center_vertical|start"
android:textSize="20sp" /> android:layoutDirection="ltr"
android:paddingStart="@dimen/exo_styled_bottom_bar_time_padding"
android:paddingLeft="@dimen/exo_styled_bottom_bar_time_padding"
android:paddingEnd="@dimen/exo_styled_bottom_bar_time_padding"
android:paddingRight="@dimen/exo_styled_bottom_bar_time_padding">
<TextView <TextView
android:layout_width="wrap_content" android:id="@id/exo_position"
android:layout_height="wrap_content" style="@style/ExoStyledControls.TimeText.Position" />
android:layout_marginHorizontal="4dp"
android:text="/"
android:textColor="#CBCDC8"
android:textSize="20sp" />
<TextView <TextView
android:id="@+id/exo_duration" style="@style/ExoStyledControls.TimeText.Separator"
android:text="/" />
<TextView
android:id="@id/exo_duration"
style="@style/ExoStyledControls.TimeText.Duration" />
</LinearLayout>
<LinearLayout
android:id="@id/exo_basic_controls"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_gravity="center_vertical|end"
android:textColor="#CBCDC8" android:layoutDirection="ltr">
android:textSize="20sp" />
<ImageView <ImageButton
android:id="@id/exo_subtitle"
style="@style/ExoStyledControls.Button.Bottom.CC" />
<ImageButton
android:id="@id/exo_settings"
style="@style/ExoStyledControls.Button.Bottom.Settings" />
<ImageButton
android:id="@+id/exo_fullscreen_custom" android:id="@+id/exo_fullscreen_custom"
android:layout_width="50dp" style="@style/ExoStyledControls.Button.Bottom.Settings"
android:layout_height="50dp" android:src="@drawable/ic_fullscreen_24"
android:visibility="visible" />
</LinearLayout>
</FrameLayout>
<View android:id="@id/exo_progress_placeholder"
android:layout_width="match_parent"
android:layout_height="@dimen/exo_styled_progress_layout_height"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/exo_styled_progress_margin_bottom"/>
<LinearLayout
android:id="@id/exo_center_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_weight="0" android:background="@android:color/transparent"
android:src="@drawable/ic_fullscreen_24" /> android:gravity="center"
</LinearLayout> android:padding="@dimen/exo_styled_controls_padding"
android:clipToPadding="false"
android:layoutDirection="ltr">
<include layout="@layout/exo_player_control_rewind_button" />
<ImageButton android:id="@id/exo_play_pause"
style="@style/ExoStyledControls.Button.Center.PlayPause"/>
<include layout="@layout/exo_player_control_ffwd_button" />
</LinearLayout> </LinearLayout>
</merge>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -23,6 +23,7 @@
android:minHeight="?attr/actionBarSize" /> android:minHeight="?attr/actionBarSize" />
<include <include
android:id="@+id/commentThread"
layout="@layout/view_commentary" layout="@layout/view_commentary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -41,6 +42,7 @@
</LinearLayout> </LinearLayout>
<include <include
android:id="@+id/commentBox"
layout="@layout/comment_component" layout="@layout/comment_component"
android:layout_width="700dp" android:layout_width="700dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -8,10 +8,27 @@
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
tools:openDrawer="start"> tools:openDrawer="start">
<include <androidx.coordinatorlayout.widget.CoordinatorLayout
layout="@layout/app_bar_main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"/>
</com.google.android.material.appbar.AppBarLayout>
<include
android:id="@+id/content"
layout="@layout/content_main" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView <com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view" android:id="@+id/nav_view"

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout 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"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -29,7 +29,7 @@
android:contentDescription="Logo" android:contentDescription="Logo"
app:srcCompat="@drawable/icon" /> app:srcCompat="@drawable/icon" />
<Space <androidx.legacy.widget.Space
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="30dp" /> android:layout_height="30dp" />
@ -42,7 +42,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Medium.Inverse" android:textAppearance="@android:style/TextAppearance.Material.Medium.Inverse"
android:textColor="@android:color/black" /> android:textColor="@android:color/black" />
<Space <androidx.legacy.widget.Space
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="30dp" /> android:layout_height="30dp" />
@ -99,4 +99,4 @@
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -74,12 +74,9 @@
android:id="@+id/exoPlayer" android:id="@+id/exoPlayer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="205dp" android:layout_height="205dp"
app:auto_show="true"
app:show_buffering="always" app:show_buffering="always"
app:controller_layout_id="@layout/custom_player_controls"
app:surface_type="surface_view"
app:use_controller="true" app:use_controller="true"
app:repeat_toggle_modes="none"/> app:controller_layout_id="@layout/custom_player_controls" />
<TextView <TextView
android:id="@+id/tittleVideoTxt" android:id="@+id/tittleVideoTxt"
@ -329,7 +326,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="20dp" /> android:layout_height="20dp" />
<include layout="@layout/comment_component" /> <include
android:id="@+id/commentBox"
layout="@layout/comment_component" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/listCommentaries" android:id="@+id/listCommentaries"

View File

@ -6,17 +6,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"/>
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_main" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,107 +1,113 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <!-- Copyright 2020 The Android Open Source Project
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/exo_controls"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#44000000">
<ImageView Licensed under the Apache License, Version 2.0 (the "License");
android:id="@+id/exo_settings" you may not use this file except in compliance with the License.
android:layout_width="30dp" You may obtain a copy of the License at
android:layout_height="30dp"
android:layout_gravity="center" http://www.apache.org/licenses/LICENSE-2.0
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp" Unless required by applicable law or agreed to in writing, software
android:layout_weight="0" distributed under the License is distributed on an "AS IS" BASIS,
android:alpha="0.5" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
android:src="@drawable/ic_baseline_settings_24" See the License for the specific language governing permissions and
app:layout_constraintEnd_toEndOf="parent" limitations under the License.
app:layout_constraintTop_toTopOf="parent" /> -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 0dp dimensions are used to prevent this view from influencing the size of
the parent view if it uses "wrap_content". It is expanded to occupy the
entirety of the parent in code, after the parent's size has been
determined. See: https://github.com/google/ExoPlayer/issues/8726.
-->
<View android:id="@id/exo_controls_background"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/exo_black_opacity_60"/>
<FrameLayout
android:id="@id/exo_bottom_bar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:layout_marginTop="@dimen/exo_styled_bottom_bar_margin_top"
android:background="@color/exo_bottom_bar_background"
android:layoutDirection="ltr">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:id="@id/exo_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:layout_gravity="center_vertical|start"
android:orientation="horizontal" android:layoutDirection="ltr"
app:layout_constraintBottom_toBottomOf="parent" android:paddingStart="@dimen/exo_styled_bottom_bar_time_padding"
app:layout_constraintEnd_toEndOf="parent" android:paddingLeft="@dimen/exo_styled_bottom_bar_time_padding"
app:layout_constraintStart_toStartOf="parent" android:paddingEnd="@dimen/exo_styled_bottom_bar_time_padding"
app:layout_constraintTop_toTopOf="parent"> android:paddingRight="@dimen/exo_styled_bottom_bar_time_padding">
<ImageView <TextView
android:id="@+id/exo_rew" android:id="@id/exo_position"
android:layout_width="35dp" style="@style/ExoStyledControls.TimeText.Position" />
android:layout_height="35dp"
android:src="@drawable/ic_replay_10_24" />
<ImageView <TextView
android:id="@+id/exo_play_pause" style="@style/ExoStyledControls.TimeText.Separator"
android:layout_width="43dp" android:text="/" />
android:layout_height="43dp"
android:layout_marginHorizontal="30dp" />
<ImageView <TextView
android:id="@+id/exo_ffwd" android:id="@id/exo_duration"
android:layout_width="35dp" style="@style/ExoStyledControls.TimeText.Duration" />
android:layout_height="35dp"
android:src="@drawable/ic_forward_10_24" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/linearLayout4" android:id="@id/exo_basic_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.media3.ui.DefaultTimeBar
android:id="@+id/exo_progress"
android:layout_width="wrap_content"
android:layout_height="10dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/exo_position"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="#fff" /> android:layout_gravity="center_vertical|end"
android:layoutDirection="ltr">
<TextView <ImageButton
android:layout_width="wrap_content" android:id="@id/exo_subtitle"
android:layout_height="wrap_content" style="@style/ExoStyledControls.Button.Bottom.CC" />
android:layout_marginHorizontal="4dp"
android:text="/"
android:textColor="#CBCDC8" />
<TextView <ImageButton
android:id="@+id/exo_duration" android:id="@id/exo_settings"
android:layout_width="wrap_content" style="@style/ExoStyledControls.Button.Bottom.Settings" />
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#CBCDC8" />
<ImageView <ImageButton
android:id="@+id/exo_fullscreen_custom" android:id="@+id/exo_fullscreen_custom"
android:layout_width="35dp" style="@style/ExoStyledControls.Button.Bottom.Settings"
android:layout_height="42dp" android:src="@drawable/ic_fullscreen_24"
android:visibility="visible" />
</LinearLayout>
</FrameLayout>
<View android:id="@id/exo_progress_placeholder"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:layout_marginBottom="45dp"/>
<LinearLayout
android:id="@id/exo_center_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_weight="0" android:background="@android:color/transparent"
android:src="@drawable/ic_fullscreen_24" /> android:gravity="center"
</LinearLayout> android:padding="@dimen/exo_styled_controls_padding"
android:clipToPadding="false"
android:layoutDirection="ltr">
<include layout="@layout/exo_player_control_rewind_button" />
<ImageButton android:id="@id/exo_play_pause"
style="@style/ExoStyledControls.Button.Center.PlayPause"/>
<include layout="@layout/exo_player_control_ffwd_button" />
</LinearLayout> </LinearLayout>
</merge>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout 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"
xmlns:tools="http://schemas.android.com/tools"
android:background="?attr/colorSurface" android:background="?attr/colorSurface"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -24,6 +23,7 @@
android:minHeight="?attr/actionBarSize" /> android:minHeight="?attr/actionBarSize" />
<include <include
android:id="@+id/commentThread"
layout="@layout/view_commentary" layout="@layout/view_commentary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -42,6 +42,7 @@
</LinearLayout> </LinearLayout>
<include <include
android:id="@+id/commentBox"
layout="@layout/comment_component" layout="@layout/comment_component"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -1,29 +0,0 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- NOTE: EditTextPreference accepts EditText attributes. -->
<!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. -->
<EditTextPreference
android:capitalize="words"
android:defaultValue="@string/pref_hostname_error"
android:inputType="text"
android:key="hostP2play"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/pref_hostname_title" />
<SwitchPreference
android:defaultValue="false"
android:key="show_nfsw"
android:summary="@string/pref_nfsw_description"
android:title="@string/pref_nfsw_title" />
<EditTextPreference
android:defaultValue="15"
android:inputType="number"
android:key="videos_count"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/pref_videos_count_title" />
</PreferenceScreen>

View File

@ -1,23 +0,0 @@
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- These settings headers are only used on tablets. -->
<header
android:fragment="org.libre.agosto.p2play.SettingsActivity$GeneralPreferenceFragment"
android:icon="@drawable/ic_info_black_24dp"
android:title="@string/pref_header_general"
android:textColor="@color/md_theme_light_secondary"/>
<!-- <header
android:fragment="org.libre.agosto.p2play.SettingsActivity$NotificationPreferenceFragment"
android:icon="@drawable/ic_notifications_black_24dp"
android:title="@string/pref_header_notifications" />
<header
android:fragment="org.libre.agosto.p2play.SettingsActivity$DataSyncPreferenceFragment"
android:icon="@drawable/ic_sync_black_24dp"
android:title="@string/pref_header_data_sync" /> -->
</preference-headers>

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.6.21' ext.kotlin_version = '1.9.20'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()