mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3407 App | Tech | New debug menu + allow exporting work directory (#2122)
This commit is contained in:
parent
003929c4c2
commit
2d115aa64b
15 changed files with 376 additions and 23 deletions
|
@ -74,6 +74,7 @@ fun ProfileSettingsScreen(
|
|||
onKeychainPhraseClicked: () -> Unit,
|
||||
onLogoutClicked: () -> Unit,
|
||||
isLogoutInProgress: Boolean,
|
||||
isDebugEnabled: Boolean,
|
||||
onNameChange: (String) -> Unit,
|
||||
onProfileIconClick: () -> Unit,
|
||||
account: AccountProfile,
|
||||
|
@ -84,7 +85,9 @@ fun ProfileSettingsScreen(
|
|||
onMembershipClicked: () -> Unit,
|
||||
membershipStatus: MembershipStatus?,
|
||||
showMembership: ShowMembership?,
|
||||
clearProfileImage: () -> Unit
|
||||
clearProfileImage: () -> Unit,
|
||||
onDebugClicked: () -> Unit,
|
||||
onHeaderTitleClicked: () -> Unit
|
||||
) {
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
|
@ -97,7 +100,8 @@ fun ProfileSettingsScreen(
|
|||
account = account,
|
||||
onNameSet = onNameChange,
|
||||
onProfileIconClick = onProfileIconClick,
|
||||
clearProfileImage = clearProfileImage
|
||||
clearProfileImage = clearProfileImage,
|
||||
onTitleClicked = onHeaderTitleClicked
|
||||
)
|
||||
}
|
||||
item {
|
||||
|
@ -163,6 +167,18 @@ fun ProfileSettingsScreen(
|
|||
onClick = onAboutClicked
|
||||
)
|
||||
}
|
||||
if (isDebugEnabled) {
|
||||
item {
|
||||
Divider(paddingStart = 60.dp)
|
||||
}
|
||||
item {
|
||||
Option(
|
||||
image = R.drawable.ic_debug,
|
||||
text = stringResource(R.string.debug),
|
||||
onClick = onDebugClicked
|
||||
)
|
||||
}
|
||||
}
|
||||
item {
|
||||
Divider(paddingStart = 60.dp)
|
||||
}
|
||||
|
@ -277,7 +293,8 @@ private fun Header(
|
|||
account: AccountProfile,
|
||||
onProfileIconClick: () -> Unit,
|
||||
onNameSet: (String) -> Unit,
|
||||
clearProfileImage: () -> Unit
|
||||
clearProfileImage: () -> Unit,
|
||||
onTitleClicked: () -> Unit
|
||||
) {
|
||||
when (account) {
|
||||
is AccountProfile.Data -> {
|
||||
|
@ -285,7 +302,7 @@ private fun Header(
|
|||
Dragger()
|
||||
}
|
||||
Box(modifier = modifier.padding(top = 12.dp, bottom = 28.dp)) {
|
||||
ProfileTitleBlock()
|
||||
ProfileTitleBlock(onTitleClicked)
|
||||
}
|
||||
Box(modifier = modifier.padding(bottom = 16.dp)) {
|
||||
ProfileImageBlock(
|
||||
|
@ -389,11 +406,16 @@ fun ProfileNameBlock(
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun ProfileTitleBlock() {
|
||||
fun ProfileTitleBlock(
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.profile),
|
||||
style = Title1,
|
||||
color = colorResource(id = R.color.text_primary)
|
||||
color = colorResource(id = R.color.text_primary),
|
||||
modifier = Modifier.noRippleClickable {
|
||||
onClick()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -519,7 +541,10 @@ private fun ProfileSettingPreview() {
|
|||
onMembershipClicked = {},
|
||||
membershipStatus = null,
|
||||
showMembership = ShowMembership(true),
|
||||
clearProfileImage = {}
|
||||
clearProfileImage = {},
|
||||
onDebugClicked = {},
|
||||
isDebugEnabled = true,
|
||||
onHeaderTitleClicked = {}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -48,11 +48,15 @@ class ProfileSettingsViewModel(
|
|||
|
||||
private val jobs = mutableListOf<Job>()
|
||||
|
||||
private var headerTitleClickCount = 0
|
||||
|
||||
val isLoggingOut = MutableStateFlow(false)
|
||||
val debugSyncReportUri = MutableStateFlow<Uri?>(null)
|
||||
val membershipStatusState = MutableStateFlow<MembershipStatus?>(null)
|
||||
val showMembershipState = MutableStateFlow<ShowMembership?>(null)
|
||||
|
||||
val isDebugEnabled = MutableStateFlow(false)
|
||||
|
||||
val profileData = profileContainer.observe().map { obj ->
|
||||
AccountProfile.Data(
|
||||
name = obj.name.orEmpty(),
|
||||
|
@ -166,6 +170,13 @@ class ProfileSettingsViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun onHeaderTitleClicked() {
|
||||
headerTitleClickCount = headerTitleClickCount + 1
|
||||
if (headerTitleClickCount >= ENABLE_DEBUG_MENU_CLICK_COUNT && isDebugEnabled.value == false) {
|
||||
isDebugEnabled.value = true
|
||||
}
|
||||
}
|
||||
|
||||
class Factory(
|
||||
private val analytics: Analytics,
|
||||
private val container: StorelessSubscriptionContainer,
|
||||
|
@ -194,6 +205,10 @@ class ProfileSettingsViewModel(
|
|||
) as T
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ENABLE_DEBUG_MENU_CLICK_COUNT = 5
|
||||
}
|
||||
}
|
||||
|
||||
private const val STOP_SUBSCRIPTION_TIMEOUT = 1_000L
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue