OSDN Git Service

詳細画面の作成開始。
authorMRSa <mrsa@myad.jp>
Sat, 20 Jan 2024 16:01:02 +0000 (01:01 +0900)
committerMRSa <mrsa@myad.jp>
Sat, 20 Jan 2024 16:01:02 +0000 (01:01 +0900)
wear/src/main/java/net/osdn/gokigen/joggingtimer/ResultListData.kt [moved from wear/src/main/java/net/osdn/gokigen/joggingtimer/presentation/ui/list/ResultListData.kt with 70% similarity]
wear/src/main/java/net/osdn/gokigen/joggingtimer/presentation/ui/detail/DetailRecordScreen.kt
wear/src/main/java/net/osdn/gokigen/joggingtimer/presentation/ui/detail/RecordDetailList.kt [moved from wear/src/main/java/net/osdn/gokigen/joggingtimer/presentation/ui/list/ResultList.kt with 52% similarity]
wear/src/main/java/net/osdn/gokigen/joggingtimer/presentation/ui/list/ResultListItem.kt
wear/src/main/java/net/osdn/gokigen/joggingtimer/presentation/ui/list/ResultListTitle.kt
wear/src/main/java/net/osdn/gokigen/joggingtimer/stopwatch/IWearableActivityControl.kt
wear/src/main/java/net/osdn/gokigen/joggingtimer/stopwatch/WearableActivityController.kt
wear/src/main/res/drawable/baseline_post_add_24.xml [new file with mode: 0644]
wear/src/main/res/values-ja/strings.xml
wear/src/main/res/values/strings.xml

@@ -1,3 +1,3 @@
-package net.osdn.gokigen.joggingtimer.presentation.ui.list
+package net.osdn.gokigen.joggingtimer
 
 data class ResultListData(val indexId: Long, val title: String, val memo: String, val iconId: Int, val startTime: Long, val duration: Long)
index e0a49b4..6778cf8 100644 (file)
@@ -2,6 +2,7 @@ package net.osdn.gokigen.joggingtimer.presentation.ui.detail
 
 import android.content.Context
 import android.text.format.DateFormat
+import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.PaddingValues
 import androidx.compose.foundation.layout.fillMaxSize
@@ -10,6 +11,7 @@ import androidx.compose.foundation.layout.padding
 import androidx.compose.runtime.Composable
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.unit.dp
@@ -20,12 +22,17 @@ import androidx.wear.compose.material.Scaffold
 import androidx.wear.compose.material.Text
 import androidx.wear.compose.material.TimeText
 import androidx.wear.compose.material.TimeTextDefaults
+import net.osdn.gokigen.joggingtimer.AppSingleton
 import net.osdn.gokigen.joggingtimer.R
 import java.util.Locale
 
 @Composable
 fun DetailRecordScreen(context: Context, navController: NavHostController, id: Int)
 {
+    val dataItem = AppSingleton.controller.getRecordItem(id)
+    val lapTimeList = AppSingleton.controller.getLapTimeList(id)
+    val lapCount = if (lapTimeList.isEmpty()) { 0 } else if (lapTimeList.size < 2) { 0 } else { lapTimeList.size - 1 }
+
     Scaffold(
         timeText = {
             TimeText(
@@ -38,24 +45,65 @@ fun DetailRecordScreen(context: Context, navController: NavHostController, id: I
             )
         },
     ) {
-        Column(
-            modifier = Modifier
-                .fillMaxSize()
-                .padding(
-                    PaddingValues(
-                        top = 25.dp
-                    )
-                ),
-            //verticalArrangement = Arrangement.Center,
-            horizontalAlignment = Alignment.CenterHorizontally
-        ) {
-            Text(
-                modifier = Modifier.fillMaxWidth(),
-                textAlign = TextAlign.Center,
-                color = MaterialTheme.colors.primary,
-                fontSize = 12.sp,
-                text = "${stringResource(R.string.result_detail)} : $id "
-            )
+        if ((dataItem.indexId <= 0)||(lapTimeList.isEmpty()))
+        {
+            // 「詳細データの取得に失敗」を表示する
+            Column(
+                modifier = Modifier
+                    .fillMaxSize()
+                    .padding(
+                        PaddingValues(
+                            top = 25.dp
+                        )
+                    ),
+                verticalArrangement = Arrangement.Center,
+                horizontalAlignment = Alignment.CenterHorizontally
+            ) {
+                Text(
+                    modifier = Modifier.fillMaxWidth(),
+                    textAlign = TextAlign.Center,
+                    color = MaterialTheme.colors.primary,
+                    fontSize = 14.sp,
+                    text = stringResource(R.string.failed_to_get_details)
+                )
+            }
+
+        }
+        else
+        {
+            Column(
+                modifier = Modifier
+                    .fillMaxSize()
+                    .padding(
+                        PaddingValues(
+                            top = 30.dp
+                        )
+                    ),
+                //verticalArrangement = Arrangement.Center,
+                horizontalAlignment = Alignment.CenterHorizontally
+            ) {
+                Text(
+                    modifier = Modifier.fillMaxWidth(),
+                    textAlign = TextAlign.Center,
+                    color = Color.White,
+                    fontSize = 12.sp,
+                    text = stringResource(id = R.string.result_detail)
+                )
+                Text(
+                    modifier = Modifier.fillMaxWidth(),
+                    textAlign = TextAlign.Center,
+                    color = MaterialTheme.colors.primary,
+                    fontSize = 12.sp,
+                    text = dataItem.title
+                )
+                Text(
+                    modifier = Modifier.fillMaxWidth(),
+                    textAlign = TextAlign.Center,
+                    color = MaterialTheme.colors.primary,
+                    fontSize = 10.sp,
+                    text = "Lap : $lapCount"
+                )
+            }
         }
     }
 }
@@ -1,33 +1,20 @@
-package net.osdn.gokigen.joggingtimer.presentation.ui.list
+package net.osdn.gokigen.joggingtimer.presentation.ui.detail
 
-import androidx.compose.foundation.focusable
-import androidx.compose.foundation.gestures.scrollBy
 import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.PaddingValues
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.rememberCoroutineScope
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
-import androidx.compose.ui.focus.focusRequester
-import androidx.compose.ui.input.rotary.onRotaryScrollEvent
-import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
 import androidx.navigation.NavHostController
 import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
 import androidx.wear.compose.foundation.lazy.items
-import androidx.wear.compose.material.MaterialTheme
-import androidx.wear.compose.material.Text
-import kotlinx.coroutines.launch
-import net.osdn.gokigen.joggingtimer.AppSingleton
-import net.osdn.gokigen.joggingtimer.R
+import net.osdn.gokigen.joggingtimer.ResultListData
+import net.osdn.gokigen.joggingtimer.presentation.ui.list.ResultListItem
 
 @Composable
-fun ResultList(navController: NavHostController, recordList: List<ResultListData>)
+fun RecordDetailList(navController: NavHostController, recordList: List<ResultListData>)
 {
     ScalingLazyColumn(
         modifier = Modifier
index a71b30a..c25fb62 100644 (file)
@@ -20,6 +20,7 @@ import androidx.wear.compose.material.Chip
 import androidx.wear.compose.material.ChipDefaults
 import androidx.wear.compose.material.Icon
 import androidx.wear.compose.material.Text
+import net.osdn.gokigen.joggingtimer.ResultListData
 import net.osdn.gokigen.joggingtimer.utilities.IconIdProvider
 import net.osdn.ja.gokigen.wearos.timerapp.counter.TimeStringConvert
 
@@ -57,7 +58,6 @@ fun ResultListItem(navController: NavHostController, dataItem: ResultListData)
                 Text(
                     text = dataItem.title,
                     fontSize = 12.sp,
-                    //maxLines = 3,
                     overflow = TextOverflow.Ellipsis
                 )
             },
index 6f3248d..b877685 100644 (file)
@@ -62,7 +62,7 @@ fun ResultListTitle(navController: NavHostController)
                 enabled = true,
             ) {
                 Icon(
-                    painter = painterResource(id = R.drawable.baseline_list_24),
+                    painter = painterResource(id = R.drawable.baseline_post_add_24),
                     contentDescription = "CreateReference",
                     tint = Color.White
                 )
index 2437aa1..acfabda 100644 (file)
@@ -1,7 +1,7 @@
 package net.osdn.gokigen.joggingtimer.stopwatch
 
 import androidx.activity.ComponentActivity
-import net.osdn.gokigen.joggingtimer.presentation.ui.list.ResultListData
+import net.osdn.gokigen.joggingtimer.ResultListData
 
 /**
  *
@@ -29,6 +29,8 @@ interface IWearableActivityControl
     fun setReferenceTimerSelection(id: Int)
     fun setupReferenceData()
     fun getCounterRecordList(): List<ResultListData>
+    fun getRecordItem(id: Int): ResultListData
+    fun getLapTimeList(id: Int): List<Long>
 
     fun launchNotify(isShow: Boolean)
 
index f01ef8f..d382a6c 100644 (file)
@@ -22,7 +22,7 @@ import androidx.wear.ongoing.Status
 import net.osdn.gokigen.joggingtimer.MainActivity
 import net.osdn.gokigen.joggingtimer.MainActivity.Companion.CHANNEL_ID
 import net.osdn.gokigen.joggingtimer.R
-import net.osdn.gokigen.joggingtimer.presentation.ui.list.ResultListData
+import net.osdn.gokigen.joggingtimer.ResultListData
 import net.osdn.gokigen.joggingtimer.storage.ITimeEntryDatabase
 import net.osdn.gokigen.joggingtimer.storage.ITimeEntryDatabaseCallback
 import net.osdn.gokigen.joggingtimer.storage.TimeEntryDatabaseFactory
@@ -338,7 +338,7 @@ class WearableActivityController : IWearableActivityControl, ITimeEntryDatabaseC
                     val startTime = cursor.getLong(startTimeNumber)
                     val durationTime = cursor.getLong(durationNumber)
 
-                    Log.v(TAG, " Record ($indexId, $title, $memo, $iconId : [$startTime][$durationTime])")
+                    //Log.v(TAG, " Record ($indexId, $title, $memo, $iconId : [$startTime][$durationTime])")
 
                     recordList.add(ResultListData(indexId, title, memo, iconId, startTime, durationTime))
                 }
@@ -351,6 +351,68 @@ class WearableActivityController : IWearableActivityControl, ITimeEntryDatabaseC
         return (recordList)
     }
 
+    override fun getRecordItem(id: Int): ResultListData
+    {
+        try
+        {
+            //Log.v(TAG, " GET Record ($id)")
+            val cursor = database?.getIndexdata(id.toLong())
+            if (cursor != null)
+            {
+                while (cursor.moveToNext())
+                {
+                    val indexIdNumber = cursor.getColumnIndex(TimeEntryIndex.EntryIndex._ID)
+                    val titleNumber =
+                        cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_TITLE)
+                    val memoNumber =
+                        cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_MEMO)
+                    val iconIdNumber =
+                        cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_ICON_ID)
+                    val startTimeNumber =
+                        cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_START_TIME)
+                    val durationNumber =
+                        cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_TIME_DURATION)
+
+                    val indexId = cursor.getLong(indexIdNumber)
+                    val title = cursor.getString(titleNumber)
+                    val memo = cursor.getString(memoNumber)
+                    val iconId = cursor.getInt(iconIdNumber)
+                    val startTime = cursor.getLong(startTimeNumber)
+                    val durationTime = cursor.getLong(durationNumber)
+                    return (ResultListData(indexId, title, memo, iconId, startTime, durationTime))
+                }
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+        return (ResultListData(indexId = -1, title = "", memo = "", iconId = 0, startTime = 0, duration = 0))
+    }
+
+    override fun getLapTimeList(id: Int): List<Long>
+    {
+        val lapTimeList = ArrayList<Long>()
+        try
+        {
+            val cursor = database?.getAllDetailData(id.toLong())
+            if (cursor != null)
+            {
+                while (cursor.moveToNext())
+                {
+                    val lapTimeId = cursor.getColumnIndex(TimeEntryData.EntryData.COLUMN_NAME_TIME_ENTRY)
+                    val lapTime = cursor.getLong(lapTimeId)
+                    lapTimeList.add(lapTime)
+                }
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+        return (lapTimeList)
+    }
+
     @SuppressLint("Range")
     private fun loadReferenceData()
     {
diff --git a/wear/src/main/res/drawable/baseline_post_add_24.xml b/wear/src/main/res/drawable/baseline_post_add_24.xml
new file mode 100644 (file)
index 0000000..118e908
--- /dev/null
@@ -0,0 +1,9 @@
+<vector android:height="24dp" android:tint="#EEEEEE"
+    android:viewportHeight="24" android:viewportWidth="24"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="@android:color/white" android:pathData="M17,19.22H5V7h7V5H5C3.9,5 3,5.9 3,7v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2v-7h-2V19.22z"/>
+    <path android:fillColor="@android:color/white" android:pathData="M19,2h-2v3h-3c0.01,0.01 0,2 0,2h3v2.99c0.01,0.01 2,0 2,0V7h3V5h-3V2z"/>
+    <path android:fillColor="@android:color/white" android:pathData="M7,9h8v2h-8z"/>
+    <path android:fillColor="@android:color/white" android:pathData="M7,12l0,2l8,0l0,-2l-3,0z"/>
+    <path android:fillColor="@android:color/white" android:pathData="M7,15h8v2h-8z"/>
+</vector>
index 2b10551..c942ea1 100644 (file)
@@ -42,4 +42,5 @@
     <string name="channel_description">Running</string>
     <string name="record_data_empty">記録データはありません。</string>
     <string name="notification_description">計測中</string>
+    <string name="failed_to_get_details">記録データの取得に失敗しました。</string>
 </resources>
\ No newline at end of file
index 17a3c2c..5320a82 100644 (file)
@@ -42,4 +42,5 @@
     <string name="channel_description">Running</string>
     <string name="record_data_empty">Record data is none.</string>
     <string name="notification_description">Timer active</string>
+    <string name="failed_to_get_details">Failed to get details.</string>
 </resources>