commit fa68c57e5882c08b4490a1822b6dcb7966b6acd6 Author: Stefan Schueller Date: Sat Mar 3 01:10:13 2018 +0100 Init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a41a81 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +/app/ diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..d290270 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,45 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 27 + defaultConfig { + applicationId "net.schueller.peertube" + minSdkVersion 24 + targetSdkVersion 27 + versionCode 100 + versionName "1.0.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + implementation 'com.android.support:appcompat-v7:27.1.0' + implementation 'com.android.support:cardview-v7:27.1.0' + implementation 'com.android.support:recyclerview-v7:27.1.0' + + implementation 'com.google.android.gms:play-services-auth:11.8.0' + + implementation 'com.squareup.okhttp3:okhttp:3.10.0' + implementation 'com.squareup.retrofit2:retrofit:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.3.0' + implementation 'com.squareup.picasso:picasso:2.5.2' + + implementation 'com.google.code.gson:gson:2.8.2' + + implementation 'org.webrtc:google-webrtc:1.0.+' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/net/schueller/peertube/ExampleInstrumentedTest.java b/app/src/androidTest/java/net/schueller/peertube/ExampleInstrumentedTest.java new file mode 100644 index 0000000..1079623 --- /dev/null +++ b/app/src/androidTest/java/net/schueller/peertube/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package net.schueller.peertube; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("net.schueller.peertube", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..05f5ebe --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java new file mode 100644 index 0000000..6e58567 --- /dev/null +++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java @@ -0,0 +1,106 @@ +package net.schueller.peertube.activity; + +import android.app.Activity; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; + +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.util.Log; +import android.widget.Toast; + + +import com.google.android.gms.common.GooglePlayServicesNotAvailableException; +import com.google.android.gms.common.GooglePlayServicesRepairableException; +import com.google.android.gms.common.GooglePlayServicesUtil; +import com.google.android.gms.security.ProviderInstaller; + +import net.schueller.peertube.R; +import net.schueller.peertube.adapter.VideoAdapter; +import net.schueller.peertube.model.VideoList; +import net.schueller.peertube.network.GetVideoDataService; +import net.schueller.peertube.network.RetrofitInstance; +import net.schueller.peertube.services.RecentlyAddedVideosService; +import net.schueller.peertube.model.Video; + + +import java.util.ArrayList; +import java.util.List; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +import static org.webrtc.ContextUtils.getApplicationContext; + +public class VideoListActivity extends AppCompatActivity { + + private VideoAdapter videoAdapter; + private RecyclerView recyclerView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_video_list); + + // fix android trying to use SSLv3 for handshake + updateAndroidSecurityProvider(this); + + /*Create handle for the RetrofitInstance interface*/ + GetVideoDataService service = RetrofitInstance.getRetrofitInstance().create(GetVideoDataService.class); + + /*Call the method with parameter in the interface to get the employee data*/ + Call call = service.getVideoData(0, 12, "-createdAt"); + + /*Log the URL called*/ + Log.wtf("URL Called", call.request().url() + ""); + + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + Log.wtf("Response", response + ""); + generateVideoList(response.body().getVideoArrayList()); + } + + @Override + public void onFailure(Call call, Throwable t) { + Log.wtf("err", t.fillInStackTrace()); + Toast.makeText(VideoListActivity.this, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show(); + } + }); + + + } + + + /*Method to generate List of employees using RecyclerView with custom adapter*/ + private void generateVideoList(ArrayList