Skip to content

Commit

Permalink
Fixed the time slot bug
Browse files Browse the repository at this point in the history
  • Loading branch information
he1senbrg committed Aug 20, 2024
1 parent 135c0ec commit a6375c5
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 276 deletions.
252 changes: 0 additions & 252 deletions .idea/other.xml

This file was deleted.

Binary file modified phone/release/baselineProfiles/0/phone-release.dm
Binary file not shown.
Binary file modified phone/release/baselineProfiles/1/phone-release.dm
Binary file not shown.
6 changes: 4 additions & 2 deletions phone/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand All @@ -25,7 +26,8 @@
android:exported="true"
android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
<action android:name="com.google.android.gms.wearable.BIND_LISTENER"
tools:ignore="WearableBindListener" />
</intent-filter>
</service>

Expand Down
14 changes: 12 additions & 2 deletions phone/src/main/java/com/vte/timetable/CreateScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,19 @@ fun AddItemList() {
showDialExample = false
},
onConfirm = { time ->
selectedTime = time
var rawTimeStart = time.split(":")[0]
var rawTimeEnd = time.split(":")[1]
val index = items.size - 1
if (index >= 0 && index < buttonTexts.size) {
buttonTexts[index] = time
}
if (rawTimeStart.length == 1) {
rawTimeStart = "0$rawTimeStart"
}
if (rawTimeEnd.length == 1) {
rawTimeEnd = "0$rawTimeEnd"
}
timeRangeList.add("$rawTimeStart:$rawTimeEnd")
showDialExample = false
}
)
Expand Down Expand Up @@ -290,7 +298,7 @@ fun RangePicker(
}
Button(onClick = {
val selectedTime = "${timePickerState.hour}:${timePickerState.minute}"
timeRangeList.add(selectedTime)
// timeRangeList.add(selectedTime)
Log.d("smth", "Above list add")
Log.d("TimeRangeList", timeRangeList.toList().toString())
onConfirm(selectedTime)
Expand Down Expand Up @@ -369,5 +377,7 @@ fun saveAsJson(context: Context) {
val jsonData = readConfigFromFile(context = context, "time-table.json")
Log.d("tableJSON", jsonData.toString())
sendMessageToWear(context)
finalDayList = mutableStateListOf()
timeRangeList = mutableStateListOf()
Log.d("CreateScreenToWear", "Data sent to wear")
}
Binary file modified wear/release/baselineProfiles/0/wear-release.dm
Binary file not shown.
Binary file modified wear/release/baselineProfiles/1/wear-release.dm
Binary file not shown.
13 changes: 10 additions & 3 deletions wear/src/main/java/com/vte/timetable/presentation/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.IOException
import java.time.LocalTime

class MainActivity : AppCompatActivity(), DataClient.OnDataChangedListener {

Expand Down Expand Up @@ -118,13 +119,17 @@ class MainActivity : AppCompatActivity(), DataClient.OnDataChangedListener {

@Composable
fun TextForTableDay(dayText: String){
Text(text = dayText, fontSize = 20.sp)
Text(text = dayText, fontSize = 22.sp)
}

@Composable
fun TextForTablePeriod(tableText: String, subText: String){
Text(text = tableText, fontSize = 20.sp)
Text(text = subText, fontSize = 16.sp)
Log.d(TAG, "Table Text: $tableText, Sub Text: $subText")
val subTextStart = LocalTime.parse(subText.split("-")[0].replace(" ","")).format(java.time.format.DateTimeFormatter.ofPattern("hh:mm a"))

val subTextEnd = LocalTime.parse(subText.split("-")[1].replace(" ","")).format(java.time.format.DateTimeFormatter.ofPattern("hh:mm a"))
Text(text = tableText, fontSize = 22.sp)
Text(text = "$subTextStart - $subTextEnd", fontSize = 14.sp, color = Color(0xFFA0A0A0))
}

@Composable
Expand Down Expand Up @@ -180,6 +185,7 @@ class MainActivity : AppCompatActivity(), DataClient.OnDataChangedListener {

nodeClient.connectedNodes.addOnSuccessListener { node ->
if (node.isNotEmpty()) {
Log.d(TAG, "Sending message to node: ${node}")
val nodeId = node[node.lastIndex].id
Log.d(TAG, "Sending message to node: $nodeId")
val path = "/open-phone-app"
Expand Down Expand Up @@ -241,6 +247,7 @@ class MainActivity : AppCompatActivity(), DataClient.OnDataChangedListener {
.border(1.dp, Color.DarkGray, shape = RoundedCornerShape(20.dp)),
backgroundPainter = CardDefaults.cardBackgroundPainter(startBackgroundColor = Color.Black, endBackgroundColor = Color.Black)
){
Log.d(TAG, "Period: ${listOfHours.toString()}")
TextForTablePeriod(periodList.get(it).toString(),"${listOfHours.get(it)} - ${listOfHours.get(it+1)}")
}
}
Expand Down
Loading

0 comments on commit a6375c5

Please sign in to comment.