[mobile] support land layout - part 2

pull/142/head
FongMi 2 years ago
parent f0b05b012a
commit df19e89255
  1. 24
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  2. 3
      app/src/mobile/res/layout-sw600dp/activity_video.xml
  3. 3
      app/src/mobile/res/layout/activity_video.xml

@ -237,6 +237,14 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
return getCallingActivity() != null && getCallingActivity().getShortClassName().contains(CollectActivity.class.getSimpleName());
}
private boolean isLand() {
return mBinding.getRoot().getTag().equals("land");
}
private boolean isPort() {
return mBinding.getRoot().getTag().equals("port");
}
@Override
protected boolean transparent() {
return false;
@ -250,7 +258,6 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
mBinding.swipeLayout.setRefreshing(true);
getIntent().putExtras(intent);
stopSearch();
@ -364,7 +371,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
private void setVideoView() {
mPlayers.set(getExo(), getIjk());
if (ResUtil.isLand(this)) enterFullscreen();
if (isPort() && ResUtil.isLand(this)) enterFullscreen();
getExo().getSubtitleView().setStyle(ExoUtil.getCaptionStyle());
getIjk().getSubtitleView().setStyle(ExoUtil.getCaptionStyle());
setSubtitle(14);
@ -803,7 +810,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
private void exitFullscreen() {
if (!isFullscreen()) return;
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
setRequestedOrientation(isLand() ? ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
mBinding.episode.scrollToPosition(mEpisodeAdapter.getPosition());
mBinding.control.full.setVisibility(View.VISIBLE);
mBinding.video.setLayoutParams(mFrameParams);
@ -819,7 +826,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
return ResUtil.isLand(this) ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
} else if (isRotate()) {
return ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT;
} else if (Utils.isAutoRotate()) {
} else if (isPort() && Utils.isAutoRotate()) {
return ActivityInfo.SCREEN_ORIENTATION_FULL_USER;
} else {
return ResUtil.isLand(this) ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT;
@ -895,7 +902,8 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
}
private void setOrient() {
if (Utils.isAutoRotate()) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER);
if (isPort() && Utils.isAutoRotate()) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER);
if (isLand() && Utils.isAutoRotate()) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);
}
private void setR1Callback() {
@ -1429,9 +1437,9 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (ResUtil.isPort(this) && !isRotate()) exitFullscreen();
else if (ResUtil.isLand(this)) enterFullscreen();
else if (isFullscreen()) Utils.hideSystemUI(this);
if (isPort() && newConfig.orientation == 1 && !isRotate()) exitFullscreen();
if (isPort() && newConfig.orientation == 2) enterFullscreen();
if (isFullscreen()) Utils.hideSystemUI(this);
}
@Override

@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
android:keepScreenOn="true"
android:tag="land">
<com.fongmi.android.tv.ui.custom.ProgressLayout
android:id="@+id/progressLayout"

@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
android:keepScreenOn="true"
android:tag="port">
<FrameLayout
android:id="@+id/video"

Loading…
Cancel
Save