@@ -53,8 +53,10 @@ qx.Class.define("osparc.Application", {
5353 this . __preventAutofillBrowserStyles ( ) ;
5454 this . __loadCommonCss ( ) ;
5555 this . __updateTabName ( ) ;
56- this . __updateMetaTags ( ) ;
57-
56+ if ( osparc . utils . Utils . isDevelopmentPlatform ( ) ) {
57+ this . __updateMetaTags ( ) ;
58+ this . __setDeviceSpecificIcons ( ) ;
59+ }
5860 if ( qx . core . Environment . get ( "product.name" ) === "s4lengine" ) {
5961 const view = new osparc . auth . BlurredLoginPageS4LEngineering ( ) ;
6062 this . __loadView ( view ) ;
@@ -216,226 +218,158 @@ qx.Class.define("osparc.Application", {
216218 }
217219 } ,
218220
219- __updateMetaTags : function ( ) {
220- // Update title and meta tags
221+
222+
223+ __setDeviceSpecificIcons : function ( ) {
224+ const isIOS = / i P a d | i P h o n e | i P o d / . test ( navigator . userAgent ) && ! window . MSStream ;
225+ const isAndroid = / a n d r o i d / i. test ( navigator . userAgent ) ;
226+ const isWindows = / w i n d o w s / i. test ( navigator . userAgent ) ;
227+ // const productColor = qx.theme.manager.Color.getInstance().resolve("product-color");
228+ // const backgroundColor = qx.theme.manager.Color.getInstance().resolve("primary-background-color");
229+ // default icons
230+ this . __updateMetaTags ( ) ;
231+ this . __setDefaultIcons ( )
232+ if ( isIOS ) {
233+ this . __setIOSpIcons ( ) ;
234+ } else if ( isAndroid ) {
235+ this . __setGoogleIcons ( ) ;
236+ } else if ( isWindows ) {
237+ // this.__updateBrowserConfig(this.__getProductMetaData().productColor);
238+ }
239+ } ,
240+
241+ __getProductMetaData : function ( ) {
242+ let productName = osparc . product . Utils . getProductName ( ) ;
243+ if ( osparc . product . Utils . isS4LProduct ( ) || osparc . product . Utils . isProduct ( "s4llite" ) ) {
244+ productName = "s4l" ;
245+ } else if ( osparc . product . Utils . isProduct ( "tis" ) || osparc . product . Utils . isProduct ( "tiplite" ) ) {
246+ productName = "tis" ;
247+ }
248+
221249 const productColor = qx . theme . manager . Color . getInstance ( ) . resolve ( "product-color" ) ;
222250 const backgroundColor = qx . theme . manager . Color . getInstance ( ) . resolve ( "primary-background-color" ) ;
251+ return {
252+ productName : productName ,
253+ productColor : productColor ,
254+ backgroundColor : backgroundColor
255+ }
256+ } ,
223257
258+ __updateMetaTags : function ( ) {
259+ // check device type and only set the icons for the divice type
260+ // i.e iOS, Android or windows etc
224261 const themeColorMeta = document . querySelector ( "meta[name='theme-color']" ) ;
225262 const tileColorMeta = document . querySelector ( "meta[name='msapplication-TileColor']" ) ;
226263 const tileImageMeta = document . querySelector ( "meta[name='msapplication-TileImage']" ) ;
227- const maskIconMeta = document . querySelector ( "meta[name='mask-icon']" ) ;
264+ const maskIconMeta = document . querySelector ( "meta[rel='mask-icon']" ) ;
265+ const shortIconMeta = document . querySelector ( "link[rel='icon']" ) ;
266+ const manifestLink = document . querySelector ( "link[rel='manifest']" ) ;
267+ const msApplicationLink = document . querySelector ( "link[rel='msapplication-config']" ) ;
268+
269+ const { productName, productColor} = this . __getProductMetaData ( ) ;
228270
229271 if ( themeColorMeta ) {
230272 themeColorMeta . setAttribute ( "content" , productColor ) ;
231273 }
232274
233275 if ( tileColorMeta && tileImageMeta ) {
234- const maskIcon = osparc . product . Utils . getManifestIconUrl ( "ms-icon-150x150.png" )
235- Promise . resolve ( maskIcon )
236- . then ( resolvedUrl => {
237- // Create the manifest data object with resolved URLs
238- tileColorMeta . setAttribute ( "content" , productColor ) ;
239- tileImageMeta . setAttribute ( "content" , resolvedUrl ) ;
240- } )
241- . catch ( error => {
242- console . error ( "Failed to resolve icon URLs:" , error ) ;
243- } ) ;
276+ const maskIcon = `../resource/osparc/${ productName } /icons/ms-icon-150x150.png`
277+ tileColorMeta . setAttribute ( "content" , productColor ) ;
278+ tileImageMeta . setAttribute ( "content" , maskIcon ) ;
244279 }
245- if ( maskIconMeta ) {
246- const maskIcon = osparc . product . Utils . getManifestIconUrl ( "safari-pinned-tab.png" , "apple-icon-fallback.png" )
247- Promise . resolve ( maskIcon )
248- . then ( resolvedUrl => {
249- // Create the manifest data object with resolved URLs
250- maskIconMeta . setAttribute ( "color" , productColor ) ;
251- maskIconMeta . setAttribute ( "href" , resolvedUrl ) ;
252- } )
253- . catch ( error => {
254- console . error ( "Failed to resolve icon URLs:" , error ) ;
255- } ) ;
280+
281+ if ( shortIconMeta ) {
282+ const maskIconPath = `../resource/osparc/${ productName } /icons/favicon-96x96.png`
283+ shortIconMeta . setAttribute ( "href" , maskIconPath ) ;
256284 }
257285
258- // Update app icons
259- this . __updateAppIcons ( ) ;
286+ if ( maskIconMeta ) {
287+ const maskIconPath = `../resource/osparc/${ productName } /apple-icon-fallback.png`
288+ maskIconMeta . setAttribute ( "href" , maskIconPath ) ;
289+ }
260290
261- // Update manifest
262- this . __updateManifest ( productColor , backgroundColor ) ;
291+ if ( manifestLink ) {
292+ const manifestPath = `../resource/osparc/${ productName } /manifest.json`
293+ manifestLink . setAttribute ( "href" , manifestPath ) ;
294+ }
263295
264- // Update browserconfig
265- this . __updateBrowserConfig ( productColor ) ;
296+ if ( msApplicationLink ) {
297+ const msApplicationPath = `../resource/osparc/${ productName } /broswserconfig.xml`
298+ msApplicationLink . setAttribute ( "href" , msApplicationPath ) ;
299+ }
266300 } ,
267301
268- __updateAppIcons : function ( ) {
269- // Array of promises to resolve icon URLs for Apple Touch Icons
270- const appleIconUrls = [
271- osparc . product . Utils . getManifestIconUrl ( "apple-icon-57x57.png" , "apple-icon-fallback.png" ) ,
272- osparc . product . Utils . getManifestIconUrl ( "apple-icon-60x60.png" , "apple-icon-fallback.png" ) ,
273- osparc . product . Utils . getManifestIconUrl ( "apple-icon-72x72.png" , "apple-icon-fallback.png" ) ,
274- osparc . product . Utils . getManifestIconUrl ( "apple-icon-76x76.png" , "apple-icon-fallback.png" ) ,
275- osparc . product . Utils . getManifestIconUrl ( "apple-icon-114x114.png" , "apple-icon-fallback.png" ) ,
276- osparc . product . Utils . getManifestIconUrl ( "apple-icon-120x120.png" , "apple-icon-fallback.png" ) ,
277- osparc . product . Utils . getManifestIconUrl ( "apple-icon-144x144.png" , "apple-icon-fallback.png" ) ,
278- osparc . product . Utils . getManifestIconUrl ( "apple-icon-152x152.png" , "apple-icon-fallback.png" ) ,
279- osparc . product . Utils . getManifestIconUrl ( "apple-icon-180x180.png" , "apple-icon-fallback.png" )
280- ] ;
281-
282- // Array of promises to resolve icon URLs for Favicons
302+ __setDefaultIcons : function ( ) {
303+ const { productName} = this . __getProductMetaData ( )
304+ const resourcePath = `../resource/osparc/${ productName } /icons` ;
283305 const favIconUrls = [
284- osparc . product . Utils . getManifestIconUrl ( "android-icon-192x192.png" ) ,
285- osparc . product . Utils . getManifestIconUrl ( "favicon-32x32.png" ) ,
286- osparc . product . Utils . getManifestIconUrl ( "favicon-96x96.png" ) ,
287- osparc . product . Utils . getManifestIconUrl ( "favicon-16x16.png" )
306+ "favicon-16x16.png" ,
307+ "favicon-32x32.png" ,
308+ "favicon-96x96.png"
288309 ] ;
289310
290- // Wait for all icon URLs to be resolved
291- Promise . all ( [ ...appleIconUrls , ...favIconUrls ] )
292- . then ( resolvedUrls => {
293- const appleResolvedUrls = resolvedUrls . slice ( 0 , appleIconUrls . length ) ;
294- const favResolvedUrls = resolvedUrls . slice ( appleIconUrls . length ) ;
295-
296- // Remove existing Apple Touch Icons and Favicons
297- document . querySelectorAll ( "link[rel='apple-touch-icon'], link[rel='icon']" ) . forEach ( link => link . remove ( ) ) ;
298-
299- // Create and insert new Apple Touch Icon links
300- const appleIconSizes = [
301- "57x57" , "60x60" , "72x72" , "76x76" , "114x114" , "120x120" , "144x144" , "152x152" , "180x180"
302- ] ;
303- appleResolvedUrls . forEach ( ( url , index ) => {
304- let link = document . createElement ( "link" ) ;
305- link . setAttribute ( "rel" , "apple-touch-icon" ) ;
306- link . setAttribute ( "sizes" , appleIconSizes [ index ] ) ;
307- link . setAttribute ( "href" , url ) ;
308- document . head . appendChild ( link ) ;
309- } ) ;
310-
311- // Create and insert new Favicon links
312- const favIconSizes = [
313- "192x192" , "32x32" , "96x96" , "16x16"
314- ] ;
315- favResolvedUrls . forEach ( ( url , index ) => {
316- let link = document . createElement ( "link" ) ;
317- link . setAttribute ( "rel" , "icon" ) ;
318- link . setAttribute ( "type" , "image/png" ) ;
319- link . setAttribute ( "sizes" , favIconSizes [ index ] ) ;
320- link . setAttribute ( "href" , url ) ;
321- document . head . appendChild ( link ) ;
322- } ) ;
323- } )
324- . catch ( error => {
325- console . error ( "Failed to resolve icon URLs:" , error ) ;
326- } ) ;
311+ const iconSizes = [
312+ "16x16" , "32x32" , "96x96"
313+ ] ;
314+ favIconUrls . forEach ( ( url , index ) => {
315+ let link = document . createElement ( "link" ) ;
316+ link . setAttribute ( "rel" , "icon" ) ;
317+ link . setAttribute ( "sizes" , iconSizes [ index ] ) ;
318+ link . setAttribute ( "type" , "image/png" ) ;
319+ link . setAttribute ( "href" , resourcePath + url ) ;
320+ document . head . appendChild ( link ) ;
321+ } ) ;
327322 } ,
328323
329- __updateManifest : function ( themeColor , backgroundColor ) {
330- const productName = osparc . product . Utils . getProductName ( ) ;
331- let manifestLink = document . querySelector ( "link[rel='manifest']" ) ;
332-
333- // Array of promises to resolve icon URLs
334- const iconUrls = [
335- osparc . product . Utils . getManifestIconUrl ( "android-icon-36x36.png" ) ,
336- osparc . product . Utils . getManifestIconUrl ( "android-icon-48x48.png" ) ,
337- osparc . product . Utils . getManifestIconUrl ( "android-icon-72x72.png" ) ,
338- osparc . product . Utils . getManifestIconUrl ( "android-icon-96x96.png" ) ,
339- osparc . product . Utils . getManifestIconUrl ( "android-icon-144x144.png" ) ,
340- osparc . product . Utils . getManifestIconUrl ( "android-icon-192x192.png" )
324+ __setGoogleIcons : function ( ) {
325+ const { productName} = this . __getProductMetaData ( )
326+ const resourcePath = `../resource/osparc/${ productName } /icons` ;
327+
328+ const favIconUrls = [
329+ "android-icon-48x48.png" ,
330+ "android-icon-192x192.png" ,
341331 ] ;
342332
343- // Wait for all icon URLs to be resolved
344- Promise . all ( iconUrls )
345- . then ( resolvedUrls => {
346- // Create the manifest data object with resolved URLs
347- const manifestData = {
348- shortName : productName ,
349- name : productName ,
350- icons : [
351- {
352- src : resolvedUrls [ 0 ] ,
353- sizes : "36x36" ,
354- type : "image/png" ,
355- density : "0.75"
356- } ,
357- {
358- src : resolvedUrls [ 1 ] ,
359- sizes : "48x48" ,
360- type : "image/png" ,
361- density : "1.0"
362- } ,
363- {
364- src : resolvedUrls [ 2 ] ,
365- sizes : "72x72" ,
366- type : "image/png" ,
367- density : "1.5"
368- } ,
369- {
370- src : resolvedUrls [ 3 ] ,
371- sizes : "96x96" ,
372- type : "image/png" ,
373- density : "2.0"
374- } ,
375- {
376- src : resolvedUrls [ 4 ] ,
377- sizes : "144x144" ,
378- type : "image/png" ,
379- density : "3.0"
380- } ,
381- {
382- src : resolvedUrls [ 5 ] ,
383- sizes : "192x192" ,
384- type : "image/png" ,
385- density : "4.0"
386- }
387- ] ,
388- display : "standalone" ,
389- themeColor : themeColor ,
390- backgroundColor : backgroundColor
391- } ;
392-
393- const blob = new Blob ( [ JSON . stringify ( manifestData ) ] , { type : "application/json" } ) ;
394- const manifestURL = URL . createObjectURL ( blob ) ;
395-
396- // Create or update the manifest link in the document head
397- if ( ! manifestLink ) {
398- manifestLink = document . createElement ( "link" ) ;
399- manifestLink . setAttribute ( "rel" , "manifest" ) ;
400- document . head . appendChild ( manifestLink ) ;
401- }
402- manifestLink . setAttribute ( "href" , manifestURL ) ;
403- } )
404- . catch ( error => {
405- console . error ( "Failed to resolve icon URLs:" , error ) ;
406- } ) ;
333+ const iconSizes = [
334+ "48x48" , "192x192"
335+ ] ;
336+ favIconUrls . forEach ( ( url , index ) => {
337+ let link = document . createElement ( "link" ) ;
338+ link . setAttribute ( "rel" , "icon" ) ;
339+ link . setAttribute ( "sizes" , iconSizes [ index ] ) ;
340+ link . setAttribute ( "type" , "image/png" ) ;
341+ link . setAttribute ( "href" , resourcePath + url ) ;
342+ document . head . appendChild ( link ) ;
343+ } ) ;
407344 } ,
408345
409- // Method to dynamically update the browserconfig
410- __updateBrowserConfig : function ( tileColor ) {
411- // Resolve the icon URL asynchronously
412- osparc . product . Utils . getManifestIconUrl ( "ms-icon-150x150.png" )
413- . then ( msTileIcon => {
414- const browserconfigData = `<?xml version="1.0" encoding="utf-8"?>
415- <browserconfig>
416- <msapplication>
417- <tile>
418- <square150x150logo src="${ msTileIcon } "/>
419- <TileColor>${ tileColor } </TileColor>
420- </tile>
421- </msapplication>
422- </browserconfig>` ;
423-
424- const blob = new Blob ( [ browserconfigData ] , { type : "application/xml" } ) ;
425- const browserconfigURL = URL . createObjectURL ( blob ) ;
426-
427- // Check if the meta tag exists, create it if not
428- let browserConfigLink = document . querySelector ( "meta[name='msapplication-config']" ) ;
429- if ( ! browserConfigLink ) {
430- browserConfigLink = document . createElement ( "meta" ) ;
431- browserConfigLink . setAttribute ( "name" , "msapplication-config" ) ;
432- document . head . appendChild ( browserConfigLink ) ;
433- }
434- browserConfigLink . setAttribute ( "content" , browserconfigURL ) ;
435- } )
436- . catch ( error => {
437- console . error ( "Failed to resolve msTileIcon URL:" , error ) ;
438- } ) ;
346+ __setIOSpIcons : function ( ) {
347+ // Array of promises to resolve icon URLs for Apple Touch Icons
348+ const { productName} = this . __getProductMetaData ( )
349+ const resourcePath = `../resource/osparc/${ productName } /icons` ;
350+
351+ const appleIconUrls = [
352+ "apple-icon-57x57.png" ,
353+ "apple-icon-60x60.png" ,
354+ "apple-icon-72x72.png" ,
355+ "apple-icon-76x76.png" ,
356+ "apple-icon-114x114.png" ,
357+ "apple-icon-120x120.png" ,
358+ "apple-icon-144x144.png" ,
359+ "apple-icon-152x152.png" ,
360+ "apple-icon-180x180.png"
361+ ] ;
362+
363+ const appleIconSizes = [
364+ "57x57" , "60x60" , "72x72" , "76x76" , "114x114" , "120x120" , "144x144" , "152x152" , "180x180"
365+ ] ;
366+ appleIconUrls . forEach ( ( url , index ) => {
367+ let link = document . createElement ( "link" ) ;
368+ link . setAttribute ( "rel" , "apple-touch-icon" ) ;
369+ link . setAttribute ( "sizes" , appleIconSizes [ index ] ) ;
370+ link . setAttribute ( "href" , resourcePath + url ) ;
371+ document . head . appendChild ( link ) ;
372+ } ) ;
439373 } ,
440374
441375 __startupChecks : function ( ) {
0 commit comments