From 3c1ecfdee0937d7294b12ec79ba6f60d320fa17d Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Wed, 3 May 2023 22:50:20 +0800 Subject: Fix https://github.com/Docile-Alligator/Infinity-For-Reddit/issues/1414 --- .../activities/ViewVideoActivity.java | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index 07840a95..f819fe17 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -44,6 +44,10 @@ import androidx.appcompat.app.AppCompatDelegate; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; +import androidx.core.graphics.Insets; +import androidx.core.view.OnApplyWindowInsetsListener; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ExoPlayer; @@ -343,19 +347,18 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe dataSavingModeDefaultResolution = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.REDDIT_VIDEO_DEFAULT_RESOLUTION, "360")); if (!mSharedPreferences.getBoolean(SharedPreferencesUtils.VIDEO_PLAYER_IGNORE_NAV_BAR, false)) { - if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { - //Set player controller bottom margin in order to display it above the navbar - int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); - LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view); - ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams(); - params.bottomMargin = resources.getDimensionPixelSize(resourceId); - } else { - //Set player controller right margin in order to display it above the navbar - int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); - LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view); - ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams(); - params.rightMargin = resources.getDimensionPixelSize(resourceId); - } + LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view); + ViewCompat.setOnApplyWindowInsetsListener(controllerLinearLayout, new OnApplyWindowInsetsListener() { + @NonNull + @Override + public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) { + Insets systemBar = insets.getInsets(WindowInsetsCompat.Type.systemBars()); + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams(); + params.bottomMargin = systemBar.bottom; + params.rightMargin = systemBar.right; + return WindowInsetsCompat.CONSUMED; + } + }); } haulerView.setOnDragDismissedListener(dragDirection -> { -- cgit v1.2.3