some fixes
This commit is contained in:
parent
f7f85a9dbb
commit
4d6cb47e6c
|
@ -40,7 +40,7 @@
|
|||
android:name=".PeertubeActivity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:label="@string/app_name"
|
||||
android:resizeableActivity="true"
|
||||
android:launchMode="singleTask"
|
||||
android:supportsPictureInPicture="true"
|
||||
tools:targetApi="n" />
|
||||
<activity
|
||||
|
|
|
@ -148,13 +148,8 @@ public class PeertubeActivity extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
fullscreen = FullScreenMediaController.fullscreen.OFF;
|
||||
fullScreenMode = false;
|
||||
playlistForVideo = new ArrayList<>();
|
||||
setContentView(R.layout.activity_peertube);
|
||||
loader = findViewById(R.id.loader);
|
||||
|
||||
peertube_view_count = findViewById(R.id.peertube_view_count);
|
||||
peertube_bookmark = findViewById(R.id.peertube_bookmark);
|
||||
peertube_like_count = findViewById(R.id.peertube_like_count);
|
||||
|
@ -164,22 +159,23 @@ public class PeertubeActivity extends AppCompatActivity {
|
|||
peertube_description = findViewById(R.id.peertube_description);
|
||||
peertube_title = findViewById(R.id.peertube_title);
|
||||
peertube_information_container = findViewById(R.id.peertube_information_container);
|
||||
CustomWebview webview_video = findViewById(R.id.webview_video);
|
||||
playerView = findViewById(R.id.media_video);
|
||||
write_comment_container = findViewById(R.id.write_comment_container);
|
||||
ImageView my_pp = findViewById(R.id.my_pp);
|
||||
add_comment_read = findViewById(R.id.add_comment_read);
|
||||
add_comment_write = findViewById(R.id.add_comment_write);
|
||||
peertube_playlist = findViewById(R.id.peertube_playlist);
|
||||
send = findViewById(R.id.send);
|
||||
CustomWebview webview_video = findViewById(R.id.webview_video);
|
||||
playerView = findViewById(R.id.media_video);
|
||||
write_comment_container = findViewById(R.id.write_comment_container);
|
||||
|
||||
loader = findViewById(R.id.loader);
|
||||
ImageView my_pp = findViewById(R.id.my_pp);
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = Helper.getLiveInstance(PeertubeActivity.this);
|
||||
Account account = new AccountDAO(PeertubeActivity.this, db).getUniqAccount(userId, instance);
|
||||
Helper.loadGiF(PeertubeActivity.this, account, my_pp);
|
||||
|
||||
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
||||
&& !getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
|
||||
playInMinimized = false;
|
||||
}
|
||||
peertube_playlist.setVisibility(View.VISIBLE);
|
||||
peertube_bookmark.setVisibility(View.GONE);
|
||||
|
||||
if (Helper.isTablet(PeertubeActivity.this)) {
|
||||
RelativeLayout video_container = findViewById(R.id.video_container);
|
||||
|
@ -191,28 +187,33 @@ public class PeertubeActivity extends AppCompatActivity {
|
|||
video_container.setLayoutParams(param);
|
||||
}
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = Helper.getLiveInstance(PeertubeActivity.this);
|
||||
Account account = new AccountDAO(PeertubeActivity.this, db).getUniqAccount(userId, instance);
|
||||
Helper.loadGiF(PeertubeActivity.this, account, my_pp);
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
||||
|
||||
playlistForVideo = new ArrayList<>();
|
||||
playlistsViewModel = new ViewModelProvider(PeertubeActivity.this).get(PlaylistsVM.class);
|
||||
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||
playlistsViewModel.manage(GET_PLAYLIST, null, null, null).observe(PeertubeActivity.this, apiResponse -> manageVIewPlaylists(GET_PLAYLIST, apiResponse));
|
||||
}
|
||||
Bundle b = getIntent().getExtras();
|
||||
if (b != null) {
|
||||
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
|
||||
videoId = b.getString("video_id", null);
|
||||
}
|
||||
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
||||
&& !getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
|
||||
playInMinimized = false;
|
||||
}
|
||||
|
||||
|
||||
mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
||||
if (mode != Helper.VIDEO_MODE_WEBVIEW && mode != Helper.VIDEO_MODE_NORMAL)
|
||||
mode = Helper.VIDEO_MODE_NORMAL;
|
||||
if (mode == Helper.VIDEO_MODE_WEBVIEW) {
|
||||
webview_video.setVisibility(View.VISIBLE);
|
||||
playerView.setVisibility(View.GONE);
|
||||
|
||||
webview_video = Helper.initializeWebview(PeertubeActivity.this, R.id.webview_video, null);
|
||||
FrameLayout webview_container = findViewById(R.id.main_media_frame);
|
||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
|
||||
|
@ -251,17 +252,43 @@ public class PeertubeActivity extends AppCompatActivity {
|
|||
loader.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
if (mode != Helper.VIDEO_MODE_WEBVIEW) {
|
||||
playerView.setControllerShowTimeoutMs(1000);
|
||||
playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
|
||||
initFullscreenDialog();
|
||||
initFullscreenButton();
|
||||
}
|
||||
playlistsViewModel = new ViewModelProvider(PeertubeActivity.this).get(PlaylistsVM.class);
|
||||
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||
playlistsViewModel.manage(GET_PLAYLIST, null, null, null).observe(PeertubeActivity.this, apiResponse -> manageVIewPlaylists(GET_PLAYLIST, apiResponse));
|
||||
playVideo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
Bundle b = intent.getExtras();
|
||||
if (b != null) {
|
||||
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
|
||||
videoId = b.getString("video_id", null);
|
||||
playVideo();
|
||||
}
|
||||
}
|
||||
|
||||
private void playVideo() {
|
||||
if (player != null) {
|
||||
player.setPlayWhenReady(false);
|
||||
player.release();
|
||||
player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this);
|
||||
playerView.setPlayer(player);
|
||||
loader.setVisibility(View.GONE);
|
||||
player.setPlayWhenReady(true);
|
||||
|
||||
}
|
||||
fullscreen = FullScreenMediaController.fullscreen.OFF;
|
||||
setFullscreen(FullScreenMediaController.fullscreen.OFF);
|
||||
fullScreenMode = false;
|
||||
|
||||
peertube_playlist.setVisibility(View.VISIBLE);
|
||||
peertube_bookmark.setVisibility(View.GONE);
|
||||
|
||||
|
||||
FeedsVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(FeedsVM.class);
|
||||
feedsViewModel.getVideo(peertubeInstance, videoId).observe(PeertubeActivity.this, this::manageVIewVideo);
|
||||
|
@ -380,6 +407,7 @@ public class PeertubeActivity extends AppCompatActivity {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
peertube = apiResponse.getPeertubes().get(0);
|
||||
//TODO: currently streaming service gives the wrong values for duration
|
||||
playlistsViewModel.manage(GET_PLAYLIST_FOR_VIDEO, null, peertube.getId(), null).observe(PeertubeActivity.this, apiResponse2 -> manageVIewPlaylists(GET_PLAYLIST_FOR_VIDEO, apiResponse2));
|
||||
|
@ -461,7 +489,7 @@ public class PeertubeActivity extends AppCompatActivity {
|
|||
item1.setTitle("✔ " + playlist.getDisplayName());
|
||||
playlistsViewModel.manage(PlaylistsVM.action.ADD_VIDEOS, playlist, peertube.getId(), null).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.ADD_VIDEOS, apiResponse3));
|
||||
PlaylistElement playlistElement = new PlaylistElement();
|
||||
playlistElement.setPlaylistElementId(finalElementId);
|
||||
playlistElement.setPlaylistElementId(null);
|
||||
playlistElement.setPlaylistId(playlist.getId());
|
||||
playlistForVideo.add(playlistElement);
|
||||
}
|
||||
|
@ -700,11 +728,26 @@ public class PeertubeActivity extends AppCompatActivity {
|
|||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void onUserLeaveHint() {
|
||||
if (playInMinimized) {
|
||||
enterVideoMode();
|
||||
}
|
||||
|
||||
private void enterVideoMode() {
|
||||
if (playInMinimized && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
enterPictureInPictureMode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (playInMinimized) {
|
||||
enterVideoMode();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
|
||||
if (isInPictureInPictureMode) {
|
||||
|
@ -778,6 +821,7 @@ public class PeertubeActivity extends AppCompatActivity {
|
|||
builderSingle.show();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||
public void manageVIewPostActions(PeertubeAPI.StatusAction statusAction, APIResponse apiResponse) {
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue