From fa68c57e5882c08b4490a1822b6dcb7966b6acd6 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 3 Mar 2018 01:10:13 +0100 Subject: [PATCH] Init --- .gitignore | 9 + app/build.gradle | 45 ++++ app/proguard-rules.pro | 21 ++ .../peertube/ExampleInstrumentedTest.java | 26 +++ app/src/main/AndroidManifest.xml | 23 ++ .../peertube/activity/VideoListActivity.java | 106 +++++++++ .../peertube/adapter/VideoAdapter.java | 68 ++++++ .../net/schueller/peertube/model/Video.java | 218 ++++++++++++++++++ .../schueller/peertube/model/VideoList.java | 18 ++ .../peertube/network/GetVideoDataService.java | 16 ++ .../peertube/network/RetrofitInstance.java | 21 ++ .../services/RecentlyAddedVideosService.java | 44 ++++ .../drawable-v24/ic_launcher_foreground.xml | 34 +++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++ .../main/res/layout/activity_video_list.xml | 15 ++ app/src/main/res/layout/row_video.xml | 40 ++++ app/src/main/res/layout/video_list.xml | 44 ++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes app/src/main/res/values/colors.xml | 8 + app/src/main/res/values/strings.xml | 3 + app/src/main/res/values/styles.xml | 11 + .../schueller/peertube/ExampleUnitTest.java | 17 ++ build.gradle | 27 +++ gradle.properties | 17 ++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53636 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 160 +++++++++++++ gradlew.bat | 90 ++++++++ settings.gradle | 1 + 40 files changed, 1268 insertions(+) create mode 100644 .gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/androidTest/java/net/schueller/peertube/ExampleInstrumentedTest.java create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java create mode 100644 app/src/main/java/net/schueller/peertube/adapter/VideoAdapter.java create mode 100644 app/src/main/java/net/schueller/peertube/model/Video.java create mode 100644 app/src/main/java/net/schueller/peertube/model/VideoList.java create mode 100644 app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java create mode 100644 app/src/main/java/net/schueller/peertube/network/RetrofitInstance.java create mode 100644 app/src/main/java/net/schueller/peertube/services/RecentlyAddedVideosService.java create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/layout/activity_video_list.xml create mode 100644 app/src/main/res/layout/row_video.xml create mode 100644 app/src/main/res/layout/video_list.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/styles.xml create mode 100644 app/src/test/java/net/schueller/peertube/ExampleUnitTest.java create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle 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