- Full screen on landscape

This commit is contained in:
Stefan Schueller 2018-11-07 23:50:54 +01:00
parent 3709b6c043
commit 85e0862414

View File

@ -2,6 +2,7 @@ package net.schueller.peertube.activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -11,7 +12,12 @@ import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.Surface; import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -216,6 +222,41 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
} }
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
TextView nameView = findViewById(R.id.name);
TextView videoMetaView = findViewById(R.id.videoMeta);
TextView descriptionView = findViewById(R.id.description);
// Checking the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) simpleExoPlayerView.getLayoutParams();
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
simpleExoPlayerView.setLayoutParams(params);
nameView.setVisibility(View.GONE);
videoMetaView.setVisibility(View.GONE);
descriptionView.setVisibility(View.GONE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
} 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;
simpleExoPlayerView.setLayoutParams(params);
nameView.setVisibility(View.VISIBLE);
videoMetaView.setVisibility(View.VISIBLE);
descriptionView.setVisibility(View.VISIBLE);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
@Override @Override
public void onVideoEnabled(DecoderCounters counters) { public void onVideoEnabled(DecoderCounters counters) {