Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0.0 #230

Merged
merged 9 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ android {
applicationId = "com.app.calendar"
minSdk = 27
targetSdk = 35
versionCode = 47
versionCode = 48
versionName = "2.0.0"
applicationId = "com.app.body_manage"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
named("release") {
isMinifyEnabled = false
isMinifyEnabled = true
setProguardFiles(
listOf(
getDefaultProguardFile("proguard-android-optimize.txt"),
Expand Down Expand Up @@ -94,7 +94,7 @@ dependencies {
implementation("com.facebook.soloader:soloader:0.11.0")

// lifecycle
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.3")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4")

// In-App-Review
implementation("com.google.android.play:review:2.0.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FloatNumberPickerDialog : DialogFragment() {
private var number: Float = 50F
private var unit: String = ""
private var label: String = ""
private lateinit var callBack: (weight: Float) -> Unit
private var callBack: (weight: Float) -> Unit = { _ -> }

// 初期値
private var hundredsPlace: String = ""
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/app/body_manage/ui/top/TopActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.app.body_manage.ui.top

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.Toast
import androidx.activity.addCallback
Expand Down Expand Up @@ -180,11 +181,14 @@ class TopActivity : AppCompatActivity() {
val lastMeasure by viewModel.lastMeasure.collectAsState()
val initialMeasure by viewModel.initialMeasure.collectAsState()
val todayMeasure by viewModel.todayMeasure.collectAsState()
val enableUpdate by viewModel.enableUpdate.collectAsState(false)

TopScreen(
userPreference = userPreference,
lastMeasure = lastMeasure,
initialMeasure = initialMeasure,
todayMeasure = todayMeasure,
enableUpdate = enableUpdate,
bottomSheetDataList = bottomSheetDataList,
onClickSeeTrainingMenu = {
launcher.launch(TrainingMenuListActivity.createIntent(this))
Expand Down Expand Up @@ -247,11 +251,23 @@ class TopActivity : AppCompatActivity() {
LocalDate.now()
)
)
},
onClickStore = {
openPlayStore()
}
)
}
}

private fun openPlayStore() {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("market://details?id=$packageName")
)
)
}

companion object {
fun createIntent(
context: Context
Expand Down
98 changes: 79 additions & 19 deletions app/src/main/java/com/app/body_manage/ui/top/TopScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
Expand All @@ -73,6 +75,7 @@ import com.app.body_manage.extension.toCentiMeter
import com.app.body_manage.extension.toMMDDEE
import com.app.body_manage.extension.toWeight
import com.app.body_manage.extension.withPercent
import com.app.body_manage.style.Colors.Companion.accentColor
import com.app.body_manage.style.Colors.Companion.background
import com.app.body_manage.style.Colors.Companion.theme
import com.app.body_manage.ui.common.ColumTextWithLabelAndIcon
Expand All @@ -88,6 +91,7 @@ fun TopScreen(
lastMeasure: BodyMeasure?,
initialMeasure: BodyMeasure?,
todayMeasure: TodayMeasure,
enableUpdate: Boolean,
bottomSheetDataList: List<BottomSheetData>,
onClickSeeTrainingMenu: () -> Unit = {},
onClickCompare: () -> Unit = {},
Expand All @@ -98,6 +102,7 @@ fun TopScreen(
onClickAddTraining: () -> Unit = {},
onClickSetGoal: () -> Unit = {},
onClickSetting: () -> Unit = {},
onClickStore: () -> Unit = {},
) {
val scope = rememberCoroutineScope()
var openMultiFb by remember {
Expand Down Expand Up @@ -197,7 +202,10 @@ fun TopScreen(
.fillMaxHeight()
) {
item {
Row(verticalAlignment = Alignment.Bottom) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start,
) {
if (lastMeasure?.weight != null) {
Text(
text = lastMeasure.weight.toString(),
Expand All @@ -212,29 +220,37 @@ fun TopScreen(
)
}
Spacer(modifier = Modifier.size(10.dp))
lastMeasure?.time?.toLocalDate()?.toMMDDEE()?.let { mmdd ->
val label = stringResource(id = R.string.label_registered_date)
Text(
text = "$label: $mmdd",
fontSize = 14.sp,
color = Color.Gray,
)
Column {
(lastMeasure?.tall)?.let { tall ->
Text(
text = tall.toCentiMeter(),
fontSize = 11.sp,
color = Color.Gray,
)
}
lastMeasure?.time?.toLocalDate()?.toMMDDEE()?.let { mmdd ->
val label = stringResource(id = R.string.label_registered_date)
Text(
text = "$label: $mmdd",
fontSize = 11.sp,
color = Color.Gray,
)
}
}
Spacer(modifier = Modifier.weight(1F))
(lastMeasure?.tall)?.let { tall ->
Text(
text = tall.toCentiMeter(),
fontSize = 14.sp,
color = Color.Gray,
)
}
Spacer(modifier = Modifier.size(10.dp))
UpdateIcon(
enableUpdate = enableUpdate,
onClickStore = onClickStore,
)
Spacer(modifier = Modifier.size(5.dp))
Icon(
imageVector = Icons.Default.Settings,
contentDescription = null,
modifier = Modifier.clickable {
onClickSetting()
}
modifier = Modifier
.clickable {
onClickSetting()
}
.size(20.dp)
)
}
Spacer(modifier = Modifier.size(10.dp))
Expand Down Expand Up @@ -315,6 +331,50 @@ fun TopScreen(
}
}

@Composable
private fun UpdateIcon(
enableUpdate: Boolean,
onClickStore: () -> Unit,
) {
if (enableUpdate) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.clickable {
onClickStore()
}
.background(accentColor, RoundedCornerShape(5.dp))
.border(1.dp, Color.Blue, RoundedCornerShape(5.dp))
.padding(vertical = 3.dp, horizontal = 6.dp),
) {
Text(
text = stringResource(id = R.string.enable_update),
fontSize = 11.sp,
color = Color.White,
fontWeight = FontWeight.Bold,
)
Spacer(modifier = Modifier.size(3.dp))
Icon(
painter = painterResource(id = R.drawable.icons8_google_play_store),
contentDescription = null,
modifier = Modifier.size(20.dp),
tint = Color.Unspecified
)
}
} else {
Icon(
painter = painterResource(id = R.drawable.icons8_google_play_store),
contentDescription = null,
modifier = Modifier
.clickable {
onClickStore()
}
.size(20.dp),
tint = Color.Unspecified
)
}
}

@Composable
private fun FabItem(
@StringRes textRes: Int,
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/app/body_manage/ui/top/TopViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class TopViewModel(
private val _initialMeasure: MutableStateFlow<BodyMeasure?> = MutableStateFlow(null)
val initialMeasure = _initialMeasure.stateIn(viewModelScope, SharingStarted.Eagerly, null)

private val _enableUpdate: MutableStateFlow<Boolean> = MutableStateFlow(false)
val enableUpdate = _enableUpdate.asSharedFlow()

// 当日の測定
private val _todayMeasure: MutableStateFlow<TodayMeasure> = MutableStateFlow(
TodayMeasure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ data class UserPreferenceSettingViewModelState(
val name: String? = null,
val gender: Gender = Gender.MALE,
val birth: TextFieldValue = TextFieldValue(),
val hasMealFeature: Boolean = false,
val hasTrainingFeature: Boolean = false,
val hasMealFeature: Boolean = true,
val hasTrainingFeature: Boolean = true,
) {
fun toUiState(): UiState {
val setBirth = try {
Expand Down
67 changes: 67 additions & 0 deletions app/src/main/res/drawable/icons8_google_play_store.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:pathData="M13.488,4.012C10.794,2.508 7.605,3.778 6.45,6.323L24.126,24l9.014,-9.014L13.488,4.012z">
<aapt:attr name="android:fillColor">
<gradient
android:startX="18.102"
android:startY="3.244"
android:endX="25.297"
android:endY="34.74"
android:type="linear">
<item android:offset="0" android:color="#FF35AB4A"/>
<item android:offset="0.297" android:color="#FF31A145"/>
<item android:offset="0.798" android:color="#FF288739"/>
<item android:offset="1" android:color="#FF237A33"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M33.14,33.014L24.126,24L6.45,41.677c1.156,2.546 4.345,3.815 7.038,2.312L33.14,33.014z">
<aapt:attr name="android:fillColor">
<gradient
android:startX="19.158"
android:startY="23.862"
android:endX="21.194"
android:endY="66.931"
android:type="linear">
<item android:offset="0" android:color="#FFF14E5D"/>
<item android:offset="0.499" android:color="#FFEA3D4F"/>
<item android:offset="1" android:color="#FFE12138"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M41.419,28.393c1.72,-0.96 2.58,-2.676 2.581,-4.393c-0.001,-1.717 -0.861,-3.434 -2.581,-4.393l-8.279,-4.621L24.126,24l9.014,9.014L41.419,28.393z">
<aapt:attr name="android:fillColor">
<gradient
android:startX="32.943"
android:startY="14.899"
android:endX="36.541"
android:endY="43.612"
android:type="linear">
<item android:offset="0" android:color="#FFFFD844"/>
<item android:offset="0.519" android:color="#FFFFC63F"/>
<item android:offset="1" android:color="#FFFFB03A"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M6.45,6.323C6.168,6.948 6,7.652 6,8.408v31.179c0,0.761 0.164,1.463 0.45,2.09l17.674,-17.68L6.45,6.323z">
<aapt:attr name="android:fillColor">
<gradient
android:startX="13.853"
android:startY="5.901"
android:endX="15.572"
android:endY="42.811"
android:type="linear">
<item android:offset="0.003" android:color="#FF0090E6"/>
<item android:offset="1" android:color="#FF0065A0"/>
</gradient>
</aapt:attr>
</path>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values-b+en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<string name="saturday">S</string>
<string name="increase">increase</string>
<string name="decrease">decrease</string>
<string name="enable_update">Update</string>

<!-- User Settings -->
<string name="label_user_name">User Name</string>
Expand Down
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 @@ -36,6 +36,7 @@
<string name="saturday">土</string>
<string name="increase">増加</string>
<string name="decrease">減少</string>
<string name="enable_update">アップデート可能</string>

<!-- ユーザ設定 -->
<string name="label_user_name">▪️ユーザ名</string>
Expand Down