Make it easier to understand years statistics diagram when there are few months (#7454)
This commit is contained in:
parent
f30cdf0e80
commit
a0d9f2aa7e
|
@ -751,6 +751,7 @@
|
||||||
<string name="statistics_expected_next_episode_any_day">Any day now</string>
|
<string name="statistics_expected_next_episode_any_day">Any day now</string>
|
||||||
<string name="statistics_expected_next_episode_unknown">Unknown</string>
|
<string name="statistics_expected_next_episode_unknown">Unknown</string>
|
||||||
<string name="statistics_view_all">All podcasts »</string>
|
<string name="statistics_view_all">All podcasts »</string>
|
||||||
|
<string name="statistics_years_barchart_description">Time played per month</string>
|
||||||
<string name="wait_icon" translatable="false">…</string>
|
<string name="wait_icon" translatable="false">…</string>
|
||||||
<string name="edit_url_menu">Edit feed URL</string>
|
<string name="edit_url_menu">Edit feed URL</string>
|
||||||
<string name="edit_url_confirmation_msg">Changing the RSS address can easily break the playback state and episode listings of the podcast. We do NOT recommend changing it and will NOT provide support if anything goes wrong. This cannot be undone. The broken subscription CANNOT be repaired by simply changing the address back. We recommend creating a backup before continuing.</string>
|
<string name="edit_url_confirmation_msg">Changing the RSS address can easily break the playback state and episode listings of the podcast. We do NOT recommend changing it and will NOT provide support if anything goes wrong. This cannot be undone. The broken subscription CANNOT be repaired by simply changing the address back. We recommend creating a backup before continuing.</string>
|
||||||
|
|
|
@ -89,19 +89,26 @@ public class BarChartView extends AppCompatImageView {
|
||||||
paintBars.setStrokeWidth(height * 0.015f);
|
paintBars.setStrokeWidth(height * 0.015f);
|
||||||
paintBars.setColor(colors[0]);
|
paintBars.setColor(colors[0]);
|
||||||
int colorIndex = 0;
|
int colorIndex = 0;
|
||||||
int lastYear = data.size() > 0 ? data.get(0).getYear() : 0;
|
int prevYear = data.isEmpty() ? 0 : data.get(0).getYear();
|
||||||
|
int monthsInFirstYear = 0;
|
||||||
|
while (monthsInFirstYear < data.size() && data.get(monthsInFirstYear).getYear() == data.get(0).getYear()) {
|
||||||
|
monthsInFirstYear++;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
float x = textPadding + (i + 1) * stepSize;
|
float x = textPadding + (i + 1) * stepSize;
|
||||||
if (lastYear != data.get(i).getYear()) {
|
if (prevYear != data.get(i).getYear() || (i == 0 && monthsInFirstYear > 4)) {
|
||||||
lastYear = data.get(i).getYear();
|
prevYear = data.get(i).getYear();
|
||||||
colorIndex++;
|
colorIndex++;
|
||||||
paintBars.setColor(colors[colorIndex % 2]);
|
paintBars.setColor(colors[colorIndex % 2]);
|
||||||
if (i < data.size() - 2) {
|
if (i < data.size() - 4) {
|
||||||
canvas.drawText(String.valueOf(data.get(i).getYear()), x + stepSize,
|
canvas.drawText(String.valueOf(data.get(i).getYear()), x + stepSize,
|
||||||
barHeight + (height - barHeight + textSize) / 2, paintGridText);
|
barHeight + (height - barHeight + textSize) / 2, paintGridText);
|
||||||
}
|
}
|
||||||
|
if (data.get(i).getMonth() == 1) {
|
||||||
canvas.drawLine(x, height, x, barHeight, paintGridText);
|
canvas.drawLine(x, height, x, barHeight, paintGridText);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float valuePercentage = (float) Math.max(0.005, (float) data.get(i).getTimePlayed() / maxValue);
|
float valuePercentage = (float) Math.max(0.005, (float) data.get(i).getTimePlayed() / maxValue);
|
||||||
float y = (1 - valuePercentage) * barHeight;
|
float y = (1 - valuePercentage) * barHeight;
|
||||||
|
|
|
@ -11,6 +11,14 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="200dp" />
|
android:layout_height="200dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/barchart_description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:text="@string/statistics_years_barchart_description"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
|
Loading…
Reference in New Issue