Skip to content

Commit

Permalink
VersionCode: 40
Browse files Browse the repository at this point in the history
Opt Prevent text from being obscured
Some other optimizes
  • Loading branch information
Z-Siqi committed Nov 24, 2023
1 parent f43ae5f commit 9695841
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 67 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.sqz.writingboard"
minSdk 29
targetSdk 34
versionCode 39
versionName "0.3.0"
versionCode 40
versionName "0.4.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 39,
"versionName": "0.3.0",
"versionCode": 40,
"versionName": "0.4.0",
"outputFile": "app-release.apk"
}
],
Expand Down
143 changes: 106 additions & 37 deletions app/src/main/java/com/sqz/writingboard/ui/WritingBoardLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.Surface
Expand Down Expand Up @@ -124,24 +126,44 @@ fun WritingBoardLayout(navController: NavController, modifier: Modifier = Modifi
Box {
//for bottom style
val boardBottom = if (
(valueState.editingHorizontalScreen) ||
(readButtonStyle != 2)
(!valueState.editingHorizontalScreen) &&
(readButtonStyle == 1) &&
(!valueState.isEditing) &&
(screenController)
) {
modifier.padding(bottom = 60.dp)
} else if (
(valueState.isEditing) &&
(readButtonStyle == 2) &&
(!valueState.editingHorizontalScreen)
) {
modifier
} else if (valueState.isEditing) {
modifier.padding(bottom = 55.dp)
} else {
} else if (
(valueState.isEditing) &&
(screenController) &&
(!valueState.editingHorizontalScreen)
) {
modifier.padding(bottom = 45.dp)
} else if (
(readButtonStyle == 2) &&
(!valueState.editingHorizontalScreen)
) {
modifier.padding(bottom = 70.dp)
} else {
modifier
}
//for horizontal screen
val horizontalScreen = if (valueState.editingHorizontalScreen) {
modifier.padding(start = 25.dp, end = 25.dp, top = 5.dp, bottom = 4.dp)
} else {
modifier.padding(20.dp)
}
//for always visible test
if (readAlwaysVisibleText) {
if (scrollState.value == scrollState.maxValue && !valueState.isEditing) {
//for calculate always visible test
if (readAlwaysVisibleText && readButtonStyle != 2) {
if (
(scrollState.value == scrollState.maxValue) &&
(scrollState.canScrollBackward)
) {
Handler(Looper.getMainLooper()).postDelayed(50) {
if (scrollState.value == scrollState.maxValue) {
Handler(Looper.getMainLooper()).postDelayed(50) {
Expand All @@ -153,18 +175,14 @@ fun WritingBoardLayout(navController: NavController, modifier: Modifier = Modifi
screenController = false
}
}
val screen = if (screenController) {
modifier.padding(bottom = 60.dp)
} else {
modifier
}
//writing board
Column(
modifier = modifier.animateContentSize(
animationSpec = spring(
dampingRatio = Spring.DampingRatioLowBouncy,
stiffness = Spring.StiffnessMediumLow
)
) then boardBottom then horizontalScreen then screen
) then boardBottom then horizontalScreen
.shadow(5.dp, RoundedCornerShape(26.dp))
.border(
4.dp,
Expand Down Expand Up @@ -210,34 +228,85 @@ fun WritingBoardLayout(navController: NavController, modifier: Modifier = Modifi
(readButtonStyle == 2) &&
(valueState.editingHorizontalScreen) && (valueState.isEditing)
) {
Column(
modifier = modifier
.fillMaxSize()
.padding(36.dp),
verticalArrangement = Arrangement.Bottom,
horizontalAlignment = Alignment.End
) {
//clean all text button
if (readCleanAllText) {
if (!readAlwaysVisibleText) {
Column(
modifier = modifier
.fillMaxSize()
.padding(36.dp),
verticalArrangement = Arrangement.Bottom,
horizontalAlignment = Alignment.End
) {
//clean all text button
if (readCleanAllText) {
FloatingActionButton(onClick = {
valueState.cleanAllText = true
}) {
Icon(
imageVector = Icons.Filled.Delete,
contentDescription = "Clean all texts"
)
}
}
//done button
Spacer(modifier = modifier.height(10.dp))
FloatingActionButton(onClick = {
valueState.cleanAllText = true
valueState.matchText = true
valueState.doneAction = true
}) {
Icon(
imageVector = Icons.Filled.Delete,
contentDescription = "Clean all texts"
imageVector = Icons.Filled.Done,
contentDescription = "Done"
)
}
}
//done button
Spacer(modifier = modifier.height(10.dp))
FloatingActionButton(onClick = {
valueState.matchText = true
valueState.doneAction = true
}) {
Icon(
imageVector = Icons.Filled.Done,
contentDescription = "Done"
)
} else {
val bottom = if (screenController) {
2.dp
} else {
25.dp
}
Column(
modifier = modifier.fillMaxWidth().height(30.dp),
horizontalAlignment = Alignment.End,
verticalArrangement = Arrangement.Bottom
) {
ExtendedFloatingActionButton(
modifier = modifier
.padding(10.dp)
.padding(end = 26.dp, bottom = bottom)
.size(80.dp, 45.dp),
onClick = {
valueState.matchText = true
valueState.doneAction = true
},
shape = RoundedCornerShape(8.dp)
) {
Icon(
imageVector = Icons.Filled.Done,
contentDescription = "Done"
)
}
}
if (readCleanAllText) {
Column(
modifier = modifier.fillMaxWidth().height(30.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Bottom
) {
FloatingActionButton(
modifier = modifier
.padding(10.dp)
.padding(start = 50.dp, bottom = bottom)
.size(45.dp, 45.dp),
onClick = { valueState.cleanAllText = true },
shape = RoundedCornerShape(8.dp)
) {
Icon(
imageVector = Icons.Filled.Delete,
contentDescription = "Clean all texts"
)
}
}
}
}
}
Expand All @@ -249,7 +318,7 @@ fun WritingBoardLayout(navController: NavController, modifier: Modifier = Modifi
(readButtonStyle == 1)
) {
val padding = if (screenController) {
modifier.padding(end = 36.dp, top = 16.dp)
modifier.padding(end = 36.dp, bottom = 16.dp)
} else {
modifier.padding(36.dp)
}
Expand Down
46 changes: 23 additions & 23 deletions app/src/main/java/com/sqz/writingboard/ui/WritingBoardSetting.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,6 @@ private fun SettingFunction(navController: NavController, modifier: Modifier = M
valueState.updateScreen = true
}
}
item {
SwitchCardLayout(
text = stringResource(R.string.edit_writingboard_button),
checked = editButton,
onCheckedChange = {
editButton = it
setting.writeSwitchState("edit_button", context, it)
},
colors = cardColors
)
}
item {
SwitchCardLayout(
text = stringResource(R.string.clean_all_texts_button),
checked = cleanAllText,
onCheckedChange = {
cleanAllText = it
setting.writeSwitchState("clean_all_text", context, it)
},
colors = cardColors
)
}
item {
ExtraButtonCardLayout(
title = stringResource(R.string.button_style),
Expand All @@ -147,7 +125,7 @@ private fun SettingFunction(navController: NavController, modifier: Modifier = M
selectedOption = buttonStyle,
colors = cardColors,
expanded = (settingState.readSegmentedButtonState("button_style", context) <= 1),
switchText = "Prevent text\nfrom being obscured",
switchText = stringResource(R.string.always_visible_text),
checked = alwaysVisibleText,
onCheckedChange = {
alwaysVisibleText = it
Expand All @@ -162,6 +140,28 @@ private fun SettingFunction(navController: NavController, modifier: Modifier = M
)
}
}
item {
SwitchCardLayout(
text = stringResource(R.string.edit_writingboard_button),
checked = editButton,
onCheckedChange = {
editButton = it
setting.writeSwitchState("edit_button", context, it)
},
colors = cardColors
)
}
item {
SwitchCardLayout(
text = stringResource(R.string.clean_all_texts_button),
checked = cleanAllText,
onCheckedChange = {
cleanAllText = it
setting.writeSwitchState("clean_all_text", context, it)
},
colors = cardColors
)
}
item {
Text(
text = stringResource(R.string.writingboard),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text2.BasicTextField2
import androidx.compose.foundation.verticalScroll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ fun ExtraButtonCardLayout(
fontSize = 18.sp,
fontWeight = FontWeight.SemiBold,
color = MaterialTheme.colorScheme.secondary,
modifier = modifier.padding(start = 16.dp)
modifier = modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp)
)
Switch(
modifier = modifier
.fillMaxSize()
.padding(16.dp)
.padding(bottom = 16.dp, start = 16.dp, end = 16.dp)
.wrapContentWidth(Alignment.End),
checked = checked,
onCheckedChange = onCheckedChange
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
<string name="lower_than_android13">您的系统版本低于Android 13</string>
<string name="feature_supports_android13">此功能仅支持Android 13+</string>
<string name="back">返回</string>
<string name="always_visible_text">防止文本被遮挡</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rSG/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
<string name="lower_than_android13">您的系统版本低于Android 13</string>
<string name="feature_supports_android13">此功能仅支持Android 13+</string>
<string name="back">返回</string>
<string name="always_visible_text">防止文本被遮挡</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
<string name="lower_than_android13">您的系統版本低於Android 13</string>
<string name="feature_supports_android13">此功能僅支援Android 13+</string>
<string name="back">返回</string>
<string name="always_visible_text">防止文字被遮擋</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@
<string name="lower_than_android13">Your system version is lower than Android 13</string>
<string name="feature_supports_android13">This feature only supports Android 13+</string>
<string name="back">Go Back</string>
<string name="always_visible_text">Prevent text\nfrom being obscured</string>
</resources>

0 comments on commit 9695841

Please sign in to comment.