From 2fdde0255c0231f8b929efc9f8a6326f8a5c00ca Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 1 Jun 2022 15:22:37 +0300 Subject: [PATCH 1/3] [mobile] add missed source --- apps/common/mobile/utils/CThumbnailLoader.js | 98 ++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 apps/common/mobile/utils/CThumbnailLoader.js diff --git a/apps/common/mobile/utils/CThumbnailLoader.js b/apps/common/mobile/utils/CThumbnailLoader.js new file mode 100644 index 000000000..55f33fca9 --- /dev/null +++ b/apps/common/mobile/utils/CThumbnailLoader.js @@ -0,0 +1,98 @@ + +class CThumbnailLoader { + constructor() { + this.binaryFormat = null; + this.data = null; + this.width = 0; + this.heightOne = 0; + } + + load(url, callback) { + if (!callback) + return; + + let xhr = new XMLHttpRequest(); + xhr.open('GET', url + ".bin", true); + xhr.responseType = 'arraybuffer'; + + if (xhr.overrideMimeType) + xhr.overrideMimeType('text/plain; charset=x-user-defined'); + else xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); + + xhr.onload = e => { + // TODO: check errors + this.binaryFormat = e.target.response; + callback(); + }; + + xhr.send(null); + } + + #openBinary(arrayBuffer) { + //var t1 = performance.now(); + + const binaryAlpha = new Uint8Array(arrayBuffer); + this.width = (binaryAlpha[0] << 24) | (binaryAlpha[1] << 16) | (binaryAlpha[2] << 8) | (binaryAlpha[3] << 0); + this.heightOne = (binaryAlpha[4] << 24) | (binaryAlpha[5] << 16) | (binaryAlpha[6] << 8) | (binaryAlpha[7] << 0); + const count = (binaryAlpha[8] << 24) | (binaryAlpha[9] << 16) | (binaryAlpha[10] << 8) | (binaryAlpha[11] << 0); + const height = count * this.heightOne; + + this.data = new Uint8ClampedArray(4 * this.width * height); + + var binaryIndex = 12; + var imagePixels = this.data; + var index = 0; + + var len0 = 0; + var tmpValue = 0; + while (binaryIndex < binaryAlpha.length) { + tmpValue = binaryAlpha[binaryIndex++]; + if (0 == tmpValue) { + len0 = binaryAlpha[binaryIndex++]; + while (len0 > 0) { + len0--; + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; + imagePixels[index + 3] = 0; // this value is already 0. + index += 4; + } + } else { + imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; + imagePixels[index + 3] = tmpValue; + index += 4; + } + } + + //var t2 = performance.now(); + //console.log(t2 - t1); + }; + + getImage = function(index, canvas, ctx) { + //var t1 = performance.now(); + if (!canvas) { + canvas = document.createElement("canvas"); + canvas.width = this.width; + canvas.height = this.heightOne; + canvas.style.width = iconWidth + "px"; + canvas.style.height = iconHeight + "px"; + + ctx = canvas.getContext("2d"); + } + + if (!this.data) { + this.#openBinary(this.binaryFormat); + delete this.binaryFormat; + } + + let dataTmp = ctx.createImageData(this.width, this.heightOne); + const sizeImage = 4 * this.width * this.heightOne; + dataTmp.data.set(new Uint8ClampedArray(this.data.buffer, index * sizeImage, sizeImage)); + ctx.putImageData(dataTmp, 0, 0); + + //var t2 = performance.now(); + //console.log(t2 - t1); + + return canvas; + }; +}; + +export default CThumbnailLoader; \ No newline at end of file From 74041ab37316f7709c965b2385eef9a38d356dd5 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 1 Jun 2022 11:21:46 +0300 Subject: [PATCH 2/3] [mobile] debug of app launch --- apps/common/mobile/utils/utils.js | 98 ------------------- .../mobile/src/store/textSettings.js | 3 +- .../mobile/src/store/textSettings.js | 3 +- .../mobile/src/store/textSettings.js | 3 +- 4 files changed, 6 insertions(+), 101 deletions(-) diff --git a/apps/common/mobile/utils/utils.js b/apps/common/mobile/utils/utils.js index af586a73b..5a3481c5b 100644 --- a/apps/common/mobile/utils/utils.js +++ b/apps/common/mobile/utils/utils.js @@ -127,102 +127,4 @@ define([ }, 500); } }; - - Common.Utils.CThumbnailLoader = function () { - this.image = null; - this.binaryFormat = null; - this.data = null; - this.width = 0; - this.height = 0; - this.heightOne = 0; - this.count = 0; - - this.load = function(url, callback) { - if (!callback) - return; - - var me = this; - var xhr = new XMLHttpRequest(); - xhr.open('GET', url + ".bin", true); - xhr.responseType = 'arraybuffer'; - - if (xhr.overrideMimeType) - xhr.overrideMimeType('text/plain; charset=x-user-defined'); - else xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); - - xhr.onload = function() { - // TODO: check errors - me.binaryFormat = this.response; - callback(); - }; - - xhr.send(null); - }; - - this.openBinary = function(arrayBuffer) { - //var t1 = performance.now(); - - const binaryAlpha = new Uint8Array(arrayBuffer); - this.width = (binaryAlpha[0] << 24) | (binaryAlpha[1] << 16) | (binaryAlpha[2] << 8) | (binaryAlpha[3] << 0); - this.heightOne = (binaryAlpha[4] << 24) | (binaryAlpha[5] << 16) | (binaryAlpha[6] << 8) | (binaryAlpha[7] << 0); - this.count = (binaryAlpha[8] << 24) | (binaryAlpha[9] << 16) | (binaryAlpha[10] << 8) | (binaryAlpha[11] << 0); - this.height = this.count * this.heightOne; - - this.data = new Uint8ClampedArray(4 * this.width * this.height); - - var binaryIndex = 12; - var imagePixels = this.data; - var index = 0; - - var len0 = 0; - var tmpValue = 0; - while (binaryIndex < binaryAlpha.length) { - tmpValue = binaryAlpha[binaryIndex++]; - if (0 == tmpValue) { - len0 = binaryAlpha[binaryIndex++]; - while (len0 > 0) { - len0--; - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255; - imagePixels[index + 3] = 0; // this value is already 0. - index += 4; - } - } else { - imagePixels[index] = imagePixels[index + 1] = imagePixels[index + 2] = 255 - tmpValue; - imagePixels[index + 3] = tmpValue; - index += 4; - } - } - - //var t2 = performance.now(); - //console.log(t2 - t1); - }; - - this.getImage = function(index, canvas, ctx) { - //var t1 = performance.now(); - if (!canvas) { - canvas = document.createElement("canvas"); - canvas.width = this.width; - canvas.height = this.heightOne; - canvas.style.width = iconWidth + "px"; - canvas.style.height = iconHeight + "px"; - - ctx = canvas.getContext("2d"); - } - - if (!this.data) { - this.openBinary(this.binaryFormat); - delete this.binaryFormat; - } - - var dataTmp = ctx.createImageData(this.width, this.heightOne); - const sizeImage = 4 * this.width * this.heightOne; - dataTmp.data.set(new Uint8ClampedArray(this.data.buffer, index * sizeImage, sizeImage)); - ctx.putImageData(dataTmp, 0, 0); - - //var t2 = performance.now(); - //console.log(t2 - t1); - - return canvas; - }; - }; }); diff --git a/apps/documenteditor/mobile/src/store/textSettings.js b/apps/documenteditor/mobile/src/store/textSettings.js index 6240b3baf..7a1d7f1ef 100644 --- a/apps/documenteditor/mobile/src/store/textSettings.js +++ b/apps/documenteditor/mobile/src/store/textSettings.js @@ -1,4 +1,5 @@ import {action, observable, computed, makeObservable} from 'mobx'; +import CThumbnailLoader from '../../../../common/mobile/utils/CThumbnailLoader'; export class storeTextSettings { constructor() { @@ -129,7 +130,7 @@ export class storeTextSettings { } loadSprite() { - this.spriteThumbs = new Common.Utils.CThumbnailLoader(); + this.spriteThumbs = new CThumbnailLoader(); this.spriteThumbs.load(this.thumbs[this.thumbIdx].path, () => { this.spriteCols = Math.floor(this.spriteThumbs.width / (this.thumbs[this.thumbIdx].width)) || 1; }); diff --git a/apps/presentationeditor/mobile/src/store/textSettings.js b/apps/presentationeditor/mobile/src/store/textSettings.js index 16c811a14..ed7e25ddd 100644 --- a/apps/presentationeditor/mobile/src/store/textSettings.js +++ b/apps/presentationeditor/mobile/src/store/textSettings.js @@ -1,4 +1,5 @@ import {action, observable, computed, makeObservable} from 'mobx'; +import CThumbnailLoader from '../../../../common/mobile/utils/CThumbnailLoader'; export class storeTextSettings { constructor() { @@ -133,7 +134,7 @@ export class storeTextSettings { } loadSprite() { - this.spriteThumbs = new Common.Utils.CThumbnailLoader(); + this.spriteThumbs = new CThumbnailLoader(); this.spriteThumbs.load(this.thumbs[this.thumbIdx].path, () => { this.spriteCols = Math.floor(this.spriteThumbs.width / (this.thumbs[this.thumbIdx].width)) || 1; }); diff --git a/apps/spreadsheeteditor/mobile/src/store/textSettings.js b/apps/spreadsheeteditor/mobile/src/store/textSettings.js index 21e54e902..b6b7117bd 100644 --- a/apps/spreadsheeteditor/mobile/src/store/textSettings.js +++ b/apps/spreadsheeteditor/mobile/src/store/textSettings.js @@ -1,4 +1,5 @@ import {action, observable, makeObservable, computed} from 'mobx'; +import CThumbnailLoader from '../../../../common/mobile/utils/CThumbnailLoader'; export class storeTextSettings { constructor() { @@ -133,7 +134,7 @@ export class storeTextSettings { } loadSprite() { - this.spriteThumbs = new Common.Utils.CThumbnailLoader(); + this.spriteThumbs = new CThumbnailLoader(); this.spriteThumbs.load(this.thumbs[this.thumbIdx].path, () => { this.spriteCols = Math.floor(this.spriteThumbs.width / (this.thumbs[this.thumbIdx].width)) || 1; }); From 2a55a454c5177fdd90697cd3b06ddb8fe35604a8 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Mon, 6 Jun 2022 19:26:24 +0300 Subject: [PATCH 3/3] [themes] fix app launch --- apps/spreadsheeteditor/main/app/view/ViewTab.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ViewTab.js b/apps/spreadsheeteditor/main/app/view/ViewTab.js index 70df8db8f..f0ea6aa11 100644 --- a/apps/spreadsheeteditor/main/app/view/ViewTab.js +++ b/apps/spreadsheeteditor/main/app/view/ViewTab.js @@ -421,8 +421,7 @@ define([ Common.NotificationCenter.on('uitheme:countchanged', _fill_themes.bind(me)); _fill_themes.call(me); - if (me.view.btnInterfaceTheme.menu.items.length) { - me.btnInterfaceTheme.setMenu(new Common.UI.Menu({items: menuItems})); + if (me.btnInterfaceTheme.menu.items.length) { me.btnInterfaceTheme.menu.on('item:click', _.bind(function (menu, item) { var value = item.value; Common.UI.Themes.setTheme(value);