Skip to content

Commit 7239101

Browse files
committed
リモートブランチにコードを合わせました
2 parents 7e3e780 + 06d4987 commit 7239101

22 files changed

+449
-80
lines changed

.github/pull_request_template.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
<!--
2+
3+
タイトルをわかりやすい名前で入力しようね 🥸 🥸 🥸 🥸 🥸
4+
5+
-->
6+
17
## やったこと
28

39
<!--
410
- この PR で何をしたのか概要を書いてください〜
511
- 関連する issueがある場合は以下のように入力してください。(xxxはissueの番号)
12+
-->
613

714
Close #xxx
815

9-
-->
10-
1116
## やってないこと
1217

1318
<!--
@@ -19,6 +24,7 @@ Close #xxx
1924

2025
<!--
2126
* どのような動作確認を行って結果が得られたのか簡単に教えてください〜
27+
* ファイルをアップして <img src="" width="300" /> と入力し、src をアップしたファイルのURLで置き換えると画像サイズを調整できますー
2228
-->
2329

2430
## 自己評価

.github/workflows/main.yml

+49-49
Original file line numberDiff line numberDiff line change
@@ -21,63 +21,63 @@ jobs:
2121
build:
2222
runs-on: ubuntu-latest
2323
steps:
24-
# チェックアウト
25-
- uses: actions/checkout@v2
24+
# チェックアウト
25+
- uses: actions/checkout@v4
2626

27-
# JDKのセットアップ
28-
- name: set up JDK 17
29-
uses: actions/setup-java@v2
30-
with:
31-
distribution: 'zulu'
32-
java-version: '17'
27+
# JDKのセットアップ
28+
- name: set up JDK 17
29+
uses: actions/setup-java@v2
30+
with:
31+
distribution: 'zulu'
32+
java-version: '17'
3333

34-
# Gradleのキャッシュ復元
35-
- uses: actions/cache@v2
36-
with:
37-
path: ~/.gradle/caches
38-
key: ${{ runner.os }}-gradle-build-${{ hashFiles('**/*.gradle*') }}
39-
restore-keys: |
40-
${{ runner.os }}-gradle-build-
34+
# Gradleのキャッシュ復元
35+
- uses: actions/cache@v2
36+
with:
37+
path: ~/.gradle/caches
38+
key: ${{ runner.os }}-gradle-build-${{ hashFiles('**/*.gradle*') }}
39+
restore-keys: |
40+
${{ runner.os }}-gradle-build-
4141
42-
# 依存関係の出力
43-
- name: Displays the Android dependencies of the project
44-
run: ./gradlew androidDependencies
42+
# 依存関係の出力
43+
- name: Displays the Android dependencies of the project
44+
run: ./gradlew androidDependencies
4545

46-
# コンパイル
47-
- name: Run Compile
48-
run: ./gradlew assembleDebug
46+
# コンパイル
47+
- name: Run Compile
48+
run: ./gradlew assembleDebug
4949

5050
ktlint:
5151
runs-on: ubuntu-latest
5252
steps:
53-
# チェックアウト
54-
- uses: actions/checkout@v2
53+
# チェックアウト
54+
- uses: actions/checkout@v4
5555

56-
# インストール
57-
- name: Install ktlint
58-
run: |
59-
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.42.1/ktlint
60-
chmod a+x ktlint
61-
sudo mv ktlint /usr/local/bin/
62-
63-
# 静的解析
64-
- name: Lint with ktlint
65-
run: ktlint --reporter=checkstyle,output=build/ktlint-report.xml
66-
continue-on-error: true
56+
# インストール
57+
- name: Install ktlint
58+
run: |
59+
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.42.1/ktlint
60+
chmod a+x ktlint
61+
sudo mv ktlint /usr/local/bin/
6762
68-
# 結果の表示
69-
- name: Show results on GitHub
70-
uses: yutailang0119/action-ktlint@v1
71-
with:
72-
xml_path: build/ktlint-report.xml
63+
# 静的解析
64+
- name: Lint with ktlint
65+
run: ktlint --reporter=checkstyle,output=build/ktlint-report.xml
66+
continue-on-error: true
7367

74-
# アーティファクトへアップロード
75-
- name: Upload results Artifact
76-
uses: actions/upload-artifact@v2
77-
if: success() || failure()
78-
with:
79-
name: results
80-
path: |
81-
**/build/ktlint-report.xml
82-
if-no-files-found: error
83-
retention-days: 14
68+
# 結果の表示
69+
- name: Show results on GitHub
70+
uses: yutailang0119/action-ktlint@v1
71+
with:
72+
xml_path: build/ktlint-report.xml
73+
74+
# アーティファクトへアップロード
75+
- name: Upload results Artifact
76+
uses: actions/upload-artifact@v4
77+
if: success() || failure()
78+
with:
79+
name: results
80+
path: |
81+
**/build/ktlint-report.xml
82+
if-no-files-found: error
83+
retention-days: 14

app/build.gradle.kts

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id("com.android.application")
33
id("org.jetbrains.kotlin.android")
44
id("org.jlleitschuh.gradle.ktlint")
5+
id("com.google.devtools.ksp")
56
}
67

78
android {
@@ -10,7 +11,7 @@ android {
1011

1112
defaultConfig {
1213
applicationId = "com.example.runningavater"
13-
minSdk = 24
14+
minSdk = 26
1415
targetSdk = 35
1516
versionCode = 1
1617
versionName = "1.0"
@@ -85,4 +86,9 @@ dependencies {
8586
implementation("com.github.PhilJay:MPAndroidChart:3.1.0")
8687
implementation("io.coil-kt:coil-compose:2.7.0")
8788
implementation("androidx.biometric:biometric:1.4.0-alpha02")
89+
val room_version = "2.6.1"
90+
91+
implementation("androidx.room:room-runtime:$room_version")
92+
ksp("androidx.room:room-compiler:$room_version")
93+
implementation("androidx.room:room-ktx:$room_version")
8894
}

app/src/main/AndroidManifest.xml

+11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
99

1010

11+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
12+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" />
13+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
1114
<application
15+
android:name=".MainApplication"
1216
android:allowBackup="true"
1317
android:dataExtractionRules="@xml/data_extraction_rules"
1418
android:fullBackupContent="@xml/backup_rules"
@@ -29,6 +33,13 @@
2933
<category android:name="android.intent.category.LAUNCHER" />
3034
</intent-filter>
3135
</activity>
36+
37+
<!-- フォアグラウンドサービス -->
38+
<service
39+
android:name=".StepCounterService"
40+
android:enabled="true"
41+
android:exported="true"
42+
android:foregroundServiceType="health" />
3243
</application>
3344

3445
</manifest>
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
package com.example.runningavater
22

3+
import android.Manifest
4+
import android.content.Intent
5+
import android.content.pm.PackageManager
6+
import android.os.Build
37
import android.os.Bundle
48
import androidx.activity.compose.setContent
59
import androidx.compose.foundation.background
610
import androidx.compose.foundation.layout.fillMaxSize
711
import androidx.compose.material3.MaterialTheme
812
import androidx.compose.material3.Surface
913
import androidx.compose.ui.Modifier
14+
import androidx.core.app.ActivityCompat
15+
import androidx.core.content.ContextCompat
1016
import androidx.fragment.app.FragmentActivity
1117
import com.example.runningavater.ui.theme.RunningAvaterTheme
1218

1319
class MainActivity : FragmentActivity() {
1420
override fun onCreate(savedInstanceState: Bundle?) {
1521
super.onCreate(savedInstanceState)
22+
23+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
24+
ContextCompat.checkSelfPermission(this, Manifest.permission.ACTIVITY_RECOGNITION) != PackageManager.PERMISSION_GRANTED
25+
) {
26+
ActivityCompat.requestPermissions(
27+
this,
28+
arrayOf(Manifest.permission.ACTIVITY_RECOGNITION),
29+
1001,
30+
)
31+
}
32+
33+
startStepCounterService()
34+
1635
setContent {
1736
RunningAvaterTheme {
18-
// A surface container using the 'background' color from the theme
19-
// 背景色をテーマから取得
2037
Surface(
2138
modifier = Modifier.fillMaxSize(),
2239
color = MaterialTheme.colorScheme.background,
@@ -26,4 +43,13 @@ class MainActivity : FragmentActivity() {
2643
}
2744
}
2845
}
46+
47+
private fun startStepCounterService() {
48+
val intent = Intent(this, StepCounterService::class.java)
49+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
50+
startForegroundService(intent)
51+
} else {
52+
startService(intent)
53+
}
54+
}
2955
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.example.runningavater
2+
3+
import android.app.Application
4+
import androidx.room.Room
5+
import com.example.runningavater.db.AppDatabase
6+
7+
class MainApplication : Application() {
8+
val db by lazy {
9+
Room.databaseBuilder(
10+
applicationContext,
11+
AppDatabase::class.java,
12+
"database-name",
13+
).build()
14+
}
15+
}

app/src/main/java/com/example/runningavater/MyAppNavHost.kt

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.example.runningavater
22

33
import android.app.Application
44
import android.content.Context
5+
import android.content.SharedPreferences
56
import androidx.compose.foundation.layout.padding
67
import androidx.compose.material.icons.Icons
78
import androidx.compose.material.icons.filled.Home
@@ -18,6 +19,7 @@ import androidx.compose.runtime.getValue
1819
import androidx.compose.ui.Modifier
1920
import androidx.compose.ui.graphics.Color
2021
import androidx.compose.ui.graphics.vector.ImageVector
22+
import androidx.compose.ui.platform.LocalContext
2123
import androidx.datastore.preferences.preferencesDataStore
2224
import androidx.navigation.NavDestination
2325
import androidx.navigation.NavDestination.Companion.hierarchy
@@ -37,14 +39,26 @@ import com.example.runningavater.settings.SettingsScreen
3739
import com.example.runningavater.settings.SpanSettingsScreen
3840
import com.example.runningavater.ui.theme.NuclearMango
3941

42+
fun getStartDestination(context: Context): String {
43+
val prefs: SharedPreferences = context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE)
44+
val isFirstLaunch = prefs.getBoolean("is_first_launch", true)
45+
46+
if (isFirstLaunch) {
47+
return "initialFlow/1"
48+
} else {
49+
return "authentication"
50+
}
51+
}
52+
4053
@Composable
4154
fun MyAppNavHost(
4255
navController: NavHostController = rememberNavController(),
43-
startDestination: String = "initialFlow/1", // メイン画面をスタート画面に設定
56+
// startDestination: String = "initialFlow/1", // メイン画面をスタート画面に設定
4457
) {
4558
val navBackStackEntry by navController.currentBackStackEntryAsState()
4659
val currentDestination = navBackStackEntry?.destination
47-
val startDestination = if (true) "initialFlow/2" else "authentication"
60+
val context = LocalContext.current
61+
val startDestination = getStartDestination(context)
4862
Scaffold(
4963
bottomBar = {
5064
if (currentDestination?.route?.startsWith("initialFlow") != true) {

0 commit comments

Comments
 (0)