Docile-Alligator 2023-05-03 22:50:20 +08:00
parent 6c83718688
commit 3c1ecfdee0

View File

@ -44,6 +44,10 @@ import androidx.appcompat.app.AppCompatDelegate;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; 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.C;
import com.google.android.exoplayer2.ExoPlayer; 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")); dataSavingModeDefaultResolution = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.REDDIT_VIDEO_DEFAULT_RESOLUTION, "360"));
if (!mSharedPreferences.getBoolean(SharedPreferencesUtils.VIDEO_PLAYER_IGNORE_NAV_BAR, false)) { if (!mSharedPreferences.getBoolean(SharedPreferencesUtils.VIDEO_PLAYER_IGNORE_NAV_BAR, false)) {
if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view);
//Set player controller bottom margin in order to display it above the navbar ViewCompat.setOnApplyWindowInsetsListener(controllerLinearLayout, new OnApplyWindowInsetsListener() {
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); @NonNull
LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view); @Override
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams(); public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
params.bottomMargin = resources.getDimensionPixelSize(resourceId); Insets systemBar = insets.getInsets(WindowInsetsCompat.Type.systemBars());
} else { ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
//Set player controller right margin in order to display it above the navbar params.bottomMargin = systemBar.bottom;
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); params.rightMargin = systemBar.right;
LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view); return WindowInsetsCompat.CONSUMED;
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams(); }
params.rightMargin = resources.getDimensionPixelSize(resourceId); });
}
} }
haulerView.setOnDragDismissedListener(dragDirection -> { haulerView.setOnDragDismissedListener(dragDirection -> {