Report and share videos works
This commit is contained in:
parent
398265c6ed
commit
abcf2f0e6e
|
@ -2,6 +2,7 @@ package org.libre.agosto.p2play
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.graphics.Bitmap
|
||||
|
@ -11,12 +12,14 @@ import android.support.v7.app.AppCompatActivity
|
|||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.webkit.WebChromeClient
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import com.squareup.picasso.Picasso
|
||||
import kotlinx.android.synthetic.main.activity_reproductor.*
|
||||
|
@ -74,8 +77,7 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
// Load the video
|
||||
videoView.loadUrl("https://" + ManagerSingleton.url + this.video.embedUrl)
|
||||
|
||||
}
|
||||
catch (err:Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
}
|
||||
|
||||
|
@ -89,6 +91,8 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
dislikeLayout.setOnClickListener { rate("dislike") }
|
||||
commentaryBtn.setOnClickListener { makeComment() }
|
||||
showMoreBtn.setOnClickListener { getDescription() }
|
||||
shareLayout.setOnClickListener { shareIntent() }
|
||||
reportLayout.setOnClickListener { reportIntent() }
|
||||
|
||||
userImg.setOnClickListener {
|
||||
val intent = Intent(this, ChannelActivity::class.java)
|
||||
|
@ -136,8 +140,7 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
if (rate == "like") {
|
||||
textViewLike.setTextColor(ContextCompat.getColor(this, R.color.colorLike))
|
||||
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))
|
||||
textViewLike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light))
|
||||
}
|
||||
|
@ -186,8 +189,7 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
if (subscribed) {
|
||||
subscribeBtn.text = getText(R.string.unSubscribeBtn)
|
||||
subscribeBtn.setOnClickListener { this.unSubscribe() }
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
subscribeBtn.text = getText(R.string.subscribeBtn)
|
||||
subscribeBtn.setOnClickListener { this.subscribe() }
|
||||
}
|
||||
|
@ -232,8 +234,7 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
ManagerSingleton.Toast(getString(R.string.makedCommentaryMsg), this)
|
||||
commentaryText.text.clear()
|
||||
this.getComments()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ManagerSingleton.Toast(getString(R.string.errorCommentaryMsg), this)
|
||||
}
|
||||
}
|
||||
|
@ -264,6 +265,52 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun shareIntent() {
|
||||
val sendIntent: Intent = Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_TEXT, "${video.name} ${video.getVideoUrl()}")
|
||||
type = "text/plain"
|
||||
}
|
||||
startActivity(Intent.createChooser(sendIntent, resources.getText(R.string.shareBtn)))
|
||||
}
|
||||
|
||||
private fun reportIntent() {
|
||||
val builder = AlertDialog.Builder(this)
|
||||
// Get the layout inflater
|
||||
val dialog = layoutInflater.inflate(R.layout.report_dialog, null)
|
||||
|
||||
val inputReason = dialog.findViewById<EditText>(R.id.reportText)
|
||||
|
||||
// Inflate and set the layout for the dialog
|
||||
// Pass null as the parent view because its going in the dialog layout
|
||||
builder.setView(dialog)
|
||||
// Add action buttons
|
||||
.setPositiveButton(R.string.reportBtn) { dialog, id ->
|
||||
val reason = inputReason.text.toString()
|
||||
reportVideo(reason)
|
||||
}
|
||||
.setNegativeButton("Cancel") { dialog, id ->
|
||||
dialog.cancel()
|
||||
}
|
||||
val alertDialog = builder.create()
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
private fun reportVideo(reason: String){
|
||||
AsyncTask.execute {
|
||||
val res = _actions.reportVideo(video.id, reason, ManagerSingleton.token.token)
|
||||
|
||||
runOnUiThread {
|
||||
if(res) {
|
||||
ManagerSingleton.Toast(getText(R.string.reportDialogMsg).toString(), this)
|
||||
}
|
||||
else {
|
||||
ManagerSingleton.Toast(getText(R.string.errorMsg).toString(), this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal inner class WebClient: WebChromeClient() {
|
||||
private var mCustomView: View? = null
|
||||
private var mCustomViewCallback: WebChromeClient.CustomViewCallback? = null
|
||||
|
|
|
@ -127,4 +127,21 @@ class Actions: Client() {
|
|||
return rating
|
||||
}
|
||||
|
||||
fun reportVideo(videoId: Int, reason: String, token: String): Boolean {
|
||||
val con = this._newCon("videos/$videoId/abuse", "POST", token)
|
||||
val params = "reason=$reason"
|
||||
con.outputStream.write(params.toByteArray())
|
||||
|
||||
var response = false
|
||||
try {
|
||||
if(con.responseCode == 200){
|
||||
response = true
|
||||
}
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
response = false
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import java.io.Serializable
|
|||
|
||||
class VideoModel(
|
||||
var id: Int = 0,
|
||||
var uuid: String = "",
|
||||
var name: String = "",
|
||||
var description: String = "",
|
||||
var thumbUrl: String = "",
|
||||
|
@ -22,12 +23,17 @@ class VideoModel(
|
|||
return "$nameChannel@$userHost"
|
||||
}
|
||||
|
||||
fun getVideoUrl(): String {
|
||||
return "https://$userHost/videos/watch/$uuid"
|
||||
}
|
||||
|
||||
fun parseVideo(data: JsonReader){
|
||||
data.beginObject()
|
||||
while (data.hasNext()){
|
||||
val key = data.nextName()
|
||||
when (key.toString()) {
|
||||
"id"-> this.id = data.nextInt()
|
||||
"uuid" -> this.uuid = data.nextString()
|
||||
"name"->{
|
||||
this.name= data.nextString()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12.8716,3.5097L12,1.9603L11.1284,3.5097L2.1284,19.5097L1.2902,21L3,21L21,21L22.7098,21L21.8716,19.5097L12.8716,3.5097Z"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#000000"
|
||||
android:fillType="evenOdd"/>
|
||||
<path
|
||||
android:pathData="M12,17.75C12.6904,17.75 13.25,17.1904 13.25,16.5C13.25,15.8096 12.6904,15.25 12,15.25C11.3096,15.25 10.75,15.8096 10.75,16.5C10.75,17.1904 11.3096,17.75 12,17.75Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#000000"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
<path
|
||||
android:pathData="M12,9L12,9A1,1 0,0 1,13 10L13,13A1,1 0,0 1,12 14L12,14A1,1 0,0 1,11 13L11,10A1,1 0,0 1,12 9z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#000000"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
</vector>
|
|
@ -0,0 +1,29 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M20,15L20,18.0026C20,19.1057 19.1074,20 18.0049,20L5.9951,20C4.8932,20 4,19.1074 4,18.0049L4,5.9951C4,4.8932 4.8959,4 5.9974,4L9,4"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#000000"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M13,4l7.0208,0l0,7.0191"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#000000"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M19,5L12,12"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#000000"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
|
@ -124,21 +124,61 @@
|
|||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
<LinearLayout
|
||||
android:id="@+id/reportLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/shareBtn"
|
||||
android:visibility="gone" />
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
<ImageView
|
||||
android:id="@+id/imageViewAlert"
|
||||
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_alert" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewAlert"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/reportBtn"
|
||||
android:visibility="gone" />
|
||||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/shareLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewShare"
|
||||
android:layout_width="match_parent"
|
||||
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_share" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewShare"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/shareBtn"
|
||||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/layout_root"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reportTxt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/reportDialog"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/reportText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textMultiLine">
|
||||
|
||||
<requestFocus />
|
||||
|
||||
</EditText>
|
||||
|
||||
</LinearLayout>
|
|
@ -94,6 +94,10 @@
|
|||
<string name="showMore">Mostrar mas</string>
|
||||
<string name="nav_trending">Tendencias</string>
|
||||
<string name="title_trending">Tendencias</string>
|
||||
<string name="followersIndicator">Seguidores:</string>
|
||||
<string name="hostIndicator">Host:</string>
|
||||
<string name="reportDialog">Razon para reportar:</string>
|
||||
<string name="reportDialogMsg">Has reportado el video</string>
|
||||
<!-- End Settings strings -->
|
||||
|
||||
</resources>
|
|
@ -6,7 +6,7 @@
|
|||
<string name="navigation_drawer_close" translatable="false">Close navigation drawer</string>
|
||||
<string name="nav_header_desc" translatable="false">Navigation header</string>
|
||||
<string name="comming">Coming soon!</string>
|
||||
<string name="charging">Loading...</string>
|
||||
<string name="charging">Loading…</string>
|
||||
<!-- End Global string -->
|
||||
|
||||
|
||||
|
@ -111,6 +111,8 @@
|
|||
<string name="followersIndicator">Followers:</string>
|
||||
<string name="hostIndicator">Host:</string>
|
||||
<!-- End Channel strings -->
|
||||
|
||||
|
||||
<!-- Start Prompt string -->
|
||||
<string name="reportDialog">Reason for report video:</string>
|
||||
<string name="reportDialogMsg">You are reported the video</string>
|
||||
<!-- End Prompt strings -->
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue