From 490d152e843e2c246da812893c27a9d464172a38 Mon Sep 17 00:00:00 2001 From: xiajiid Date: Sun, 8 Feb 2026 17:43:08 +0800 Subject: [PATCH] Remove location permissions and dependencies; switch to release build with signing for Huawei compatibility --- .github/workflows/gradle-publish.yml | 30 +++++++++++-- app/build.gradle | 3 -- app/src/main/AndroidManifest.xml | 3 -- .../java/com/example/app/CameraActivity.kt | 43 ++----------------- 4 files changed, 29 insertions(+), 50 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 97def9f..cd87be9 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -23,11 +23,33 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew assembleDebug + - name: Generate debug keystore for release signing + run: | + keytool -genkeypair \ + -keystore debug.keystore \ + -storepass android \ + -alias androiddebugkey \ + -keypass android \ + -keyalg RSA \ + -keysize 2048 \ + -validity 10000 \ + -dname "CN=Android Debug,O=Android,C=US" + + - name: Configure signing for release build + run: | + echo "android.enableJetifier=true" >> gradle.properties + echo "android.useAndroidX=true" >> gradle.properties + echo "org.gradle.parallel=true" >> gradle.properties + echo "android.debug.keystore=debug.keystore" >> gradle.properties + echo "android.debug.storePassword=android" >> gradle.properties + echo "android.debug.keyPassword=android" >> gradle.properties + echo "android.debug.keyAlias=androiddebugkey" >> gradle.properties + + - name: Build release APK + run: ./gradlew assembleRelease - name: Upload APK uses: actions/upload-artifact@v4 with: - name: app-debug - path: app/build/outputs/apk/debug/app-debug.apk + name: app-release + path: app/build/outputs/apk/release/app-release.apk \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 40e9624..d2f2d3d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -51,9 +51,6 @@ dependencies { // CameraX Extensions (Effects) - Optional implementation "androidx.camera:camera-extensions:${camerax_version}" - // Google Play Services for location - implementation 'com.google.android.gms:play-services-location:21.0.1' - testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 00aede0..bcb8d41 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,9 +6,6 @@ - - - diff --git a/app/src/main/java/com/example/app/CameraActivity.kt b/app/src/main/java/com/example/app/CameraActivity.kt index 73844ab..1b6aa8a 100644 --- a/app/src/main/java/com/example/app/CameraActivity.kt +++ b/app/src/main/java/com/example/app/CameraActivity.kt @@ -40,8 +40,7 @@ class CameraActivity : AppCompatActivity() { private const val TAG = "LogCam" private const val REQUEST_CODE_PERMISSIONS = 10 private val REQUIRED_PERMISSIONS = arrayOf( - Manifest.permission.CAMERA, - Manifest.permission.ACCESS_FINE_LOCATION + Manifest.permission.CAMERA ) } @@ -51,8 +50,6 @@ class CameraActivity : AppCompatActivity() { private lateinit var photoPreviewLayout: LinearLayout private var imageCapture: ImageCapture? = null private lateinit var cameraExecutor: ExecutorService - private var locationManagerHelper: LocationManagerHelper? = null - private var currentLocation: Location? = null // 存储拍摄的图片URI private val capturedImageUris = mutableListOf() @@ -272,42 +269,8 @@ class CameraActivity : AppCompatActivity() { } } - private fun getAddressFromLocation(location: Location): String { - val geocoder = Geocoder(this, Locale.getDefault()) - - return try { - val addresses = geocoder.getFromLocation( - location.latitude, - location.longitude, - 1 - ) - - if (addresses != null && addresses.isNotEmpty()) { - val address = addresses[0] - "${address.locality}, ${address.subLocality}, ${address.thoroughfare}" - } else { - "${location.latitude.roundToInt()}, ${location.longitude.roundToInt()}" - } - } catch (e: Exception) { - Log.e(TAG, "无法解析地址: ${e.message}") - "${location.latitude.roundToInt()}, ${location.longitude.roundToInt()}" - } - } - - private fun getLocationString(): String { - val location = getCurrentLocation() - return if (location != null) { - getAddressFromLocation(location) - } else { - "未知位置" - } - } - private fun addWatermarkToBitmap(originalBitmap: Bitmap): Bitmap { val timestamp = SimpleDateFormat("yyyy年-MM月-dd日 HH:mm:ss", Locale.getDefault()).format(Date()) - val location = getLocationString() - - val watermarkText = "$timestamp\n$location" val mutableBitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true) val canvas = Canvas(mutableBitmap) @@ -319,13 +282,13 @@ class CameraActivity : AppCompatActivity() { setShadowLayer(5f, 0f, 0f, Color.BLACK) } - val textWidth = paint.measureText(watermarkText) + val textWidth = paint.measureText(timestamp) val textHeight = paint.descent() - paint.ascent() val x = 20f val y = mutableBitmap.height - textHeight - 20f - canvas.drawText(watermarkText, x, y, paint) + canvas.drawText(timestamp, x, y, paint) return mutableBitmap }