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 {
var cursor= db.rawQuery("SELECT * FROM tokens WHERE status=1 ORDER BY id DESC LIMIT 1",null)
if(cursor.count != 0){
cursor.moveToFirst()
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()
return token
@ -85,6 +87,8 @@ class Database(context:Context): SQLiteOpenHelper(context,"p2play",null,1) {
try {
var cursor= db.rawQuery("SELECT * FROM users WHERE status=1 ORDER BY id DESC LIMIT 1",null)
if(cursor.count != 0){
cursor.moveToFirst()
user.uuid = cursor.getString(cursor.getColumnIndex("uuid")).toInt()
@ -94,6 +98,7 @@ class Database(context:Context): SQLiteOpenHelper(context,"p2play",null,1) {
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()

View File

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

View File

@ -1,5 +1,8 @@
package org.libre.agosto.p2play
import android.app.Activity
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.AsyncTask
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
@ -9,6 +12,8 @@ import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.View
import android.webkit.WebChromeClient
import android.widget.FrameLayout
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_reproductor.*
import org.libre.agosto.p2play.adapters.CommentariesAdapter
@ -32,6 +37,7 @@ class ReproductorActivity : AppCompatActivity() {
setContentView(R.layout.activity_reproductor)
ManagerSingleton.context = this
videoView.webChromeClient = WebClient()
videoView.settings.javaScriptEnabled = true
videoView.settings.allowContentAccess = true
videoView.settings.javaScriptCanOpenWindowsAutomatically = true
@ -45,7 +51,7 @@ class ReproductorActivity : AppCompatActivity() {
tittleVideoTxt.text = this.video.name
viewsTxt.text = this.video.views.toString() + ' ' + getString(R.string.view_text)
userTxt.text = this.video.username
descriptionVideoTxt.text = this.video.description
descriptionVideoTxt.text = this.video.description.toString()
if(this.video.userImageUrl!="")
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.Looper
import android.preference.PreferenceManager
import android.util.Log
import org.libre.agosto.p2play.ajax.Auth
import java.lang.Exception
class SplashActivity : AppCompatActivity() {
lateinit var settings: SharedPreferences
@ -38,13 +40,16 @@ class SplashActivity : AppCompatActivity() {
checkUser()
}
}
else{
Handler().postDelayed({
startHostActivity()
}, 2000)
}
}
private fun checkUser(){
Log.d("was", "Chequed")
try {
val token = _db.getToken()
val user = _db.getUser()
AsyncTask.execute {
@ -70,10 +75,18 @@ class SplashActivity : AppCompatActivity() {
_db.logout()
}
startApp()
Log.d("Aqui", "81")
}
}
catch (err: Exception){
err.printStackTrace()
Log.d("Aqui", "89")
Handler().postDelayed({
startApp()
}, 2000)
}
}

View File

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

View File

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

View File

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