diff --git a/Dockerfile.android b/Dockerfile.android index c9be803..65fee64 100644 --- a/Dockerfile.android +++ b/Dockerfile.android @@ -40,8 +40,82 @@ RUN npm install COPY . . 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 = \` + + + +\`; + 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', + '#FFFFFF'); + + // 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.0"/versionName "1.0.1"/' /workspace/android/app/build.gradle +RUN sed -i 's/versionName "1.0"/versionName "1.0.1"/' /workspace/android/app/build.gradle WORKDIR /workspace/android RUN chmod +x gradlew diff --git a/十二章服饰.apk b/十二章服饰.apk index 1239e2b..4f3a96e 100644 Binary files a/十二章服饰.apk and b/十二章服饰.apk differ