Remove location permissions and dependencies; switch to release build with signing for Huawei compatibility
This commit is contained in:
30
.github/workflows/gradle-publish.yml
vendored
30
.github/workflows/gradle-publish.yml
vendored
@@ -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
|
||||
@@ -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'
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
<!-- 相机权限 -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<!-- 位置权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
||||
<!-- 硬件功能声明 -->
|
||||
<uses-feature android:name="android.hardware.camera" android:required="true" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
||||
|
||||
@@ -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<Uri>()
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user