diff --git a/oeffi/src/de/schildbach/oeffi/directions/DirectionsActivity.java b/oeffi/src/de/schildbach/oeffi/directions/DirectionsActivity.java index 4fcfd0a..1da216c 100644 --- a/oeffi/src/de/schildbach/oeffi/directions/DirectionsActivity.java +++ b/oeffi/src/de/schildbach/oeffi/directions/DirectionsActivity.java @@ -63,7 +63,9 @@ import androidx.activity.result.contract.ActivityResultContract; import androidx.activity.result.contract.ActivityResultContracts; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.ContextCompat; +import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.google.common.base.Throwables; @@ -307,9 +309,11 @@ public class DirectionsActivity extends OeffiMainActivity implements QueryHistor backgroundHandler = new Handler(backgroundThread.getLooper()); setContentView(R.layout.directions_content); - findViewById(android.R.id.content).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0); - return insets; + final View contentView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(contentView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(insets.left, 0, insets.right, 0); + return windowInsets; }); final MyActionBar actionBar = getMyActionBar(); @@ -455,10 +459,11 @@ public class DirectionsActivity extends OeffiMainActivity implements QueryHistor viewQueryHistoryList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST)); queryHistoryListAdapter = new QueryHistoryAdapter(this, network, this, this); viewQueryHistoryList.setAdapter(queryHistoryListAdapter); - viewQueryHistoryList.setOnApplyWindowInsetsListener((v, insets) -> { + ViewCompat.setOnApplyWindowInsetsListener(viewQueryHistoryList, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), - insets.getSystemWindowInsetBottom()); - return insets; + insets.bottom); + return windowInsets; }); viewQueryHistoryEmpty = findViewById(R.id.directions_query_history_empty); @@ -545,15 +550,17 @@ public class DirectionsActivity extends OeffiMainActivity implements QueryHistor }); final TextView mapDisclaimerView = findViewById(R.id.directions_map_disclaimer); mapDisclaimerView.setText(mapView.getTileProvider().getTileSource().getCopyrightNotice()); - mapDisclaimerView.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0,0,0, insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(mapDisclaimerView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); final ZoomControls zoom = findViewById(R.id.directions_map_zoom); - zoom.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(zoom, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); mapView.setZoomControls(zoom); diff --git a/oeffi/src/de/schildbach/oeffi/directions/TripDetailsActivity.java b/oeffi/src/de/schildbach/oeffi/directions/TripDetailsActivity.java index 4345fd0..8372c16 100644 --- a/oeffi/src/de/schildbach/oeffi/directions/TripDetailsActivity.java +++ b/oeffi/src/de/schildbach/oeffi/directions/TripDetailsActivity.java @@ -50,6 +50,9 @@ import android.widget.PopupMenu; import android.widget.TableLayout; import android.widget.TextView; import androidx.core.content.ContextCompat; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import com.google.common.base.MoreObjects; import de.schildbach.oeffi.Constants; import de.schildbach.oeffi.LocationAware; @@ -186,9 +189,11 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen scheduleTripIntent = scheduleTripIntent(trip); setContentView(R.layout.directions_trip_details_content); - findViewById(android.R.id.content).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0); - return insets; + final View contentView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(contentView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(insets.left, 0, insets.right, 0); + return windowInsets; }); final MyActionBar actionBar = getMyActionBar(); @@ -281,9 +286,11 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen ((TextView) findViewById(R.id.directions_trip_details_footer)) .setText(Html.fromHtml(getString(R.string.directions_trip_details_realtime))); - findViewById(R.id.directions_trip_details_disclaimer_group).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); - return insets; + final View disclaimerView = findViewById(R.id.directions_trip_details_disclaimer_group); + ViewCompat.setOnApplyWindowInsetsListener(disclaimerView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); final TextView disclaimerSourceView = findViewById(R.id.directions_trip_details_disclaimer_source); updateDisclaimerSource(disclaimerSourceView, network.name(), null); @@ -312,9 +319,10 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen }); final TextView mapDisclaimerView = findViewById(R.id.directions_trip_details_map_disclaimer); mapDisclaimerView.setText(mapView.getTileProvider().getTileSource().getCopyrightNotice()); - mapDisclaimerView.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0,0,0, insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(mapDisclaimerView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); } diff --git a/oeffi/src/de/schildbach/oeffi/directions/TripsOverviewActivity.java b/oeffi/src/de/schildbach/oeffi/directions/TripsOverviewActivity.java index f90d1e9..b0f8247 100644 --- a/oeffi/src/de/schildbach/oeffi/directions/TripsOverviewActivity.java +++ b/oeffi/src/de/schildbach/oeffi/directions/TripsOverviewActivity.java @@ -31,6 +31,9 @@ import android.text.format.DateUtils; import android.view.View; import android.widget.AdapterView; import android.widget.TextView; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import com.google.common.collect.ComparisonChain; import com.google.common.collect.Ordering; import com.google.common.util.concurrent.Uninterruptibles; @@ -130,9 +133,11 @@ public class TripsOverviewActivity extends OeffiActivity { final Uri historyUri = historyUriStr != null ? Uri.parse(historyUriStr) : null; setContentView(R.layout.directions_trip_overview_content); - findViewById(android.R.id.content).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0); - return insets; + final View contentView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(contentView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(insets.left, 0, insets.right, 0); + return windowInsets; }); final MyActionBar actionBar = getMyActionBar(); @@ -163,9 +168,11 @@ public class TripsOverviewActivity extends OeffiActivity { }); barView.setOnScrollListener(() -> handler.post(checkMoreRunnable)); - findViewById(R.id.directions_trip_overview_disclaimer_group).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); - return insets; + final View disclaimerView = findViewById(R.id.directions_trip_overview_disclaimer_group); + ViewCompat.setOnApplyWindowInsetsListener(disclaimerView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); processResult(result, dep); diff --git a/oeffi/src/de/schildbach/oeffi/network/NetworkPickerActivity.java b/oeffi/src/de/schildbach/oeffi/network/NetworkPickerActivity.java index 23e5757..e5e49fc 100644 --- a/oeffi/src/de/schildbach/oeffi/network/NetworkPickerActivity.java +++ b/oeffi/src/de/schildbach/oeffi/network/NetworkPickerActivity.java @@ -43,6 +43,9 @@ import androidx.activity.EdgeToEdge; import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.core.content.ContextCompat; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import de.schildbach.oeffi.AreaAware; @@ -123,9 +126,11 @@ public class NetworkPickerActivity extends ComponentActivity implements Location backgroundHandler = new Handler(backgroundThread.getLooper()); setContentView(R.layout.network_picker_content); - findViewById(android.R.id.content).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0); - return insets; + final View contentView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(contentView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(insets.left, 0, insets.right, 0); + return windowInsets; }); actionBar = findViewById(R.id.action_bar); @@ -138,18 +143,19 @@ public class NetworkPickerActivity extends ComponentActivity implements Location final String network = prefsGetNetwork(); listAdapter = new NetworksAdapter(this, network, this, this); listView.setAdapter(listAdapter); - listView.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), - insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(listView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), insets.bottom); + return windowInsets; }); mapView = findViewById(R.id.network_picker_map); final TextView mapDisclaimerView = findViewById(R.id.network_picker_map_disclaimer); mapDisclaimerView.setText(mapView.getTileProvider().getTileSource().getCopyrightNotice()); - mapDisclaimerView.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(mapDisclaimerView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); if (network != null) { diff --git a/oeffi/src/de/schildbach/oeffi/plans/PlansPickerActivity.java b/oeffi/src/de/schildbach/oeffi/plans/PlansPickerActivity.java index e1bb2ef..1440601 100644 --- a/oeffi/src/de/schildbach/oeffi/plans/PlansPickerActivity.java +++ b/oeffi/src/de/schildbach/oeffi/plans/PlansPickerActivity.java @@ -38,7 +38,10 @@ import androidx.activity.result.contract.ActivityResultContracts; import androidx.core.content.ContextCompat; import androidx.core.content.pm.ShortcutInfoCompat; import androidx.core.content.pm.ShortcutManagerCompat; +import androidx.core.graphics.Insets; import androidx.core.graphics.drawable.IconCompat; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.google.common.util.concurrent.FutureCallback; @@ -110,9 +113,11 @@ public class PlansPickerActivity extends OeffiMainActivity implements LocationHe thumbCache = new Cache(cacheDir, THUMB_CACHE_SIZE); setContentView(R.layout.plans_picker_content); - findViewById(android.R.id.content).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0); - return insets; + final View contentView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(contentView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(insets.left, 0, insets.right, 0); + return windowInsets; }); actionBar = getMyActionBar(); @@ -130,10 +135,10 @@ public class PlansPickerActivity extends OeffiMainActivity implements LocationHe listView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST)); listAdapter = new PlansAdapter(this, cursor, thumbCache, this, this, application.okHttpClient()); listView.setAdapter(listAdapter); - listView.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), - insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(listView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), insets.bottom); + return windowInsets; }); connectivityWarningView = findViewById(R.id.plans_picker_connectivity_warning_box); diff --git a/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java b/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java index faf02a1..2ee2611 100644 --- a/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java +++ b/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java @@ -21,6 +21,10 @@ import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.MenuItem; +import android.view.View; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import de.schildbach.oeffi.R; import java.util.List; @@ -39,10 +43,11 @@ public class PreferenceActivity extends android.preference.PreferenceActivity { @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - findViewById(android.R.id.content).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(v.getPaddingLeft(), insets.getSystemWindowInsetTop(), v.getPaddingRight(), - v.getPaddingBottom()); - return insets; + final View contentView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(contentView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(v.getPaddingLeft(), insets.top, v.getPaddingRight(), v.getPaddingBottom()); + return windowInsets; }); } diff --git a/oeffi/src/de/schildbach/oeffi/stations/FavoriteStationsActivity.java b/oeffi/src/de/schildbach/oeffi/stations/FavoriteStationsActivity.java index 4e4d191..729d99f 100644 --- a/oeffi/src/de/schildbach/oeffi/stations/FavoriteStationsActivity.java +++ b/oeffi/src/de/schildbach/oeffi/stations/FavoriteStationsActivity.java @@ -22,8 +22,12 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; +import android.view.View; import android.widget.ViewAnimator; import androidx.activity.result.contract.ActivityResultContract; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import de.schildbach.oeffi.MyActionBar; @@ -83,9 +87,11 @@ public class FavoriteStationsActivity extends OeffiActivity network = (NetworkId) intent.getSerializableExtra(INTENT_EXTRA_NETWORK); setContentView(R.layout.favorites_content); - findViewById(android.R.id.content).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0); - return insets; + final View contentView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(contentView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(insets.left, 0, insets.right, 0); + return windowInsets; }); final MyActionBar actionBar = getMyActionBar(); @@ -100,10 +106,10 @@ public class FavoriteStationsActivity extends OeffiActivity listView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST)); adapter = new FavoriteStationsAdapter(this, network, this, network == null ? this : null); listView.setAdapter(adapter); - listView.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), - insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(listView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), insets.bottom); + return windowInsets; }); updateGUI(); diff --git a/oeffi/src/de/schildbach/oeffi/stations/StationDetailsActivity.java b/oeffi/src/de/schildbach/oeffi/stations/StationDetailsActivity.java index 78abb26..b77f1ca 100644 --- a/oeffi/src/de/schildbach/oeffi/stations/StationDetailsActivity.java +++ b/oeffi/src/de/schildbach/oeffi/stations/StationDetailsActivity.java @@ -37,6 +37,9 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.ViewAnimator; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.google.common.base.Joiner; @@ -137,9 +140,11 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa backgroundHandler = new Handler(backgroundThread.getLooper()); setContentView(R.layout.stations_station_details_content); - findViewById(android.R.id.content).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0); - return insets; + final View contentView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(contentView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(insets.left, 0, insets.right, 0); + return windowInsets; }); actionBar = getMyActionBar(); @@ -173,19 +178,21 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa listView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST)); listAdapter = new DeparturesAdapter(this); listView.setAdapter(listAdapter); - listView.setOnApplyWindowInsetsListener((v, insets) -> { + ViewCompat.setOnApplyWindowInsetsListener(listView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), - insets.getSystemWindowInsetBottom() + (int)(48 * getResources().getDisplayMetrics().density)); - return insets; + insets.bottom + (int) (48 * getResources().getDisplayMetrics().density)); + return windowInsets; }); mapView = findViewById(R.id.stations_station_details_map); mapView.setStationsAware(this); final TextView mapDisclaimerView = findViewById(R.id.stations_station_details_map_disclaimer); mapDisclaimerView.setText(mapView.getTileProvider().getTileSource().getCopyrightNotice()); - mapDisclaimerView.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0,0,0, insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(mapDisclaimerView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); resultStatusView = findViewById(R.id.stations_station_details_result_status); @@ -201,9 +208,11 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa favoriteButton .setChecked(selectedFavState != null && selectedFavState == FavoriteStationsProvider.TYPE_FAVORITE); - findViewById(R.id.stations_station_details_disclaimer_group).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); - return insets; + final View disclaimerView = findViewById(R.id.stations_station_details_disclaimer_group); + ViewCompat.setOnApplyWindowInsetsListener(disclaimerView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); disclaimerSourceView = findViewById(R.id.stations_station_details_disclaimer_source); updateDisclaimerSource(disclaimerSourceView, selectedNetwork.name(), null); diff --git a/oeffi/src/de/schildbach/oeffi/stations/StationsActivity.java b/oeffi/src/de/schildbach/oeffi/stations/StationsActivity.java index 0447cff..9cfc18c 100644 --- a/oeffi/src/de/schildbach/oeffi/stations/StationsActivity.java +++ b/oeffi/src/de/schildbach/oeffi/stations/StationsActivity.java @@ -56,6 +56,9 @@ import android.widget.ViewAnimator; import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.core.content.ContextCompat; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -184,9 +187,11 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware res = getResources(); setContentView(R.layout.stations_content); - findViewById(android.R.id.content).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0); - return insets; + final View contentView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(contentView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(insets.left, 0, insets.right, 0); + return windowInsets; }); actionBar = getMyActionBar(); @@ -265,22 +270,26 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware mapView.setLocationAware(this); final TextView mapDisclaimerView = findViewById(R.id.stations_map_disclaimer); mapDisclaimerView.setText(mapView.getTileProvider().getTileSource().getCopyrightNotice()); - mapDisclaimerView.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(mapDisclaimerView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); final ZoomControls zoom = findViewById(R.id.stations_map_zoom); - zoom.setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); - return insets; + ViewCompat.setOnApplyWindowInsetsListener(zoom, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); mapView.setZoomControls(zoom); connectivityWarningView = findViewById(R.id.stations_connectivity_warning_box); - findViewById(R.id.stations_disclaimer_group).setOnApplyWindowInsetsListener((v, insets) -> { - v.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); - return insets; + final View disclaimerView = findViewById(R.id.stations_disclaimer_group); + ViewCompat.setOnApplyWindowInsetsListener(disclaimerView, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom); + return windowInsets; }); disclaimerSourceView = findViewById(R.id.stations_disclaimer_source); @@ -414,10 +423,11 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware stationList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST)); stationListAdapter = new StationsAdapter(this, maxDeparturesPerStation, products, this, this); stationList.setAdapter(stationListAdapter); - stationList.setOnApplyWindowInsetsListener((v, insets) -> { + ViewCompat.setOnApplyWindowInsetsListener(stationList, (v, windowInsets) -> { + final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), - insets.getSystemWindowInsetBottom() + (int)(48 * res.getDisplayMetrics().density)); - return insets; + insets.bottom + (int) (48 * res.getDisplayMetrics().density)); + return windowInsets; }); stationList.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override