feat(PWA): add `display_override` to set the display-mode to `minimal-ui` on supported browsers

Signed-off-by: Simon L. <szaimen@e.mail.de>
pull/51092/head
Simon L. 2025-02-27 12:06:42 +07:00
parent 951a35cc38
commit 6235ed6222
4 changed files with 12 additions and 2 deletions

@ -422,7 +422,7 @@ class ThemingController extends Controller {
* *
* @param string $app ID of the app * @param string $app ID of the app
* @psalm-suppress LessSpecificReturnStatement The content of the Manifest doesn't need to be described in the return type * @psalm-suppress LessSpecificReturnStatement The content of the Manifest doesn't need to be described in the return type
* @return JSONResponse<Http::STATUS_OK, array{name: string, short_name: string, start_url: string, theme_color: string, background_color: string, description: string, icons: list<array{src: non-empty-string, type: string, sizes: string}>, display: string}, array{}>|JSONResponse<Http::STATUS_NOT_FOUND, array{}, array{}> * @return JSONResponse<Http::STATUS_OK, array{name: string, short_name: string, start_url: string, theme_color: string, background_color: string, description: string, icons: list<array{src: non-empty-string, type: string, sizes: string}>, display_override: list<string>, display: string}, array{}>|JSONResponse<Http::STATUS_NOT_FOUND, array{}, array{}>
* *
* 200: Manifest returned * 200: Manifest returned
* 404: App not found * 404: App not found
@ -481,6 +481,7 @@ class ThemingController extends Controller {
'sizes' => '16x16' 'sizes' => '16x16'
] ]
], ],
'display_override' => [$this->config->getSystemValueBool('theming.standalone_window.enabled', true) ? 'minimal-ui' : ''],
'display' => $this->config->getSystemValueBool('theming.standalone_window.enabled', true) ? 'standalone' : 'browser' 'display' => $this->config->getSystemValueBool('theming.standalone_window.enabled', true) ? 'standalone' : 'browser'
]; ];
$response = new JSONResponse($responseJS); $response = new JSONResponse($responseJS);

@ -343,6 +343,7 @@
"background_color", "background_color",
"description", "description",
"icons", "icons",
"display_override",
"display" "display"
], ],
"properties": { "properties": {
@ -387,6 +388,12 @@
} }
} }
}, },
"display_override": {
"type": "array",
"items": {
"type": "string"
}
},
"display": { "display": {
"type": "string" "type": "string"
} }

@ -745,7 +745,7 @@ class ThemingControllerTest extends TestCase {
['theming.Icon.getFavicon', ['app' => 'core'], 'favicon'], ['theming.Icon.getFavicon', ['app' => 'core'], 'favicon'],
]); ]);
$this->config $this->config
->expects($this->once()) ->expects($this->exactly(2))
->method('getSystemValueBool') ->method('getSystemValueBool')
->with('theming.standalone_window.enabled', true) ->with('theming.standalone_window.enabled', true)
->willReturn($standalone); ->willReturn($standalone);
@ -765,6 +765,7 @@ class ThemingControllerTest extends TestCase {
'sizes' => '16x16' 'sizes' => '16x16'
] ]
], ],
'display_override' => [$standalone ? 'minimal-ui' : ''],
'display' => $standalone ? 'standalone' : 'browser', 'display' => $standalone ? 'standalone' : 'browser',
'short_name' => 'Nextcloud', 'short_name' => 'Nextcloud',
'theme_color' => null, 'theme_color' => null,

@ -10,5 +10,6 @@
"type": "image/svg+xml", "type": "image/svg+xml",
"sizes": "16x16" "sizes": "16x16"
}], }],
"display_override": ["minimal-ui"],
"display": "standalone" "display": "standalone"
} }