diff --git a/app/google-services.json b/app/google-services.json index ef6b146cc..288f3e725 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -15,20 +15,20 @@ }, "oauth_client": [ { - "client_id": "private_client_id", + "client_id": "954248734559-ssksg9m6vjn1tjqk4i4mv5jjk7pib1j9.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { - "current_key": "private_key" + "current_key": "AIzaSyDL1ls9pyufkMpuSbLT7Zk4Zvspeita05A" } ], "services": { "appinvite_service": { "other_platform_oauth_client": [ { - "client_id": "private_client_id", + "client_id": "954248734559-ssksg9m6vjn1tjqk4i4mv5jjk7pib1j9.apps.googleusercontent.com", "client_type": 3 } ] @@ -37,4 +37,4 @@ } ], "configuration_version": "1" -} +} \ No newline at end of file diff --git a/app/src/main/java/com/ds/avare/content/ContentProviderHelper.java b/app/src/main/java/com/ds/avare/content/ContentProviderHelper.java index d9c9b291b..2f893e51c 100644 --- a/app/src/main/java/com/ds/avare/content/ContentProviderHelper.java +++ b/app/src/main/java/com/ds/avare/content/ContentProviderHelper.java @@ -160,6 +160,21 @@ public static Taf getTaf(Context ctx, String station) { return taf; } + /** + * + * @param taf + * @return + */ + public static void setTaf(Context ctx, Taf taf) { + + ContentValues newValues = new ContentValues(); + + newValues.put(WeatherContract.TAF_STATION, taf.getStationId()); + newValues.put(WeatherContract.TAF_TEXT, taf.getRawText()); + newValues.put(WeatherContract.TAF_TIME, taf.getTime()); + ctx.getContentResolver().insert(WeatherContract.CONTENT_URI_TAF, newValues); + } + /** * * @param station @@ -194,6 +209,24 @@ public static Metar getMetar(Context ctx, String station) { return metar; } + /** + * + * @param metar + * @return + */ + public static void setMetar(Context ctx, Metar metar) { + + ContentValues newValues = new ContentValues(); + + newValues.put(WeatherContract.METAR_STATION, metar.getStationId()); + newValues.put(WeatherContract.METAR_TEXT, metar.getRawText()); + newValues.put(WeatherContract.METAR_TIME, metar.getTime()); + newValues.put(WeatherContract.METAR_FLIGHT_CATEGORY, metar.getFlightCategory()); + newValues.put(WeatherContract.METAR_LATITUDE, metar.getLat()); + newValues.put(WeatherContract.METAR_LONGITUDE, metar.getLon()); + ctx.getContentResolver().insert(WeatherContract.CONTENT_URI_METAR, newValues); + } + /** * @@ -234,6 +267,29 @@ public static LinkedList getAirSigMets(Context ctx) { return airsig; } + /** + * + * @param a + * @return + */ + public static void setAirSigMet(Context ctx, AirSigMet a) { + + ContentValues newValues = new ContentValues(); + + newValues.put(WeatherContract.AIRMET_TEXT, a.getRawText()); + newValues.put(WeatherContract.AIRMET_TIME_FROM, a.getTimeFrom()); + newValues.put(WeatherContract.AIRMET_TIME_TO, a.getTimeTo()); + newValues.put(WeatherContract.AIRMET_POINTS, a.getPoints()); + newValues.put(WeatherContract.AIRMET_MSL_MIN, a.getMinFt()); + newValues.put(WeatherContract.AIRMET_MSL_MAX, a.getMaxFt()); + newValues.put(WeatherContract.AIRMET_MOVEMENT_DIRECTION, a.getMovementDeg()); + newValues.put(WeatherContract.AIRMET_MOVEMENT_SPEED, a.getMovementKt()); + newValues.put(WeatherContract.AIRMET_HAZARD, a.getHazard()); + newValues.put(WeatherContract.AIRMET_SEVERITY, a.getSeverity()); + newValues.put(WeatherContract.AIRMET_TYPE, a.getReportType()); + ctx.getContentResolver().insert(WeatherContract.CONTENT_URI_AIRMET, newValues); + } + /** * * @return @@ -290,6 +346,24 @@ public int compare(Airep a1, Airep a2) { return list; } + /** + * + * @param a + * @return + */ + public static void setAirep(Context ctx, Airep a) { + + ContentValues newValues = new ContentValues(); + + newValues.put(WeatherContract.PIREP_TEXT, a.getRawText()); + newValues.put(WeatherContract.PIREP_TIME, a.getTime()); + newValues.put(WeatherContract.PIREP_LONGITUDE, a.getLon()); + newValues.put(WeatherContract.PIREP_LATITUDE, a.getLat()); + newValues.put(WeatherContract.PIREP_TYPE, a.getReportType()); + + ctx.getContentResolver().insert(WeatherContract.CONTENT_URI_PIREP, newValues); + } + /** * @@ -339,6 +413,33 @@ public static WindsAloft getWindsAloft(Context ctx, double lon, double lat) { return wa; } + /** + * + * @param a + * @return + */ + public static void setWindsAloft(Context ctx, WindsAloft wa) { + + ContentValues newValues = new ContentValues(); + + newValues.put(WeatherContract.WIND_STATION, wa.getStation()); + newValues.put(WeatherContract.WIND_TIME, wa.getTime()); + newValues.put(WeatherContract.WIND_LONGITUDE, wa.getLon()); + newValues.put(WeatherContract.WIND_LATITUDE, wa.getLat()); + newValues.put(WeatherContract.WIND_3K, wa.getW3k()); + newValues.put(WeatherContract.WIND_6K, wa.getW6k()); + newValues.put(WeatherContract.WIND_9K, wa.getW9k()); + newValues.put(WeatherContract.WIND_12K, wa.getW12k()); + newValues.put(WeatherContract.WIND_18K, wa.getW18k()); + newValues.put(WeatherContract.WIND_24K, wa.getW24k()); + newValues.put(WeatherContract.WIND_30K, wa.getW30k()); + newValues.put(WeatherContract.WIND_34K, wa.getW34k()); + newValues.put(WeatherContract.WIND_39K, wa.getW39k()); + + ctx.getContentResolver().insert(WeatherContract.CONTENT_URI_WIND, newValues); + } + + /** * * @return diff --git a/app/src/main/java/com/ds/avare/content/DataSource.java b/app/src/main/java/com/ds/avare/content/DataSource.java index e73c21d71..411423bf3 100644 --- a/app/src/main/java/com/ds/avare/content/DataSource.java +++ b/app/src/main/java/com/ds/avare/content/DataSource.java @@ -309,6 +309,28 @@ public LinkedList getAirSigMets() { return ContentProviderHelper.getAirSigMets(mContext); } + + public void setTaf(Taf taf) { + ContentProviderHelper.setTaf(mContext, taf); + } + + public void setMetar(Metar metar) { + ContentProviderHelper.setMetar(mContext, metar); + } + + public void setAirep(Airep airep) { + ContentProviderHelper.setAirep(mContext, airep); + } + + public void setWindsAloft(WindsAloft wa) { + ContentProviderHelper.setWindsAloft(mContext, wa); + } + + public void setAirSigMet(AirSigMet asm) { + ContentProviderHelper.setAirSigMet(mContext, asm); + } + + public LinkedList findProcedure(String name, String approach) { return ContentProviderHelper.findProcedure(mContext, name, approach); } diff --git a/app/src/main/java/com/ds/avare/content/WeatherContract.java b/app/src/main/java/com/ds/avare/content/WeatherContract.java index d576bd012..9b9e920e0 100644 --- a/app/src/main/java/com/ds/avare/content/WeatherContract.java +++ b/app/src/main/java/com/ds/avare/content/WeatherContract.java @@ -71,6 +71,8 @@ public static Uri buildMetarUri(long id){ public static final String METAR_TIME = "issue_time"; public static final String METAR_STATION = "station_id"; public static final String METAR_FLIGHT_CATEGORY = "flight_category"; + public static final String METAR_LATITUDE = "latitude"; + public static final String METAR_LONGITUDE = "longitude"; public static final String BASE_WIND = "wa"; public static final Uri CONTENT_URI_WIND = Uri.withAppendedPath(AUTHORITY_URI, BASE_WIND); diff --git a/app/src/main/java/com/ds/avare/content/WeatherDatabaseHelper.java b/app/src/main/java/com/ds/avare/content/WeatherDatabaseHelper.java index 23f28e909..12f5f2bbd 100644 --- a/app/src/main/java/com/ds/avare/content/WeatherDatabaseHelper.java +++ b/app/src/main/java/com/ds/avare/content/WeatherDatabaseHelper.java @@ -3,6 +3,8 @@ import android.content.Context; import android.database.sqlite.SQLiteDatabase; +import com.ds.avare.utils.WeatherHelper; + /** * Created by zkhan on 3/13/17. */ @@ -18,6 +20,80 @@ public WeatherDatabaseHelper(Context context, String folder) { @Override public void onCreate(SQLiteDatabase db) { + + try { + db.execSQL( + "CREATE TABLE " + WeatherContract.TABLE_AIRMET + " (" + + WeatherContract.AIRMET_TEXT + " TEXT, " + + WeatherContract.AIRMET_TIME_FROM + " TEXT, " + + WeatherContract.AIRMET_TIME_TO + " TEXT, " + + WeatherContract.AIRMET_POINTS + " TEXT, " + + WeatherContract.AIRMET_MSL_MIN + " TEXT, " + + WeatherContract.AIRMET_MSL_MAX + " TEXT, " + + WeatherContract.AIRMET_MOVEMENT_DIRECTION + " TEXT, " + + WeatherContract.AIRMET_MOVEMENT_SPEED + " TEXT, " + + WeatherContract.AIRMET_HAZARD + " TEXT, " + + WeatherContract.AIRMET_SEVERITY + " TEXT, " + + WeatherContract.AIRMET_TYPE + " TEXT);"); + } + catch (Exception e) { + } + + try { + db.execSQL( + "CREATE TABLE " + WeatherContract.TABLE_PIREP + " (" + + WeatherContract.PIREP_TEXT + " TEXT, " + + WeatherContract.PIREP_TIME + " TEXT, " + + WeatherContract.PIREP_LONGITUDE + " FLOAT, " + + WeatherContract.PIREP_LATITUDE + " FLOAT, " + + WeatherContract.PIREP_TYPE + " TEXT);"); + } + catch (Exception e) { + } + + try { + db.execSQL( + "CREATE TABLE " + WeatherContract.TABLE_TAF + " (" + + WeatherContract.TAF_TEXT + " TEXT, " + + WeatherContract.TAF_TIME + " TEXT, " + + WeatherContract.TAF_STATION + " TEXT UNIQUE ON CONFLICT REPLACE);"); + } + catch (Exception e) { + } + + try { + db.execSQL( + "CREATE TABLE " + WeatherContract.TABLE_METAR + " (" + + WeatherContract.METAR_TEXT + " TEXT, " + + WeatherContract.METAR_TIME + " TEXT, " + + WeatherContract.METAR_STATION + " TEXT UNIQUE ON CONFLICT REPLACE, " + + WeatherContract.METAR_FLIGHT_CATEGORY + " TEXT, " + + WeatherContract.METAR_LONGITUDE + " FLOAT, " + + WeatherContract.METAR_LATITUDE + " FLOAT);"); + } + catch (Exception e) { + } + + try { + db.execSQL( + "CREATE TABLE " + WeatherContract.TABLE_WIND + " (" + + WeatherContract.WIND_STATION + " TEXT, " + + WeatherContract.WIND_TIME + " TEXT, " + + WeatherContract.WIND_LONGITUDE + " FLOAT, " + + WeatherContract.WIND_LATITUDE + " FLOAT, " + + WeatherContract.WIND_3K + " TEXT, " + + WeatherContract.WIND_6K + " TEXT, " + + WeatherContract.WIND_9K + " TEXT, " + + WeatherContract.WIND_12K + " TEXT, " + + WeatherContract.WIND_18K + " TEXT, " + + WeatherContract.WIND_24K + " TEXT, " + + WeatherContract.WIND_30K + " TEXT, " + + WeatherContract.WIND_34K + " TEXT, " + + WeatherContract.WIND_39K + " TEXT);"); + } + catch (Exception e) { + } + } @Override diff --git a/app/src/main/java/com/ds/avare/weather/AdsbWeatherCache.java b/app/src/main/java/com/ds/avare/weather/AdsbWeatherCache.java index cbb852488..50bfd74b9 100644 --- a/app/src/main/java/com/ds/avare/weather/AdsbWeatherCache.java +++ b/app/src/main/java/com/ds/avare/weather/AdsbWeatherCache.java @@ -44,31 +44,19 @@ */ public class AdsbWeatherCache { - private HashMap mTaf; - private HashMap mMetar; - private HashMap mAirep; - private HashMap mWinds; private HashMap mSua; private NexradImage mNexrad; private NexradImageConus mNexradConus; private Preferences mPref; - private RateLimitedBackgroundQueue mMetarQueue; - private HashMap mAirSig; /** * */ public AdsbWeatherCache() { mPref = StorageService.getInstance().getPreferences(); - mTaf = new HashMap(); - mMetar = new HashMap(); - mAirep = new HashMap(); - mWinds = new HashMap(); mNexrad = new NexradImage(); - mMetarQueue = new RateLimitedBackgroundQueue(StorageService.getInstance()); mNexradConus = new NexradImageConus(); mSua = new HashMap(); - mAirSig = new HashMap(); } /** @@ -107,8 +95,7 @@ public void putMetar(long time, String location, String data, String flightCateg m.setTime(sdf.format(dt) + "Z"); m.setFlightCategory(flightCategory); m.setTimestamp(System.currentTimeMillis()); - mMetar.put(location, m); - mMetarQueue.insertMetarInQueue(m); // This will slowly make a metar map + StorageService.getInstance().getDBResource().setMetar(m); } @@ -188,9 +175,6 @@ public HashMap getAllMetars() { * @param data */ public void putTaf(long time, String location, String data) { - if(!mPref.useAdsbWeather()) { - return; - } Taf f = new Taf(); f.setRawText(location + " " + data); f.setStationId(location); @@ -199,7 +183,7 @@ public void putTaf(long time, String location, String data) { sdf.setTimeZone(TimeZone.getTimeZone("gmt")); f.setTime(sdf.format(dt) + "Z"); f.setTimestamp(System.currentTimeMillis()); - mTaf.put(location, f); + StorageService.getInstance().getDBResource().setTaf(f); } /** @@ -270,14 +254,11 @@ public void putSua(long time, String data) { * @param to */ public void putAirSigMet(long time, String id, String shape, String points, String text, String from, String to) { - if(!mPref.useAdsbWeather() || null == id) { + if(null == id) { return; } - AirSigMet s = mAirSig.get(id); - if(null == s) { - s = new AirSigMet(); - } + AirSigMet s = new AirSigMet(); s.setTimestamp(System.currentTimeMillis()); if(text != null && (!text.equals(""))) { @@ -350,8 +331,7 @@ else if(text.contains("CONVECTIVE OUTLOOK")) { s.getShape().makePolygon(); } - - mAirSig.put(id, s); + StorageService.getInstance().getDBResource().setAirSigMet(s); } @@ -362,9 +342,6 @@ else if(text.contains("CONVECTIVE OUTLOOK")) { * @param data */ public void putAirep(long time, String location, String data, DataSource db) { - if(!mPref.useAdsbWeather()) { - return; - } String lonlat = db.findLonLat(location, Destination.BASE); if(null == lonlat) { return; @@ -395,9 +372,6 @@ public void putAirep(long time, String location, String data, DataSource db) { * @param data */ public void putWinds(long time, String location, String data) { - if(!mPref.useAdsbWeather()) { - return; - } WindsAloft w = new WindsAloft(); w.setStation(location); @@ -433,7 +407,7 @@ public void putWinds(long time, String location, String data) { w.setLon(coords[0]); w.setLat(coords[1]); w.timestamp = System.currentTimeMillis(); - mWinds.put(location, w); + StorageService.getInstance().getDBResource().setWindsAloft(w); } /**