Skip to content

Commit

Permalink
/get: Support Android Direct .apk
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Mar 21, 2024
1 parent b83cb0b commit 784a8e9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
9 changes: 5 additions & 4 deletions public/get/unsupported.html → public/get/android.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MyTonWallet Desktop</title>
<title>MyTonWallet for Android</title>
<script src="./index.js"></script>
<link rel="stylesheet" href="./index.css">
</head>
Expand All @@ -12,10 +12,11 @@
<div class="logo-container">
<div class="logo mytonwallet-logo"></div>
</div>
<h1>MyTonWallet for Desktop</h1>
<div class="info">Open this page from Mac, PC or Linux<br/>to install MyTonWallet.</div>
<a href="javascript:redirectToWeb();" class="download-btn single">Open Web Version</a>
<h1>MyTonWallet for Android</h1>
<a href="javascript:redirectToStore('Android');" class="download-btn single">Download from Google Play</a>
<a href="javascript:downloadAndroidDirect();" class="download-btn single">Download MyTonWallet.apk</a>
<div class="footer">
<div class="version">&nbsp;</div>
<a href="javascript:redirectToFullList();">Other platforms</a>
· <a href="https://mytonwallet.io">mytonwallet.io</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion public/get/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MyTonWallet Desktop</title>
<title>MyTonWallet Connect</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
Expand Down
4 changes: 4 additions & 0 deletions public/get/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ body {
margin: 32px 0;
}

.download-btn.single ~ .download-btn.single {
margin-top: -12px;
}

.footer {
font-size: small;
color: #A9A9A9;
Expand Down
45 changes: 25 additions & 20 deletions public/get/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const REPO = 'mytonwalletorg/mytonwallet';
const LATEST_RELEASE_API_URL = `https://api.github.com/repos/${REPO}/releases/latest`;
const LATEST_RELEASE_WEB_URL = `https://github.com/${REPO}/releases/latest`;
const LATEST_RELEASE_DOWNLOAD_URL = `https://github.com/${REPO}/releases/download/v%VERSION%`;
const WEB_APP_URL = '/';
const MOBILE_URLS = {
ios: 'https://apps.apple.com/ru/app/mytonwallet-anyway-ton-wallet/id6464677844',
android: 'https://play.google.com/store/apps/details?id=org.mytonwallet.app',
androidDirect: `${LATEST_RELEASE_DOWNLOAD_URL}/MyTonWallet.apk`,
};

const platform = getPlatform();
const currentPage = location.href.includes('mac.html')
? 'mac'
: location.href.includes('unsupported.html')
? 'unsupported'
const currentPage = location.href.includes('/android')
? 'android'
: location.href.includes('/mac')
? 'mac'
: 'index';

// Request the latest release information from GitHub
Expand Down Expand Up @@ -52,20 +54,17 @@ const packagesPromise = fetch(LATEST_RELEASE_API_URL)
});

(function init() {
if (['Windows', 'Linux', 'iOS', 'Android'].includes(platform)) {
if (currentPage === 'index') {
if (currentPage === 'index') {
if (['Windows', 'Linux', 'iOS'].includes(platform)) {
setupDownloadButton();
setupVersion();
}
} else if (platform === 'macOS') {
if (currentPage !== 'mac') {
} else if (platform === 'Android') {
redirectToAndroid();
} else if (platform === 'macOS') {
redirectToMac();
} else {
setupVersion();
}
} else if (currentPage !== 'unsupported') {
redirectToUnsupported();
}

setupVersion();
}());

function getPlatform() {
Expand Down Expand Up @@ -122,12 +121,12 @@ function setupVersion() {
});
}

function redirectToMac() {
location.href = './mac.html';
function redirectToAndroid() {
location.href = './android';
}

function redirectToUnsupported() {
location.href = './unsupported.html';
function redirectToMac() {
location.href = './mac';
}

function redirectToWeb() {
Expand All @@ -147,15 +146,21 @@ function downloadDefault() {
download('win');
} else if (platform === 'Linux') {
download('linux');
} else if (platform === 'Android') {
redirectToAndroid();
} else if (platform === 'macOS') {
redirectToMac();
} else if (platform === 'iOS' || platform === 'Android') {
redirectToStore(platform);
} else {
redirectToUnsupported();
}
}

function downloadAndroidDirect() {
packagesPromise.then((packages) => {
location.href = MOBILE_URLS.androidDirect.replace('%VERSION%', packages.$version);
});
}

function download(platformKey) {
packagesPromise.then((packages) => {
location.href = packages[platformKey];
Expand Down

0 comments on commit 784a8e9

Please sign in to comment.