Splash screen fix + description on videos

This commit is contained in:
ivan agosto 2019-01-29 14:56:50 -06:00
parent abec98d172
commit 7930ffa582
7 changed files with 149 additions and 64 deletions

View File

@ -61,12 +61,14 @@ class Database(context:Context): SQLiteOpenHelper(context,"p2play",null,1) {
try { try {
var cursor= db.rawQuery("SELECT * FROM tokens WHERE status=1 ORDER BY id DESC LIMIT 1",null) var cursor= db.rawQuery("SELECT * FROM tokens WHERE status=1 ORDER BY id DESC LIMIT 1",null)
cursor.moveToFirst()
token.token = cursor.getString(cursor.getColumnIndex("token")).toString() if(cursor.count != 0){
token.refresh_token = cursor.getString(cursor.getColumnIndex("refresh_token")).toString() cursor.moveToFirst()
token.status = cursor.getString(cursor.getColumnIndex("status")).toInt()
token.token = cursor.getString(cursor.getColumnIndex("token")).toString()
token.refresh_token = cursor.getString(cursor.getColumnIndex("refresh_token")).toString()
token.status = cursor.getString(cursor.getColumnIndex("status")).toInt()
}
cursor.close() cursor.close()
return token return token
@ -85,15 +87,18 @@ class Database(context:Context): SQLiteOpenHelper(context,"p2play",null,1) {
try { try {
var cursor= db.rawQuery("SELECT * FROM users WHERE status=1 ORDER BY id DESC LIMIT 1",null) var cursor= db.rawQuery("SELECT * FROM users WHERE status=1 ORDER BY id DESC LIMIT 1",null)
cursor.moveToFirst()
user.uuid = cursor.getString(cursor.getColumnIndex("uuid")).toInt() if(cursor.count != 0){
user.username = cursor.getString(cursor.getColumnIndex("username")).toString() cursor.moveToFirst()
user.email = cursor.getString(cursor.getColumnIndex("email")).toString()
user.nsfw = cursor.getString(cursor.getColumnIndex("nsfw")).toBoolean() user.uuid = cursor.getString(cursor.getColumnIndex("uuid")).toInt()
user.followers = cursor.getString(cursor.getColumnIndex("followers")).toInt() user.username = cursor.getString(cursor.getColumnIndex("username")).toString()
user.avatar = cursor.getString(cursor.getColumnIndex("avatar")).toString() user.email = cursor.getString(cursor.getColumnIndex("email")).toString()
user.status = cursor.getString(cursor.getColumnIndex("status")).toInt() user.nsfw = cursor.getString(cursor.getColumnIndex("nsfw")).toBoolean()
user.followers = cursor.getString(cursor.getColumnIndex("followers")).toInt()
user.avatar = cursor.getString(cursor.getColumnIndex("avatar")).toString()
user.status = cursor.getString(cursor.getColumnIndex("status")).toInt()
}
cursor.close() cursor.close()

View File

@ -34,6 +34,7 @@ class HostActivity : AppCompatActivity() {
if(host!=""){ if(host!=""){
if(lastHost!=host){ if(lastHost!=host){
_db.logout() _db.logout()
ManagerSingleton.logout()
getKeys(host) getKeys(host)
}else{ }else{
ManagerSingleton.url=host ManagerSingleton.url=host

View File

@ -1,5 +1,8 @@
package org.libre.agosto.p2play package org.libre.agosto.p2play
import android.app.Activity
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.AsyncTask import android.os.AsyncTask
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
@ -9,6 +12,8 @@ import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import android.webkit.WebChromeClient
import android.widget.FrameLayout
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_reproductor.* import kotlinx.android.synthetic.main.activity_reproductor.*
import org.libre.agosto.p2play.adapters.CommentariesAdapter import org.libre.agosto.p2play.adapters.CommentariesAdapter
@ -32,6 +37,7 @@ class ReproductorActivity : AppCompatActivity() {
setContentView(R.layout.activity_reproductor) setContentView(R.layout.activity_reproductor)
ManagerSingleton.context = this ManagerSingleton.context = this
videoView.webChromeClient = WebClient()
videoView.settings.javaScriptEnabled = true videoView.settings.javaScriptEnabled = true
videoView.settings.allowContentAccess = true videoView.settings.allowContentAccess = true
videoView.settings.javaScriptCanOpenWindowsAutomatically = true videoView.settings.javaScriptCanOpenWindowsAutomatically = true
@ -45,7 +51,7 @@ class ReproductorActivity : AppCompatActivity() {
tittleVideoTxt.text = this.video.name tittleVideoTxt.text = this.video.name
viewsTxt.text = this.video.views.toString() + ' ' + getString(R.string.view_text) viewsTxt.text = this.video.views.toString() + ' ' + getString(R.string.view_text)
userTxt.text = this.video.username userTxt.text = this.video.username
descriptionVideoTxt.text = this.video.description descriptionVideoTxt.text = this.video.description.toString()
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(userImg)
@ -227,4 +233,54 @@ class ReproductorActivity : AppCompatActivity() {
} }
} }
} }
internal inner class WebClient(): WebChromeClient() {
private var mCustomView: View? = null
private var mCustomViewCallback: WebChromeClient.CustomViewCallback? = null
private var mFullscreenContainer: FrameLayout? = null
private var mOriginalOrientation: Int = 0
private var mOriginalSystemUiVisibility: Int = 0
fun WebClient() {}
override fun getDefaultVideoPoster(): Bitmap? {
return if (mCustomView == null) {
null
} else BitmapFactory.decodeResource(this@ReproductorActivity.resources, 2130837573)
}
override fun onHideCustomView() {
try {
(this@ReproductorActivity.window.decorView as FrameLayout).removeView(this.mCustomView)
this.mCustomView = null
this@ReproductorActivity.window.decorView.systemUiVisibility = this.mOriginalSystemUiVisibility
this@ReproductorActivity.requestedOrientation = this.mOriginalOrientation
this.mCustomViewCallback?.onCustomViewHidden()
this.mCustomViewCallback = null
}
catch (err: Exception){
err.printStackTrace()
}
}
override fun onShowCustomView(paramView: View, paramCustomViewCallback: WebChromeClient.CustomViewCallback) {
if (this.mCustomView != null) {
this.onHideCustomView()
return
}
try {
this.mCustomView = paramView
this.mOriginalSystemUiVisibility = this@ReproductorActivity.window.decorView.systemUiVisibility
this.mOriginalOrientation = this@ReproductorActivity.requestedOrientation
this.mCustomViewCallback = paramCustomViewCallback
(this@ReproductorActivity.window.decorView as FrameLayout).addView(this.mCustomView, FrameLayout.LayoutParams(-1, -1))
this@ReproductorActivity.window.decorView.systemUiVisibility = 3846
}
catch (err: Exception){
err.printStackTrace()
}
}
}
} }

View File

@ -8,7 +8,9 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.preference.PreferenceManager import android.preference.PreferenceManager
import android.util.Log
import org.libre.agosto.p2play.ajax.Auth import org.libre.agosto.p2play.ajax.Auth
import java.lang.Exception
class SplashActivity : AppCompatActivity() { class SplashActivity : AppCompatActivity() {
lateinit var settings: SharedPreferences lateinit var settings: SharedPreferences
@ -27,53 +29,64 @@ class SplashActivity : AppCompatActivity() {
val host = settings.getString("hostP2play","") val host = settings.getString("hostP2play","")
val lastHost = settings.getString("last_host","") val lastHost = settings.getString("last_host","")
if(host!=""){ if(host != ""){
if(lastHost!=host){ if(lastHost != host){
_db.logout() _db.logout()
Handler().postDelayed({ Handler().postDelayed({
startHostActivity() startHostActivity()
}, 2000) }, 2000)
}else{ }else{
ManagerSingleton.url=host ManagerSingleton.url = host
checkUser() checkUser()
} }
} }
else{
Handler().postDelayed({ Handler().postDelayed({
startHostActivity() startHostActivity()
}, 2000) }, 2000)
}
} }
private fun checkUser(){ private fun checkUser(){
val token = _db.getToken() Log.d("was", "Chequed")
val user = _db.getUser() try {
AsyncTask.execute { val token = _db.getToken()
if (Looper.myLooper() == null) val user = _db.getUser()
Looper.prepare() AsyncTask.execute {
if (Looper.myLooper() == null)
Looper.prepare()
if (token.status == 1 && user.status == 1) { if (token.status == 1 && user.status == 1) {
val client_id = settings.getString("client_id", "") val client_id = settings.getString("client_id", "")
val client_secret = settings.getString("client_secret", "") val client_secret = settings.getString("client_secret", "")
val newToken = client.refreshToken(token, client_id, client_secret) val newToken = client.refreshToken(token, client_id, client_secret)
when (token.status.toString()) { when (token.status.toString()) {
"1" -> { "1" -> {
_db.newToken(newToken) _db.newToken(newToken)
ManagerSingleton.token = newToken ManagerSingleton.token = newToken
ManagerSingleton.user = user ManagerSingleton.user = user
}
else -> _db.logout()
} }
else -> _db.logout() } else {
_db.logout()
} }
} else {
_db.logout()
}
startApp()
Log.d("Aqui", "81")
}
}
catch (err: Exception){
err.printStackTrace()
Log.d("Aqui", "89")
Handler().postDelayed({ Handler().postDelayed({
startApp() startApp()
}, 2000) }, 2000)
} }
} }

View File

@ -8,10 +8,11 @@
<ScrollView <ScrollView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent">
android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -25,7 +26,8 @@
<WebView <WebView
android:id="@+id/videoView" android:id="@+id/videoView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="270dp"> android:layout_height="270dp"
android:layout_weight="1">
</WebView> </WebView>
@ -48,7 +50,7 @@
<LinearLayout <LinearLayout
android:id="@+id/actionsLayout" android:id="@+id/actionsLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="50dp"
android:gravity="top" android:gravity="top"
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="gone"> android:visibility="gone">
@ -58,21 +60,25 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical"
android:visibility="visible">
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/imageView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:adjustViewBounds="false" android:adjustViewBounds="false"
android:contentDescription="@string/likeBtn"
android:cropToPadding="false" android:cropToPadding="false"
android:scaleType="center"
android:visibility="visible"
app:srcCompat="@drawable/ic_like" /> app:srcCompat="@drawable/ic_like" />
<TextView <TextView
android:id="@+id/textViewLike" android:id="@+id/textViewLike"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/likeBtn" android:text="@string/likeBtn"
android:textAlignment="center" /> android:textAlignment="center" />
@ -83,21 +89,24 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical"
android:visibility="visible">
<ImageView <ImageView
android:id="@+id/imageView2" android:id="@+id/imageView2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:adjustViewBounds="false" android:adjustViewBounds="false"
android:contentDescription="@string/dislikeBtn"
android:cropToPadding="false" android:cropToPadding="false"
android:visibility="visible"
app:srcCompat="@drawable/ic_dislike" /> app:srcCompat="@drawable/ic_dislike" />
<TextView <TextView
android:id="@+id/textViewDislike" android:id="@+id/textViewDislike"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/dislikeBtn" android:text="@string/dislikeBtn"
android:textAlignment="center" /> android:textAlignment="center" />
@ -105,7 +114,7 @@
<Button <Button
android:id="@+id/button4" android:id="@+id/button4"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/shareBtn" android:text="@string/shareBtn"
@ -113,7 +122,7 @@
<Button <Button
android:id="@+id/button3" android:id="@+id/button3"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/reportBtn" android:text="@string/reportBtn"
@ -122,14 +131,14 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="60dp"
android:layout_weight="1" android:layout_weight="1"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/userImg" android:id="@+id/userImg"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="50dp" android:layout_height="match_parent"
android:layout_margin="0dp" android:layout_margin="0dp"
android:layout_weight="1" android:layout_weight="1"
android:adjustViewBounds="false" android:adjustViewBounds="false"
@ -165,18 +174,16 @@
android:paddingLeft="5dp" android:paddingLeft="5dp"
android:text="@string/descriptionTxt" /> android:text="@string/descriptionTxt" />
<ScrollView <TextView
android:id="@+id/descriptionVideoTxt"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="wrap_content"
android:scrollbarStyle="insideInset"> android:autoLink="web"
android:linksClickable="true"
<TextView android:maxLength="10000"
android:id="@+id/descriptionVideoTxt" android:maxLines="100"
android:layout_width="match_parent" android:paddingLeft="10dp"
android:layout_height="wrap_content" android:paddingRight="10dp" />
android:maxLength="1000"
android:maxLines="100" />
</ScrollView>
<View <View
android:id="@+id/divider" android:id="@+id/divider"
@ -224,6 +231,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="2" android:layout_weight="2"
android:ems="10" android:ems="10"
android:hint="@string/commentHolder"
android:inputType="textMultiLine" /> android:inputType="textMultiLine" />
</LinearLayout> </LinearLayout>

View File

@ -64,6 +64,7 @@
<!-- Start Reproductor strings --> <!-- Start Reproductor strings -->
<string name="descriptionTxt">Descripcion:</string> <string name="descriptionTxt">Descripcion:</string>
<string name="commentariesTxt">Comentarios:</string> <string name="commentariesTxt">Comentarios:</string>
<string name="commentHolder">Has un comentario</string>
<!-- Actions --> <!-- Actions -->
<string name="likeBtn">Like</string> <string name="likeBtn">Like</string>
<string name="dislikeBtn">Dislike</string> <string name="dislikeBtn">Dislike</string>

View File

@ -74,6 +74,7 @@
<!-- Start Reproductor strings --> <!-- Start Reproductor strings -->
<string name="descriptionTxt">Description:</string> <string name="descriptionTxt">Description:</string>
<string name="commentariesTxt">Commentaries:</string> <string name="commentariesTxt">Commentaries:</string>
<string name="commentHolder">Make a commentary</string>
<!-- Actions --> <!-- Actions -->
<string name="subscribeBtn">Subscribe</string> <string name="subscribeBtn">Subscribe</string>
<string name="likeBtn">Like</string> <string name="likeBtn">Like</string>