Skip to content

Commit f00fcc6

Browse files
committed
Initial
0 parents  commit f00fcc6

40 files changed

+1327
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

.idea/gradle.xml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
defaultConfig {
6+
applicationId "com.danhasting.radar"
7+
minSdkVersion 15
8+
targetSdkVersion 26
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'com.android.support:appcompat-v7:26.1.0'
24+
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
25+
testImplementation 'junit:junit:4.12'
26+
androidTestImplementation 'com.android.support.test:runner:1.0.1'
27+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
28+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.danhasting.radar;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.danhasting.radar", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.danhasting.radar">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity android:name=".MainActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
<activity android:name=".RadarActivity"></activity>
22+
</application>
23+
24+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.danhasting.radar;
2+
3+
import android.content.Intent;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
import android.view.View;
7+
import android.widget.ArrayAdapter;
8+
import android.widget.Spinner;
9+
import android.widget.Switch;
10+
11+
public class MainActivity extends AppCompatActivity {
12+
13+
@Override
14+
protected void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
setContentView(R.layout.activity_main);
17+
18+
Spinner typeSpinner = findViewById(R.id.typeSpinner);
19+
ArrayAdapter<CharSequence> typeAdapter = ArrayAdapter.createFromResource(
20+
this, R.array.type_names, android.R.layout.simple_spinner_dropdown_item);
21+
typeSpinner.setAdapter(typeAdapter);
22+
23+
Spinner locationSpinner = findViewById(R.id.locationSpinner);
24+
ArrayAdapter<CharSequence> locationAdapter = ArrayAdapter.createFromResource(
25+
this, R.array.location_names, android.R.layout.simple_spinner_dropdown_item);
26+
locationSpinner.setAdapter(locationAdapter);
27+
28+
}
29+
30+
public void viewRadar(View v) {
31+
Intent radarIntent = new Intent(MainActivity.this, RadarActivity.class);
32+
33+
Spinner typeSpinner = findViewById(R.id.typeSpinner);
34+
radarIntent.putExtra("type",
35+
getResources().getStringArray(R.array.type_values)[typeSpinner.getSelectedItemPosition()]);
36+
37+
Spinner locationSpinner = findViewById(R.id.locationSpinner);
38+
radarIntent.putExtra("location",
39+
getResources().getStringArray(R.array.location_values)[locationSpinner.getSelectedItemPosition()]);
40+
41+
Switch loopSwitch = findViewById(R.id.loopSwitch);
42+
radarIntent.putExtra("loop", loopSwitch.isChecked());
43+
44+
MainActivity.this.startActivity(radarIntent);
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package com.danhasting.radar;
2+
3+
import android.content.Intent;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
import android.util.Log;
7+
import android.webkit.WebView;
8+
9+
public class RadarActivity extends AppCompatActivity {
10+
11+
@Override
12+
protected void onCreate(Bundle savedInstanceState) {
13+
super.onCreate(savedInstanceState);
14+
setContentView(R.layout.activity_radar);
15+
16+
Intent intent = getIntent();
17+
String type = intent.getStringExtra("type");
18+
String location = intent.getStringExtra("location");
19+
Boolean loop = intent.getBooleanExtra("loop", false);
20+
21+
WebView radarWebView = findViewById(R.id.radarWebView);
22+
radarWebView.getSettings().setLoadWithOverviewMode(true);
23+
radarWebView.getSettings().setUseWideViewPort(true);
24+
25+
radarWebView.loadData(displayLiteImage(location, type, loop), "text/html", null);
26+
}
27+
28+
public String displayMosaicImage(String mosaic, Boolean loop) {
29+
String url = "https://radar.weather.gov/Conus/";
30+
if (loop) {
31+
url += "Loop/"+mosaic+"_loop.gif";
32+
} else {
33+
url += "RadarImg/"+mosaic+".gif";
34+
}
35+
36+
return displayRadar(url);
37+
}
38+
39+
public String displayMosaicImage(String mosaic) {
40+
return displayMosaicImage(mosaic, false);
41+
}
42+
43+
public String displayLiteImage(String loc, String type, Boolean loop) {
44+
String url = "https://radar.weather.gov/lite/"+type+"/";
45+
if (loop) {
46+
url += loc+"_loop.gif";
47+
} else {
48+
url += loc+"_0.png";
49+
}
50+
51+
return displayRadar(url);
52+
}
53+
54+
public String displayLiteImage(String loc, String type) {
55+
return displayLiteImage(loc, type, false);
56+
}
57+
58+
public String displayLiteImage(String loc) {
59+
return displayLiteImage(loc, "N0R", false);
60+
}
61+
62+
public String displayRadar(String url) {
63+
String data =
64+
"<html>" +
65+
"<head>" +
66+
"<meta name=\"viewport\" content=\"user-scalable=yes, width=device-width, height=device-height, target-densitydpi=device-dpi, initial-scale=1, minimum-scale=1, maximum-scale=2\">" +
67+
"<style>body {margin:0;} img {min-width:100%}</style>" +
68+
"<script>document.addEventListener('DOMContentLoaded', function() {\n" +
69+
" scrollTo(($(document).width() - $(window).width()) / 2, 0);\n" +
70+
"});</script>" +
71+
"</head>" +
72+
"<body>" +
73+
"<img src=\""+url+"\" alt=\"Failed to load image.\" />" +
74+
"</body>" +
75+
"</html>";
76+
return data;
77+
}
78+
79+
public String displayEnhancedRadar(String loc, String type) {
80+
String data =
81+
"<html>" +
82+
"<head>" +
83+
"<meta name=\"viewport\" content=\"user-scalable=yes, width=device-width, height=device-height, target-densitydpi=device-dpi, initial-scale=1, minimum-scale=1, maximum-scale=2\">" +
84+
"<style>body {margin:0;} div {position:absolute;top:0;}img {min-width:100%}</style>" +
85+
"</head>" +
86+
"<body>\n" +
87+
"<div id=\"image0\"><img style=\"z-index:0\" src=\"https://radar.weather.gov/ridge/Overlays/Topo/Short/"+loc+"_Topo_Short.jpg\"></div>\n" +
88+
"<div id=\"image1\"><img style=\"z-index:1\" src=\"https://radar.weather.gov/ridge/RadarImg/"+type+"/"+loc+"_"+type+"_0.gif\" name=\"conditionalimage\"></div>\n" +
89+
"<div id=\"image2\"><img style=\"z-index:2\" src=\"https://radar.weather.gov/ridge/Overlays/County/Short/"+loc+"_County_Short.gif\"></div>\n" +
90+
"<div id=\"image4\"><img style=\"z-index:4\" src=\"https://radar.weather.gov/ridge/Overlays/Highways/Short/"+loc+"_Highways_Short.gif\"></div>\n" +
91+
"<div id=\"image5\"><img style=\"z-index:5\" src=\"https://radar.weather.gov/ridge/Overlays/Cities/Short/"+loc+"_City_Short.gif\"></div>\n" +
92+
"<div id=\"image6\"><img style=\"z-index:6\" src=\"https://radar.weather.gov/ridge/Warnings/Short/"+loc+"_Warnings_0.gif\" border=\"0\"></div>\n" +
93+
"<div id=\"image7\"><img style=\"z-index:7\" src=\"https://radar.weather.gov/ridge/Legend/"+type+"/"+loc+"_N0R_Legend_0.gif\" name=\"conditionallegend\" border=\"0\"></div>\n" +
94+
"</body>" +
95+
"</html>";
96+
return data;
97+
}
98+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportHeight="108"
6+
android:viewportWidth="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeColor="#00000000"
11+
android:strokeWidth="1">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0" />
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0" />
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeColor="#00000000"
33+
android:strokeWidth="1" />
34+
</vector>

0 commit comments

Comments
 (0)