Skip to content
Closed
Binary file added src/download0/img/text/ar/sortAlphabetical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/download0/img/text/ar/sortReverse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/download0/img/text/ja/sortAlphabetical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/download0/img/text/ja/sortReverse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/download0/img/text/ko/sortAlphabetical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/download0/img/text/ko/sortReverse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/download0/img/text/zh/sortAlphabetical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/download0/img/text/zh/sortReverse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 27 additions & 1 deletion src/download0/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export const lang: Record<string, string> = {
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
Expand Down Expand Up @@ -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':
Expand All @@ -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':
Expand All @@ -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':
Expand All @@ -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':
Expand All @@ -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':
Expand All @@ -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':
Expand All @@ -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':
Expand All @@ -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':
Expand All @@ -210,6 +228,8 @@ switch (detectedLocale) {
lang.theme = 'سمة'
lang.xToGoBack = 'X للرجوع'
lang.oToGoBack = 'O للرجوع'
lang.sortAlphabetical = 'ترتيب أبجدي'
lang.sortReverse = 'ترتيب عكسي'
break

case 'ja':
Expand All @@ -229,6 +249,8 @@ switch (detectedLocale) {
lang.theme = 'テーマ'
lang.xToGoBack = 'Xで戻る'
lang.oToGoBack = 'Oで戻る'
lang.sortAlphabetical = 'アルファベット順'
lang.sortReverse = '逆順'
break

case 'ko':
Expand All @@ -248,6 +270,8 @@ switch (detectedLocale) {
lang.theme = '테마'
lang.xToGoBack = 'X로 뒤로 가기'
lang.oToGoBack = 'O로 뒤로 가기'
lang.sortAlphabetical = '알파벳순'
lang.sortReverse = '역순'
break

case 'zh':
Expand All @@ -267,6 +291,8 @@ switch (detectedLocale) {
lang.theme = '主题'
lang.xToGoBack = '按 X 返回'
lang.oToGoBack = '按 O 返回'
lang.sortAlphabetical = '按字母排序'
lang.sortReverse = '逆序排序'
break

case 'en':
Expand Down
131 changes: 98 additions & 33 deletions src/download0/themes/default/payload_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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]
Expand Down Expand Up @@ -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()
}
}

Expand Down
8 changes: 8 additions & 0 deletions tools/generate_text_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"theme": "سمة",
"xToGoBack": "X للرجوع",
"oToGoBack": "O للرجوع",
"sortAlphabetical": "ترتيب أبجدي",
"sortReverse": "ترتيب عكسي",
},
"ja": {
"jailbreak": "脱獄",
Expand All @@ -67,6 +69,8 @@
"theme": "テーマ",
"xToGoBack": "Xで戻る",
"oToGoBack": "Oで戻る",
"sortAlphabetical": "アルファベット順",
"sortReverse": "逆順",
},
"ko": {
"jailbreak": "탈옥",
Expand All @@ -84,6 +88,8 @@
"theme": "테마",
"xToGoBack": "X로 뒤로 가기",
"oToGoBack": "O로 뒤로 가기",
"sortAlphabetical": "알파벳순",
"sortReverse": "역순",
},
"zh": {
"jailbreak": "越狱",
Expand All @@ -101,6 +107,8 @@
"theme": "主题",
"xToGoBack": "按 X 返回",
"oToGoBack": "按 O 返回",
"sortAlphabetical": "按字母排序",
"sortReverse": "逆序排序",
},
}

Expand Down