Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 65ad0d8166 | |||
| e8e1a2bb69 | |||
| 937cea5f9d |
@@ -38,7 +38,84 @@ COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
RUN npm run build && npx cap add android && npx cap sync android
|
||||
RUN npm run build && npx cap add android && npx cap copy android && npx cap sync android
|
||||
|
||||
# Generate and copy custom icons to Android res/ AFTER cap sync
|
||||
RUN node -e "
|
||||
const sharp = require('sharp');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
async function gen() {
|
||||
const src = 'public/icons/icon.png';
|
||||
|
||||
// sizes for each mipmap density
|
||||
const densities = [
|
||||
{ suffix: 'mdpi', size: 48 },
|
||||
{ suffix: 'hdpi', size: 72 },
|
||||
{ suffix: 'xhdpi', size: 96 },
|
||||
{ suffix: 'xxhdpi', size: 144 },
|
||||
{ suffix: 'xxxhdpi', size: 192 }
|
||||
];
|
||||
|
||||
const base = '/workspace/android/app/src/main/res';
|
||||
|
||||
// Generate regular icons (with white background) - these are used for API < 26
|
||||
for (const d of densities) {
|
||||
const dir = base + '/mipmap-' + d.suffix + '-v4';
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
|
||||
// ic_launcher and ic_launcher_round: full logo with white bg
|
||||
const icon = await sharp(src)
|
||||
.resize(d.size, d.size, { fit: 'contain', background: '#ffffff' })
|
||||
.png()
|
||||
.toBuffer();
|
||||
fs.writeFileSync(dir + '/ic_launcher.png', icon);
|
||||
fs.writeFileSync(dir + '/ic_launcher_round.png', icon);
|
||||
|
||||
// foreground for adaptive icon (transparent bg, scaled 4x)
|
||||
const fgSize = d.size * 4;
|
||||
const logo = await sharp(src)
|
||||
.resize(fgSize, fgSize, { fit: 'contain', background: { r: 0, g: 0, b: 0, alpha: 0 } })
|
||||
.png()
|
||||
.toBuffer();
|
||||
fs.writeFileSync(dir + '/ic_launcher_foreground.png', logo);
|
||||
}
|
||||
|
||||
// Create mipmap-anydpi-v26 (adaptive icon config)
|
||||
const v26Dir = base + '/mipmap-anydpi-v26';
|
||||
fs.mkdirSync(v26Dir, { recursive: true });
|
||||
|
||||
const adXml = \`<?xml version=\"1.0\" encoding=\"utf-8\"?>
|
||||
<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">
|
||||
<background android:drawable=\"@color/ic_launcher_background\"/>
|
||||
<foreground android:drawable=\"@mipmap/ic_launcher_foreground\"/>
|
||||
</adaptive-icon>\`;
|
||||
fs.writeFileSync(v26Dir + '/ic_launcher.xml', adXml);
|
||||
fs.writeFileSync(v26Dir + '/ic_launcher_round.xml', adXml);
|
||||
|
||||
// Color for background
|
||||
const valuesDir = base + '/values';
|
||||
fs.mkdirSync(valuesDir, { recursive: true });
|
||||
fs.writeFileSync(valuesDir + '/colors.xml',
|
||||
'<?xml version=\"1.0\" encoding=\"utf-8\"?><resources><color name=\"ic_launcher_background\">#FFFFFF</color></resources>');
|
||||
|
||||
// Create drawable for foreground on API < 26 (use same as mipmap)
|
||||
const drawDir = base + '/drawable';
|
||||
fs.mkdirSync(drawDir, { recursive: true });
|
||||
const fgDraw = await sharp(src)
|
||||
.resize(48, 48, { fit: 'contain', background: { r: 0, g: 0, b: 0, alpha: 0 } })
|
||||
.png()
|
||||
.toBuffer();
|
||||
fs.writeFileSync(drawDir + '/ic_launcher_foreground.png', fgDraw);
|
||||
|
||||
console.log('Icons copied successfully!');
|
||||
}
|
||||
gen().catch(e => { console.error(e); process.exit(1); });
|
||||
"
|
||||
|
||||
# Patch version to 1.0.1
|
||||
RUN sed -i 's/versionName "1.0"/versionName "1.0.1"/' /workspace/android/app/build.gradle
|
||||
|
||||
WORKDIR /workspace/android
|
||||
RUN chmod +x gradlew
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
"allowMixedContent": true,
|
||||
"icon": "public/icons/icon.png",
|
||||
"adaptiveIcon": {
|
||||
"foreground": "public/icons/ic_launcher_foreground.png",
|
||||
"background": "public/icons/ic_launcher_background.png"
|
||||
"foreground": "public/icons/ic_launcher_foreground_clean.png",
|
||||
"background": "public/icons/ic_launcher_background_white.png"
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
|
||||
BIN
public/icons/ic_launcher_background_white.png
Normal file
BIN
public/icons/ic_launcher_background_white.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
public/icons/ic_launcher_foreground_clean.png
Normal file
BIN
public/icons/ic_launcher_foreground_clean.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Reference in New Issue
Block a user