Skip to content

Commit db1fe74

Browse files
authored
Merge pull request #4137 from Navid200/Navid_2025_08_21
Statistics time period label
2 parents bd79f78 + 12e0895 commit db1fe74

File tree

3 files changed

+113
-106
lines changed

3 files changed

+113
-106
lines changed

app/src/main/java/com/eveningoutpost/dexdrip/stats/StatsActivity.java

Lines changed: 29 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -207,55 +207,35 @@ void setButtonColors() {
207207
break;
208208
}
209209

210-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
211-
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{0xFF606060});
212-
buttonTD.setBackgroundTintList(csl);
213-
buttonYTD.setBackgroundTintList(csl);
214-
button7d.setBackgroundTintList(csl);
215-
button30d.setBackgroundTintList(csl);
216-
button90d.setBackgroundTintList(csl);
217-
csl = new ColorStateList(new int[][]{new int[0]}, new int[]{0xFFAA0000});
218-
switch (state) {
219-
case TODAY:
220-
buttonTD.setBackgroundTintList(csl);
221-
break;
222-
case YESTERDAY:
223-
buttonYTD.setBackgroundTintList(csl);
224-
break;
225-
case D7:
226-
button7d.setBackgroundTintList(csl);
227-
break;
228-
case D30:
229-
button30d.setBackgroundTintList(csl);
230-
break;
231-
case D90:
232-
button90d.setBackgroundTintList(csl);
233-
break;
234-
}
235-
} else {
236-
237-
buttonTD.setAlpha(0.5f);
238-
buttonYTD.setAlpha(0.5f);
239-
button7d.setAlpha(0.5f);
240-
button30d.setAlpha(0.5f);
241-
button90d.setAlpha(0.5f);
242-
switch (state) {
243-
case TODAY:
244-
buttonTD.setAlpha(1f);
245-
break;
246-
case YESTERDAY:
247-
buttonYTD.setAlpha(1f);
248-
break;
249-
case D7:
250-
button7d.setAlpha(1f);
251-
break;
252-
case D30:
253-
button30d.setAlpha(1f);
254-
break;
255-
case D90:
256-
button90d.setAlpha(1f);
257-
break;
258-
}
210+
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{0xFF606060});
211+
buttonTD.setBackgroundTintList(csl);
212+
buttonYTD.setBackgroundTintList(csl);
213+
button7d.setBackgroundTintList(csl);
214+
button30d.setBackgroundTintList(csl);
215+
button90d.setBackgroundTintList(csl);
216+
TextView statsTimePeriodLabelText = findViewById(R.id.stats_time_period_label);
217+
csl = new ColorStateList(new int[][]{new int[0]}, new int[]{0xFFAA0000});
218+
switch (state) {
219+
case TODAY:
220+
buttonTD.setBackgroundTintList(csl);
221+
statsTimePeriodLabelText.setText(R.string.today);
222+
break;
223+
case YESTERDAY:
224+
buttonYTD.setBackgroundTintList(csl);
225+
statsTimePeriodLabelText.setText(R.string.yesterday);
226+
break;
227+
case D7:
228+
button7d.setBackgroundTintList(csl);
229+
statsTimePeriodLabelText.setText(R.string.last_7_days);
230+
break;
231+
case D30:
232+
button30d.setBackgroundTintList(csl);
233+
statsTimePeriodLabelText.setText(R.string.last_30_days);
234+
break;
235+
case D90:
236+
button90d.setBackgroundTintList(csl);
237+
statsTimePeriodLabelText.setText(R.string.last_90_days);
238+
break;
259239
}
260240
}
261241

app/src/main/res/layout/activity_statistics.xml

Lines changed: 79 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -21,65 +21,87 @@
2121
android:minHeight="1dp"
2222
android:minWidth="1dp">
2323

24-
<Button
24+
<LinearLayout
2525
android:layout_width="wrap_content"
2626
android:layout_height="wrap_content"
27-
android:text="TD"
28-
android:id="@+id/button_stats_today"
29-
android:layout_marginTop="1dp"
30-
android:layout_marginBottom="1dp"
31-
android:paddingTop="1dp"
32-
android:paddingBottom="1dp"
33-
android:minHeight="1dp"
34-
android:minWidth="1dp"/>
35-
36-
<Button
37-
android:layout_width="wrap_content"
38-
android:layout_height="wrap_content"
39-
android:text="YTD"
40-
android:id="@+id/button_stats_yesterday"
41-
android:layout_marginTop="1dp"
42-
android:layout_marginBottom="1dp"
43-
android:paddingTop="1dp"
44-
android:paddingBottom="1dp"
45-
android:minHeight="1dp"
46-
android:minWidth="1dp"/>
47-
48-
<Button
49-
android:layout_width="wrap_content"
50-
android:layout_height="wrap_content"
51-
android:text="7d"
52-
android:id="@+id/button_stats_7d"
53-
android:layout_marginTop="1dp"
54-
android:layout_marginBottom="1dp"
55-
android:paddingTop="1dp"
56-
android:paddingBottom="1dp"
57-
android:minHeight="1dp"
58-
android:minWidth="1dp"/>
59-
60-
<Button
61-
android:layout_width="wrap_content"
62-
android:layout_height="wrap_content"
63-
android:text="30d"
64-
android:id="@+id/button_stats_30d"
65-
android:layout_marginTop="1dp"
66-
android:layout_marginBottom="1dp"
67-
android:paddingTop="1dp"
68-
android:paddingBottom="1dp"
69-
android:minHeight="1dp"
70-
android:minWidth="1dp"/>
71-
72-
<Button
73-
android:layout_width="wrap_content"
74-
android:layout_height="wrap_content"
75-
android:text="90d"
76-
android:id="@+id/button_stats_90d"
77-
android:layout_marginTop="0dp"
78-
android:layout_marginBottom="0dp"
79-
android:paddingTop="1dp"
80-
android:paddingBottom="1dp"
81-
android:minHeight="1dp"
82-
android:minWidth="1dp"/>
27+
android:layout_marginBottom="10dp"
28+
android:orientation="vertical">
29+
30+
<TextView
31+
android:id="@+id/stats_time_period_label"
32+
android:layout_width="wrap_content"
33+
android:layout_height="wrap_content"
34+
android:layout_gravity="center_horizontal"
35+
android:text="Stats time period label">
36+
</TextView>
37+
38+
<LinearLayout
39+
android:id="@+id/stats_buttons_layout"
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content">
42+
43+
<Button
44+
android:layout_width="wrap_content"
45+
android:layout_height="wrap_content"
46+
android:text="TD"
47+
android:id="@+id/button_stats_today"
48+
android:layout_marginTop="1dp"
49+
android:layout_marginBottom="1dp"
50+
android:paddingTop="1dp"
51+
android:paddingBottom="1dp"
52+
android:minHeight="1dp"
53+
android:minWidth="1dp" />
54+
55+
<Button
56+
android:layout_width="wrap_content"
57+
android:layout_height="wrap_content"
58+
android:text="YTD"
59+
android:id="@+id/button_stats_yesterday"
60+
android:layout_marginTop="1dp"
61+
android:layout_marginBottom="1dp"
62+
android:paddingTop="1dp"
63+
android:paddingBottom="1dp"
64+
android:minHeight="1dp"
65+
android:minWidth="1dp" />
66+
67+
<Button
68+
android:layout_width="wrap_content"
69+
android:layout_height="wrap_content"
70+
android:text="7d"
71+
android:id="@+id/button_stats_7d"
72+
android:layout_marginTop="1dp"
73+
android:layout_marginBottom="1dp"
74+
android:paddingTop="1dp"
75+
android:paddingBottom="1dp"
76+
android:minHeight="1dp"
77+
android:minWidth="1dp" />
78+
79+
<Button
80+
android:layout_width="wrap_content"
81+
android:layout_height="wrap_content"
82+
android:text="30d"
83+
android:id="@+id/button_stats_30d"
84+
android:layout_marginTop="1dp"
85+
android:layout_marginBottom="1dp"
86+
android:paddingTop="1dp"
87+
android:paddingBottom="1dp"
88+
android:minHeight="1dp"
89+
android:minWidth="1dp" />
90+
91+
<Button
92+
android:layout_width="wrap_content"
93+
android:layout_height="wrap_content"
94+
android:text="90d"
95+
android:id="@+id/button_stats_90d"
96+
android:layout_marginTop="0dp"
97+
android:layout_marginBottom="0dp"
98+
android:paddingTop="1dp"
99+
android:paddingBottom="1dp"
100+
android:minHeight="1dp"
101+
android:minWidth="1dp" />
102+
</LinearLayout>
103+
104+
</LinearLayout>
83105

84106
<ImageButton
85107
android:layout_width="35dp"

app/src/main/res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,4 +1972,9 @@
19721972
<string name="sensor_will_expire_in">Sensor will expire in %1$s</string>
19731973
<string name="xdrip_update">xDrip+ Update</string>
19741974
<string name="a_new_version_on_channel_1_s_is_available">A new version on channel %1$s is available</string>
1975+
<string name="today">Today</string>
1976+
<string name="yesterday">Yesterday</string>
1977+
<string name="last_7_days">Last 7 days</string>
1978+
<string name="last_30_days">Last 30 days</string>
1979+
<string name="last_90_days">Last 90 days</string>
19751980
</resources>

0 commit comments

Comments
 (0)