From 6535ac37c37f4ff313218d34298fdbe8fe7e41ef Mon Sep 17 00:00:00 2001 From: subhadipThinkpad Date: Mon, 31 Dec 2018 22:37:36 +0530 Subject: [PATCH 01/13] Codebase merged from master --- CHANGELOG.md | 13 ++ README.md | 4 +- app/build.gradle | 15 +- .../activity/AppCompatPreferenceActivity.java | 18 +++ .../peertube/activity/LoginActivity.java | 18 +++ .../activity/SelectServerActivity.java | 18 +++ .../peertube/activity/SettingsActivity.java | 50 +++++- .../peertube/activity/VideoListActivity.java | 47 +++++- .../peertube/activity/VideoPlayActivity.java | 123 ++++++++++----- .../peertube/adapter/VideoAdapter.java | 26 ++- .../fragment/VideoOptionsFragment.java | 95 +++++++++++ .../peertube/helper/APIUrlHelper.java | 17 ++ .../schueller/peertube/helper/Constants.java | 18 +++ .../peertube/helper/MetaDataHelper.java | 17 ++ .../schueller/peertube/intents/Intents.java | 17 ++ .../net/schueller/peertube/model/Account.java | 18 +++ .../net/schueller/peertube/model/Avatar.java | 17 ++ .../schueller/peertube/model/Category.java | 17 ++ .../net/schueller/peertube/model/Channel.java | 17 ++ .../net/schueller/peertube/model/Config.java | 17 ++ .../net/schueller/peertube/model/File.java | 17 ++ .../schueller/peertube/model/Language.java | 17 ++ .../net/schueller/peertube/model/Licence.java | 17 ++ .../schueller/peertube/model/OauthClient.java | 17 ++ .../net/schueller/peertube/model/Privacy.java | 17 ++ .../schueller/peertube/model/Resolution.java | 17 ++ .../net/schueller/peertube/model/Server.java | 17 ++ .../schueller/peertube/model/ServerList.java | 17 ++ .../net/schueller/peertube/model/Token.java | 17 ++ .../net/schueller/peertube/model/Video.java | 57 +++++++ .../schueller/peertube/model/VideoList.java | 17 ++ .../network/AuthenticationService.java | 17 ++ .../network/GetConfigDataService.java | 17 ++ .../network/GetServerListDataService.java | 17 ++ .../peertube/network/GetVideoDataService.java | 25 ++- .../peertube/network/RetrofitInstance.java | 17 ++ .../provider/SearchSuggestionsProvider.java | 17 ++ .../peertube/service/VideoPlayerService.java | 79 ++++++++-- .../res/drawable-hdpi/ic_action_more_vert.png | Bin 236 -> 0 bytes .../res/drawable-mdpi/ic_action_more_vert.png | Bin 156 -> 0 bytes .../drawable-xhdpi/ic_action_more_vert.png | Bin 323 -> 0 bytes .../drawable-xxhdpi/ic_action_more_vert.png | Bin 565 -> 0 bytes .../drawable-xxxhdpi/ic_action_more_vert.png | Bin 693 -> 0 bytes .../main/res/layout/activity_video_play.xml | 63 ++------ .../bottom_sheet_video_options_fragment.xml | 127 +++++++++++++++ .../res/layout/exo_playback_control_view.xml | 74 --------- app/src/main/res/layout/row_video.xml | 11 +- .../res/layout/video_playback_controls.xml | 149 ++++++++++++++++++ app/src/main/res/menu/menu_bottom.xml | 5 + app/src/main/res/menu/menu_main.xml | 2 + .../main/res/menu/menu_video_play_options.xml | 7 + app/src/main/res/values-ar/strings.xml | 47 +++++- app/src/main/res/values-zh-rCN/strings.xml | 59 +++++++ app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/strings.xml | 13 ++ app/src/main/res/xml/pref_general.xml | 8 +- 56 files changed, 1347 insertions(+), 217 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java delete mode 100644 app/src/main/res/drawable-hdpi/ic_action_more_vert.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_action_more_vert.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_action_more_vert.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_action_more_vert.png delete mode 100644 app/src/main/res/drawable-xxxhdpi/ic_action_more_vert.png create mode 100644 app/src/main/res/layout/bottom_sheet_video_options_fragment.xml delete mode 100644 app/src/main/res/layout/exo_playback_control_view.xml create mode 100644 app/src/main/res/layout/video_playback_controls.xml create mode 100644 app/src/main/res/menu/menu_video_play_options.xml create mode 100644 app/src/main/res/values-zh-rCN/strings.xml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9e48cd4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,13 @@ +### Version 1.0.18 Tag: v1.0.18 (2018-12-31) + * Bug Fixes + * Arabic translation update + * Dependence update + +### Version 1.0.17 Tag: v1.0.17 (2018-12-29) + * Replaced more buttons with fonts + * Translated app to Chinese. (@lishoujun) + +### Version 1.0.16 Tag: v1.0.16 (2018-12-28) + * Fullscreen button + * Local Videos + * Bug Fixes diff --git a/README.md b/README.md index 281692d..dd4fc90 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,12 @@ Beta Test on Google Play: https://play.google.com/store/apps/details?id=net.schu - [X] Change Server - [X] Search - [X] App Icon and assets -- [!] Themes / Dark mode (needs work) +- [X] Themes / Dark mode - [X] Background playback - [X] NSFW Filter option -# TODO +## TODO - [ ] Video Playback via WebRTC - [ ] Authentication / Login diff --git a/app/build.gradle b/app/build.gradle index 6be087c..d51e17c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "net.schueller.peertube" minSdkVersion 21 targetSdkVersion 28 - versionCode 1012 - versionName "1.0.12" + versionCode 1018 + versionName "1.0.18" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) @@ -26,18 +26,18 @@ android { implementation 'com.mikepenz:fontawesome-typeface:5.3.1.1@aar' // http client / REST - implementation 'com.squareup.okhttp3:okhttp:3.10.0' - implementation 'com.squareup.retrofit2:retrofit:2.3.0' + implementation 'com.squareup.okhttp3:okhttp:3.12.1' + implementation 'com.squareup.retrofit2:retrofit:2.5.0' // image downloading and caching library implementation 'com.squareup.picasso:picasso:2.5.2' // json decoder/encoder - implementation 'com.google.code.gson:gson:2.8.2' - implementation 'com.squareup.retrofit2:converter-gson:2.3.0' + implementation 'com.google.code.gson:gson:2.8.5' + implementation 'com.squareup.retrofit2:converter-gson:2.5.0' // Torrents and WebRTC - implementation 'com.github.TorrentStream:TorrentStream-Android:2.5.0' + implementation 'com.github.TorrentStream:TorrentStream-Android:2.6.1' // implementation "com.github.TorrentStream:TorrentStreamServer-Android:1.0.1" // implementation 'org.webrtc:google-webrtc:1.0.+' @@ -47,6 +47,7 @@ android { implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.2' implementation 'com.google.android.exoplayer:exoplayer-hls:2.9.2' implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.9.2' + implementation 'com.google.android.exoplayer:extension-mediasession:2.9.2' // testing testImplementation 'junit:junit:4.12' diff --git a/app/src/main/java/net/schueller/peertube/activity/AppCompatPreferenceActivity.java b/app/src/main/java/net/schueller/peertube/activity/AppCompatPreferenceActivity.java index f4ef791..b2d9461 100644 --- a/app/src/main/java/net/schueller/peertube/activity/AppCompatPreferenceActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/AppCompatPreferenceActivity.java @@ -1,3 +1,21 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.schueller.peertube.activity; import android.content.res.Configuration; diff --git a/app/src/main/java/net/schueller/peertube/activity/LoginActivity.java b/app/src/main/java/net/schueller/peertube/activity/LoginActivity.java index 990f8a8..4ea13ea 100644 --- a/app/src/main/java/net/schueller/peertube/activity/LoginActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/LoginActivity.java @@ -1,3 +1,21 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.schueller.peertube.activity; import android.content.SharedPreferences; diff --git a/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java b/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java index 5f15750..4a8789e 100644 --- a/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java @@ -1,3 +1,21 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.schueller.peertube.activity; import androidx.annotation.NonNull; diff --git a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java index eabde7c..3d7352d 100644 --- a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java @@ -1,3 +1,21 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.schueller.peertube.activity; import android.annotation.TargetApi; @@ -23,6 +41,8 @@ import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; public class SettingsActivity extends AppCompatPreferenceActivity { + private static String previousThemeColorValue = ""; + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { @@ -33,6 +53,21 @@ public class SettingsActivity extends AppCompatPreferenceActivity { return super.onOptionsItemSelected(item); } + private static String getSelectedColor(Context context, String colorId){ + + String res = "Color not found"; + String [ ] themeArray = context.getResources().getStringArray(R.array.themeValues); + String [ ] colorArray = context.getResources().getStringArray(R.array.themeArray); + + for (int i = 0 ; i < themeArray.length ; i++){ + if (themeArray[i].equals(colorId)){ + res = colorArray[i]; + break; + } + } + return res; + } + /** * A preference value change listener that updates the preference's summary * to reflect its new value. @@ -45,6 +80,19 @@ public class SettingsActivity extends AppCompatPreferenceActivity { Toast.makeText(preference.getContext(), R.string.invalid_url, Toast.LENGTH_LONG).show(); return false; } + // Check if Theme color has change & Provide selected color + else if (preference.getKey().equals("pref_theme")) { + + stringValue = getSelectedColor(preference.getContext(), stringValue); + + if (!previousThemeColorValue.equals("") && !previousThemeColorValue.equals(stringValue)) { + Toast.makeText(preference.getContext(), R.string.pref_description_app_theme, Toast.LENGTH_LONG).show(); + } + + previousThemeColorValue = stringValue; + preference.setSummary(stringValue); + return true; + } preference.setSummary(stringValue); @@ -96,7 +144,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity { setupActionBar(); getFragmentManager().beginTransaction().replace(android.R.id.content, new GeneralPreferenceFragment()).commit(); - } /** @@ -153,6 +200,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { // updated to reflect the new value, per the Android Design // guidelines. bindPreferenceSummaryToValue(findPreference("pref_api_base")); + bindPreferenceSummaryToValue(findPreference("pref_theme")); } @Override diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java index a256766..bef23d9 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java @@ -1,3 +1,21 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.schueller.peertube.activity; import android.Manifest; @@ -38,6 +56,7 @@ import net.schueller.peertube.model.VideoList; import net.schueller.peertube.network.GetVideoDataService; import net.schueller.peertube.network.RetrofitInstance; import net.schueller.peertube.provider.SearchSuggestionsProvider; +import net.schueller.peertube.service.VideoPlayerService; import java.util.ArrayList; @@ -61,7 +80,7 @@ public class VideoListActivity extends AppCompatActivity { private int currentStart = 0; private int count = 12; private String sort = "-createdAt"; - private String filter = ""; + private String filter = null; private String searchQuery = ""; private TextView emptyView; @@ -89,7 +108,7 @@ public class VideoListActivity extends AppCompatActivity { setContentView(R.layout.activity_video_list); - filter = ""; + filter = null; createBottomBarNavigation(); @@ -151,6 +170,11 @@ public class VideoListActivity extends AppCompatActivity { return true; } + @Override + protected void onDestroy() { + super.onDestroy(); + stopService(new Intent(this, VideoPlayerService.class)); + } @Override public boolean onOptionsItemSelected(MenuItem item) { @@ -236,9 +260,9 @@ public class VideoListActivity extends AppCompatActivity { Call call; if (!searchQuery.equals("")) { - call = service.searchVideosData(start, count, sort, nsfw, searchQuery); + call = service.searchVideosData(start, count, sort, nsfw, searchQuery, filter); } else { - call = service.getVideosData(start, count, sort, nsfw); + call = service.getVideosData(start, count, sort, nsfw, filter); } /*Log the URL called*/ @@ -339,6 +363,8 @@ public class VideoListActivity extends AppCompatActivity { new IconicsDrawable(this, FontAwesome.Icon.faw_home)); navMenu.findItem(R.id.navigation_trending).setIcon( new IconicsDrawable(this, FontAwesome.Icon.faw_fire)); + navMenu.findItem(R.id.navigation_local).setIcon( + new IconicsDrawable(this, FontAwesome.Icon.faw_home)); navMenu.findItem(R.id.navigation_subscriptions).setIcon( new IconicsDrawable(this, FontAwesome.Icon.faw_folder)); navMenu.findItem(R.id.navigation_account).setIcon( @@ -353,6 +379,7 @@ public class VideoListActivity extends AppCompatActivity { if (!isLoading) { sort = "-createdAt"; currentStart = 0; + filter = null; loadVideos(currentStart, count, sort, filter); } @@ -363,6 +390,18 @@ public class VideoListActivity extends AppCompatActivity { if (!isLoading) { sort = "-trending"; currentStart = 0; + filter = null; + loadVideos(currentStart, count, sort, filter); + } + + return true; + case R.id.navigation_local: + //Log.v(TAG, "navigation_trending"); + + if (!isLoading) { + sort = "-publishedAt"; + filter = "local"; + currentStart = 0; loadVideos(currentStart, count, sort, filter); } diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 3972bbd..b8f0699 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -1,3 +1,21 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.schueller.peertube.activity; import android.content.ComponentName; @@ -5,6 +23,7 @@ import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.net.Uri; import android.os.Bundle; @@ -16,6 +35,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.PopupMenu; import android.util.Log; +import android.util.TypedValue; import android.view.Surface; import android.view.View; import android.view.ViewGroup; @@ -35,11 +55,14 @@ import com.github.se_bastiaan.torrentstream.TorrentStream; import com.github.se_bastiaan.torrentstream.listeners.TorrentListener; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.decoder.DecoderCounters; +import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.VideoRendererEventListener; +import com.mikepenz.iconics.Iconics; import com.squareup.picasso.Picasso; import net.schueller.peertube.R; +import net.schueller.peertube.fragment.VideoOptionsFragment; import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.helper.MetaDataHelper; import net.schueller.peertube.intents.Intents; @@ -52,6 +75,7 @@ import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; +import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; @@ -63,6 +87,8 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere private PlayerView simpleExoPlayerView; private Intent videoPlayerIntent; private Context context = this; + private TextView fullscreenButton; + private Boolean isFullscreen = false; boolean mBound = false; VideoPlayerService mService; @@ -110,8 +136,27 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere simpleExoPlayerView = new PlayerView(this); simpleExoPlayerView = findViewById(R.id.video_view); - videoPlayerIntent = new Intent(this, VideoPlayerService.class); - bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE); + simpleExoPlayerView.setControllerShowTimeoutMs(1000); + simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT); + + // Full screen Icon + fullscreenButton = findViewById(R.id.exo_fullscreen); + fullscreenButton.setText(R.string.video_expand_icon); + new Iconics.IconicsBuilder().ctx(this).on(fullscreenButton).build(); + + fullscreenButton.setOnClickListener(view -> { + Log.d(TAG, "Fullscreen"); + if (!isFullscreen) { + isFullscreen = true; + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + fullscreenButton.setText(R.string.video_compress_icon); + } else { + isFullscreen = false; + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + fullscreenButton.setText(R.string.video_expand_icon); + } + new Iconics.IconicsBuilder().ctx(this).on(fullscreenButton).build(); + }); } @@ -203,7 +248,7 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) simpleExoPlayerView.getLayoutParams(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = ViewGroup.LayoutParams.WRAP_CONTENT; + params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics()); simpleExoPlayerView.setLayoutParams(params); nameView.setVisibility(View.VISIBLE); @@ -241,13 +286,9 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere TextView videoOwner = findViewById(R.id.videoOwner); TextView videoMeta = findViewById(R.id.videoMeta); ImageView avatarView = findViewById(R.id.avatar); - ImageButton moreButton = findViewById(R.id.moreButton); + TextView moreButton = findViewById(R.id.moreButton); + TextView videoOptions = findViewById(R.id.exo_more); - //Playback speed buttons - Button speed05 = findViewById(R.id.speed05); - Button speed10 = findViewById(R.id.speed10); - Button speed15 = findViewById(R.id.speed15); - Button speed20 = findViewById(R.id.speed20); Video video = response.body(); @@ -279,6 +320,9 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere ); videoDescription.setText(video.getDescription()); + moreButton.setText(R.string.video_more_icon); + new Iconics.IconicsBuilder().ctx(context).on(moreButton).build(); + moreButton.setOnClickListener(v -> { PopupMenu popup = new PopupMenu(context, v); popup.setOnMenuItemClickListener(menuItem -> { @@ -294,42 +338,20 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere popup.show(); }); + // video player options + videoOptions.setText(R.string.video_more_icon); + new Iconics.IconicsBuilder().ctx(context).on(videoOptions).build(); + + videoOptions.setOnClickListener(v -> { + + VideoOptionsFragment videoOptionsFragment = + VideoOptionsFragment.newInstance(mService); + videoOptionsFragment.show(getSupportFragmentManager(), + "video_options_fragment"); + }); + mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl()); - //Playback speed controls - speed05.setOnClickListener(view -> { - mService.setPlayBackSpeed(0.5f); - speed05.setTextColor(getResources().getColor(R.color.primaryColorRed)); - - speed10.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - speed15.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - speed20.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - - }); - speed10.setOnClickListener(view -> { - mService.setPlayBackSpeed(1.0f); - speed10.setTextColor(getResources().getColor(R.color.primaryColorRed)); - - speed05.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - speed15.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - speed20.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - }); - speed15.setOnClickListener(view -> { - mService.setPlayBackSpeed(1.5f); - speed15.setTextColor(getResources().getColor(R.color.primaryColorRed)); - - speed05.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - speed10.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - speed20.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - }); - speed20.setOnClickListener(view -> { - mService.setPlayBackSpeed(2.0f); - speed20.setTextColor(getResources().getColor(R.color.primaryColorRed)); - - speed05.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - speed10.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - speed15.setTextColor(getResources().getColor(R.color.secondaryTextColorRed)); - }); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (sharedPref.getBoolean("pref_torrent_player", false)) { @@ -409,6 +431,16 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere @Override protected void onStop() { super.onStop(); + +// SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); +// +// Log.v(TAG, "" + sharedPref.getBoolean(BACKGROUND_PLAY_PREF_KEY, false)); +// +// if (!sharedPref.getBoolean(BACKGROUND_PLAY_PREF_KEY, false)) { +// Log.v(TAG, "BACKGROUND_PLAY_PREF_KEY..."); +// stopService(new Intent(this, VideoPlayerService.class)); +// } + if (mBound) { unbindService(mConnection); mBound = false; @@ -419,6 +451,11 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere @Override protected void onStart() { super.onStart(); + + if (!mBound) { + videoPlayerIntent = new Intent(this, VideoPlayerService.class); + bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE); + } Log.v(TAG, "onStart()..."); } diff --git a/app/src/main/java/net/schueller/peertube/adapter/VideoAdapter.java b/app/src/main/java/net/schueller/peertube/adapter/VideoAdapter.java index b898133..7bda3aa 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/VideoAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/VideoAdapter.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.adapter; import android.content.Context; @@ -5,6 +22,8 @@ import android.content.Intent; import androidx.annotation.NonNull; import androidx.appcompat.widget.PopupMenu; import androidx.recyclerview.widget.RecyclerView; + +import android.content.pm.ActivityInfo; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -12,6 +31,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; +import com.mikepenz.iconics.Iconics; import com.squareup.picasso.Picasso; import net.schueller.peertube.R; @@ -94,6 +114,9 @@ public class VideoAdapter extends RecyclerView.Adapter { PopupMenu popup = new PopupMenu(context, v); @@ -130,9 +153,8 @@ public class VideoAdapter extends RecyclerView.Adapter + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.schueller.peertube.fragment; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.google.android.material.bottomsheet.BottomSheetDialogFragment; +import com.mikepenz.iconics.Iconics; +import net.schueller.peertube.R; +import net.schueller.peertube.service.VideoPlayerService; + +import androidx.annotation.Nullable; + +public class VideoOptionsFragment extends BottomSheetDialogFragment { + + private static VideoPlayerService videoPlayerService; + + private TextView speed05Icon; + private TextView speed10Icon; + private TextView speed15Icon; + private TextView speed20Icon; + + public static VideoOptionsFragment newInstance(VideoPlayerService mService) { + videoPlayerService = mService; + return new VideoOptionsFragment(); + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, + @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + + View view = inflater.inflate(R.layout.bottom_sheet_video_options_fragment, container, + false); + + // Icons + speed05Icon = view.findViewById(R.id.video_speed05_icon); + speed10Icon = view.findViewById(R.id.video_speed10_icon); + speed15Icon = view.findViewById(R.id.video_speed15_icon); + speed20Icon = view.findViewById(R.id.video_speed20_icon); + + // Buttons + TextView speed05 = view.findViewById(R.id.video_speed05); + TextView speed10 = view.findViewById(R.id.video_speed10); + TextView speed15 = view.findViewById(R.id.video_speed15); + TextView speed20 = view.findViewById(R.id.video_speed20); + + // Default + setVideoSpeed(1.0f, speed10Icon); + + // Attach the listener + speed05.setOnClickListener(v -> setVideoSpeed(0.5f, speed05Icon)); + speed10.setOnClickListener(v -> setVideoSpeed(1.0f, speed10Icon)); + speed15.setOnClickListener(v -> setVideoSpeed(1.5f, speed15Icon)); + speed20.setOnClickListener(v -> setVideoSpeed(2.0f, speed20Icon)); + + return view; + + } + + + private void setVideoSpeed(Float speed, TextView icon) { + + speed05Icon.setText(""); + speed10Icon.setText(""); + speed15Icon.setText(""); + speed20Icon.setText(""); + + videoPlayerService.setPlayBackSpeed(speed); + + icon.setText(R.string.video_speed_active_icon); + new Iconics.IconicsBuilder().ctx(getContext()).on(icon).build(); + } + +} \ No newline at end of file diff --git a/app/src/main/java/net/schueller/peertube/helper/APIUrlHelper.java b/app/src/main/java/net/schueller/peertube/helper/APIUrlHelper.java index c1ed8d2..4a4c06a 100644 --- a/app/src/main/java/net/schueller/peertube/helper/APIUrlHelper.java +++ b/app/src/main/java/net/schueller/peertube/helper/APIUrlHelper.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.helper; import android.content.Context; diff --git a/app/src/main/java/net/schueller/peertube/helper/Constants.java b/app/src/main/java/net/schueller/peertube/helper/Constants.java index 02d03bf..e9c4ba7 100644 --- a/app/src/main/java/net/schueller/peertube/helper/Constants.java +++ b/app/src/main/java/net/schueller/peertube/helper/Constants.java @@ -1,6 +1,24 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.helper; public class Constants { public static final String THEME_PREF_KEY = "pref_theme"; public static final String DEFAULT_THEME = "AppTheme.ORANGE"; + public static final String BACKGROUND_PLAY_PREF_KEY = "pref_background_play"; } diff --git a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java index c0bc26d..7d7bbd2 100644 --- a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java +++ b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.helper; import android.content.Context; diff --git a/app/src/main/java/net/schueller/peertube/intents/Intents.java b/app/src/main/java/net/schueller/peertube/intents/Intents.java index a31edfb..2ca421b 100644 --- a/app/src/main/java/net/schueller/peertube/intents/Intents.java +++ b/app/src/main/java/net/schueller/peertube/intents/Intents.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.intents; import android.content.Context; diff --git a/app/src/main/java/net/schueller/peertube/model/Account.java b/app/src/main/java/net/schueller/peertube/model/Account.java index 4b08406..54c5282 100644 --- a/app/src/main/java/net/schueller/peertube/model/Account.java +++ b/app/src/main/java/net/schueller/peertube/model/Account.java @@ -1,3 +1,21 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.schueller.peertube.model; import java.util.Date; diff --git a/app/src/main/java/net/schueller/peertube/model/Avatar.java b/app/src/main/java/net/schueller/peertube/model/Avatar.java index 791e411..356816d 100644 --- a/app/src/main/java/net/schueller/peertube/model/Avatar.java +++ b/app/src/main/java/net/schueller/peertube/model/Avatar.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; import java.util.Date; diff --git a/app/src/main/java/net/schueller/peertube/model/Category.java b/app/src/main/java/net/schueller/peertube/model/Category.java index 6bde429..505da79 100644 --- a/app/src/main/java/net/schueller/peertube/model/Category.java +++ b/app/src/main/java/net/schueller/peertube/model/Category.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class Category { diff --git a/app/src/main/java/net/schueller/peertube/model/Channel.java b/app/src/main/java/net/schueller/peertube/model/Channel.java index c001e05..28f0aa5 100644 --- a/app/src/main/java/net/schueller/peertube/model/Channel.java +++ b/app/src/main/java/net/schueller/peertube/model/Channel.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; import java.util.Date; diff --git a/app/src/main/java/net/schueller/peertube/model/Config.java b/app/src/main/java/net/schueller/peertube/model/Config.java index ebd770d..9aa3904 100644 --- a/app/src/main/java/net/schueller/peertube/model/Config.java +++ b/app/src/main/java/net/schueller/peertube/model/Config.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class Config { diff --git a/app/src/main/java/net/schueller/peertube/model/File.java b/app/src/main/java/net/schueller/peertube/model/File.java index 9537ffc..eb426ba 100644 --- a/app/src/main/java/net/schueller/peertube/model/File.java +++ b/app/src/main/java/net/schueller/peertube/model/File.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class File { diff --git a/app/src/main/java/net/schueller/peertube/model/Language.java b/app/src/main/java/net/schueller/peertube/model/Language.java index 2c677f0..f1abc74 100644 --- a/app/src/main/java/net/schueller/peertube/model/Language.java +++ b/app/src/main/java/net/schueller/peertube/model/Language.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class Language { diff --git a/app/src/main/java/net/schueller/peertube/model/Licence.java b/app/src/main/java/net/schueller/peertube/model/Licence.java index 654f160..11f8330 100644 --- a/app/src/main/java/net/schueller/peertube/model/Licence.java +++ b/app/src/main/java/net/schueller/peertube/model/Licence.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class Licence { diff --git a/app/src/main/java/net/schueller/peertube/model/OauthClient.java b/app/src/main/java/net/schueller/peertube/model/OauthClient.java index 35221bc..e8044be 100644 --- a/app/src/main/java/net/schueller/peertube/model/OauthClient.java +++ b/app/src/main/java/net/schueller/peertube/model/OauthClient.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class OauthClient { diff --git a/app/src/main/java/net/schueller/peertube/model/Privacy.java b/app/src/main/java/net/schueller/peertube/model/Privacy.java index 5d2c216..6de6798 100644 --- a/app/src/main/java/net/schueller/peertube/model/Privacy.java +++ b/app/src/main/java/net/schueller/peertube/model/Privacy.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class Privacy { diff --git a/app/src/main/java/net/schueller/peertube/model/Resolution.java b/app/src/main/java/net/schueller/peertube/model/Resolution.java index c969c89..815d96e 100644 --- a/app/src/main/java/net/schueller/peertube/model/Resolution.java +++ b/app/src/main/java/net/schueller/peertube/model/Resolution.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class Resolution { diff --git a/app/src/main/java/net/schueller/peertube/model/Server.java b/app/src/main/java/net/schueller/peertube/model/Server.java index f8b1d21..4d14404 100644 --- a/app/src/main/java/net/schueller/peertube/model/Server.java +++ b/app/src/main/java/net/schueller/peertube/model/Server.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class Server { diff --git a/app/src/main/java/net/schueller/peertube/model/ServerList.java b/app/src/main/java/net/schueller/peertube/model/ServerList.java index 709cdc2..941c34c 100644 --- a/app/src/main/java/net/schueller/peertube/model/ServerList.java +++ b/app/src/main/java/net/schueller/peertube/model/ServerList.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; import com.google.gson.annotations.SerializedName; diff --git a/app/src/main/java/net/schueller/peertube/model/Token.java b/app/src/main/java/net/schueller/peertube/model/Token.java index 4a703ea..a4ac1f1 100644 --- a/app/src/main/java/net/schueller/peertube/model/Token.java +++ b/app/src/main/java/net/schueller/peertube/model/Token.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; public class Token { diff --git a/app/src/main/java/net/schueller/peertube/model/Video.java b/app/src/main/java/net/schueller/peertube/model/Video.java index a640c73..11bf4ad 100644 --- a/app/src/main/java/net/schueller/peertube/model/Video.java +++ b/app/src/main/java/net/schueller/peertube/model/Video.java @@ -1,8 +1,38 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; +import android.content.Context; +import android.graphics.Bitmap; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.media.MediaDescriptionCompat; + +import com.squareup.picasso.Picasso; + +import net.schueller.peertube.R; +import net.schueller.peertube.helper.APIUrlHelper; + import java.util.ArrayList; import java.util.Date; +import androidx.annotation.DrawableRes; + public class Video { private Integer id; @@ -247,4 +277,31 @@ public class Video { public void setFiles(ArrayList files) { this.files = files; } + + + + public static MediaDescriptionCompat getMediaDescription(Context context, Video video) { + +// String apiBaseURL = APIUrlHelper.getUrlWithVersion(context); + +// Bundle extras = new Bundle(); +// Bitmap bitmap = getBitmap(context, Uri.parse(apiBaseURL + video.thumbnailPath)); +// extras.putParcelable(MediaDescriptionCompat.DESCRIPTION_KEY_MEDIA_URI, bitmap); + + return new MediaDescriptionCompat.Builder() + .setMediaId(video.getUuid()) +// .setIconBitmap(bitmap) +// .setExtras(extras) + .setTitle(video.getName()) + .setDescription(video.getDescription()) + .build(); + } + +// TODO: add support for the thumbnail +// public static Bitmap getBitmap(Context context, Uri fullThumbnailUrl) { +// +// return Picasso.with(context).load(fullThumbnailUrl) +// .placeholder(R.drawable.ic_peertube) +// .error(R.drawable.ic_peertube).get(); +// } } diff --git a/app/src/main/java/net/schueller/peertube/model/VideoList.java b/app/src/main/java/net/schueller/peertube/model/VideoList.java index 2748cbc..336a0cb 100644 --- a/app/src/main/java/net/schueller/peertube/model/VideoList.java +++ b/app/src/main/java/net/schueller/peertube/model/VideoList.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.model; import com.google.gson.annotations.SerializedName; diff --git a/app/src/main/java/net/schueller/peertube/network/AuthenticationService.java b/app/src/main/java/net/schueller/peertube/network/AuthenticationService.java index ce55b96..898c9bd 100644 --- a/app/src/main/java/net/schueller/peertube/network/AuthenticationService.java +++ b/app/src/main/java/net/schueller/peertube/network/AuthenticationService.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.network; import net.schueller.peertube.model.OauthClient; diff --git a/app/src/main/java/net/schueller/peertube/network/GetConfigDataService.java b/app/src/main/java/net/schueller/peertube/network/GetConfigDataService.java index aded270..b8a4279 100644 --- a/app/src/main/java/net/schueller/peertube/network/GetConfigDataService.java +++ b/app/src/main/java/net/schueller/peertube/network/GetConfigDataService.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.network; import net.schueller.peertube.model.Config; diff --git a/app/src/main/java/net/schueller/peertube/network/GetServerListDataService.java b/app/src/main/java/net/schueller/peertube/network/GetServerListDataService.java index 5962353..bdb8a26 100644 --- a/app/src/main/java/net/schueller/peertube/network/GetServerListDataService.java +++ b/app/src/main/java/net/schueller/peertube/network/GetServerListDataService.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.network; import net.schueller.peertube.model.ServerList; diff --git a/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java b/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java index 97ce8f2..b66b727 100644 --- a/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java +++ b/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.network; import net.schueller.peertube.model.Video; @@ -14,8 +31,8 @@ public interface GetVideoDataService { @Query("start") int start, @Query("count") int count, @Query("sort") String sort, - @Query("nsfw") String nsfw - //@Query("filter") String filter + @Query("nsfw") String nsfw, + @Query("filter") String filter ); @GET("videos/{id}") @@ -29,7 +46,7 @@ public interface GetVideoDataService { @Query("count") int count, @Query("sort") String sort, @Query("nsfw") String nsfw, - @Query("search") String search -// @Query("filter") String filter + @Query("search") String search, + @Query("filter") String filter ); } \ No newline at end of file diff --git a/app/src/main/java/net/schueller/peertube/network/RetrofitInstance.java b/app/src/main/java/net/schueller/peertube/network/RetrofitInstance.java index d8a6cd8..fc8936f 100644 --- a/app/src/main/java/net/schueller/peertube/network/RetrofitInstance.java +++ b/app/src/main/java/net/schueller/peertube/network/RetrofitInstance.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.network; import retrofit2.Retrofit; diff --git a/app/src/main/java/net/schueller/peertube/provider/SearchSuggestionsProvider.java b/app/src/main/java/net/schueller/peertube/provider/SearchSuggestionsProvider.java index 2101fb4..8532e8c 100644 --- a/app/src/main/java/net/schueller/peertube/provider/SearchSuggestionsProvider.java +++ b/app/src/main/java/net/schueller/peertube/provider/SearchSuggestionsProvider.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.provider; import android.content.SearchRecentSuggestionsProvider; diff --git a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java index 063bde0..bc62ddb 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.schueller.peertube.service; import android.app.Notification; @@ -11,14 +28,22 @@ import android.graphics.Bitmap; import android.media.AudioManager; import android.net.Uri; import android.os.Binder; +import android.os.Bundle; import android.os.IBinder; import androidx.annotation.Nullable; + +import android.support.v4.media.MediaDescriptionCompat; +import android.support.v4.media.session.MediaSessionCompat; import android.util.Log; +import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; +import com.google.android.exoplayer2.audio.AudioAttributes; +import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector; +import com.google.android.exoplayer2.ext.mediasession.TimelineQueueNavigator; import com.google.android.exoplayer2.source.ExtractorMediaSource; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.ui.PlayerNotificationManager; @@ -37,6 +62,9 @@ import static net.schueller.peertube.activity.VideoListActivity.EXTRA_VIDEOID; public class VideoPlayerService extends Service { + private static final String TAG = "VideoPlayerService"; + private static final String MEDIA_SESSION_TAG = "peertube_player"; + private final IBinder mBinder = new LocalBinder(); private static final String PLAYBACK_CHANNEL_ID = "playback_channel"; @@ -64,12 +92,12 @@ public class VideoPlayerService extends Service { public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { if (playbackState == ACTION_PAUSE) { // this means that pause is available, hence the audio is playing - Log.v("VideoPlayerService", "ACTION_PLAY: " + playbackState); + Log.v(TAG, "ACTION_PLAY: " + playbackState); registerReceiver(myNoisyAudioStreamReceiver, becomeNoisyIntentFilter); } if (playbackState == ACTION_PLAY) { // this means that play is available, hence the audio is paused or stopped - Log.v("VideoPlayerService", "ACTION_PAUSE: " + playbackState); + Log.v(TAG, "ACTION_PAUSE: " + playbackState); unregisterReceiver(myNoisyAudioStreamReceiver); } } @@ -89,12 +117,14 @@ public class VideoPlayerService extends Service { @Override public void onDestroy() { - Log.v("VideoPlayerService", "onDestroy..."); - - playerNotificationManager.setPlayer(null); - player.release(); - player = null; - + Log.v(TAG, "onDestroy..."); + if (playerNotificationManager != null) { + playerNotificationManager.setPlayer(null); + } + if (player != null) { + player.release(); + player = null; + } super.onDestroy(); } @@ -106,7 +136,7 @@ public class VideoPlayerService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { - Log.v("VideoPlayerService", "onStartCommand..."); + Log.v(TAG, "onStartCommand..."); playVideo(); return START_STICKY; } @@ -114,27 +144,27 @@ public class VideoPlayerService extends Service { public void setCurrentVideo(Video video) { - Log.v("VideoPlayerService", "setCurrentVideo..."); + Log.v(TAG, "setCurrentVideo..."); currentVideo = video; } public void setCurrentStreamUrl(String streamUrl) { - Log.v("VideoPlayerService", "setCurrentStreamUrl..."); + Log.v(TAG, "setCurrentStreamUrl..."); currentStreamUrl = streamUrl; } //Playback speed control public void setPlayBackSpeed(float speed) { - Log.v("VideoPlayerService", "setPlayBackSpeed..."); + Log.v(TAG, "setPlayBackSpeed..."); player.setPlaybackParameters(new PlaybackParameters(speed)); } public void playVideo() { Context context = this; - Log.v("VideoPlayerService", "playVideo..."); + Log.v(TAG, "playVideo..."); // Produces DataSource instances through which media data is loaded. DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(), @@ -203,7 +233,7 @@ public class VideoPlayerService extends Service { @Override public void onNotificationCancelled(int notificationId) { - Log.v("VideoPlayerService", "onNotificationCancelled..."); + Log.v(TAG, "onNotificationCancelled..."); // TODO: only kill the notification if we no longer have a bound activity stopForeground(true); @@ -213,6 +243,26 @@ public class VideoPlayerService extends Service { playerNotificationManager.setPlayer(player); + // external Media control, Android Wear / Google Home etc. + MediaSessionCompat mediaSession = new MediaSessionCompat(context, MEDIA_SESSION_TAG); + mediaSession.setActive(true); + playerNotificationManager.setMediaSessionToken(mediaSession.getSessionToken()); + MediaSessionConnector mediaSessionConnector = new MediaSessionConnector(mediaSession); + mediaSessionConnector.setQueueNavigator(new TimelineQueueNavigator(mediaSession) { + @Override + public MediaDescriptionCompat getMediaDescription(Player player, int windowIndex) { + return Video.getMediaDescription(context, currentVideo); + } + }); + mediaSessionConnector.setPlayer(player, null); + + // Audio Focus + AudioAttributes audioAttributes = new AudioAttributes.Builder() + .setUsage(C.USAGE_MEDIA) + .setContentType(C.CONTENT_TYPE_MOVIE) + .build(); + player.setAudioAttributes(audioAttributes,true); + } // pause playback on audio output change @@ -225,4 +275,5 @@ public class VideoPlayerService extends Service { } } + } diff --git a/app/src/main/res/drawable-hdpi/ic_action_more_vert.png b/app/src/main/res/drawable-hdpi/ic_action_more_vert.png deleted file mode 100644 index ad914ed3c2eb735be6e8f65f637532ad7fb8118e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbBHha1_hD5l(y<*M9SVim2RNT)QK5N6^inW3Wwady_#)&`>(v} zcf19Eg>L^EcU{-pS+G&(SVw?ZvWrHyq0*J#Hr<9!x2A&l7C`=#qY{FzYVVc4y&UkK gWf8marj85jwV?*8YkyXj0iDm_>FVdQ&MBb@0O%iBz5oCK diff --git a/app/src/main/res/drawable-mdpi/ic_action_more_vert.png b/app/src/main/res/drawable-mdpi/ic_action_more_vert.png deleted file mode 100644 index 4ccef014d0615bc679f7ffc440497696019c22e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gj$(}BbAs*hzDGLk}mTdgVqkNjl zmyNB>AY;P1q=bYWem);23Audb;o-Rx;Jn|+z`%shk~>4rs|7J)-iax`njxgN@xNA DU@0zt diff --git a/app/src/main/res/drawable-xhdpi/ic_action_more_vert.png b/app/src/main/res/drawable-xhdpi/ic_action_more_vert.png deleted file mode 100644 index 17428a44699b30189173b458b8d8d1b2311170ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 323 zcmV-J0lfZ+P)Js=W&~Cz_O_W91=mxkm| zle~Te;NJ|20Wo0gK(vIq_zz>9#p6)`7Qh-xF^cgsMvfvG%jkgD8g(C034se?Z0r=4A)Dmj(q#xoAMA~cgT~%opndeRUHJ0}+ z^s~adM9~1!N=RO4tQI3AlzNfL3yqad?^EK}yiyO3(yg zsea3AtK8i!jMx;g2y6iJ9iT_x9Jm2q%e9;Sq}qUHfz1xka4jFeEpP_hr?*z-j+%fh zIa|OAV59Zj)k8W4Udptb_LQ1{R)O7aq(ZAUNGHHmT5DyhYXaH>7MyK70Ef=nqGh!J z*+?A#lg@75f&Ch9w_1P=|l2MdVOdF?RwRDG!;_nkAqv&9#5tC7L#6(6h50Z?cgP)9|1Coql0;Hx&Thkp) z!Lh{%kd$j)D3u^3ND0a#pakXd(;1`$DM5JzB6oiR!HRxKd{oBw00000NkvXXu0mjf D|E}#D diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_more_vert.png b/app/src/main/res/drawable-xxxhdpi/ic_action_more_vert.png deleted file mode 100644 index cb4d006336a9c27dcb11072f26bf937912ffa9a2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 693 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>V5;$SaSW-5dppO_kJ*vOwO+tf ze8KVs%bJxHyuA7jFbb$XVvuQ^Bvi=qVuj|5oeZW-CYRj2nx|}C`$zKAipL+H?X4(3 z7PnELK8%SwyKE9S<1=|iCV>RC1V4XPg#$hZ=FH=AXqeexX)D^mV9Z!trNzLQ#`Nq< z2m{j@mNPHi*Eihlygz+rvc=yHrf;gU-c}Q~nAd*x_k2GoPNlXbQ-aA|XoK?0lBWOH zOaJ=_%~PqBt~lps+10@I-|5oBS@%EqUi!-+=1Q0qvNQpCUM|5}wl*_UIl7usgO^rR#f>m%%Y{M~6AFkt*94 z7){yOTETIA$5hviyt>Yk@g2<(b7DPJ)^-T>>~zgI_VmY8*UNo+&NJgX8hz$HEL(rT z=f)d(Mh*jEgXPO1kzrrOx`Eg9PlH8=Y>Ro)F2zpSYP}+rl(PU0Zg;%`Er0jkp&`UTVsX diff --git a/app/src/main/res/layout/activity_video_play.xml b/app/src/main/res/layout/activity_video_play.xml index 78aa385..2a2d293 100644 --- a/app/src/main/res/layout/activity_video_play.xml +++ b/app/src/main/res/layout/activity_video_play.xml @@ -17,11 +17,11 @@ android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="250dp" + android:background="@color/videoBackgroundColor" + app:resize_mode="fixed_width" + app:controller_layout_id="@layout/video_playback_controls" - app:layout_constraintDimensionRatio="H,3:1" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + /> - + android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" + /> - - -