Skip to content

Commit

Permalink
Made viewing indoor values optional and added code for viewing rainfa…
Browse files Browse the repository at this point in the history
…ll yesterday from since.py
  • Loading branch information
evilbunny2008 committed May 26, 2018
1 parent d205785 commit 1052437
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.odiousapps.weewxweather"
minSdkVersion 16
targetSdkVersion 26
versionCode 3020
versionName "0.3.20"
versionCode 3021
versionName "0.3.21"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ public void onFocusChange(View v, boolean hasFocus)
if(!metric)
cb2.setChecked(false);

boolean showIndoor = common.GetBoolPref("showIndoor", false);
CheckBox cb3 = findViewById(R.id.showIndoor);
if(!showIndoor)
cb3.setChecked(false);

boolean radarforecast = common.GetBoolPref("radarforecast", true);
RadioButton showForecast = findViewById(R.id.showForecast);
if(!radarforecast)
Expand Down Expand Up @@ -335,6 +340,7 @@ public void onClick(DialogInterface dialoginterface, int i)
common.RemovePref("CUSTOM_URL");
common.RemovePref("custom_url");
common.RemovePref("metric");
common.RemovePref("showIndoor");
common.RemovePref("bgdl");
common.RemovePref("rssCheck");
common.RemovePref("forecastData");
Expand Down Expand Up @@ -405,6 +411,7 @@ public void run()

CheckBox cb1 = findViewById(R.id.cb1);
CheckBox cb2 = findViewById(R.id.cb2);
CheckBox cb3 = findViewById(R.id.showIndoor);

RadioButton showRadar = findViewById(R.id.showRadar);
int curtime = Math.round(System.currentTimeMillis() / 1000);
Expand Down Expand Up @@ -772,6 +779,7 @@ protected PasswordAuthentication getPasswordAuthentication()
common.SetStringPref("CUSTOM_URL", custom);
common.SetStringPref("custom_url", custom_url);
common.SetBoolPref("metric", cb2.isChecked());
common.SetBoolPref("showIndoor", cb3.isChecked());
common.SetBoolPref("bgdl", cb1.isChecked());
common.SetBoolPref("radarforecast", showRadar.isChecked());

Expand Down
23 changes: 18 additions & 5 deletions app/src/main/java/com/odiousapps/weewxweather/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private void updateFields()
"</td><td>" + convert(bits[42]) + "</td><td>" + bits[41] + bits[63] + "</td><td><img style='width:" + iw + "px' src='barometer.png'></td></tr>";
sb.append(stmp);

if(bits.length > 201)
if(bits.length > 201 && common.GetBoolPref("showIndoor", false))
{
stmp = "<tr><td><img style='width:" + iw + "px' src='home.png'></td><td>" + bits[163] + bits[60] + "</td><td>" + convert(bits[164]) +
"</td><td>" + convert(bits[162]) + "</td><td>" + bits[161] + bits[60] + "</td><td><img style='width:" + iw + "px' src='home.png'></td></tr>";
Expand Down Expand Up @@ -323,7 +323,7 @@ private void updateFields()
"</td><td>" + convert(bits[87]) + "</td><td>" + bits[86] + bits[63] + "</td><td><img style='width:" + iw + "px' src='barometer.png'></td></tr>";
sb.append(stmp);

if(bits.length > 201)
if(bits.length > 201 && common.GetBoolPref("showIndoor", false))
{
stmp = "<tr><td><img style='width:" + iw + "px' src='home.png'></td><td>" + bits[172] + bits[60] + "</td><td>" + convert(bits[173]) +
"</td><td>" + convert(bits[171]) + "</td><td>" + bits[170] + bits[60] + "</td><td><img style='width:" + iw + "px' src='home.png'></td></tr>";
Expand All @@ -338,6 +338,19 @@ private void updateFields()
"</td><td>" + bits[21] + bits[62] + "</td><td><img style='width:" + iw + "px' src='umbrella.png'></td></tr>";
sb.append(stmp);

rain = bits[21];
since = "before mn";

if (bits.length > 203 && !bits[203].equals(""))
rain = bits[202];

if (bits.length > 203 && !bits[202].equals("") && !bits[203].equals(""))
since = "before " + bits[203];

stmp = "<tr><td>&nbsp;</td><td colspan='3'>&nbsp;</td><td>" + since + "</td><td>&nbsp;</td></tr>";
sb.append(stmp);


stmp = "</table><br>";
sb.append(stmp);
}
Expand All @@ -364,7 +377,7 @@ private void updateFields()
"</td><td>" + getTime(bits[110]) + "</td><td>" + bits[109] + bits[63] + "</td><td><img style='width:" + iw + "px' src='barometer.png'></td></tr>";
sb.append(stmp);

if(bits.length > 201)
if(bits.length > 201 && common.GetBoolPref("showIndoor", false))
{
stmp = "<tr><td><img style='width:" + iw + "px' src='home.png'></td><td>" + bits[180] + bits[60] + "</td><td>" + getTime(bits[181]) +
"</td><td>" + getTime(bits[179]) + "</td><td>" + bits[178] + bits[60] + "</td><td><img style='width:" + iw + "px' src='home.png'></td></tr>";
Expand Down Expand Up @@ -405,7 +418,7 @@ private void updateFields()
"</td><td>" + getTime(bits[133]) + "</td><td>" + bits[132] + bits[63] + "</td><td><img style='width:" + iw + "px' src='barometer.png'></td></tr>";
sb.append(stmp);

if(bits.length > 201)
if(bits.length > 201 && common.GetBoolPref("showIndoor", false))
{
stmp = "<tr><td><img style='width:" + iw + "px' src='home.png'></td><td>" + bits[188] + bits[60] + "</td><td>" + getTime(bits[189]) +
"</td><td>" + getTime(bits[187]) + "</td><td>" + bits[186] + bits[60] + "</td><td><img style='width:" + iw + "px' src='home.png'></td></tr>";
Expand Down Expand Up @@ -446,7 +459,7 @@ private void updateFields()
"</td><td>" + getTime(bits[156]) + "</td><td>" + bits[155] + bits[63] + "</td><td><img style='width:" + iw + "px' src='barometer.png'></td></tr>";
sb.append(stmp);

if(bits.length > 201)
if(bits.length > 201 && common.GetBoolPref("showIndoor", false))
{
stmp = "<tr><td><img style='width:" + iw + "px' src='home.png'></td><td>" + bits[196] + bits[60] + "</td><td>" + getTime(bits[197]) +
"</td><td>" + getTime(bits[195]) + "</td><td>" + bits[194] + bits[60] + "</td><td><img style='width:" + iw + "px' src='home.png'></td></tr>";
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/odiousapps/weewxweather/Weather.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.io.BufferedReader;
Expand Down Expand Up @@ -75,6 +76,12 @@ private View updateFields()
checkFields((TextView)rootView.findViewById(R.id.textView14), bits[47]);
checkFields((TextView)rootView.findViewById(R.id.textView15), bits[48]);

LinearLayout homerow = rootView.findViewById(R.id.homerow);
if(common.GetBoolPref("showIndoor", false))
homerow.setVisibility(View.VISIBLE);
else
homerow.setVisibility(View.GONE);

if(bits.length > 169)
{
checkFields((TextView) rootView.findViewById(R.id.hometemp), bits[160] + bits[60]);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_weather.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
</LinearLayout>

<LinearLayout
android:id="@+id/homerow"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/layout/main_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@
android:inputType="textUri"
android:textSize="18sp"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/indoor_readings"
android:textSize="18sp"/>

<CheckBox
android:id="@+id/showIndoor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/yes"
android:textSize="18sp"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@
<string name="custom_url">Enter your custom URL (optional)</string>
<string name="fgColour">Widget Foreground Colour Picker</string>
<string name="bgColour">Widget Background Colour Picker</string>
<string name="indoor_readings">Show Indoor Readings?</string>
</resources>

0 comments on commit 1052437

Please sign in to comment.