diff options
Diffstat (limited to 'app')
3 files changed, 22 insertions, 36 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index a36924452..f30c3d456 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -90,6 +90,7 @@ public class MainActivity extends CastEnabledActivity { private LockableBottomSheetBehavior sheetBehavior; private RecyclerView.RecycledViewPool recycledViewPool = new RecyclerView.RecycledViewPool(); private int lastTheme = 0; + private Insets navigationBarInsets = Insets.NONE; @NonNull public static Intent getIntentToOpenFeed(@NonNull Context context, long feedId) { @@ -116,10 +117,13 @@ public class MainActivity extends CastEnabledActivity { setNavDrawerSize(); // Consume navigation bar insets - we apply them in setPlayerVisible() - ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main_view), (v, insets) -> - new WindowInsetsCompat.Builder(insets) - .setInsets(WindowInsetsCompat.Type.navigationBars(), Insets.NONE) - .build()); + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main_view), (v, insets) -> { + navigationBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars()); + updateInsets(); + return new WindowInsetsCompat.Builder(insets) + .setInsets(WindowInsetsCompat.Type.navigationBars(), Insets.NONE) + .build(); + }); final FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentByTag(MAIN_FRAGMENT_TAG) == null) { @@ -160,8 +164,7 @@ public class MainActivity extends CastEnabledActivity { @Override public void onAttachedToWindow() { super.onAttachedToWindow(); - int playerHeight = (int) getResources().getDimension(R.dimen.external_player_height); - sheetBehavior.setPeekHeight(playerHeight + getBottomInset()); + updateInsets(); } /** @@ -253,9 +256,10 @@ public class MainActivity extends CastEnabledActivity { return sheetBehavior; } - private int getBottomInset() { - WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(getWindow().getDecorView()); - return insets == null ? 0 : insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom; + private void updateInsets() { + setPlayerVisible(findViewById(R.id.audioplayerFragment).getVisibility() == View.VISIBLE); + int playerHeight = (int) getResources().getDimension(R.dimen.external_player_height); + sheetBehavior.setPeekHeight(playerHeight + navigationBarInsets.bottom); } public void setPlayerVisible(boolean visible) { @@ -268,7 +272,8 @@ public class MainActivity extends CastEnabledActivity { FragmentContainerView mainView = findViewById(R.id.main_view); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mainView.getLayoutParams(); int externalPlayerHeight = (int) getResources().getDimension(R.dimen.external_player_height); - params.setMargins(0, 0, 0, getBottomInset() + (visible ? externalPlayerHeight : 0)); + params.setMargins(navigationBarInsets.left, 0, navigationBarInsets.right, + navigationBarInsets.bottom + (visible ? externalPlayerHeight : 0)); mainView.setLayoutParams(params); findViewById(R.id.audioplayerFragment).setVisibility(visible ? View.VISIBLE : View.GONE); } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/SplashActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/SplashActivity.java index 4e300ef25..43da309d7 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/SplashActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/SplashActivity.java @@ -1,15 +1,12 @@ package de.danoeh.antennapod.activity; +import android.annotation.SuppressLint; +import android.app.Activity; import android.content.Intent; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.os.Bundle; +import android.view.View; import android.widget.Toast; import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import android.widget.ProgressBar; - -import de.danoeh.antennapod.R; import de.danoeh.antennapod.error.CrashReportWriter; import de.danoeh.antennapod.storage.database.PodDBAdapter; import io.reactivex.Completable; @@ -19,15 +16,13 @@ import io.reactivex.schedulers.Schedulers; /** * Shows the AntennaPod logo while waiting for the main activity to start. */ -public class SplashActivity extends AppCompatActivity { +@SuppressLint("CustomSplashScreen") +public class SplashActivity extends Activity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.splash); - - ProgressBar progressBar = findViewById(R.id.progressBar); - progressBar.getIndeterminateDrawable().setColorFilter( - new PorterDuffColorFilter(0xffffffff, PorterDuff.Mode.SRC_IN)); + final View content = findViewById(android.R.id.content); + content.getViewTreeObserver().addOnPreDrawListener(() -> false); // Keep splash screen active Completable.create(subscriber -> { // Trigger schema updates diff --git a/app/src/main/res/layout/splash.xml b/app/src/main/res/layout/splash.xml deleted file mode 100644 index 126b93481..000000000 --- a/app/src/main/res/layout/splash.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <ProgressBar - style="?android:attr/progressBarStyle" - android:layout_width="24dp" - android:layout_height="24dp" - android:layout_alignParentBottom="true" - android:layout_centerHorizontal="true" - android:layout_marginBottom="96dp" - android:id="@+id/progressBar"/> -</RelativeLayout> |