Skip to content

Commit ef58e63

Browse files
Added support for minimal-ui and browser display modes
1 parent 7454f5e commit ef58e63

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

packages/core/src/lib/TwaManifest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const SHORT_NAME_MAX_SIZE = 12;
4141
const MIN_NOTIFICATION_ICON_SIZE = 48;
4242

4343
// Supported display modes for TWA
44-
const DISPLAY_MODE_VALUES = ['standalone', 'minimal-ui', 'fullscreen', 'fullscreen-sticky'];
44+
const DISPLAY_MODE_VALUES = ['standalone', 'minimal-ui', 'fullscreen', 'fullscreen-sticky',
45+
'browser'];
4546
export type DisplayMode = typeof DISPLAY_MODE_VALUES[number];
4647
export const DisplayModes: DisplayMode[] = [...DISPLAY_MODE_VALUES];
4748

packages/core/src/spec/lib/TwaManifestSpec.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,6 @@ describe('TwaManifest', () => {
196196
expect(twaManifest.maskableIconUrl).toBe('https://pwa-directory.com/favicons/maskable.png');
197197
expect(twaManifest.monochromeIconUrl).toBe('https://pwa-directory.com/favicons/monochrome.png');
198198
});
199-
200-
it('Replaces unsupported display modes with `standalone`', () => {
201-
const manifestUrl = new URL('https://pwa-directory.com/manifest.json');
202-
expect(TwaManifest.fromWebManifestJson(manifestUrl, {display: 'browser'}).display)
203-
.toBe('standalone');
204-
});
205199
});
206200

207201
describe('#constructor', () => {
@@ -345,10 +339,10 @@ describe('TwaManifest', () => {
345339
expect(asDisplayMode('standalone')).toBe('standalone');
346340
expect(asDisplayMode('fullscreen')).toBe('fullscreen');
347341
expect(asDisplayMode('minimal-ui')).toBe('minimal-ui');
342+
expect(asDisplayMode('browser')).toBe('browser');
348343
});
349344

350345
it('Returns null for unsupported display modes', () => {
351-
expect(asDisplayMode('browser')).toBeNull();
352346
expect(asDisplayMode('bogus')).toBeNull();
353347
expect(asDisplayMode('')).toBeNull();
354348
});

packages/core/template_project/app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@
164164
<% } else if (display === 'fullscreen-sticky') { %>
165165
<meta-data android:name="android.support.customtabs.trusted.DISPLAY_MODE"
166166
android:value="sticky-immersive" />
167+
<% } else if (display === 'minimal-ui') { %>
168+
<meta-data android:name="android.support.customtabs.trusted.DISPLAY_MODE"
169+
android:value="minimal-ui" />
170+
<% } else if (display === 'browser') { %>
171+
<meta-data android:name="android.support.customtabs.trusted.DISPLAY_MODE"
172+
android:value="browser" />
167173
<% } %>
168174

169175
<meta-data android:name="android.support.customtabs.trusted.SCREEN_ORIENTATION"

0 commit comments

Comments
 (0)