diff --git a/src/download0/img/text/ar/sortAlphabetical.png b/src/download0/img/text/ar/sortAlphabetical.png new file mode 100644 index 00000000..0fcd059a Binary files /dev/null and b/src/download0/img/text/ar/sortAlphabetical.png differ diff --git a/src/download0/img/text/ar/sortReverse.png b/src/download0/img/text/ar/sortReverse.png new file mode 100644 index 00000000..490010da Binary files /dev/null and b/src/download0/img/text/ar/sortReverse.png differ diff --git a/src/download0/img/text/ja/sortAlphabetical.png b/src/download0/img/text/ja/sortAlphabetical.png new file mode 100644 index 00000000..5509ac6f Binary files /dev/null and b/src/download0/img/text/ja/sortAlphabetical.png differ diff --git a/src/download0/img/text/ja/sortReverse.png b/src/download0/img/text/ja/sortReverse.png new file mode 100644 index 00000000..56d8b113 Binary files /dev/null and b/src/download0/img/text/ja/sortReverse.png differ diff --git a/src/download0/img/text/ko/sortAlphabetical.png b/src/download0/img/text/ko/sortAlphabetical.png new file mode 100644 index 00000000..b0120bd4 Binary files /dev/null and b/src/download0/img/text/ko/sortAlphabetical.png differ diff --git a/src/download0/img/text/ko/sortReverse.png b/src/download0/img/text/ko/sortReverse.png new file mode 100644 index 00000000..6e11fd3b Binary files /dev/null and b/src/download0/img/text/ko/sortReverse.png differ diff --git a/src/download0/img/text/zh/sortAlphabetical.png b/src/download0/img/text/zh/sortAlphabetical.png new file mode 100644 index 00000000..c765d75a Binary files /dev/null and b/src/download0/img/text/zh/sortAlphabetical.png differ diff --git a/src/download0/img/text/zh/sortReverse.png b/src/download0/img/text/zh/sortReverse.png new file mode 100644 index 00000000..253d9b57 Binary files /dev/null and b/src/download0/img/text/zh/sortReverse.png differ diff --git a/src/download0/languages.ts b/src/download0/languages.ts index 985067bb..41f61339 100644 --- a/src/download0/languages.ts +++ b/src/download0/languages.ts @@ -16,7 +16,9 @@ export const lang: Record = { jbBehaviorLapse: 'Lapse', theme: 'Theme', xToGoBack: 'X to go back', - oToGoBack: 'O to go back' + oToGoBack: 'O to go back', + sortAlphabetical: 'Sort A-Z', + sortReverse: 'Sort Z-A' } export let useImageText = false @@ -58,6 +60,8 @@ switch (detectedLocale) { lang.theme = 'Tema' lang.xToGoBack = 'X para volver' lang.oToGoBack = 'O para volver' + lang.sortAlphabetical = 'Orden Alfabético' + lang.sortReverse = 'Orden Inverso' break case 'pt': @@ -77,6 +81,8 @@ switch (detectedLocale) { lang.theme = 'Tema' lang.xToGoBack = 'X para voltar' lang.oToGoBack = 'O para voltar' + lang.sortAlphabetical = 'Ordem Alfabética' + lang.sortReverse = 'Ordem Inversa' break case 'fr': @@ -96,6 +102,8 @@ switch (detectedLocale) { lang.theme = 'Thème' lang.xToGoBack = 'X pour retourner' lang.oToGoBack = 'O pour retourner' + lang.sortAlphabetical = 'Ordre Alphabétique' + lang.sortReverse = 'Ordre Inverse' break case 'de': @@ -115,6 +123,8 @@ switch (detectedLocale) { lang.theme = 'Thema' lang.xToGoBack = 'X für Zurueck' lang.oToGoBack = 'O für Zurueck' + lang.sortAlphabetical = 'Alphabetisch' + lang.sortReverse = 'Umgekehrte Reihenfolge' break case 'it': @@ -134,6 +144,8 @@ switch (detectedLocale) { lang.theme = 'Tema' lang.xToGoBack = 'X per tornare indietro' lang.oToGoBack = 'O per tornare indietro' + lang.sortAlphabetical = 'Ordine Alfabetico' + lang.sortReverse = 'Ordine Inverso' break case 'nl': @@ -153,6 +165,8 @@ switch (detectedLocale) { lang.theme = 'Thema' lang.xToGoBack = 'X om terug te gaan' lang.oToGoBack = 'O om terug te gaan' + lang.sortAlphabetical = 'Alfabetisch Sorteren' + lang.sortReverse = 'Omgekeerd Sorteren' break case 'pl': @@ -172,6 +186,8 @@ switch (detectedLocale) { lang.theme = 'Motyw' lang.xToGoBack = 'X aby wrocic' lang.oToGoBack = 'O aby wrocic' + lang.sortAlphabetical = 'Sortuj Alfabetycznie' + lang.sortReverse = 'Sortuj Odwrotnie' break case 'tr': @@ -191,6 +207,8 @@ switch (detectedLocale) { lang.theme = 'Tema' lang.xToGoBack = 'Geri gitmek icin X' lang.oToGoBack = 'Geri gitmek icin O' + lang.sortAlphabetical = 'Alfabetik Sırala' + lang.sortReverse = 'Ters Sırala' break case 'ar': @@ -210,6 +228,8 @@ switch (detectedLocale) { lang.theme = 'سمة' lang.xToGoBack = 'X للرجوع' lang.oToGoBack = 'O للرجوع' + lang.sortAlphabetical = 'ترتيب أبجدي' + lang.sortReverse = 'ترتيب عكسي' break case 'ja': @@ -229,6 +249,8 @@ switch (detectedLocale) { lang.theme = 'テーマ' lang.xToGoBack = 'Xで戻る' lang.oToGoBack = 'Oで戻る' + lang.sortAlphabetical = 'アルファベット順' + lang.sortReverse = '逆順' break case 'ko': @@ -248,6 +270,8 @@ switch (detectedLocale) { lang.theme = '테마' lang.xToGoBack = 'X로 뒤로 가기' lang.oToGoBack = 'O로 뒤로 가기' + lang.sortAlphabetical = '알파벳순' + lang.sortReverse = '역순' break case 'zh': @@ -267,6 +291,8 @@ switch (detectedLocale) { lang.theme = '主题' lang.xToGoBack = '按 X 返回' lang.oToGoBack = '按 O 返回' + lang.sortAlphabetical = '按字母排序' + lang.sortReverse = '逆序排序' break case 'en': diff --git a/src/download0/themes/default/payload_host.ts b/src/download0/themes/default/payload_host.ts index af879e06..73613e42 100644 --- a/src/download0/themes/default/payload_host.ts +++ b/src/download0/themes/default/payload_host.ts @@ -152,14 +152,28 @@ import { checkJailbroken } from 'download0/check-jailbroken' const startX = 130 const xSpacing = 340 - for (let i = 0; i < fileList.length; i++) { - const row = Math.floor(i / buttonsPerRow) - const col = i % buttonsPerRow - - let displayName = fileList[i]!.name - - const btnX = startX + col * xSpacing - const btnY = startY + row * buttonSpacing + const totalButtons = fileList.length + 2 + + for (let i = 0; i < totalButtons; i++) { + let btnX = 0 + let btnY = 0 + let displayName = '' + + if (i < fileList.length) { + const row = Math.floor(i / buttonsPerRow) + const col = i % buttonsPerRow + btnX = startX + col * xSpacing + btnY = startY + row * buttonSpacing + displayName = fileList[i]!.name + } else if (i === fileList.length) { + btnX = 130 + btnY = 100 + displayName = lang.sortAlphabetical || 'Sort A-Z' + } else { + btnX = 450 + btnY = 100 + displayName = lang.sortReverse || 'Sort Z-A' + } const button = new Image({ url: normalButtonImg, @@ -182,20 +196,32 @@ import { checkJailbroken } from 'download0/check-jailbroken' buttonMarkers.push(marker) jsmaf.root.children.push(marker) - if (displayName.length > 30) { - displayName = displayName.substring(0, 27) + '...' + let textNode: any + if (i >= fileList.length && useImageText) { + const imgName = i === fileList.length ? 'sortAlphabetical.png' : 'sortReverse.png' + textNode = new Image({ + url: textImageBase + imgName, + x: btnX + 50, + y: btnY + 20, + width: 200, + height: 40 + }) + } else { + if (displayName.length > 30) { + displayName = displayName.substring(0, 27) + '...' + } + textNode = new jsmaf.Text() + textNode.text = displayName + textNode.x = btnX + 20 + textNode.y = btnY + 30 + textNode.style = 'white' } - const text = new jsmaf.Text() - text.text = displayName - text.x = btnX + 20 - text.y = btnY + 30 - text.style = 'white' - buttonTexts.push(text) - jsmaf.root.children.push(text) + buttonTexts.push(textNode as jsmaf.Text) + jsmaf.root.children.push(textNode) buttonOrigPos.push({ x: btnX, y: btnY }) - textOrigPos.push({ x: text.x, y: text.y }) + textOrigPos.push({ x: textNode.x, y: textNode.y }) } let backHint: Image | jsmaf.Text @@ -342,32 +368,53 @@ import { checkJailbroken } from 'download0/check-jailbroken' jsmaf.onKeyDown = function (keyCode) { log('Key pressed: ' + keyCode) - const fileButtonCount = fileList.length + const btnAIndex = fileList.length + const btnZIndex = fileList.length + 1 if (keyCode === 6) { - const nextButton = currentButton + buttonsPerRow - if (nextButton < fileButtonCount) { - currentButton = nextButton + if (currentButton === btnAIndex) { + if (fileList.length > 0) currentButton = 0 + } else if (currentButton === btnZIndex) { + if (fileList.length > 0) currentButton = Math.min(3, fileList.length - 1) + } else { + const nextButton = currentButton + buttonsPerRow + if (nextButton < fileList.length) { + currentButton = nextButton + } } updateHighlight() } else if (keyCode === 4) { - const nextButton = currentButton - buttonsPerRow - if (nextButton >= 0) { - currentButton = nextButton + if (currentButton < fileList.length) { + if (currentButton < buttonsPerRow) { + if (currentButton < 3) { + currentButton = btnAIndex + } else { + currentButton = btnZIndex + } + } else { + currentButton = currentButton - buttonsPerRow + } } updateHighlight() } else if (keyCode === 5) { - const nextButton = currentButton + 1 - const row = Math.floor(currentButton / buttonsPerRow) - const nextRow = Math.floor(nextButton / buttonsPerRow) - if (nextButton < fileButtonCount && nextRow === row) { - currentButton = nextButton + if (currentButton === btnAIndex) { + currentButton = btnZIndex + } else if (currentButton !== btnZIndex && currentButton < fileList.length) { + const row = Math.floor(currentButton / buttonsPerRow) + const nextButton = currentButton + 1 + if (nextButton < fileList.length && Math.floor(nextButton / buttonsPerRow) === row) { + currentButton = nextButton + } } updateHighlight() } else if (keyCode === 7) { - const col = currentButton % buttonsPerRow - if (col > 0) { - currentButton = currentButton - 1 + if (currentButton === btnZIndex) { + currentButton = btnAIndex + } else if (currentButton !== btnAIndex && currentButton < fileList.length) { + const col = currentButton % buttonsPerRow + if (col > 0) { + currentButton = currentButton - 1 + } } updateHighlight() } else if (keyCode === confirmKey) { @@ -384,6 +431,18 @@ import { checkJailbroken } from 'download0/check-jailbroken' } } + function updateButtonLabels () { + for (let i = 0; i < fileList.length; i++) { + let displayName = fileList[i]!.name + if (displayName.length > 30) { + displayName = displayName.substring(0, 27) + '...' + } + if (buttonTexts[i] && !(buttonTexts[i] instanceof Image)) { + buttonTexts[i]!.text = displayName + } + } + } + function handleButtonPress () { if (currentButton < fileList.length) { const selectedEntry = fileList[currentButton] @@ -454,6 +513,12 @@ import { checkJailbroken } from 'download0/check-jailbroken' log('ERROR: ' + err.message) if (err.stack) log(err.stack) } + } else if (currentButton === fileList.length) { + fileList.sort((a, b) => a.name.localeCompare(b.name)) + updateButtonLabels() + } else if (currentButton === fileList.length + 1) { + fileList.sort((a, b) => b.name.localeCompare(a.name)) + updateButtonLabels() } } diff --git a/tools/generate_text_images.py b/tools/generate_text_images.py index cc09954c..fd0525b6 100644 --- a/tools/generate_text_images.py +++ b/tools/generate_text_images.py @@ -50,6 +50,8 @@ "theme": "سمة", "xToGoBack": "X للرجوع", "oToGoBack": "O للرجوع", + "sortAlphabetical": "ترتيب أبجدي", + "sortReverse": "ترتيب عكسي", }, "ja": { "jailbreak": "脱獄", @@ -67,6 +69,8 @@ "theme": "テーマ", "xToGoBack": "Xで戻る", "oToGoBack": "Oで戻る", + "sortAlphabetical": "アルファベット順", + "sortReverse": "逆順", }, "ko": { "jailbreak": "탈옥", @@ -84,6 +88,8 @@ "theme": "테마", "xToGoBack": "X로 뒤로 가기", "oToGoBack": "O로 뒤로 가기", + "sortAlphabetical": "알파벳순", + "sortReverse": "역순", }, "zh": { "jailbreak": "越狱", @@ -101,6 +107,8 @@ "theme": "主题", "xToGoBack": "按 X 返回", "oToGoBack": "按 O 返回", + "sortAlphabetical": "按字母排序", + "sortReverse": "逆序排序", }, }