Skip to content
Open
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
45 changes: 45 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ dependencies {

testImplementation(libs.junit)

// implementation("net.openid:appauth:0.11.1")

androidTestImplementation(libs.androidx.test.junit)
androidTestImplementation(libs.androidx.test.espresso.core)
androidTestImplementation(libs.compose.ui.test.junit)
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/java/com/mcwilliams/streak/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import androidx.annotation.RequiresApi
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Settings
Expand Down Expand Up @@ -286,7 +289,6 @@ class MainActivity : ComponentActivity() {
)
}
}

}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class StravaSessionRepository @Inject constructor(
GrantType.AUTHORIZATION_CODE.toString()
)
setAccessToken(firstToken.access_token)
setRefreshToken(firstToken.refresh_token)
setRefreshToken(firstToken.refresh_token!!)
firstToken
}

Expand All @@ -48,7 +48,7 @@ class StravaSessionRepository @Inject constructor(
)

setAccessToken(newTokens.access_token)
setRefreshToken(newTokens.refresh_token)
setRefreshToken(newTokens.refresh_token!!)
newTokens.access_token
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ data class TokenResponse(
val access_token: String,
val expires_at: Int,
val expires_in: Int,
val refresh_token: String,
val refresh_token: String? = null,
val token_type: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import android.util.Log
import androidx.annotation.Keep
import com.mcwilliams.streak.R
import com.mcwilliams.streak.inf.ISessionRepository
import com.mcwilliams.streak.inf.StravaSessionRepository
import com.mcwilliams.streak.inf.model.GrantType
import com.mcwilliams.streak.inf.model.TokenResponse
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
Expand All @@ -33,7 +31,7 @@ class SpotifySessionRepository @Inject constructor(
redirectUri = "https://www.streakapp.com/authorize/"
)
setAccessToken(firstToken.access_token)
setRefreshToken(firstToken.refresh_token)
setRefreshToken(firstToken.refresh_token!!)
firstToken
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import com.mcwilliams.streak.ui.dashboard.widgets.DashboardType
import com.mcwilliams.streak.ui.dashboard.widgets.MonthWidget
import com.mcwilliams.streak.ui.dashboard.widgets.WeekCompareWidget
import com.mcwilliams.streak.ui.dashboard.widgets.WeekSummaryWidget
import com.mcwilliams.streak.ui.dashboard.widgets.YearSummaryWidget
import com.mcwilliams.streak.ui.dashboard.widgets.YearWidget
import com.mcwilliams.streak.ui.theme.primaryColor

Expand Down Expand Up @@ -224,6 +225,21 @@ fun StravaDashboard(viewModel: StravaDashboardViewModel, paddingValues: PaddingV
}, widgetName = "Year to Date"
)

StreakDashboardWidget(
content = {
YearSummaryWidget(
yearDistanceByMonth = state.calendarActivities.yearDistanceByMonth,
yearMetrics = state.calendarActivities.currentYearActivities.getStats(
selectedActivityType
),
selectedActivityType = selectedActivityType,
selectedUnitType = selectedUnitType,
isLoading = state.calendarActivities.lastTwoMonthsActivities.isEmpty(),
)
},
widgetName = "Year Summary"
)

StreakDashboardWidget(
content = {
val yearlySummaryMetrics by viewModel.yearlySummaryMetrics.observeAsState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ class StravaDashboardRepository @Inject constructor(
currentMonthActivities.plus(previousYearActivities).plus(currentYearActivities).filter {
if (calendarData.currentMonthInt == 1) {
it.start_date.getDate().monthValue == 12
&& it.start_date.getDate().year == 2022
&& it.start_date.getDate().year == 2023
} else {
it.start_date.getDate().monthValue == calendarData.currentMonthInt - 1
&& it.start_date.getDate().year == 2023
&& it.start_date.getDate().year == 2024
}
}

Expand All @@ -225,10 +225,10 @@ class StravaDashboardRepository @Inject constructor(
currentMonthActivities.plus(previousYearActivities).plus(currentYearActivities).filter {
if (calendarData.currentMonthInt == 1) {
it.start_date.getDate().monthValue == 11
&& it.start_date.getDate().year == 2022
&& it.start_date.getDate().year == 2023
} else {
it.start_date.getDate().monthValue == calendarData.currentMonthInt - 2
&& it.start_date.getDate().year == 2023
&& it.start_date.getDate().year == 2024
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mcwilliams.streak.ui.dashboard.data

import android.util.Log
import com.mcwilliams.streak.strava.model.activites.ActivitiesItem
import com.mcwilliams.streak.ui.dashboard.ActivityType
import com.mcwilliams.streak.ui.dashboard.MeasureType
Expand Down Expand Up @@ -50,6 +51,19 @@ data class CalendarActivities(
}
}

val yearlyGrouping = currentYearActivities.sortedBy { it.start_date.getDate().monthValue }.groupBy {
it.start_date.getDate().monthValue
}

val yearDistanceByMonth = yearlyGrouping.map {
var distanceForMonth = 0.0
it.value.forEach {
distanceForMonth += it.distance
}
Log.d("TAG", "yearDistanceByMonth: $distanceForMonth")
return@map it.key to distanceForMonth
}

lateinit var weeklyActivityIds: MutableList<Long>

private fun loadWeeklyDistanceMap(): Pair<SummaryInfo, MutableMap<Int, Int>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import com.mcwilliams.streak.ui.dashboard.StatType
import com.mcwilliams.streak.ui.dashboard.StreakWidgetCard
import com.mcwilliams.streak.ui.dashboard.SummaryMetrics
import com.mcwilliams.streak.ui.dashboard.UnitType
import com.mcwilliams.streak.ui.utils.getAveragePaceFromDistance
import com.mcwilliams.streak.ui.utils.getAveragePaceString
import com.mcwilliams.streak.ui.utils.getDistanceString
import com.mcwilliams.streak.ui.utils.getElevationString
import com.mcwilliams.streak.ui.utils.getTimeStringHoursAndMinutes
Expand Down Expand Up @@ -230,6 +232,70 @@ fun CompareWidget(
monthColumnWidth = monthColumnWidth
)
}

// Avg Speed Row
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 4.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
DashboardStat(
image = R.drawable.ic_speed,
modifier = Modifier.width(firstColumnWidth)
)

MonthTextStat(
getAveragePaceString(
currentMonthMetrics.totalDistance,
currentMonthMetrics.totalTime,
selectedUnitType!!
),
monthColumnWidth = monthColumnWidth,
)

PercentDelta(
now = currentMonthMetrics.totalDistance.getAveragePaceFromDistance(
currentMonthMetrics.totalTime
),
then = prevMetrics.totalDistance.getAveragePaceFromDistance(
prevMetrics.totalTime
),
monthColumnWidth = monthColumnWidth,
type = StatType.Pace
)

MonthTextStat(
getAveragePaceString(
prevMetrics.totalDistance,
prevMetrics.totalTime,
selectedUnitType!!
),
monthColumnWidth = monthColumnWidth,
)

PercentDelta(
now = prevMetrics.totalDistance.getAveragePaceFromDistance(
prevMetrics.totalTime
),
then = prevPrevMetrics.totalDistance.getAveragePaceFromDistance(
prevPrevMetrics.totalTime
),
monthColumnWidth = monthColumnWidth,
type = StatType.Pace
)

MonthTextStat(
getAveragePaceString(
prevPrevMetrics.totalDistance,
prevPrevMetrics.totalTime,
selectedUnitType!!
),
monthColumnWidth = monthColumnWidth,
)
}

//Count Row
Row(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ fun WeekCompareWidget(
)
}

// Elevation Row
// Avg Speed Row
Row(
modifier = Modifier
.fillMaxWidth()
Expand Down Expand Up @@ -381,6 +381,7 @@ fun WeekCompareWidget(
isLoading = isLoading
)
}

//Count Row
Row(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fun WeekSummaryWidget(
Column(
modifier = Modifier
.width(width = width)
.height(120.dp)
.height(140.dp)
) {
ConstraintLayout(modifier = Modifier.fillMaxSize()) {
val (progress, days) = createRefs()
Expand Down
Loading