Merge branch 'development' into 'master'

Development version 0.1.5

See merge request agosto182/p2play!2
This commit is contained in:
Ivan Agosto
2018-12-31 14:34:20 +00:00
23 changed files with 526 additions and 89 deletions

View File

@@ -1,18 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="p2play" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
<option name="GRADLE_PROJECT_PATH" value=":" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>

View File

@@ -17,14 +17,17 @@ Comming soon!
- Login and register in your instance
- Pull to refresh
- Show uploaded videos
- Subscribe to accounts
- Show your subscripcion videos
- Rate videos
## What to do? (in next version)
- Search videos
- Show and make commentaries
- Subscribe to accounts
- Show your subscripcion videos
- Rate and share videos
- Share videos
- View Peertube profiles
- Splash screen
## Demostrations
Demostration P2Play Beta 0.1: [https://peertube.video/videos/watch/2eb7b953-0b1b-4019-9300-817539f5f4e8](https://peertube.video/videos/watch/2eb7b953-0b1b-4019-9300-817539f5f4e8)

View File

@@ -50,19 +50,19 @@
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/compileDebugUnitTestJavaWithJavac/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources/debugAndroidTest/processDebugAndroidTestResources/r" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
@@ -97,13 +97,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@@ -111,32 +104,46 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotation_processor_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/apk_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-libraries" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/checkDebugClasspath" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compatible_screen_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-main-apk-res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_split_apk_resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/processed_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shader_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/kotlin" />
@@ -145,36 +152,37 @@
</content>
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: com.android.support:transition-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:transition-27.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner-1.0.2" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-compat-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.51@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support:support-annotations:27.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-27.1.0" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.2.51@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel-1.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:recyclerview-v7-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-compat-27.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:recyclerview-v7-27.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.squareup:javawriter:2.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat-27.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-27.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-1.1.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-27.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-27.1.0" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.squareup.okio:okio:1.14.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-core-3.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-fragment-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-fragment-27.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.2.51@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:design-27.1.0" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:runtime-1.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.51@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:design-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:monitor-1.0.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-27.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-idling-resource-3.0.2" level="project" />
<orderEntry type="library" name="Gradle: com.squareup.okhttp3:okhttp:3.10.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-solver:1.1.2@jar" level="project" />

View File

@@ -10,8 +10,8 @@ android {
applicationId "org.libre.agosto.p2play"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "0.1"
versionCode 2
versionName "0.1.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -20,7 +20,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.3'
buildToolsVersion '28.0.2'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
@@ -29,11 +29,11 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.squareup.picasso:picasso:2.71828'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'

View File

@@ -11,7 +11,8 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_p2play"
android:supportsRtl="true"
android:theme="@style/P2playTheme">
android:theme="@style/P2playTheme"
android:hardwareAccelerated="true">
<activity android:name=".HostActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@@ -29,6 +29,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
private lateinit var viewManager: RecyclerView.LayoutManager
val client: Videos = Videos()
private lateinit var lastItem: MenuItem
private lateinit var subItem: MenuItem
lateinit var myMenu: Menu
val _db = Database(this)
var section: String = ""
@@ -89,6 +90,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
"local" -> this.getLocalVideos()
"popular" -> this.getPopularVideos()
"last" -> this.getLastVideos()
"sub" -> this.getSubscriptionVideos()
"my_videos" -> {
if(ManagerSingleton.token.token != "")
this.getMyVideos()
@@ -98,6 +100,23 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
}
fun getSubscriptionVideos(){
if(ManagerSingleton.user.status != 1){
ManagerSingleton.Toast("Inicia session primero")
startActivity(Intent(this, LoginActivity::class.java))
return
}
swipeContainer.isRefreshing = true
section = "sub"
setTitle(R.string.title_subscriptions)
AsyncTask.execute {
val videos = client.videoSubscriptions(ManagerSingleton.token.token)
runOnUiThread {
this.setData(videos)
}
}
}
// Last videos
fun getLastVideos(){
swipeContainer.isRefreshing = true
@@ -202,6 +221,9 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
lastItem = item
// item.isChecked = true
when (item.itemId) {
R.id.nav_subscriptions->{
getSubscriptionVideos()
}
R.id.nav_popular-> {
getPopularVideos()
}

View File

@@ -1,14 +1,21 @@
package org.libre.agosto.p2play
import android.opengl.Visibility
import android.os.AsyncTask
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.os.Looper
import android.support.v4.content.ContextCompat
import android.util.Log
import android.view.View
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_reproductor.*
import org.libre.agosto.p2play.ajax.Actions
import org.libre.agosto.p2play.models.VideoModel
class ReproductorActivity : AppCompatActivity() {
lateinit var video:VideoModel
private val _actions: Actions = Actions()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -17,6 +24,12 @@ class ReproductorActivity : AppCompatActivity() {
videoView.settings.javaScriptEnabled = true
videoView.settings.allowContentAccess = true
videoView.settings.javaScriptCanOpenWindowsAutomatically = true
videoView.settings.allowFileAccess = true
videoView.settings.allowFileAccessFromFileURLs = true
videoView.settings.allowUniversalAccessFromFileURLs = true
videoView.settings.domStorageEnabled = true
try {
this.video = this.intent.extras.getSerializable("video") as VideoModel
tittleVideoTxt.text = this.video.name
@@ -34,6 +47,117 @@ class ReproductorActivity : AppCompatActivity() {
Log.d("Error", err?.message)
}
subscribeBtn.setOnClickListener { ManagerSingleton.Toast(getString(R.string.comming)) }
// subscribeBtn.setOnClickListener { ManagerSingleton.Toast(getString(R.string.comming)) }
subscribeBtn.setOnClickListener { subscribe() }
likeLayout.setOnClickListener { rate("like") }
dislikeLayout.setOnClickListener { rate("dislike") }
}
fun subscribe(){
val account = this.video.userUuid+"@"+this.video.userHost
AsyncTask.execute {
if (Looper.myLooper() == null)
Looper.prepare()
val res = this._actions.subscribe(ManagerSingleton.token.token, account)
if (res == 1) {
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.subscribeMsg))
this.changeSubscribeBtn(true)
}
}
}
}
fun unSubscribe(){
val account = this.video.userUuid+"@"+this.video.userHost
AsyncTask.execute {
if (Looper.myLooper() == null)
Looper.prepare()
val res = this._actions.unSubscribe(ManagerSingleton.token.token, account)
if (res == 1) {
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.unSubscribeMsg))
this.changeSubscribeBtn(false)
}
}
}
}
fun rate(rate: String){
AsyncTask.execute {
if (Looper.myLooper() == null)
Looper.prepare()
val res = this._actions.rate(ManagerSingleton.token.token, this.video.id, rate)
if (res == 1) {
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.rateMsg))
if(rate=="like"){
likeLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.colorLike))
dislikeLayout.background = null
}
else if(rate=="dislike"){
dislikeLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.colorDislike))
likeLayout.background = null
}
}
}
}
}
fun getRate(){
AsyncTask.execute {
if (Looper.myLooper() == null)
Looper.prepare()
val rate = this._actions.getRate(ManagerSingleton.token.token, this.video.id)
runOnUiThread {
when (rate){
"like" -> {
likeLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.colorLike))
dislikeLayout.background = null
}
"dislike" -> {
dislikeLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.colorDislike))
likeLayout.background = null
}
else -> {
likeLayout.background = null
dislikeLayout.background = null
}
}
}
}
}
fun getSubscription(){
val account = this.video.userUuid+"@"+this.video.userHost
AsyncTask.execute {
if (Looper.myLooper() == null)
Looper.prepare()
val isSubscribed = this._actions.getSubscription(ManagerSingleton.token.token, account)
runOnUiThread {
this.changeSubscribeBtn(isSubscribed)
}
}
}
fun changeSubscribeBtn(subscribed: Boolean){
if(subscribed){
subscribeBtn.text = getText(R.string.unSubscribeBtn)
subscribeBtn.setOnClickListener { this.unSubscribe() }
}
else{
subscribeBtn.text = getText(R.string.subscribeBtn)
subscribeBtn.setOnClickListener { this.subscribe() }
}
}
override fun onResume() {
super.onResume()
if(ManagerSingleton.user.status == 1) {
this.getRate()
this.getSubscription()
actionsLayout.visibility = View.VISIBLE
subscribeBtn.visibility = View.VISIBLE
}
}
}

View File

@@ -0,0 +1,123 @@
package org.libre.agosto.p2play.ajax
import android.util.JsonReader
import java.io.InputStreamReader
class Actions: Client() {
fun subscribe(token: String, account: String):Int{
var con=this._newCon("users/me/subscriptions","POST", token)
val params:String= "uri=$account"
con.outputStream.write(params.toByteArray())
var response = 0
try {
if (con.responseCode == 204) {
response = 1
}
}
catch (err: Exception){
err.printStackTrace()
response = -1
}
return response
}
fun unSubscribe(token: String, account: String):Int{
var con=this._newCon("users/me/subscriptions/$account","DELETE", token)
var response = 0
try {
if (con.responseCode == 204) {
response = 1
}
}
catch (err: Exception){
err.printStackTrace()
response = -1
}
return response
}
fun getSubscription(token: String, account: String): Boolean{
var con=this._newCon("users/me/subscriptions/exist?uris=$account","GET", token)
var isSubscribed = false
try {
if (con.responseCode == 200) {
var response = InputStreamReader(con.inputStream)
var data = JsonReader(response)
data.beginObject()
while (data.hasNext()){
val key = data.nextName()
when (key.toString()) {
account->{
isSubscribed = data.nextBoolean()
}
else->{
data.skipValue()
}
}
}
}
}
catch (err: Exception){
err.printStackTrace()
isSubscribed = false
}
return isSubscribed
}
fun rate(token: String, id_video: Int, rate: String):Int{
var con=this._newCon("videos/$id_video/rate","PUT", token)
val params:String= "rating=$rate"
con.outputStream.write(params.toByteArray())
var response = 0
try {
if (con.responseCode == 204) {
response = 1
}
}
catch (err: Exception){
err.printStackTrace()
response = -1
}
return response
}
fun getRate(token: String, id_video: Int):String{
var con=this._newCon("users/me/videos/$id_video/rating","GET", token)
var rating = "none"
try {
if (con.responseCode == 200) {
var response = InputStreamReader(con.inputStream)
var data = JsonReader(response)
data.beginObject()
while (data.hasNext()){
val key = data.nextName()
when (key.toString()) {
"rating"->{
rating = data.nextString()
}
else->{
data.skipValue()
}
}
}
}
}
catch (err: Exception){
err.printStackTrace()
rating = "none"
}
return rating
}
}

View File

@@ -1,7 +1,8 @@
package org.libre.agosto.p2play.ajax
import android.support.design.widget.Snackbar
// import android.support.design.widget.Snackbar
import android.util.JsonReader
import android.util.JsonToken
import android.util.Log
import org.libre.agosto.p2play.ManagerSingleton
import org.libre.agosto.p2play.models.TokenModel
@@ -133,15 +134,20 @@ class Auth: Client() {
when(l.toString()){
"followersCount" -> user.followers = data.nextInt()
"avatar" -> {
data.beginObject()
while (data.hasNext()){
val m = data.nextName()
when (m.toString()){
"path" -> user.avatar = data.nextString()
else -> data.skipValue()
if(data.peek() == JsonToken.BEGIN_OBJECT) {
data.beginObject()
while (data.hasNext()) {
val m = data.nextName()
when (m.toString()) {
"path" -> user.avatar = data.nextString()
else -> data.skipValue()
}
}
data.endObject()
}
else{
data.skipValue()
}
data.endObject()
}
else -> data.skipValue()
}

View File

@@ -21,6 +21,7 @@ class Videos: Client() {
while (data.hasNext()){
val key = data.nextName()
when (key.toString()) {
"id"-> video.id = data.nextInt()
"name"->{
video.name= data.nextString()
}
@@ -42,13 +43,13 @@ class Videos: Client() {
"views"->{
video.views = data.nextInt()
}
"account"->{
"channel"->{
data.beginObject()
while (data.hasNext()){
val acKey = data.nextName()
when(acKey.toString()){
"name"->video.username=data.nextString()
"avatar"->{
"displayName"-> video.username=data.nextString()
"avatar"-> {
if(data.peek() == JsonToken.BEGIN_OBJECT){
data.beginObject()
while (data.hasNext()){
@@ -64,6 +65,8 @@ class Videos: Client() {
data.skipValue()
}
"uuid" -> video.userUuid = data.nextString()
"host" -> video.userHost = data.nextString()
else-> data.skipValue()
}
}
@@ -88,7 +91,9 @@ class Videos: Client() {
}
private fun getVideos(start:Int, count:Int, sort:String = "-publishedAt", filter:String = ""):ArrayList<VideoModel>{
val params = "start=$start&count=$count&sort=$sort&filter=$filter"
var params = "start=$start&count=$count&sort=$sort"
if(filter != "")
params+="&filter=$filter"
var con=this._newCon("videos?$params","GET")
var videos = arrayListOf<VideoModel>()
try {
@@ -133,4 +138,21 @@ class Videos: Client() {
}
return videos
}
fun videoSubscriptions(token: String): ArrayList<VideoModel>{
var con=this._newCon("users/me/subscriptions/videos","GET", token)
var videos = arrayListOf<VideoModel>()
try {
if (con.responseCode == 200) {
var response = InputStreamReader(con.inputStream)
var data = JsonReader(response)
videos = parseVideos(data)
}
} catch(err:Exception){
err?.printStackTrace()
Log.d("TypeErr",err?.message ,err.cause)
Log.d("Error","fallo la coneccion")
}
return videos
}
}

View File

@@ -3,12 +3,15 @@ package org.libre.agosto.p2play.models
import java.io.Serializable
class VideoModel(
var name:String="",
var description:String="",
var thumbUrl:String="",
var userImageUrl:String="",
var embedUrl:String="",
var duration:Number=0,
var username:String="",
var views:Number=0
var id: Int = 0,
var name: String = "",
var description: String = "",
var thumbUrl: String = "",
var userImageUrl: String = "",
var embedUrl: String = "",
var duration: Number = 0,
var username: String = "",
var views: Number = 0,
var userUuid: String = "",
var userHost: String = ""
):Serializable

View File

@@ -0,0 +1,21 @@
<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="M6,10C6,7.5 6.5,5 8,5L16.9938,5C17.5495,5 18.182,5.4044 18.4073,5.9051L20.8563,11.3473C21.7641,13.3646 20.7155,15 18.5093,15L15.5,15C15.5,15 18.5,21 15,21C12.5,21 11.5,15 8,15C6.5,15 6,12.5 6,10Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#585858"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
<path
android:pathData="M4,15.5C4,15.5 3,13 3,10C3,7 4,4.5 4,4.5"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#585858"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
</vector>

View File

@@ -0,0 +1,21 @@
<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="M6,14C6,16.5 6.5,19 8,19L16.9938,19C17.5495,19 18.182,18.5956 18.4073,18.0949L20.8563,12.6527C21.7641,10.6354 20.7155,9 18.5093,9L15.5,9C15.5,9 18.5,3 15,3C12.5,3 11.5,9 8,9C6.5,9 6,11.5 6,14Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#585858"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
<path
android:pathData="M4,8.5C4,8.5 3,11 3,14C3,17 4,19.5 4,19.5"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#585858"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,6L2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6zM20,2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM12,14.5v-9l6,4.5 -6,4.5z"/>
</vector>

View File

@@ -45,38 +45,78 @@
android:textSize="12sp" />
<LinearLayout
android:id="@+id/actionsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="40dp"
android:gravity="top"
android:orientation="horizontal"
android:visibility="gone">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<LinearLayout
android:id="@+id/likeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/likeBtn" />
android:orientation="vertical">
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="false"
android:cropToPadding="false"
app:srcCompat="@drawable/ic_like" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/likeBtn"
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
android:id="@+id/dislikeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/dislikeBtn" />
android:orientation="vertical">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="false"
android:cropToPadding="false"
app:srcCompat="@drawable/ic_dislike" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/dislikeBtn"
android:textAlignment="center" />
</LinearLayout>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/shareBtn" />
android:text="@string/shareBtn"
android:visibility="gone" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/reportBtn" />
android:text="@string/reportBtn"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
@@ -112,7 +152,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/subscribeBtn"
android:visibility="invisible" />
android:visibility="gone" />
</LinearLayout>
<TextView

View File

@@ -5,6 +5,10 @@
<item android:title="Videos">
<menu>
<item
android:id="@+id/nav_subscriptions"
android:icon="@drawable/ic_video_library_black_24dp"
android:title="@string/nav_subscriptions" />
<item
android:id="@+id/nav_popular"
android:icon="@android:drawable/btn_star"

View File

@@ -7,4 +7,6 @@
<color name="colorBody">#fff</color>
<color name="colorMenu">#000</color>
<color name="colorBlack">#000</color>
<color name="colorLike">#FF3C9100</color>
<color name="colorDislike">#ec020e</color>
</resources>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title_subscriptions">Subscriptions</string>
<string name="title_recent">Recent videos</string>
<string name="title_popular">Popular videos</string>
<string name="title_local">Local videos</string>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="nav_subscriptions">Subscriptions</string>
<string name="nav_popular">Popular</string>
<string name="nav_recent">Recent</string>
<string name="nav_local">Local</string>

View File

@@ -1,9 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="descriptionTxt">Description:</string>
<!-- Actions -->
<string name="subscribeBtn">Subscribe</string>
<string name="likeBtn">Like</string>
<string name="dislikeBtn">Dislike</string>
<string name="shareBtn">Share</string>
<string name="reportBtn">Report</string>
<string name="subscribeBtn">Subscribe</string>
<string name="unSubscribeBtn">Unsubscribe</string>
<!-- Messages -->
<string name="subscribeMsg">You are subscribed to this channel</string>
<string name="rateMsg">You are rated the video</string>
<string name="unSubscribeMsg">You are unsubscribed to this channel</string>
</resources>

View File

@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong

View File

@@ -1,6 +1,6 @@
#Wed Jul 11 18:31:20 CDT 2018
#Sun Sep 30 14:50:40 CDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

19
p2play.iml Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="p2play" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>