Skip to content

Commit 8479bcd

Browse files
committed
Add produced / remaining today
Remove dependenciesInfo block
1 parent 972de57 commit 8479bcd

File tree

6 files changed

+126
-39
lines changed

6 files changed

+126
-39
lines changed

app/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ apply plugin: 'com.android.application'
22

33
android {
44

5+
lintOptions {
6+
disable 'MissingTranslation'
7+
}
8+
9+
dependenciesInfo {
10+
// Disable including dependency metadata when building APKs
11+
includeInApk = false
12+
// Disable including dependency metadata when building Android App Bundles
13+
includeInBundle = false
14+
}
15+
516
compileSdk 34
617

718
defaultConfig {

app/src/main/java/org/woheller69/weather/ui/RecycleList/CityWeatherAdapter.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class CityWeatherAdapter extends RecyclerView.Adapter<CityWeatherAdapter.
3838
private int[] dataSetTypes;
3939
private List<HourlyForecast> courseDayList;
4040
private List<WeekForecast> weekForecastList;
41+
private float producedToday;
42+
private float remainingToday;
4143

4244
private Context context;
4345
private ViewGroup mParent;
@@ -118,6 +120,13 @@ public void updateForecastData(List<HourlyForecast> hourlyForecasts, List<WeekFo
118120
courseDayList.add(f);
119121
}
120122

123+
if (f.getForecastTime() < System.currentTimeMillis() && stepCounter <= 24) producedToday = f.getEnergyCum();
124+
if (f.getForecastTime() > System.currentTimeMillis() && f.getForecastTime() < System.currentTimeMillis() + 3600000 && stepCounter <= 24) {
125+
long millisRemainingThisHour = f.getForecastTime() - System.currentTimeMillis();
126+
long millisSoFarThisHour = 3600000 - millisRemainingThisHour;
127+
producedToday = producedToday + (f.getEnergyCum()-producedToday) * millisSoFarThisHour/3600000;
128+
}
129+
121130
stepCounter++;
122131
// if not in debug mode: Reset energyCumulated after every 24 hours if next step is 01:00 am because values are for previous hour
123132
if (!isDebugMode && stepCounter % 24 == 1) {
@@ -136,7 +145,7 @@ public void updateForecastData(List<HourlyForecast> hourlyForecasts, List<WeekFo
136145
}
137146
weekForecast.setEnergyDay(totalEnergy/1000);
138147
}
139-
148+
remainingToday = weekForecasts.get(0).getEnergyDay()*1000 - producedToday;
140149
weekForecastList = weekForecasts;
141150

142151
notifyDataSetChanged();
@@ -150,15 +159,17 @@ static class ViewHolder extends RecyclerView.ViewHolder {
150159
}
151160

152161
public class OverViewHolder extends ViewHolder {
153-
TextView temperature;
162+
TextView produced;
163+
TextView remaining;
154164
TextView updatetime;
155165
TextView sun;
156166

157167
OverViewHolder(View v) {
158168
super(v);
159-
this.temperature = v.findViewById(R.id.card_overview_temperature);
160169
this.sun=v.findViewById(R.id.card_overview_sunrise_sunset);
161170
this.updatetime=v.findViewById(R.id.card_overview_update_time);
171+
this.produced=v.findViewById(R.id.card_overview_produced_today);
172+
this.remaining=v.findViewById(R.id.card_overview_remaining_today);
162173
}
163174
}
164175

@@ -276,6 +287,8 @@ public void onBindViewHolder(ViewHolder viewHolder, final int position) {
276287

277288
holder.updatetime.setText("("+StringFormatUtils.formatTimeWithoutZone(context, updateTime)+")");
278289

290+
holder.produced.setText(StringFormatUtils.formatEnergyCum(context, producedToday));
291+
holder.remaining.setText(StringFormatUtils.formatEnergyCum(context, remainingToday));
279292

280293
} else if (viewHolder.getItemViewType() == WEEK) {
281294

app/src/main/java/org/woheller69/weather/ui/WeatherCityFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.CHART;
44
import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.DAY;
55
import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.EMPTY;
6+
import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.OVERVIEW;
67
import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.WEEK;
78

89
import android.annotation.SuppressLint;
@@ -38,7 +39,7 @@ public class WeatherCityFragment extends Fragment implements IUpdateableCityUI {
3839

3940
private int mCityId = -1;
4041
private int[] mDataSetTypes = new int[]{};
41-
private static int[] mFull = {DAY, WEEK, CHART}; //TODO Make dynamic from Settings
42+
private static int[] mFull = {OVERVIEW, DAY, WEEK, CHART}; //TODO Make dynamic from Settings
4243
private static int[] mEmpty = {EMPTY};
4344
private CityWeatherAdapter mAdapter;
4445

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

Lines changed: 91 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,116 @@
55
android:layout_height="wrap_content"
66
android:layout_margin="@dimen/card_margin">
77

8-
9-
<TextView
10-
android:layout_width="wrap_content"
11-
android:layout_height="wrap_content"
12-
android:textColor="#fafafa"
13-
android:layout_marginTop="5dp"
14-
android:layout_marginStart="7dp"
15-
android:textSize="12dp"
16-
android:text="Weather data by Open-Meteo.com" />
17-
188
<RelativeLayout
199
android:layout_width="match_parent"
20-
android:layout_height="match_parent"
21-
android:layout_gravity="center_vertical">
22-
10+
android:layout_height="wrap_content"
11+
android:layout_gravity="center_vertical"
12+
android:background="@color/backgroundBlue">
2313

2414
<TextView
25-
android:id="@+id/card_overview_temperature"
26-
android:layout_width="wrap_content"
15+
android:id="@+id/card_overview_header"
16+
android:layout_width="match_parent"
2717
android:layout_height="wrap_content"
28-
android:layout_alignParentEnd="true"
29-
android:layout_centerVertical="true"
18+
android:layout_marginStart="10dp"
19+
android:layout_marginTop="10dp"
3020
android:layout_marginEnd="10dp"
31-
android:background="@drawable/rounded_corner"
32-
android:paddingLeft="7dp"
33-
android:paddingRight="7dp"
21+
android:layout_marginBottom="10dp"
22+
android:gravity="center"
23+
android:text="@string/card_today_heading"
24+
android:textAllCaps="true"
3425
android:textColor="@color/colorPrimaryDark"
35-
android:textSize="45dp" />
26+
android:textStyle="bold" />
27+
28+
<View
29+
android:id="@+id/card_overview_header_spacer"
30+
android:layout_width="match_parent"
31+
android:layout_height="1dp"
32+
android:layout_below="@id/card_overview_header"
33+
android:background="@color/white" />
3634

3735
<TextView
3836
android:id="@+id/card_overview_update_time"
3937
android:layout_width="wrap_content"
4038
android:layout_height="wrap_content"
41-
android:layout_alignParentTop="true"
39+
android:layout_alignBaseline="@id/card_overview_header"
4240
android:layout_alignParentEnd="true"
4341
android:layout_marginEnd="10dp"
4442
android:paddingLeft="7dp"
4543
android:paddingRight="7dp"
4644
android:textColor="#fafafa"
4745
android:textSize="18dp" />
4846

47+
48+
<TextView
49+
android:id="@+id/card_overview_sunrise_sunset"
50+
android:layout_alignBaseline="@id/card_overview_remaining_today"
51+
android:layout_alignParentEnd="true"
52+
android:layout_width="wrap_content"
53+
android:layout_height="wrap_content"
54+
android:textSize="15dp"
55+
android:textColor="@color/colorPrimaryDark"
56+
android:layout_marginEnd="10dp"
57+
android:paddingRight="7dp"
58+
android:paddingLeft="7dp" />
59+
60+
<TextView
61+
android:id="@+id/card_overview_credits"
62+
android:layout_width="wrap_content"
63+
android:layout_height="wrap_content"
64+
android:layout_below="@id/card_overview_sunrise_sunset"
65+
android:layout_centerHorizontal="true"
66+
android:textColor="#fafafa"
67+
android:layout_marginStart="7dp"
68+
android:textSize="12dp"
69+
android:text="Weather data by Open-Meteo.com" />
70+
71+
72+
<TextView
73+
android:id="@+id/card_overview_produced_today_header"
74+
android:layout_width="wrap_content"
75+
android:layout_height="wrap_content"
76+
android:layout_below="@id/card_overview_header_spacer"
77+
android:textAppearance="?android:attr/textAppearanceMedium"
78+
android:textColor="@color/colorPrimaryDark"
79+
android:layout_marginTop="5dp"
80+
android:layout_marginStart="7dp"
81+
android:text="@string/card_today_produced" />
82+
83+
<TextView
84+
android:id="@+id/card_overview_produced_today"
85+
android:layout_width="wrap_content"
86+
android:layout_height="wrap_content"
87+
android:layout_below="@id/card_overview_header_spacer"
88+
android:layout_toEndOf="@id/card_overview_produced_today_header"
89+
android:textAppearance="?android:attr/textAppearanceMedium"
90+
android:textColor="@color/colorPrimaryDark"
91+
android:layout_marginTop="5dp"
92+
android:layout_marginStart="7dp"
93+
android:text="1500 Wh" />
94+
95+
<TextView
96+
android:id="@+id/card_overview_remaining_today_header"
97+
android:layout_width="wrap_content"
98+
android:layout_height="wrap_content"
99+
android:layout_below="@id/card_overview_produced_today"
100+
android:textAppearance="?android:attr/textAppearanceMedium"
101+
android:textColor="@color/colorPrimaryDark"
102+
android:layout_marginTop="5dp"
103+
android:layout_marginStart="7dp"
104+
android:text="@string/card_today_remaining" />
105+
106+
<TextView
107+
android:id="@+id/card_overview_remaining_today"
108+
android:layout_width="wrap_content"
109+
android:layout_height="wrap_content"
110+
android:layout_below="@id/card_overview_produced_today"
111+
android:layout_toEndOf="@id/card_overview_remaining_today_header"
112+
android:textAppearance="?android:attr/textAppearanceMedium"
113+
android:textColor="@color/colorPrimaryDark"
114+
android:layout_marginTop="5dp"
115+
android:layout_marginStart="7dp"
116+
android:text="1500 Wh" />
117+
49118
</RelativeLayout>
50-
<TextView
51-
android:id="@+id/card_overview_sunrise_sunset"
52-
android:layout_width="wrap_content"
53-
android:layout_height="wrap_content"
54-
android:layout_gravity="bottom|right"
55-
android:textSize="15dp"
56-
android:textColor="@color/colorPrimaryDark"
57-
android:background="@drawable/rounded_corner"
58-
android:layout_marginEnd="10dp"
59-
android:layout_marginBottom="5dp"
60-
android:paddingRight="7dp"
61-
android:paddingLeft="7dp" />
62119

63120
</androidx.cardview.widget.CardView>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,7 @@
111111
<string name="settings_server_urls">Server URLs</string>
112112
<string name="settings_server_summary">Nur ändern, wenn Sie Ihre eigenen Server betreiben wollen</string>
113113
<string name="edit_location_hint_central_inverter">Zentralwechselrichter</string>
114+
<string name="card_today_heading">Heute</string>
115+
<string name="card_today_produced">Produziert:</string>
116+
<string name="card_today_remaining">Verbleibend:</string>
114117
</resources>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,7 @@
114114
<string name="settings_server_urls">Server URLs</string>
115115
<string name="settings_server_summary">Only change if you want to host your own servers</string>
116116
<string name="edit_location_hint_central_inverter">Central Inverter</string>
117-
117+
<string name="card_today_heading">Today</string>
118+
<string name="card_today_produced">Produced:</string>
119+
<string name="card_today_remaining">Remaining:</string>
118120
</resources>

0 commit comments

Comments
 (0)