Skip to content

Commit

Permalink
Issue rilling#102: Implemented the Season Totals Sections for showing…
Browse files Browse the repository at this point in the history
… the aggregated stats.

Signed-off-by: Vaibhav2399 <vaibhavparihar38@gmail.com>
  • Loading branch information
Vaibhav2399 committed Apr 8, 2024
1 parent 8d95710 commit f5825e0
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ private void drawPointer(final Canvas canvas) {
break;
}
}
if (firstChartValueSeries != null && !chartPoints.isEmpty()) {
if (firstChartSeries != null && !chartPoints.isEmpty()) {
int dx = getX(maxX) - pointer.getIntrinsicWidth() / 2;
double value = firstChartSeries.extractDataFromChartPoint(last);
int dy = getY(firstChartSeries, value) - pointer.getIntrinsicHeight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class CustomContentProvider extends ContentProvider {
* It computes the average for heart rate, cadence and power (duration-based average) and the maximum for heart rate, cadence and power.
* Finally, it ignores manual pause (SEGMENT_START_MANUAL).
*/
private final static String SENSOR_STATS_QUERY
private final static String SENSOR_STATS_QUERY=
"WITH time_select as " +
"(SELECT t1." + TrackPointsColumns.TIME + " * (t1." + TrackPointsColumns.TYPE + " NOT IN (" + TrackPoint.Type.SEGMENT_START_MANUAL.type_db + ")) time_value " +
"FROM " + TrackPointsColumns.TABLE_NAME + " t1 " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@

import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.databinding.ActivityRunAndChairStatBinding;
import de.dennisguse.opentracks.databinding.FragmentRunsStatBinding;

public class RunAndChairStatActivity extends AppCompatActivity {

ActivityRunAndChairStatBinding binding;
FragmentRunsStatBinding fragmentRunsStatBinding;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityRunAndChairStatBinding.inflate(getLayoutInflater());
fragmentRunsStatBinding = FragmentRunsStatBinding.inflate(getLayoutInflater());

EdgeToEdge.enable(this);
setContentView(binding.getRoot());

replaceFragment(new RunsStatFragment());


binding.bottomNavigationViewSeasons.setOnItemSelectedListener(item -> {
if (item.getItemId() == R.id.runs_frag) {
replaceFragment(new RunsStatFragment());
Expand All @@ -47,17 +54,17 @@ private void replaceFragment(Fragment fragment){
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (fragment instanceof RunsStatFragment) {
Intent intent = this.getIntent();
String seasonName = "123";
String days = "123";
String runs = "123";
String resort = "123";
String vertical_m = "123";
String distance = "123";
String active= "123";
String max_Speed="123";
String max_alt="123";
String tallestRun="123";
String longestRun="123";
String seasonName = "Summer 2024";
String days = "12";
String runs = "12";
String resort = "2";
String vertical_m = "10024";
String distance = "231";
String active= "12";
String max_Speed="6.3";
String max_alt="10.45";
String tallestRun="9.31";
String longestRun="25";
if (intent != null){

seasonName = intent.getStringExtra("seasonName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import androidx.core.view.WindowInsetsCompat;

import java.util.ArrayList;
import java.util.Random;

import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.databinding.ActivitySeasonStatBinding;
Expand All @@ -33,10 +34,38 @@ protected void onCreate(Bundle savedInstanceState) {
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
String[] seasonNames = {"Season 2020 - 2021", "Season 2021 - 2022", "Season 2022 - 2023", "Season 2023 - 2024"};
String[] seasonNames = {"2020 - 2021 Season Stats", "2021 - 2022 Season Stats", "2022 - 2023 Season Stats", "2023 - 2024 Season Stats"};
Random random = new Random();

String[] Days = new String[4];
int[] VerticalM = new int[4];
int[] Runs = new int[4];
double[] DistanceKM = new double[4];
int[] Resort = new int[4];
String[] Active = new String[4];
double[] MaxSpeed = new double[4];
int[] MaxAltitude = new int[4];
int[] TallestRun = new int[4];
double[] LongestRun = new double[4];

ArrayList<DummySeason> seasonArrayList = new ArrayList<>();
for (int i = 0; i < seasonNames.length ; i++){
seasonArrayList.add(new DummySeason(seasonNames[i],i,i,i,i,i,"10:10:10", i,i,i,i));
for (int i = 0; i < 4; i++) {
Days[i] = Integer.toString(random.nextInt(1001));
VerticalM[i] = random.nextInt(1000);
Runs[i] = random.nextInt(20);
DistanceKM[i] = random.nextDouble() * 20;
Resort[i] = random.nextInt(10) + 1;
int hours = random.nextInt(24);
int minutes = random.nextInt(60);
int seconds = random.nextInt(60);
String activeTime = String.format("%02d:%02d:%02d", hours, minutes, seconds);
Active[i] = activeTime;
MaxSpeed[i] = random.nextDouble() * 100;
TallestRun[i] = (int) (random.nextDouble() * 100);
MaxAltitude[i] = (int) (random.nextDouble() * 5000);
LongestRun[i] = random.nextDouble() * 10;

seasonArrayList.add(new DummySeason(seasonNames[i], Integer.parseInt(Days[i]), Runs[i], Resort[i], VerticalM[i], DistanceKM[i], Active[i], MaxSpeed[i], MaxAltitude[i], TallestRun[i], LongestRun[i]));
}

SeasonListAdapter listAdapter = new SeasonListAdapter(SeasonStatActivity.this, seasonArrayList);
Expand Down
166 changes: 159 additions & 7 deletions src/main/res/layout/fragment_runs_stat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
android:layout_height="wrap_content"
android:gravity="center"
android:text="Season Name"
android:textSize="30dp"
android:textSize="24dp"
android:textStyle="bold"
android:background="#0047AB"
android:textColor="#FFFFFF"
android:padding="6dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand All @@ -29,6 +32,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Season Totals"
android:layout_marginStart="20dp"
android:textSize="18dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
Expand Down Expand Up @@ -83,7 +87,7 @@
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vertical M"
android:text="Vertical m"
android:layout_marginTop="-10dp"
android:textSize="15dp"
android:textStyle="bold"
Expand Down Expand Up @@ -148,7 +152,7 @@
android:id="@+id/textView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Distance Km"
android:text="Distance KM"
android:layout_marginTop="-10dp"
android:textSize="15dp"
android:textStyle="bold"
Expand Down Expand Up @@ -237,6 +241,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Season Bests"
android:layout_marginStart="20dp"
android:textSize="18dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
Expand Down Expand Up @@ -264,7 +269,7 @@
android:id="@+id/textView111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Max Km/h"
android:text="Max KM/H"
android:layout_marginTop="-10dp"
android:textSize="15dp"
android:textStyle="bold"
Expand All @@ -291,7 +296,7 @@
android:id="@+id/textView112"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tallest Run M"
android:text="Tallest Run m"
android:layout_marginTop="-10dp"
android:textSize="15dp"
android:textStyle="bold"
Expand Down Expand Up @@ -329,7 +334,7 @@
android:id="@+id/textView121"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Max Altitude M"
android:text="Max Altitude m"
android:layout_marginTop="-10dp"
android:textSize="15dp"
android:textStyle="bold"
Expand All @@ -356,7 +361,7 @@
android:id="@+id/textView122"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Distance Km"
android:text="Longest run KM"
android:layout_marginTop="-10dp"
android:textSize="15dp"
android:textStyle="bold"
Expand All @@ -374,6 +379,153 @@
</FrameLayout>
</LinearLayout>

<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Season Favorites"
android:layout_marginStart="20dp"
android:textSize="18dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/row12" />

<!-- Season Favorites -->
<LinearLayout
android:id="@+id/row13"
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
android:layout_margin="10dp"
app:layout_constraintTop_toBottomOf="@id/textView6"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp">

<TextView
android:id="@+id/max_speed_tv_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="McTavish Street"
android:textSize="15dp"
android:layout_marginStart="20dp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
</FrameLayout>

<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp">

<TextView
android:id="@+id/max_speed_tv_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="37 Days"
android:textSize="15dp"
android:layout_gravity="right"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
</FrameLayout>
</LinearLayout>

<LinearLayout
android:id="@+id/row14"
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
android:layout_margin="10dp"
app:layout_constraintTop_toBottomOf="@id/row13"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp">

<TextView
android:id="@+id/max_speed_tv_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="West Islands"
android:textSize="15dp"
android:layout_marginStart="20dp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
</FrameLayout>

<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp">

<TextView
android:id="@+id/max_speed_tv_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="173 Rides"
android:textSize="15dp"
android:layout_gravity="right"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
</FrameLayout>
</LinearLayout>

<LinearLayout
android:id="@+id/row15"
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
android:layout_margin="10dp"
app:layout_constraintTop_toBottomOf="@id/row14"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp">

<TextView
android:id="@+id/max_speed_tv_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mont Royal"
android:textSize="15dp"
android:layout_marginStart="20dp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
</FrameLayout>

<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp">

<TextView
android:id="@+id/max_speed_tv_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="132 Rides"
android:textSize="15dp"
android:layout_gravity="right"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
</FrameLayout>
</LinearLayout>


</androidx.constraintlayout.widget.ConstraintLayout>

</layout>

0 comments on commit f5825e0

Please sign in to comment.