feat: phantom mode
This commit is contained in:
1 parent
f6f511e43d
commit
6af064b2e8
15 files changed
+368
-25
No files matched your search
@@ -54,6 +54,24 @@
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<service
|
||||
android:name=".phantom.PhantomTileService"
|
||||
android:label="@string/ghost_mode"
|
||||
android:icon="@drawable/ic_camera_qs"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".phantom.PhantomShortcutActivity"
|
||||
android:exported="true"
|
||||
android:taskAffinity="${applicationId}.phantom"
|
||||
android:label="@string/ghost_mode"
|
||||
android:theme="@android:style/Theme.NoDisplay" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.hinnka.mycamera
|
||||
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
@@ -16,8 +16,16 @@ import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -53,9 +61,6 @@ import com.hinnka.mycamera.utils.BuglyHelper
|
||||
import com.hinnka.mycamera.utils.OrientationObserver
|
||||
import com.hinnka.mycamera.viewmodel.CameraViewModel
|
||||
import com.hinnka.mycamera.viewmodel.GalleryViewModel
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.hinnka.mycamera.utils.PLog
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* 路由常量
|
||||
@@ -107,20 +112,8 @@ class MainActivity : ComponentActivity() {
|
||||
ContextCompat.checkSelfPermission(this, it) == PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
intent?.getStringExtra("route")?.let {
|
||||
pendingRoute = it
|
||||
}
|
||||
handleIntent(intent)
|
||||
|
||||
lifecycleScope.launch {
|
||||
cameraViewModel.phantomMode.collect { phantomMode ->
|
||||
PLog.d("MainActivity", "phantomMode: $phantomMode")
|
||||
if (phantomMode) {
|
||||
MyCameraApplication.phantomService.start()
|
||||
} else {
|
||||
MyCameraApplication.phantomService.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setContent {
|
||||
PhotonCameraTheme {
|
||||
@@ -158,9 +151,17 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
handleIntent(intent)
|
||||
}
|
||||
|
||||
private fun handleIntent(intent: Intent?) {
|
||||
intent ?: return
|
||||
intent.getStringExtra("route")?.let {
|
||||
pendingRoute = it
|
||||
}
|
||||
intent.getBooleanExtra("show_ghost_permissions", false).let {
|
||||
cameraViewModel.showGhostPermissions = it
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideSystemUI() {
|
||||
|
||||
@@ -2,9 +2,15 @@ package com.hinnka.mycamera
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import android.content.Intent
|
||||
import com.hinnka.mycamera.data.ContentRepository
|
||||
import com.hinnka.mycamera.phantom.PhantomService
|
||||
import com.hinnka.mycamera.phantom.PhantomShortcutActivity
|
||||
import com.hinnka.mycamera.utils.BuglyHelper
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class MyCameraApplication : Application() {
|
||||
|
||||
@@ -14,10 +20,36 @@ class MyCameraApplication : Application() {
|
||||
BuglyHelper.init(this)
|
||||
ContentRepository.getInstance(this).initialize()
|
||||
phantomService = PhantomService(this)
|
||||
|
||||
val userPreferencesRepository = ContentRepository.getInstance(this).userPreferencesRepository
|
||||
MainScope().launch {
|
||||
userPreferencesRepository.userPreferences.map { it.phantomMode }.distinctUntilChanged()
|
||||
.collect { phantomMode ->
|
||||
if (phantomMode) {
|
||||
phantomService.start()
|
||||
} else {
|
||||
phantomService.stop()
|
||||
}
|
||||
updateShortcuts(phantomMode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateShortcuts(isActive: Boolean) {
|
||||
val shortcutManager = getSystemService(android.content.pm.ShortcutManager::class.java)
|
||||
val shortcut = android.content.pm.ShortcutInfo.Builder(this, "phantom_toggle")
|
||||
.setShortLabel(getString(if (isActive) R.string.close_ghost_mode else R.string.ghost_mode))
|
||||
.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_camera_shortcut))
|
||||
.setIntent(Intent(this, PhantomShortcutActivity::class.java).apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
})
|
||||
.build()
|
||||
shortcutManager.dynamicShortcuts = listOf(shortcut)
|
||||
}
|
||||
|
||||
companion object {
|
||||
lateinit var instance: MyCameraApplication
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
lateinit var phantomService: PhantomService
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ data class UserPreferences(
|
||||
val rawLuts: Map<String, String> = emptyMap(),
|
||||
val useP010: Boolean = false,
|
||||
val phantomMode: Boolean = false,
|
||||
val phantomButtonHidden: Boolean = false,
|
||||
val launchCameraOnPhantomMode: Boolean = false,
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -122,6 +124,8 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
private val LOG_CURVE = stringPreferencesKey("log_curve")
|
||||
private val USE_P010 = booleanPreferencesKey("use_p010")
|
||||
private val PHANTOM_MODE = booleanPreferencesKey("phantom_mode")
|
||||
private val PHANTOM_BUTTON_HIDDEN = booleanPreferencesKey("phantom_button_hidden")
|
||||
private val LAUNCH_CAMERA_ON_PHANTOM_MODE = booleanPreferencesKey("launch_camera_on_phantom_mode")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,6 +174,8 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
rawLuts = parseRawLuts(preferences),
|
||||
useP010 = preferences[USE_P010] ?: false,
|
||||
phantomMode = preferences[PHANTOM_MODE] ?: false,
|
||||
phantomButtonHidden = preferences[PHANTOM_BUTTON_HIDDEN] ?: false,
|
||||
launchCameraOnPhantomMode = preferences[LAUNCH_CAMERA_ON_PHANTOM_MODE] ?: false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -490,6 +496,7 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
preferences[BACKGROUND_IMAGE] = image
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存是否启用 GPU 加速
|
||||
*/
|
||||
@@ -561,4 +568,22 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
preferences[PHANTOM_MODE] = enabled
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存是否隐藏幻影模式悬浮按钮
|
||||
*/
|
||||
suspend fun savePhantomButtonHidden(hidden: Boolean) {
|
||||
context.dataStore.edit { preferences ->
|
||||
preferences[PHANTOM_BUTTON_HIDDEN] = hidden
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存是否在启动幻影模式时启动系统相机
|
||||
*/
|
||||
suspend fun saveLaunchCameraOnPhantomMode(launch: Boolean) {
|
||||
context.dataStore.edit { preferences ->
|
||||
preferences[LAUNCH_CAMERA_ON_PHANTOM_MODE] = launch
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.Recomposer
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -200,6 +201,22 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
|
||||
initComposeView()
|
||||
|
||||
ProcessLifecycleOwner.get().lifecycle.addObserver(appLifecycleObserver)
|
||||
|
||||
if (!ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||
showFloatingWindow()
|
||||
registerObserver()
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
userPreferencesRepository.userPreferences.map { it.phantomButtonHidden }.collect { hidden ->
|
||||
if (isWindowShown) {
|
||||
updateWindowParams(hidden)
|
||||
composeView?.let { windowManager.updateViewLayout(it, windowParams) }
|
||||
} else if (!ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
||||
showFloatingWindow()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val appLifecycleObserver = LifecycleEventObserver { _, event ->
|
||||
@@ -273,10 +290,31 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateWindowParams(hidden: Boolean) {
|
||||
if (hidden) {
|
||||
windowParams.width = 1
|
||||
windowParams.height = 1
|
||||
windowParams.flags = windowParams.flags or WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
||||
windowParams.alpha = 0f
|
||||
} else {
|
||||
windowParams.width = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
windowParams.flags = windowParams.flags and WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE.inv()
|
||||
windowParams.alpha = 1f
|
||||
}
|
||||
}
|
||||
|
||||
private fun initComposeView() {
|
||||
composeView = ComposeView(context).apply {
|
||||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||
setContent {
|
||||
val phantomButtonHiddenFlow = remember {
|
||||
userPreferencesRepository.userPreferences.map { it.phantomButtonHidden }
|
||||
}
|
||||
val phantomButtonHidden by phantomButtonHiddenFlow.collectAsState(initial = false)
|
||||
|
||||
if (phantomButtonHidden) return@setContent
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
|
||||
@@ -384,9 +422,13 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
|
||||
private fun showFloatingWindow() {
|
||||
if (!Settings.canDrawOverlays(context)) return
|
||||
if (isWindowShown) return
|
||||
composeView?.let {
|
||||
windowManager.addView(it, windowParams)
|
||||
isWindowShown = true
|
||||
lifecycleScope.launch {
|
||||
val hidden = userPreferencesRepository.userPreferences.map { it.phantomButtonHidden }.firstOrNull() ?: false
|
||||
updateWindowParams(hidden)
|
||||
composeView?.let {
|
||||
windowManager.addView(it, windowParams)
|
||||
isWindowShown = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.hinnka.mycamera.phantom
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.provider.MediaStore
|
||||
import android.provider.Settings
|
||||
import com.hinnka.mycamera.MainActivity
|
||||
import com.hinnka.mycamera.data.ContentRepository
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
class PhantomShortcutActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val userPreferencesRepository = ContentRepository.getInstance(this).userPreferencesRepository
|
||||
runBlocking {
|
||||
val currentMode = userPreferencesRepository.userPreferences.first().phantomMode
|
||||
val newMode = !currentMode
|
||||
|
||||
if (newMode && (!Settings.canDrawOverlays(this@PhantomShortcutActivity) || !Environment.isExternalStorageManager())) {
|
||||
val intent = Intent(this@PhantomShortcutActivity, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
putExtra("show_ghost_permissions", true)
|
||||
}
|
||||
startActivity(intent)
|
||||
} else {
|
||||
userPreferencesRepository.savePhantomMode(newMode)
|
||||
if (newMode) {
|
||||
val prefs = userPreferencesRepository.userPreferences.first()
|
||||
if (prefs.launchCameraOnPhantomMode) {
|
||||
try {
|
||||
val cameraIntent = Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
startActivity(cameraIntent)
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finish()
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.hinnka.mycamera.phantom
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import android.provider.MediaStore
|
||||
import android.service.quicksettings.Tile
|
||||
import android.service.quicksettings.TileService
|
||||
import androidx.core.service.quicksettings.PendingIntentActivityWrapper
|
||||
import androidx.core.service.quicksettings.TileServiceCompat
|
||||
import com.hinnka.mycamera.MainActivity
|
||||
import com.hinnka.mycamera.data.ContentRepository
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class PhantomTileService : TileService() {
|
||||
|
||||
private val serviceScope = CoroutineScope(Dispatchers.Main + Job())
|
||||
|
||||
override fun onStartListening() {
|
||||
super.onStartListening()
|
||||
val userPreferencesRepository = ContentRepository.getInstance(this).userPreferencesRepository
|
||||
serviceScope.launch {
|
||||
val phantomMode = userPreferencesRepository.userPreferences.first().phantomMode
|
||||
updateTileState(phantomMode)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick() {
|
||||
super.onClick()
|
||||
val userPreferencesRepository = ContentRepository.getInstance(this).userPreferencesRepository
|
||||
serviceScope.launch {
|
||||
val currentMode = userPreferencesRepository.userPreferences.first().phantomMode
|
||||
val newMode = !currentMode
|
||||
|
||||
if (newMode && (!android.provider.Settings.canDrawOverlays(this@PhantomTileService) || !android.os.Environment.isExternalStorageManager())) {
|
||||
val intent = Intent(this@PhantomTileService, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
putExtra("show_ghost_permissions", true)
|
||||
}
|
||||
TileServiceCompat.startActivityAndCollapse(
|
||||
this@PhantomTileService,
|
||||
PendingIntentActivityWrapper(
|
||||
this@PhantomTileService,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT,
|
||||
false
|
||||
)
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
|
||||
userPreferencesRepository.savePhantomMode(newMode)
|
||||
updateTileState(newMode)
|
||||
|
||||
if (newMode) {
|
||||
val prefs = userPreferencesRepository.userPreferences.first()
|
||||
if (prefs.launchCameraOnPhantomMode) {
|
||||
val cameraIntent = Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
}
|
||||
TileServiceCompat.startActivityAndCollapse(
|
||||
this@PhantomTileService,
|
||||
PendingIntentActivityWrapper(
|
||||
this@PhantomTileService,
|
||||
0,
|
||||
cameraIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTileState(isActive: Boolean) {
|
||||
val tile = qsTile ?: return
|
||||
tile.state = if (isActive) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
|
||||
tile.updateTile()
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,13 @@ fun CameraScreen(
|
||||
|
||||
var showGhostPermissionDialog by remember { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(viewModel.showGhostPermissions) {
|
||||
if (viewModel.showGhostPermissions) {
|
||||
showGhostPermissionDialog = true
|
||||
viewModel.showGhostPermissions = false
|
||||
}
|
||||
}
|
||||
|
||||
if (viewModel.showPaymentDialog) {
|
||||
val activity = context.findActivity()
|
||||
PaymentDialog(
|
||||
|
||||
@@ -309,7 +309,7 @@ fun QuickSettingButton(
|
||||
Text(
|
||||
text = title,
|
||||
color = Color.White,
|
||||
fontSize = 14.sp,
|
||||
fontSize = 10.sp,
|
||||
fontWeight = FontWeight.Normal
|
||||
)
|
||||
Icon(
|
||||
|
||||
@@ -78,6 +78,9 @@ fun SettingsScreen(
|
||||
val rawLut by viewModel.rawLut.collectAsState()
|
||||
val useP010 by viewModel.useP010.collectAsState()
|
||||
val isPurchased by viewModel.isPurchased.collectAsState()
|
||||
val phantomMode by viewModel.phantomMode.collectAsState()
|
||||
val phantomButtonHidden by viewModel.phantomButtonHidden.collectAsState()
|
||||
val launchCameraOnPhantomMode by viewModel.launchCameraOnPhantomMode.collectAsState()
|
||||
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
|
||||
@@ -511,6 +514,42 @@ fun SettingsScreen(
|
||||
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
|
||||
// 幻影模式设置
|
||||
SettingsSection(title = stringResource(R.string.ghost_mode)) {
|
||||
SwitchSettingItem(
|
||||
title = stringResource(R.string.ghost_mode),
|
||||
description = stringResource(R.string.ghost_mode_dialog_description),
|
||||
checked = phantomMode,
|
||||
onCheckedChange = { viewModel.togglePhantomMode() }
|
||||
)
|
||||
|
||||
HorizontalDivider(
|
||||
color = Color.White.copy(alpha = 0.1f),
|
||||
modifier = Modifier.padding(vertical = 8.dp)
|
||||
)
|
||||
|
||||
SwitchSettingItem(
|
||||
title = stringResource(R.string.settings_phantom_button_hidden),
|
||||
description = stringResource(R.string.settings_phantom_button_hidden_description),
|
||||
checked = phantomButtonHidden,
|
||||
onCheckedChange = { viewModel.setPhantomButtonHidden(it) }
|
||||
)
|
||||
|
||||
HorizontalDivider(
|
||||
color = Color.White.copy(alpha = 0.1f),
|
||||
modifier = Modifier.padding(vertical = 8.dp)
|
||||
)
|
||||
|
||||
SwitchSettingItem(
|
||||
title = stringResource(R.string.settings_launch_camera_on_phantom_mode),
|
||||
description = stringResource(R.string.settings_launch_camera_on_phantom_mode_description),
|
||||
checked = launchCameraOnPhantomMode,
|
||||
onCheckedChange = { viewModel.setLaunchCameraOnPhantomMode(it) }
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
|
||||
// 开发者选项
|
||||
SettingsSection(title = stringResource(R.string.settings_section_developer)) {
|
||||
// 日志收集按钮
|
||||
@@ -1209,6 +1248,7 @@ fun DefaultFocalLengthSetting(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 背景设置
|
||||
*/
|
||||
|
||||
@@ -175,6 +175,14 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
.map { it.phantomMode }
|
||||
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
|
||||
|
||||
val phantomButtonHidden: StateFlow<Boolean> = userPreferencesRepository.userPreferences
|
||||
.map { it.phantomButtonHidden }
|
||||
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
|
||||
|
||||
val launchCameraOnPhantomMode: StateFlow<Boolean> = userPreferencesRepository.userPreferences
|
||||
.map { it.launchCameraOnPhantomMode }
|
||||
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
|
||||
|
||||
// 软件处理参数 Flow
|
||||
val sharpening: Flow<Float> = userPreferencesRepository.userPreferences.map { it.sharpening }
|
||||
val noiseReduction: Flow<Float> = userPreferencesRepository.userPreferences.map { it.noiseReduction }
|
||||
@@ -202,6 +210,8 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
var burstImageCount by mutableStateOf(0)
|
||||
private set
|
||||
|
||||
var showGhostPermissions by mutableStateOf(false)
|
||||
|
||||
init {
|
||||
cameraController.initialize()
|
||||
cameraController.onImageCaptured = { image, captureInfo, characteristics, captureResult ->
|
||||
@@ -902,6 +912,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
reopenCamera()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否启用 Live Photo
|
||||
*/
|
||||
@@ -1757,4 +1768,16 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
userPreferencesRepository.savePhantomMode(newMode)
|
||||
}
|
||||
}
|
||||
|
||||
fun setPhantomButtonHidden(hidden: Boolean) {
|
||||
viewModelScope.launch {
|
||||
userPreferencesRepository.savePhantomButtonHidden(hidden)
|
||||
}
|
||||
}
|
||||
|
||||
fun setLaunchCameraOnPhantomMode(launch: Boolean) {
|
||||
viewModelScope.launch {
|
||||
userPreferencesRepository.saveLaunchCameraOnPhantomMode(launch)
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:viewportHeight="1024" android:viewportWidth="1024" android:width="24dp">
|
||||
|
||||
<path android:fillColor="#000000" android:pathData="M846.5,288.8 L733.7,288.8l-48.5,-116.7c-11.3,-27.1 -37.5,-44.6 -66.8,-44.6L408.8,127.5c-29.3,0 -55.6,17.5 -66.8,44.6l-48.5,116.7L180.6,288.8c-62.7,0 -113.7,51 -113.7,113.7l0,378.5c0,62.7 51,113.7 113.7,113.7l665.9,0c62.7,0 113.7,-51 113.7,-113.7L960.3,402.6C960.3,339.8 909.2,288.8 846.5,288.8zM918.9,781c0,39.9 -32.5,72.4 -72.4,72.4L180.6,853.4c-39.9,0 -72.4,-32.5 -72.4,-72.4L108.2,402.6c0,-39.9 32.5,-72.4 72.4,-72.4l126.6,0c8.4,0 15.9,-5 19.1,-12.7l53.8,-129.4c4.8,-11.6 16.1,-19.1 28.6,-19.1l209.6,0c12.6,0 23.8,7.5 28.6,19.1l53.8,129.4c3.2,7.7 10.7,12.7 19.1,12.7l126.6,0c39.9,0 72.4,32.5 72.4,72.4L918.9,781z"/>
|
||||
|
||||
<path android:fillColor="#000000" android:pathData="M513.6,349.8c-115.8,0 -210.1,94.2 -210.1,210.1s94.2,210.1 210.1,210.1 210.1,-94.2 210.1,-210.1S629.4,349.8 513.6,349.8zM513.6,728.7c-93,0 -168.7,-75.7 -168.7,-168.7s75.7,-168.7 168.7,-168.7c93,0 168.7,75.7 168.7,168.7S606.6,728.7 513.6,728.7z"/>
|
||||
|
||||
<path android:fillColor="#000000" android:pathData="M456.2,645c-28.3,-19.1 -45.2,-50.9 -45.2,-85 0,-11.4 -9.3,-20.7 -20.7,-20.7s-20.7,9.3 -20.7,20.7c0,47.9 23.7,92.5 63.4,119.3 3.5,2.4 7.6,3.5 11.6,3.5 6.6,0 13.2,-3.2 17.2,-9.1C468.2,664.2 465.7,651.4 456.2,645z"/>
|
||||
|
||||
<path android:fillColor="#000000" android:pathData="M263.7,381.1l-86.9,0c-11.4,0 -20.7,9.3 -20.7,20.7s9.3,20.7 20.7,20.7l86.9,0c11.4,0 20.7,-9.3 20.7,-20.7S275.2,381.1 263.7,381.1z"/>
|
||||
|
||||
</vector>
|
||||
@@ -320,10 +320,15 @@
|
||||
<string name="settings_color_space_description">选择 RAW 处理的目标色彩空间。</string>
|
||||
<string name="settings_log_curve">RAW 伽马</string>
|
||||
<string name="ghost_mode">幻影模式</string>
|
||||
<string name="close_ghost_mode">关闭幻影模式</string>
|
||||
<string name="ghost_mode_dialog_title">开启幻影模式</string>
|
||||
<string name="ghost_mode_dialog_description">开启后,App 将在后台自动为系统相机拍摄的照片(DCIM/Camera 目录)应用当前选择的 LUT 效果。</string>
|
||||
<string name="ghost_mode_permissions_required">需开启以下权限:</string>
|
||||
<string name="ghost_mode_overlay_permission">• 悬浮窗权限:允许 App 在后台稳定运行而不被系统清理,确保监测的连续性。</string>
|
||||
<string name="ghost_mode_file_permission">• 所有文件管理权限:准许 App 直接读写系统相机照片,为您提供无感的自动修图体验。</string>
|
||||
<string name="ghost_mode_dialog_confirm">同意并前往设置</string>
|
||||
<string name="settings_phantom_button_hidden">隐藏悬浮按钮</string>
|
||||
<string name="settings_phantom_button_hidden_description">在幻影模式下隐藏屏幕上的悬浮按钮。你仍可以通过快捷设置或应用快捷方式来控制。</string>
|
||||
<string name="settings_launch_camera_on_phantom_mode">启动系统相机</string>
|
||||
<string name="settings_launch_camera_on_phantom_mode_description">通过快捷设置或应用快捷方式开启幻影模式时,自动启动系统相机。</string>
|
||||
</resources>
|
||||
@@ -319,11 +319,16 @@
|
||||
<string name="settings_log_curve_description">Choose the transfer function for RAW processing (Log Curve).</string>
|
||||
<string name="settings_use_p010">P010 (10-bit YUV)</string>
|
||||
<string name="settings_use_p010_description">Enable 10-bit YUV output for better image data precision. Effective on supported devices when RAW is disabled.</string>
|
||||
<string name="ghost_mode">Ghost Mode</string>
|
||||
<string name="ghost_mode_dialog_title">Enable Ghost Mode</string>
|
||||
<string name="ghost_mode">Phantom Mode</string>
|
||||
<string name="close_ghost_mode">Close Phantom Mode</string>
|
||||
<string name="ghost_mode_dialog_title">Enable Phantom Mode</string>
|
||||
<string name="ghost_mode_dialog_description">When enabled, the app will automatically apply the current LUT to photos taken by the system camera (DCIM/Camera directory) in the background.</string>
|
||||
<string name="ghost_mode_permissions_required">Permissions required:</string>
|
||||
<string name="ghost_mode_overlay_permission">• Overlay Permission: Allows the app to run stably in the background to ensure continuous monitoring.</string>
|
||||
<string name="ghost_mode_file_permission">• All Files Access: Allows the app to read and write system camera photos for a seamless auto-editing experience.</string>
|
||||
<string name="ghost_mode_dialog_confirm">Agree and Go to Settings</string>
|
||||
<string name="settings_phantom_button_hidden">Hide Floating Button</string>
|
||||
<string name="settings_phantom_button_hidden_description">Hide the floating button in Phantom Mode. You can still control it via Quick Settings or App Shortcuts.</string>
|
||||
<string name="settings_launch_camera_on_phantom_mode">Launch System Camera</string>
|
||||
<string name="settings_launch_camera_on_phantom_mode_description">Automatically launch the system camera when enabling Phantom Mode via Quick Settings or App Shortcut.</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user