diff --git a/app/src/main/java/de/apps4ics/mountainnavigation/MainActivity.java b/app/src/main/java/de/apps4ics/mountainnavigation/MainActivity.java index c514122..1022ba8 100644 --- a/app/src/main/java/de/apps4ics/mountainnavigation/MainActivity.java +++ b/app/src/main/java/de/apps4ics/mountainnavigation/MainActivity.java @@ -125,6 +125,7 @@ private ImageView weatherSymbol; private ImageView weatherWarning; private TextView weatherCity; + private TextView weatherDesc; private TextView weatherMinTemp; private TextView weatherMaxTemp; @@ -205,6 +206,7 @@ weatherSymbol = (ImageView) findViewById(R.id.weather_symbol); weatherWarning = (ImageView) findViewById(R.id.warning_symbol); weatherCity = (TextView) findViewById(R.id.weather_city); + weatherDesc = (TextView) findViewById(R.id.weather_desc); weatherMinTemp = (TextView) findViewById(R.id.weather_min_temp); weatherMaxTemp = (TextView) findViewById(R.id.weather_max_temp); @@ -646,6 +648,7 @@ public MyWeather postRetrieve(MyWeather weather) { weatherSymbol.setImageDrawable(weather.getWeatherCodeImage()); weatherCity.setText(weather.getCity() + ", " + weather.getCountry()); + weatherDesc.setText(weather.getWeatherDesc()); weatherMinTemp.setText(String.format(res.getString(R.string.preferences_n_degree_floating), weather.getMinTemp())); weatherMaxTemp.setText(String.format(res.getString(R.string.preferences_n_degree_floating), weather.getMaxTemp())); if(weather.isSevereWeather()) weatherWarning.setImageDrawable(res.getDrawable(R.drawable.ic_warning)); diff --git a/app/src/main/java/de/apps4ics/mountainnavigation/MyWeather.java b/app/src/main/java/de/apps4ics/mountainnavigation/MyWeather.java index 48b1248..a03c4b7 100644 --- a/app/src/main/java/de/apps4ics/mountainnavigation/MyWeather.java +++ b/app/src/main/java/de/apps4ics/mountainnavigation/MyWeather.java @@ -23,6 +23,7 @@ import android.graphics.drawable.Drawable; import android.location.Location; +import android.util.Log; import com.survivingwithandroid.weather.lib.WeatherCode; import com.survivingwithandroid.weather.lib.model.DayForecast; @@ -43,6 +44,8 @@ private long sunset; private int weatherId; //OWM id private int weatherCode; //OWM code + private String weatherTitle; + private String weatherDesc; private float pressure; private float humidity; private float windSpeed; @@ -95,6 +98,10 @@ city = weather.location.getCity(); country = weather.location.getCountry(); } + weatherDesc = weather.currentCondition.getDescr(); + weatherTitle = weather.currentCondition.getCondition(); + Log.d(MainActivity.TAG, "desc: " + weatherDesc + ", title: " + weatherTitle); + //weather.currentCondition.getWeatherCode().getLabel(null); minTemp = weather.temperature.getMinTemp() > 0 ? weather.temperature.getMinTemp() : -1; maxTemp = weather.temperature.getMaxTemp() > 0 ? weather.temperature.getMaxTemp() : -1; sunrise = weather.location.getSunrise() > 0 ? weather.location.getSunrise() : -1; @@ -372,6 +379,10 @@ return weatherId; } + public String getWeatherTitle() { return weatherTitle; } + + public String getWeatherDesc() { return weatherDesc; } + public float getWindDir() { return windDir; } @@ -440,6 +451,10 @@ this.weatherId = weatherId; } + public void setWeatherTitle(String weatherTitle) { this.weatherTitle = weatherTitle; } + + public void setWeatherDesc(String weatherDesc) { this.weatherDesc = weatherDesc; } + public void setWindDir(float windDir) { this.windDir = windDir; } diff --git a/app/src/main/java/de/apps4ics/mountainnavigation/WeatherDatabase.java b/app/src/main/java/de/apps4ics/mountainnavigation/WeatherDatabase.java index aab74d0..1e4bb1b 100644 --- a/app/src/main/java/de/apps4ics/mountainnavigation/WeatherDatabase.java +++ b/app/src/main/java/de/apps4ics/mountainnavigation/WeatherDatabase.java @@ -46,6 +46,8 @@ private static final String KEY_WEATHER_CODE = "_weather_code"; private static final String KEY_PRESSURE = "_pressure"; private static final String KEY_HUMIDITY = "_humidity"; + private static final String KEY_MAIN = "_main"; + private static final String KEY_DESC = "_desc"; private static final String KEY_WIND_ID = "_wind_id"; private static final String KEY_RAIN = "_rain"; //Rain volume for the last 3 hours private static final String KEY_SNOW = "_snow"; //Snow volume for the last 3 hours @@ -79,6 +81,8 @@ + KEY_WEATHER_CODE + " INTEGER," + KEY_PRESSURE + " REAL," + KEY_HUMIDITY + " REAL," + + KEY_MAIN + " TEXT," + + KEY_DESC + " TEXT," + KEY_WIND_ID + " INTEGER," + KEY_RAIN + " REAL," + KEY_SNOW + " REAL," @@ -129,8 +133,8 @@ weather.setWeatherCode(cursor.getInt(cursor.getColumnIndex(KEY_WEATHER_CODE))); weather.setPressure(cursor.getFloat(cursor.getColumnIndex(KEY_PRESSURE))); weather.setHumidity(cursor.getFloat(cursor.getColumnIndex(KEY_HUMIDITY))); - //cursor.getInt(cursor.getColumnIndex(KEY_MAIN)); - //cursor.getInt(cursor.getColumnIndex(KEY_DESC)); + weather.setWeatherTitle(cursor.getString(cursor.getColumnIndex(KEY_MAIN))); + weather.setWeatherDesc(cursor.getString(cursor.getColumnIndex(KEY_DESC))); weather.setRain(cursor.getFloat(cursor.getColumnIndex(KEY_RAIN))); weather.setSnow(cursor.getFloat(cursor.getColumnIndex(KEY_SNOW))); weather.setClouds(cursor.getInt(cursor.getColumnIndex(KEY_CLOUDS))); @@ -232,6 +236,8 @@ values.put(KEY_WEATHER_CODE, weather.getWeatherCode()); values.put(KEY_PRESSURE, weather.getPressure()); values.put(KEY_HUMIDITY, weather.getHumidity()); + values.put(KEY_MAIN, weather.getWeatherTitle()); + values.put(KEY_DESC, weather.getWeatherDesc()); values.put(KEY_RAIN, weather.getRain()); values.put(KEY_SNOW, weather.getSnow()); values.put(KEY_CLOUDS, weather.getClouds()); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 23289ae..7339ca5 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -85,11 +85,11 @@ @@ -119,6 +119,15 @@ android:layout_height="wrap_content" android:layout_marginLeft="6dp" android:layout_marginStart="6dp" + android:id="@+id/weather_desc" + android:textSize="12sp" + android:textColor="@color/text_color" + android:fontFamily="sans-serif-medium" /> +