From c14ac5d173ec69c847aec86e274a29e21c6258f1 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 1 Jul 2018 15:11:26 +0200 Subject: [PATCH] - gradle update - support for android 6 - video playback select - NSFW toogle (not implemented) --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 4 +- .../peertube/activity/VideoListActivity.java | 18 +- ...ayActivity.java => VideoPlayActivity.java} | 194 ++++++++++++------ .../peertube/adapter/VideoAdapter.java | 6 +- .../peertube/network/GetVideoDataService.java | 3 +- .../layout/activity_torrent_video_play.xml | 2 +- app/src/main/res/values-ar/strings.xml | 2 +- app/src/main/res/values/strings.xml | 8 +- app/src/main/res/xml/pref_general.xml | 13 ++ build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 12 files changed, 176 insertions(+), 82 deletions(-) rename app/src/main/java/net/schueller/peertube/activity/{TorrentVideoPlayActivity.java => VideoPlayActivity.java} (71%) diff --git a/app/build.gradle b/app/build.gradle index 956f95d..ea8cc53 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,7 @@ android { compileSdkVersion 27 defaultConfig { applicationId "net.schueller.peertube" - minSdkVersion 24 + minSdkVersion 23 targetSdkVersion 27 versionCode 100 versionName "1.0.0" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2a335cb..86887d5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,8 +27,8 @@ android:name=".activity.LoginActivity" android:label="@string/title_activity_login" /> (), VideoListActivity.this); recyclerView.setAdapter(videoAdapter); - loadVideos(currentStart, count, sort); + loadVideos(currentStart, count, sort, filter); recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override @@ -211,7 +215,7 @@ public class VideoListActivity extends AppCompatActivity { if(!recyclerView.canScrollVertically(RecyclerView.FOCUS_DOWN)){ if (!isLoading) { currentStart = currentStart + count; - loadVideos(currentStart, count, sort); + loadVideos(currentStart, count, sort, filter); } } } @@ -223,13 +227,13 @@ public class VideoListActivity extends AppCompatActivity { // Refresh items if (!isLoading) { currentStart = 0; - loadVideos(currentStart, count, sort); + loadVideos(currentStart, count, sort, filter); } }); } - private void loadVideos(int start, int count, String sort) { + private void loadVideos(int start, int count, String sort, String filter) { isLoading = true; @@ -237,7 +241,7 @@ public class VideoListActivity extends AppCompatActivity { GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL + "/api/v1/").create(GetVideoDataService.class); - Call call = service.getVideosData(start, count, sort); + Call call = service.getVideosData(start, count, sort, filter); /*Log the URL called*/ Log.d("URL Called", call.request().url() + ""); diff --git a/app/src/main/java/net/schueller/peertube/activity/TorrentVideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java similarity index 71% rename from app/src/main/java/net/schueller/peertube/activity/TorrentVideoPlayActivity.java rename to app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 3cb6451..b559ac6 100644 --- a/app/src/main/java/net/schueller/peertube/activity/TorrentVideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -1,13 +1,16 @@ package net.schueller.peertube.activity; import android.content.Intent; +import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.os.Environment; +import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.util.Log; +import android.view.Surface; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; @@ -18,7 +21,9 @@ import com.github.se_bastiaan.torrentstream.TorrentOptions; import com.github.se_bastiaan.torrentstream.TorrentStream; import com.github.se_bastiaan.torrentstream.listeners.TorrentListener; import com.google.android.exoplayer2.ExoPlayerFactory; +import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.SimpleExoPlayer; +import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.source.ExtractorMediaSource; import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; @@ -31,6 +36,7 @@ import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.util.Util; +import com.google.android.exoplayer2.video.VideoRendererEventListener; import net.schueller.peertube.R; import net.schueller.peertube.helper.APIUrlHelper; @@ -44,11 +50,12 @@ import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; -public class TorrentVideoPlayActivity extends AppCompatActivity { +public class VideoPlayActivity extends AppCompatActivity implements VideoRendererEventListener { - private static final String TAG = "TorrentVideoPlayActivity"; + private static final String TAG = "VideoPlayActivity"; private ProgressBar progressBar; + private PlayerView simpleExoPlayerView; private SimpleExoPlayer player; @Override @@ -64,7 +71,9 @@ public class TorrentVideoPlayActivity extends AppCompatActivity { progressBar = findViewById(R.id.progress); progressBar.setMax(100); - PlayerView videoView = findViewById(R.id.video_view); +// PlayerView videoView = findViewById(R.id.video_view); + simpleExoPlayerView = new PlayerView(this); + simpleExoPlayerView = findViewById(R.id.video_view); // 1. Create a default TrackSelector BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); @@ -75,8 +84,68 @@ public class TorrentVideoPlayActivity extends AppCompatActivity { // 2. Create the player player = ExoPlayerFactory.newSimpleInstance(getApplicationContext(), trackSelector); - videoView.setPlayer(player); + simpleExoPlayerView.setPlayer(player); + // get video details from api + String apiBaseURL = APIUrlHelper.getUrl(this); + GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL + "/api/v1/").create(GetVideoDataService.class); + + Call