diff --git a/app/src/main/java/com/emanuelef/remote_capture/activities/AboutActivity.java b/app/src/main/java/com/emanuelef/remote_capture/activities/AboutActivity.java index 43565ddc..d5d1a0fa 100644 --- a/app/src/main/java/com/emanuelef/remote_capture/activities/AboutActivity.java +++ b/app/src/main/java/com/emanuelef/remote_capture/activities/AboutActivity.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with PCAPdroid. If not, see . * - * Copyright 2020-24 - Emanuele Faranda + * Copyright 2020-25 - Emanuele Faranda */ package com.emanuelef.remote_capture.activities; diff --git a/app/src/main/res/layout/about_activity.xml b/app/src/main/res/layout/about_activity.xml index 78301d96..9308ab17 100644 --- a/app/src/main/res/layout/about_activity.xml +++ b/app/src/main/res/layout/about_activity.xml @@ -71,7 +71,7 @@ android:layout_height="wrap_content" android:layout_marginTop="20dp" android:autoLink="email" - android:text="Copyright (C) 2020-24 - Emanuele Faranda black.silver@hotmail.it" /> + android:text="Copyright (C) 2020-25 - Emanuele Faranda black.silver@hotmail.it" /> + + + + +``` + +- Implementing edge-to-edge support requires a lot of efforts, in particular to handle all the possible cases for insets +- Moreover, there can be issues which only appear on older Android versions (e.g. Android 9, see adbc33afe55f2c1795d250707fc3f29aadacdbb0) +- When edge-to-edge support is enabled, it breaks the ability to select a custom theme, see 5f50ae30c1e8b4f2ce73cb684066d12fb0d65b0a + +# How it works + +- inset types: + - WindowInsetsCompat.Type.statusBars: the status bar, which is the one with icons and wall clock + - WindowInsetsCompat.Type.systemBars: any system bar, e.g. 3-buttons navigation bar + - WindowInsetsCompat.Type.displayCutout: cutouts in the displays, e.g. camera holes + - WindowInsetsCompat.Type.ime: virtual keyboard. Handling of this inset is not usually required, but it allows to get a better behavior on IME open + - e.g. to resize the ReciclerView to make all the items visible on screen + +- insets handling works hierarchically: + - the top views first get a chance to handle the insets + - if the top views don't consume the insets, they get propagated to the children + - it's unclear how it affects siblings, but it does, see issues on Android 9 adbc33afe55f2c1795d250707fc3f29aadacdbb0 + +- insets can either be handled via: + - ViewCompat.setOnApplyWindowInsetsListener + - you can choose to consume or not the insets + - makes it possible to implement edge-to-edge + - fitsSystemWindows="true" + - it always *consumes* all the insets + - it just adds margins, without proper edge-to-edge support. Normally it should not be used + +- ViewPager2 does not handle insets dispatching properly + - https://issuetracker.google.com/issues/145617093#comment10 + - to fix it, it's necessary to dispatch the insets manually on tab change: ViewCompat.dispatchApplyWindowInsets + - see Utils.fixViewPager2Insets + +# Guidelines + +- To enable proper edge-to-edge support, in particular on older platforms, when creating an Activity be sure to either: + - just inherit from BaseActivity, which internally calls Utils.enableEdgeToEdge and handles the insets for the toolbar (preferred approach) + - call Utils.enableEdgeToEdge manually in onCreate, before super.onCreate + +- The activity layout must use AppBarLayout and Toolbar (with id `toolbar`) in a CoordinatorLayout. See how it is done for other activities (e.g. about_activity.xml) + - this makes proper space for the toolbar + - when possible, reuse `fragment_activity.xml`, for simple activities made of just 1 fragment + - for tab-based activities, either use `tab_activity.xml` or `tab_activity_fixed.xml`. In the latter case, be sure to call `Utils.fixScrollableTabLayoutInsets` + - the toolbar needs some top insets handling; if you inherit from BaseActivity, this is already implemented + +- When using ViewPager2, be sure to call Utils.fixViewPager2Insets to properly dispatch insets to sub-views +- For ReciclerViews, use EmptyRecyclerView when possible, which already handles insets, IME (virtual keyboard), uses setClipToPadding(false) for edge-to-edge support +- For ListViews, use Utils.fixListviewInsetsBottom for edge-to-edge support + +- New activity testing: + - test with 3-buttons bottom navbar. This can be enabled from the Android settings + - to properly test scrolling behavior, ensure to populate the views + - test horizontal insets with rotated device + - test with IME open/closed in views that use it + - test on the newest Android version + - test on Android 9 or lower, as some bugs are only visible there (e.g. adbc33afe55f2c1795d250707fc3f29aadacdbb0)