Добавил фичу скрытия иконок приложений в маркете

This commit is contained in:
IgorTimofeev 2022-05-16 22:47:43 +03:00
parent 47ecff679e
commit 24c9cffe32
12 changed files with 63 additions and 32 deletions

Binary file not shown.

View File

@ -13,6 +13,7 @@
typeUserName = "用户名", typeUserName = "用户名",
yourText = "你:", yourText = "你:",
hereBeYourDialogs = "这是你们的谈话内容", hereBeYourDialogs = "这是你们的谈话内容",
hideApplicationIcons = "Hide application icons",
categoryOverview = "预览", categoryOverview = "预览",
categoryApplications = "软件", categoryApplications = "软件",

View File

@ -13,6 +13,7 @@
typeUserName = "Schrijf gebruikersnaam", typeUserName = "Schrijf gebruikersnaam",
yourText = "Jij:", yourText = "Jij:",
hereBeYourDialogs = "Hier zullen uw gesprekken zijn", hereBeYourDialogs = "Hier zullen uw gesprekken zijn",
hideApplicationIcons = "Hide application icons",
categoryOverview = "Overzicht", categoryOverview = "Overzicht",
categoryApplications = "Applicaties", categoryApplications = "Applicaties",

View File

@ -13,6 +13,7 @@
typeUserName = "Type user name", typeUserName = "Type user name",
yourText = "You:", yourText = "You:",
hereBeYourDialogs = "Here will be your conversations", hereBeYourDialogs = "Here will be your conversations",
hideApplicationIcons = "Hide application icons",
categoryOverview = "Overview", categoryOverview = "Overview",
categoryApplications = "Applications", categoryApplications = "Applications",

View File

@ -13,6 +13,7 @@
typeUserName = "Tapez le nom d'utilisateur", typeUserName = "Tapez le nom d'utilisateur",
yourText = "Vous :", yourText = "Vous :",
hereBeYourDialogs = "Voici vos conversations", hereBeYourDialogs = "Voici vos conversations",
hideApplicationIcons = "Hide application icons",
categoryOverview = "Aperçu", categoryOverview = "Aperçu",
categoryApplications = "Applications", categoryApplications = "Applications",

View File

@ -13,6 +13,7 @@
typeUserName = "Typ Benutzername", typeUserName = "Typ Benutzername",
yourText = "Sie:", yourText = "Sie:",
hereBeYourDialogs = "Hier werden Ihre Gespräche", hereBeYourDialogs = "Hier werden Ihre Gespräche",
hideApplicationIcons = "Hide application icons",
categoryOverview = "Überblick", categoryOverview = "Überblick",
categoryApplications = "Applications", categoryApplications = "Applications",

View File

@ -13,6 +13,7 @@
typeUserName = "Tipo Nome Utente", typeUserName = "Tipo Nome Utente",
yourText = "Si:", yourText = "Si:",
hereBeYourDialogs = "Ecco le vostre conversazioni", hereBeYourDialogs = "Ecco le vostre conversazioni",
hideApplicationIcons = "Hide application icons",
categoryOverview = "Panoramica", categoryOverview = "Panoramica",
categoryApplications = "Applicazione", categoryApplications = "Applicazione",

View File

@ -13,6 +13,7 @@
typeUserName = "Введите имя пользователя", typeUserName = "Введите имя пользователя",
yourText = "Вы:", yourText = "Вы:",
hereBeYourDialogs = "Здесь будут отображены ваши диалоги", hereBeYourDialogs = "Здесь будут отображены ваши диалоги",
hideApplicationIcons = "Скрыть иконки приложений",
categoryOverview = "Главная", categoryOverview = "Главная",
categoryApplications = "Приложения", categoryApplications = "Приложения",

View File

@ -13,6 +13,7 @@
typeUserName = "Pon nombre de usuario", typeUserName = "Pon nombre de usuario",
yourText = "Tu:", yourText = "Tu:",
hereBeYourDialogs = "Aqui estaran tus conversaciones", hereBeYourDialogs = "Aqui estaran tus conversaciones",
hideApplicationIcons = "Hide application icons",
categoryOverview = "Vision General", categoryOverview = "Vision General",
categoryApplications = "Aplicaciones", categoryApplications = "Aplicaciones",

View File

@ -13,6 +13,7 @@
typeUserName = "Введіть ім'я користувача", typeUserName = "Введіть ім'я користувача",
yourText = "Ви:", yourText = "Ви:",
hereBeYourDialogs = "Тут будуть відображені ваші діалоги", hereBeYourDialogs = "Тут будуть відображені ваші діалоги",
hideApplicationIcons = "Hide application icons",
categoryOverview = "Головна", categoryOverview = "Головна",
categoryApplications = "Додатки", categoryApplications = "Додатки",

View File

@ -72,9 +72,18 @@ local languages = {
filesystem.makeDirectory(iconCachePath) filesystem.makeDirectory(iconCachePath)
local luaIcon = image.load(currentScriptDirectory .. "Icons/Lua.pic") local iconsCache = {}
local fileNotExistsIcon = image.load(currentScriptDirectory .. "Icons/FileNotExists.pic")
local scriptIcon = image.load(currentScriptDirectory .. "Icons/Script.pic") local function loadIcon(name)
local icon = iconsCache[name]
if not icon then
icon = image.load(currentScriptDirectory .. "Icons/" .. name .. ".pic")
iconsCache[name] = icon
end
return icon
end
local search = "" local search = ""
local appWidth, appHeight, appHSpacing, appVSpacing, currentPage, appsPerPage, appsPerWidth, appsPerHeight = 32, 6, 2, 1, 0 local appWidth, appHeight, appHSpacing, appVSpacing, currentPage, appsPerPage, appsPerWidth, appsPerHeight = 32, 6, 2, 1, 0
@ -139,6 +148,7 @@ local function loadConfig()
orderBy = 4, orderBy = 4,
orderDirection = 1, orderDirection = 1,
singleSession = false, singleSession = false,
hideApplicationIcons = false
} }
end end
@ -558,37 +568,41 @@ local function loadImage(path)
if picture then if picture then
return picture return picture
else else
return fileNotExistsIcon return loadIcon("FileNotExists")
end end
end end
local function getPublicationIcon(publication) local function getPublicationIcon(publication)
if publication.icon_url then if publication.icon_url then
local path = iconCachePath .. publication.file_id .. "@" .. publication.version .. ".pic" if config.hideApplicationIcons then
return loadIcon("Application")
if filesystem.exists(path) then
return loadImage(path)
else else
progressIndicator.active = true local path = iconCachePath .. publication.file_id .. "@" .. publication.version .. ".pic"
workspace:draw()
local data, reason = checkImage(publication.icon_url)
progressIndicator.active = false
workspace:draw()
if data then
filesystem.write(path, data)
if filesystem.exists(path) then
return loadImage(path) return loadImage(path)
else else
return fileNotExistsIcon progressIndicator.active = true
workspace:draw()
local data, reason = checkImage(publication.icon_url)
progressIndicator.active = false
workspace:draw()
if data then
filesystem.write(path, data)
return loadImage(path)
else
return loadIcon("FileNotExists")
end
end end
end end
elseif publication.category_id == 2 then elseif publication.category_id == 2 then
return luaIcon return loadIcon("Lua")
else else
return scriptIcon return loadIcon("Script")
end end
end end
@ -601,9 +615,11 @@ local function addApplicationInfo(container, publication, limit)
local updateState = getUpdateState(publication.file_id, publication.version) local updateState = getUpdateState(publication.file_id, publication.version)
container.downloadButton = container:addChild(GUI.adaptiveRoundedButton(13, 5, 1, 0, 0xC3C3C3, 0xFFFFFF, 0x969696, 0xFFFFFF, updateState == 4 and localization.installed or updateState == 3 and localization.update or localization.install)) container.downloadButton = container:addChild(GUI.adaptiveRoundedButton(13, 5, 1, 0, 0xC3C3C3, 0xFFFFFF, 0x969696, 0xFFFFFF, updateState == 4 and localization.installed or updateState == 3 and localization.update or localization.install))
container.downloadButton.onTouch = function() container.downloadButton.onTouch = function()
download(publication) download(publication)
end end
container.downloadButton.colors.disabled.background = 0xE1E1E1 container.downloadButton.colors.disabled.background = 0xE1E1E1
container.downloadButton.colors.disabled.text = 0xFFFFFF container.downloadButton.colors.disabled.text = 0xFFFFFF
container.downloadButton.disabled = updateState == 4 container.downloadButton.disabled = updateState == 4
@ -788,13 +804,11 @@ local function overview()
iconsContainer.eventHandler = function(workspace, object, e1, e2, e3, e4) iconsContainer.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then if e1 == "touch" or e1 == "drag" then
local child, deltaX, deltaY, vectorLength local child, deltaX, deltaY, vectorLength
for i = 1, #iconsContainer.children do for i = 1, #iconsContainer.children do
child = iconsContainer.children[i] child = iconsContainer.children[i]
deltaX, deltaY = math.ceil(e3) - child.x, math.ceil(e4) - child.y deltaX, deltaY = e3 - child.x, e4 - child.y
vectorLength = math.sqrt(deltaX ^ 2 + deltaY ^ 2) vectorLength = math.sqrt(deltaX ^ 2 + deltaY ^ 2)
if vectorLength > 0 then if vectorLength > 0 then
child.forceX = deltaX / vectorLength * math.random(overviewMaximumTouchAcceleration) child.forceX = deltaX / vectorLength * math.random(overviewMaximumTouchAcceleration)
child.forceY = deltaY / vectorLength * math.random(overviewMaximumTouchAcceleration) child.forceY = deltaY / vectorLength * math.random(overviewMaximumTouchAcceleration)
@ -932,6 +946,13 @@ local function settings()
textLayout:addChild(GUI.keyAndValue(1, 1, 0x696969, 0x969696, localization.registrationDate, ": " .. os.date("%d.%m.%Y", user.timestamp))) textLayout:addChild(GUI.keyAndValue(1, 1, 0x696969, 0x969696, localization.registrationDate, ": " .. os.date("%d.%m.%Y", user.timestamp)))
textLayout.height = #textLayout.children * 2 - 1 textLayout.height = #textLayout.children * 2 - 1
local hideApplicationIconsSwitch = layout:addChild(GUI.switchAndLabel(1, 1, 36, 6, 0x66DB80, 0xC3C3C3, 0xFFFFFF, 0x696969, localization.hideApplicationIcons .. ":", config.hideApplicationIcons))
hideApplicationIconsSwitch.switch.onStateChanged = function()
config.hideApplicationIcons = hideApplicationIconsSwitch.switch.state
saveConfig()
end
local buttonsLayout = layout:addChild(newButtonsLayout(1, 1, layout.width, 2)) local buttonsLayout = layout:addChild(newButtonsLayout(1, 1, layout.width, 2))
buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.changePassword)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.changePassword)).onTouch = function()
@ -1253,7 +1274,7 @@ newPublicationInfo = function(file_id)
local cyka = pizda:addChild(newRatingWidget(eblo.width + 1, 1, 4)) local cyka = pizda:addChild(newRatingWidget(eblo.width + 1, 1, 4))
cyka.eventHandler = function(workspace, object, e1, e2, e3) cyka.eventHandler = function(workspace, object, e1, e2, e3)
if e1 == "touch" then if e1 == "touch" then
cyka.rating = number.round((math.ceil(e3) - object.x + 1) / object.width * 5) cyka.rating = number.round((e3 - object.x + 1) / object.width * 5)
workspace:draw() workspace:draw()
end end
end end

View File

@ -98,6 +98,7 @@
"Applications/App Market.app/Icons/Lua.pic", "Applications/App Market.app/Icons/Lua.pic",
"Applications/App Market.app/Icons/Script.pic", "Applications/App Market.app/Icons/Script.pic",
"Applications/App Market.app/Icons/FileNotExists.pic", "Applications/App Market.app/Icons/FileNotExists.pic",
"Applications/App Market.app/Icons/Application.pic",
"Applications/App Market.app/Localizations/Chinese.lang", "Applications/App Market.app/Localizations/Chinese.lang",
"Applications/App Market.app/Localizations/Russian.lang", "Applications/App Market.app/Localizations/Russian.lang",
"Applications/App Market.app/Localizations/English.lang", "Applications/App Market.app/Localizations/English.lang",