Skip to content

Commit

Permalink
Shifted about to the main settings drawer and added a zoom option to …
Browse files Browse the repository at this point in the history
…the stats page
  • Loading branch information
evilbunny2008 committed May 7, 2018
1 parent f3b4fc2 commit 16a7c3b
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 66 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 3002
versionName "0.3.2"
versionCode 3004
versionName "0.3.4"
}
buildTypes {
release {
Expand Down
29 changes: 0 additions & 29 deletions app/src/main/java/com/odiousapps/weewxweather/About.java

This file was deleted.

59 changes: 54 additions & 5 deletions app/src/main/java/com/odiousapps/weewxweather/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -34,9 +36,11 @@
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RemoteViews;
import android.widget.Spinner;
import android.widget.TextView;

import java.io.BufferedReader;
import java.io.File;
Expand All @@ -60,6 +64,8 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
private EditText et1;
private Button b1;
private Button b2;
private Button b3;
private boolean showSettings = true;

private ProgressDialog dialog;

Expand Down Expand Up @@ -144,6 +150,12 @@ public void onFocusChange(View v, boolean hasFocus)

b1 = findViewById(R.id.button);
b2 = findViewById(R.id.deleteData);
b3 = findViewById(R.id.aboutButton);

LinearLayout settingsLayout = findViewById(R.id.settingsLayout);
settingsLayout.setVisibility(View.VISIBLE);
LinearLayout aboutLayout = findViewById(R.id.aboutLayout);
aboutLayout.setVisibility(View.GONE);

b1.setOnClickListener(new View.OnClickListener()
{
Expand All @@ -170,6 +182,46 @@ public void onClick(View arg0)
checkReally();
}
});

b3.setOnClickListener(new View.OnClickListener()
{
public void onClick(View arg0)
{
if(showSettings)
{
showSettings = false;
b1.setVisibility(View.INVISIBLE);
b3.setText(R.string.settings2);

LinearLayout settingsLayout = findViewById(R.id.settingsLayout);
settingsLayout.setVisibility(View.GONE);
LinearLayout aboutLayout = findViewById(R.id.aboutLayout);
aboutLayout.setVisibility(View.VISIBLE);
} else {
showSettings = true;
b1.setVisibility(View.VISIBLE);
b3.setText(R.string.about2);

LinearLayout aboutLayout = findViewById(R.id.aboutLayout);
aboutLayout.setVisibility(View.GONE);
LinearLayout settingsLayout = findViewById(R.id.settingsLayout);
settingsLayout.setVisibility(View.VISIBLE);
}

}
});

TextView tv = findViewById(R.id.aboutText);

String lines = "<html><body>Big thanks to the <a href='http://weewx.com'>weeWx project</a>, as this app " +
"wouldn't be possible otherwise.<br><br>" +
"Weather Icons from <a href='https://www.flaticon.com/'>FlatIcon</a> and " +
"is licensed under <a href='http://creativecommons.org/licenses/by/3.0/'>CC 3.0 BY</a><br><br>" +
"<a href='https://www.yahoo.com/?ilc=401'>Yahoo! Weather</a> Forecast API<br><br>" +
"This app is by <a href='https://odiousapps.com'>OdiousApps</a>.</body</html>";

tv.setText(Html.fromHtml(lines));
tv.setMovementMethod(LinkMovementMethod.getInstance());
}

private void hideKeyboard(View view)
Expand Down Expand Up @@ -212,6 +264,7 @@ public void onClick(DialogInterface dialoginterface, int i)
common.RemovePref("LastDownload");
common.RemovePref("LastDownloadTime");
common.RemovePref("radarforecast");
common.RemovePref("seekBar");
common.commit();

common.context.stopService(new Intent(common.context, myService.class));
Expand Down Expand Up @@ -828,7 +881,6 @@ public static class PlaceholderFragment extends Fragment
private Forecast forecast;
private Webcam webcam;
private Custom custom;
private About about;

public PlaceholderFragment() {}

Expand Down Expand Up @@ -893,9 +945,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
} else if(getArguments().getInt(ARG_SECTION_NUMBER) == 5) {
custom = new Custom(common);
return custom.myCustom(inflater, container);
} else if(getArguments().getInt(ARG_SECTION_NUMBER) == 6) {
about = new About();
return about.myAbout(inflater, container);
}

return null;
Expand All @@ -918,7 +967,7 @@ public Fragment getItem(int position)
@Override
public int getCount()
{
return 6;
return 5;
}
}
}
38 changes: 35 additions & 3 deletions app/src/main/java/com/odiousapps/weewxweather/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.webkit.WebView;
import android.widget.SeekBar;
import android.widget.TextView;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;

public class Stats
{
private Common common;
private View rootView;
private WebView wv;
private SeekBar seekBar;

Stats(Common common)
Stats(Common common)
{
this.common = common;
}
Expand Down Expand Up @@ -84,6 +88,30 @@ public void onScrollChanged() {
}
});

seekBar = rootView.findViewById(R.id.pageZoom);
seekBar.setProgress(common.GetIntPref("seekBar", 10));

seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b)
{
updateFields();
if(b)
common.SetIntPref("seekBar", i);
}

@Override
public void onStartTrackingTouch(SeekBar seekBar)
{
}

@Override
public void onStopTrackingTouch(SeekBar seekBar)
{
}
});

updateFields();

IntentFilter filter = new IntentFilter();
Expand Down Expand Up @@ -212,10 +240,14 @@ private void updateFields()
checkFields((TextView)rootView.findViewById(R.id.textView), bits[56]);
checkFields((TextView)rootView.findViewById(R.id.textView2), bits[54] + " " + bits[55]);

double percent = (seekBar.getProgress() + 90) / 100.00;
NumberFormat formatter = new DecimalFormat("#0.00");
String p = formatter.format(percent);

String stmp;
StringBuilder sb = new StringBuilder();

String header = "<html><body style='text-align:center;'>";
String header = "<html><body style='text-align:center; transform: scale(" + p + "); transform-origin: 0 0;'>";
String footer = "</body></html>";

sb.append(header);
Expand All @@ -239,7 +271,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);

stmp = "<tr><td><img style='width:"+iw+"px' src='windsock.png'></td><td colspan='3'>" + bits[25] + bits[61] + " " + bits[32] + " " + convert(bits[33]) +
stmp = "<tr><td><img style='width:"+iw+"px' src='windsock.png'></td><td colspan='3'>" + bits[19] + bits[61] + " " + bits[32] + " " + convert(bits[33]) +
"</td><td>" + bits[20] + bits[62] + "</td><td><img style='width:"+iw+"px' src='umbrella.png'></td></tr>";
sb.append(stmp);

Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/odiousapps/weewxweather/Weather.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,6 @@ public void run()
}

Common.LogMessage("done downloading, prompt handler to draw to movie");
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@
android:layout_height="wrap_content"
android:text="@string/custom2"/>

<android.support.design.widget.TabItem
android:id="@+id/tabItem6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about2"/>

</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>

Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/layout/fragment_stats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
android:layout_height="wrap_content"
android:gravity="center"/>

<SeekBar
android:id="@+id/pageZoom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:hapticFeedbackEnabled="true"
android:max="20"
android:padding="10dp"
android:progress="10"
android:soundEffectsEnabled="true"/>

<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
Expand Down
76 changes: 61 additions & 15 deletions app/src/main/res/layout/main_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main">

<ScrollView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/nav_header_height"
android:orientation="vertical">

<LinearLayout
android:id="@+id/settingsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/nav_header_height"
android:orientation="vertical">

android:orientation="vertical"
android:visibility="visible">

<TextView
android:layout_width="match_parent"
Expand Down Expand Up @@ -117,25 +119,69 @@
android:text="@string/show_forecast"
android:textSize="18sp"/>
</RadioGroup>
</LinearLayout>

<Button
android:id="@+id/button"
<LinearLayout
android:id="@+id/aboutLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/save_settings"
android:gravity="center_horizontal"
android:text="@string/about"
android:textSize="28sp"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="18sp"/>

<Button
android:id="@+id/deleteData"
<TextView
android:id="@+id/aboutText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/delete_all_data"
android:gravity="center_horizontal"
android:textSize="18sp"/>

</LinearLayout>
</ScrollView>
</android.support.design.widget.NavigationView>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/save_settings"
android:layout_weight="1"
android:textSize="18sp"
tools:ignore="ButtonStyle"/>

<Button
android:id="@+id/aboutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about2"
android:layout_weight="1"
android:textSize="18sp"
tools:ignore="ButtonStyle"/>
</LinearLayout>

<Button
android:id="@+id/deleteData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/delete_all_data"
android:textSize="18sp"/>
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Loading

0 comments on commit 16a7c3b

Please sign in to comment.