Skip to content

Commit b186398

Browse files
rpdomeCopilot
andauthored
Full edge to edge support (#2721)
[AB#3129177](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3129177) - Make sure the status bar is visible. - Adjust insets to make sure the view is not overlapped by system UI/UX - Also included keyboard insets as raised in #2712. Thank you @Alexeyca <img width="207" height="459" alt="image" src="https://github.com/user-attachments/assets/c39af0bb-2338-49ca-b008-558d8da3fd43" /> <img width="207" height="459" alt="image" src="https://github.com/user-attachments/assets/55b97826-c1cd-43e1-8c3a-1eb942142686" /> --------- Co-authored-by: Copilot <[email protected]>
1 parent 9966d2e commit b186398

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
vNext
22
----------
3+
- [MINOR] Full edge to edge support (#2721)
34
- [MAJOR] Bump TargetSdk to 35, minSdk to 24, AGP to 8.10.0 (#2713)
45
- [Minor] Improve tenant-based flighting for broker supporting code (#2717)
56
- [PATCH] Fix caching of secret key and add retries for InvalidKeyException during unwrap (#2659)

common/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ dependencies {
158158

159159
implementation 'org.apache.httpcomponents.core5:httpcore5:5.3'
160160
implementation "com.nimbusds:nimbus-jose-jwt:$rootProject.ext.nimbusVersion"
161+
implementation "androidx.activity:activity:1.8.2"
161162
implementation "androidx.appcompat:appcompat:$rootProject.ext.appCompatVersion"
162163
implementation "com.google.code.gson:gson:$rootProject.ext.gsonVersion"
163164
implementation "com.squareup.moshi:moshi:$rootProject.ext.moshiVersion"

common/src/main/java/com/microsoft/identity/common/internal/ui/DualScreenActivity.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,21 @@
2626
import android.content.Context;
2727
import android.content.pm.PackageManager;
2828
import android.content.res.Configuration;
29+
import android.graphics.Color;
2930
import android.graphics.Rect;
31+
import android.os.Bundle;
3032
import android.view.LayoutInflater;
3133
import android.view.Surface;
3234
import android.view.WindowManager;
3335
import android.widget.RelativeLayout;
3436

37+
import androidx.activity.EdgeToEdge;
38+
import androidx.activity.SystemBarStyle;
3539
import androidx.annotation.NonNull;
40+
import androidx.annotation.Nullable;
3641
import androidx.constraintlayout.widget.ConstraintLayout;
3742
import androidx.constraintlayout.widget.ConstraintSet;
43+
import androidx.core.graphics.Insets;
3844
import androidx.core.view.ViewCompat;
3945
import androidx.core.view.WindowInsetsCompat;
4046
import androidx.fragment.app.Fragment;
@@ -52,6 +58,22 @@
5258
// This activity readjusts its child layouts so that they're displayed on both single-screen and dual-screen device correctly.
5359
public class DualScreenActivity extends FragmentActivity {
5460

61+
@Override
62+
protected void onCreate(@Nullable Bundle savedInstanceState) {
63+
super.onCreate(savedInstanceState);
64+
65+
if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_HANDLING_FOR_EDGE_TO_EDGE)) {
66+
// Force set to a light theme (to status and navigation bars) since broker/common activities always have white background.
67+
// We don't support dark mode in broker/common activities yet.
68+
// Until then, having everything consistently rendered with a white background looks better.
69+
// This will also guarantee that the icons on those bars are always visible.
70+
setTheme(R.style.DualScreenActivityTheme);
71+
EdgeToEdge.enable(this,
72+
SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT),
73+
SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT));
74+
}
75+
}
76+
5577
@Override
5678
public void setContentView(int layoutResID) {
5779
initializeContentView();
@@ -65,18 +87,19 @@ private void initializeContentView(){
6587
if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_HANDLING_FOR_EDGE_TO_EDGE)) {
6688
try {
6789
ViewCompat.setOnApplyWindowInsetsListener(findViewById(android.R.id.content), (view, insets) -> {
68-
int topInset = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top;
69-
int bottomInset = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom;
70-
int leftInset = insets.getInsets(WindowInsetsCompat.Type.systemBars()).left;
71-
int rightInset = insets.getInsets(WindowInsetsCompat.Type.systemBars()).right;
72-
73-
view.setPadding(leftInset, topInset, rightInset, bottomInset);
90+
// Set the padding of the view to the insets of system bars, display cutout, system gestures, and Input (keyboards).
91+
final Insets inset = insets.getInsets(WindowInsetsCompat.Type.systemBars()
92+
| WindowInsetsCompat.Type.displayCutout()
93+
| WindowInsetsCompat.Type.systemGestures()
94+
| WindowInsetsCompat.Type.ime());
95+
view.setPadding(inset.left, inset.top, inset.right, inset.bottom);
7496
return insets;
7597
});
7698
} catch (final Throwable throwable) {
7799
Logger.warn("DualScreenActivity:initializeContentView", "Failed to set OnApplyWindowInsetsListener");
78100
}
79101
}
102+
80103
adjustLayoutForDualScreenActivity();
81104
}
82105

common/src/main/res/values/styles.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@
4848
<item name="android:windowTitleSize">20sp</item>
4949
</style>
5050

51+
<!-- Theme for DualScreenActivity.
52+
Force set to a light theme (to status and navigation bars) since broker/common activities always have white background. -->
53+
<style name="DualScreenActivityTheme" parent="Base.Theme.AppCompat.Light"/>
54+
5155
</resources>

common4j/src/main/com/microsoft/identity/common/java/flighting/CommonFlight.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public enum CommonFlight implements IFlightConfig {
124124
/**
125125
* Flight to enable handling the UI in edge to edge mode
126126
*/
127-
ENABLE_HANDLING_FOR_EDGE_TO_EDGE("EnableHandlingEdgeToEdge", false),
127+
ENABLE_HANDLING_FOR_EDGE_TO_EDGE("EnableHandlingEdgeToEdge", true),
128128

129129
/**
130130
* Flight to enable the Web CP in WebView.

0 commit comments

Comments
 (0)