- Moved video playback into fragment
This commit is contained in:
parent
33a0f501ae
commit
9fa7a3bbc7
@ -18,73 +18,34 @@
|
|||||||
|
|
||||||
package net.schueller.peertube.activity;
|
package net.schueller.peertube.activity;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.github.se_bastiaan.torrentstream.StreamStatus;
|
import android.view.WindowManager;
|
||||||
import com.github.se_bastiaan.torrentstream.Torrent;
|
import android.widget.FrameLayout;
|
||||||
import com.github.se_bastiaan.torrentstream.TorrentOptions;
|
|
||||||
import com.github.se_bastiaan.torrentstream.TorrentStream;
|
import android.widget.RelativeLayout;
|
||||||
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.R;
|
||||||
import net.schueller.peertube.fragment.VideoMetaDataFragment;
|
|
||||||
import net.schueller.peertube.fragment.VideoOptionsFragment;
|
|
||||||
import net.schueller.peertube.fragment.VideoPlayerFragment;
|
import net.schueller.peertube.fragment.VideoPlayerFragment;
|
||||||
import net.schueller.peertube.helper.APIUrlHelper;
|
|
||||||
import net.schueller.peertube.helper.MetaDataHelper;
|
import java.util.Objects;
|
||||||
import net.schueller.peertube.intents.Intents;
|
|
||||||
import net.schueller.peertube.model.Account;
|
|
||||||
import net.schueller.peertube.model.Avatar;
|
|
||||||
import net.schueller.peertube.model.Video;
|
|
||||||
import net.schueller.peertube.network.GetVideoDataService;
|
|
||||||
import net.schueller.peertube.network.RetrofitInstance;
|
|
||||||
import net.schueller.peertube.service.VideoPlayerService;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
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.BACKGROUND_PLAY_PREF_KEY;
|
||||||
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
||||||
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
||||||
|
|
||||||
@ -121,7 +82,6 @@ public class VideoPlayActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
|
||||||
@ -132,39 +92,40 @@ public class VideoPlayActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
Fragment videoPlayerFragment = fragmentManager.findFragmentById(R.id.video_player_fragment);
|
Fragment videoPlayerFragment = fragmentManager.findFragmentById(R.id.video_player_fragment);
|
||||||
|
Fragment videoMetaFragment = fragmentManager.findFragmentById(R.id.video_meta_data_fragment);
|
||||||
// LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT);
|
|
||||||
// params.weight = 3.0f;
|
|
||||||
// fragment.getView().setLayoutParams(params);
|
|
||||||
|
|
||||||
// Checking the orientation of the screen
|
// Checking the orientation of the screen
|
||||||
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.getView().getLayoutParams();
|
assert videoPlayerFragment != null;
|
||||||
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams();
|
||||||
params.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
params.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
params.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
params.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
//simpleExoPlayerView.setLayoutParams(params);
|
|
||||||
|
|
||||||
videoPlayerFragment.getView().setLayoutParams(params);
|
videoPlayerFragment.getView().setLayoutParams(params);
|
||||||
|
|
||||||
|
if (videoMetaFragment != null) {
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
||||||
.hide(fragmentManager.findFragmentById(R.id.video_meta_data_fragment))
|
.hide(videoMetaFragment)
|
||||||
.commit();
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
|
||||||
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.getView().getLayoutParams();
|
|
||||||
|
assert videoPlayerFragment != null;
|
||||||
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams();
|
||||||
params.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
params.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics());
|
params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics());
|
||||||
//simpleExoPlayerView.setLayoutParams(params);
|
|
||||||
|
|
||||||
videoPlayerFragment.getView().setLayoutParams(params);
|
videoPlayerFragment.getView().setLayoutParams(params);
|
||||||
|
|
||||||
|
|
||||||
|
if (videoMetaFragment != null) {
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
||||||
.show(fragmentManager.findFragmentById(R.id.video_meta_data_fragment))
|
.show(videoMetaFragment)
|
||||||
.commit();
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Stefan Schüller <sschueller@techdroid.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package net.schueller.peertube.fragment;
|
package net.schueller.peertube.fragment;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Stefan Schüller <sschueller@techdroid.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package net.schueller.peertube.fragment;
|
package net.schueller.peertube.fragment;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
Loading…
Reference in New Issue
Block a user