Skip to content

Commit

Permalink
fix(hw-642): Android app crashes when RTL enabled (#2077)
Browse files Browse the repository at this point in the history
Co-authored-by: iGroza <[email protected]>
  • Loading branch information
iGroza and iGroza authored Aug 29, 2024
1 parent 98ce252 commit f9eb4e7
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 53 deletions.
15 changes: 14 additions & 1 deletion assets/locales/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"StakingInfoUnDelegationDay": " ({{day}} day left)",
"StakingInfoUnDelegationDays": " ({{days}} days left)",
"Welcome_haqq_pin": "Welcome to HAQQ Wallet",
"_hash": "4fd37808dc9c0b8dd789da69c848b4957dced3343710c86f8f4034e11cd9c06e",
"_hash": "24f6a3ed5f0c1c2eb36ac4f6dd85a8d71cd1daf476d6f43e494c54e5b9d81a06",
"accept": "Accept",
"accountInfoNftTabTitle": "NFTs",
"accountInfoTokensTabTitle": "Tokens",
Expand Down Expand Up @@ -338,6 +338,19 @@
"lockedTokensVested": "Vested: {{count}}",
"lockedTokensVestedAvailableIn": " (Will be available in: {{value}})",
"low": "Low",
"markupAdAmbasadorTitle": "Ambassador Program",
"markupAdAmbassadorDescription": "Together, we are creating the largest online community promoting Islamic values in crypto.",
"markupAdBuyWithFiatDescription": "Purchase ISLM with cash at the best price through a reliable provider",
"markupAdBuyWithFiatTitle": "Buy ISLM with fiat",
"markupAdExpeditionDescription": "Complete quests & get rewards",
"markupAdExpeditionTitle": "Join HAQQ Expedition Vol.2",
"markupAdFruitTitle": "Fruits of Jannah NFT collection is minting now",
"markupAdPurchaseOptionsDescription": "List of platforms where you can purchase Islamic Coin",
"markupAdPurchaseOptionsTitle": "ISLM Purchase Options",
"markupAdStakingDescription": "Delegate your ISLM and get rewarded for your contribution to network security",
"markupAdStakingTitle": "Staking",
"markupAdSurveyDescription": "Complete & Get Rewarded",
"markupAdSurveyTitle": "Survey: HAQQCommunity Compass",
"maxBaseFee": "Max Base Fee",
"maxBaseFeeDescription": "The max fee is the most you'll pay (base fee + priority fee. We have updated the gas fee based on current network conditions and have increased it by at least 10% (required by the network).",
"maxBaseFeeGWei": "Max Base Fee (GWei)",
Expand Down
4 changes: 3 additions & 1 deletion assets/locales/tr/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"StakingInfoUnDelegationDay": "({{day}} gün kaldı)",
"StakingInfoUnDelegationDays": "({{days}} gün kaldı)",
"Welcome_haqq_pin": "HAQQ Cüzdanına Hoş Geldiniz",
"_hash": "1d431c9db691ddd3bd8e4995316416f0439660035e6477cd7219a58214c44c02",
"_hash": "3679f2a32c3760b653e61e4f155515f6a04fdd462112674e8893965473cfcf78",
"accept": "Kabul Et",
"accountInfoNftTabTitle": "NFT’ler",
"accountInfoTokensTabTitle": "Tokenlar",
Expand Down Expand Up @@ -338,6 +338,8 @@
"lockedTokensVested": "Yatırılmış: {{count}}",
"lockedTokensVestedAvailableIn": " (Kullanılabilir olacak: {{value}})",
"low": "Düşük",
"markupAdAmbasadorTitle": "Büyükelçi Programı",
"markupAdAmbassadorDescription": "Birlikte, kriptoda İslami değerleri teşvik eden en büyük çevrimiçi topluluğu oluşturuyoruz.",
"maxBaseFee": "Maksimum Taban Ücreti",
"maxBaseFeeDescription": "Maksimum ücret, ödeyeceğiniz en fazla tutardır (taban ücreti + öncelik ücreti). Ağ koşullarına göre gas ücretini güncelledik ve en az %10 artırdık (ağ tarafından gerekli).",
"maxBaseFeeGWei": "Maksimum Taban Ücreti (GWei)",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"detox:android:test": "detox test --configuration android.sim.release --loglevel warn --cleanup --record-videos failing --take-screenshots failing --record-logs failing",
"detox:android": "yarn detox:android:build && yarn detox:android:test",
"clean-ios-app": "sh ./scripts/clean-ios-app.sh",
"clean-android-app": "sh ./scripts/clean-android-app.sh",
"clean-android-app": "yarn zx ./scripts/clean-android-app.mjs",
"devmode:ios": "xcrun simctl openurl booted haqq:enableDeveloperMode:true",
"devmode:android": "adb shell am start -a android.intent.action.VIEW -d haqq:enableDeveloperMode:true",
"clean": "sh ./scripts/clean.sh",
Expand Down
60 changes: 60 additions & 0 deletions scripts/clean-android-app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env zx

import {$, spinner, chalk} from 'zx';

const APP_PACKAGE_NAME = 'com.haqq.wallet';

const cleanAndroidApp = async () => {
try {
const isAppInstalled = await spinner(
'🔍 Checking if app is installed',
async () => {
await $`adb shell pm list packages ${APP_PACKAGE_NAME}`;
},
);

if (isAppInstalled?.stdout?.trim?.() === '') {
await spinner('📲 Installing app', async () => {
await $`adb install -f -r -t ./android/app/build/outputs/apk/debug/app-debug.apk`;
});
} else {
await spinner('🛑 Stopping app', async () => {
await $`adb shell am force-stop ${APP_PACKAGE_NAME}`;
});

await spinner('🧹 Clearing app data', async () => {
await $`adb shell pm clear ${APP_PACKAGE_NAME}`;
});

await spinner('📦 Extracting APK', async () => {
const apkPath =
await $`adb shell pm path ${APP_PACKAGE_NAME} | sed -e "s/package://"`;
await $`adb pull ${apkPath.stdout.trim()} /tmp/app.apk`;
});

await spinner('🗑️ Uninstalling app', async () => {
await $`adb uninstall ${APP_PACKAGE_NAME}`;
});

await spinner('📲 Reinstalling app', async () => {
await $`adb install -f -r -t /tmp/app.apk`;
});

await spinner('🧼 Cleaning up', async () => {
await $`rm /tmp/app.apk`;
});
}

await spinner('🚀 Launching app', async () => {
await $`yarn devmode:android`;
});

console.log(
chalk.green('✅ Android app cleaned and reinstalled successfully!'),
);
} catch (error) {
console.error(chalk.red(`❌ An error occurred: ${error.message}`));
}
};

await cleanAndroidApp();
44 changes: 0 additions & 44 deletions scripts/clean-android-app.sh

This file was deleted.

5 changes: 3 additions & 2 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Language} from '@app/models/language';
import {AppLanguage} from '@app/types';

import {app} from './contexts';
import {setRTL} from './utils';

import en from '../assets/locales/en/en.json';

Expand Down Expand Up @@ -1062,7 +1063,7 @@ export const supportedTranslationsMap: {[key in AppLanguage]: NodeRequire} = {
en: require('../assets/locales/en/en.json'),
tr: require('../assets/locales/tr/tr.json'),
id: require('../assets/locales/id/id.json'),
// ar: require('../assets/locales/ar/ar.json'),
ar: require('../assets/locales/ar/ar.json'),
// ru: require('../assets/locales/ru/ru.json'),
};

Expand All @@ -1077,5 +1078,5 @@ export function setLanguage(lang: AppLanguage, keys?: Object) {
translations.setContent({[lang]: keys ?? supportedTranslationsMap[lang]});
translations.setLanguage(lang);
app.emit(Events.onLocaleChanged, lang);
// setRTL(lang);
setRTL(lang);
}
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ export enum AppLanguage {
en = 'en',
tr = 'tr',
id = 'id',
// ar = 'ar',
ar = 'ar',
// ru = 'ru',
}

Expand Down
4 changes: 1 addition & 3 deletions src/variables/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,4 @@ export const SUPPORTED_UR_TYPE = {

export const KEYSTONE_NAME = 'Keystone';

export const RTL_LANGUAGES: AppLanguage[] = [
// AppLanguage.ar
];
export const RTL_LANGUAGES: AppLanguage[] = [AppLanguage.ar];

0 comments on commit f9eb4e7

Please sign in to comment.