};
- actionBar.addTab(actionBar.newTab().setText("CURRENTLY").setTabListener(tabListener));
- actionBar.addTab(actionBar.newTab().setText("FORECAST").setTabListener(tabListener));
+ actionBar.addTab(actionBar.newTab().setText(this.getString(R.string.text_tab_currently)).setTabListener(tabListener));
+ actionBar.addTab(actionBar.newTab().setText(this.getString(R.string.text_tab_five_days_forecast)).setTabListener(tabListener));
}
@Override
final String keyPreference = this.getString(R.string.weather_preferences_day_forecast_key);
final String value = sharedPreferences.getString(keyPreference, "");
String humanValue = "";
- if (value.equals("5")) {
+ if (value.equals(this.getString(R.string.weather_preferences_day_forecast_five_day))) {
humanValue = this.getString(R.string.text_tab_five_days_forecast);
- } else if (value.equals("10")) {
+ } else if (value.equals(this.getString(R.string.weather_preferences_day_forecast_ten_day))) {
humanValue = this.getString(R.string.text_tab_ten_days_forecast);
- } else if (value.equals("14")) {
+ } else if (value.equals(this.getString(R.string.weather_preferences_day_forecast_fourteen_day))) {
humanValue = this.getString(R.string.text_tab_fourteen_days_forecast);
}
actionBar.getTabAt(1).setText(humanValue);
.getString(R.string.weather_preferences_update_time_rate_key);
final String updateTimeRate = sharedPreferences.getString(keyPreference, "");
long chosenInterval = 0;
- if (updateTimeRate.equals("900")) {
+ if (updateTimeRate.equals(context.getString(R.string.update_time_rate_900))) {
chosenInterval = AlarmManager.INTERVAL_FIFTEEN_MINUTES;
- } else if (updateTimeRate.equals("1800")) {
+ } else if (updateTimeRate.equals(context.getString(R.string.update_time_rate_1800))) {
chosenInterval = AlarmManager.INTERVAL_HALF_HOUR;
- } else if (updateTimeRate.equals("3600")) {
+ } else if (updateTimeRate.equals(context.getString(R.string.update_time_rate_3600))) {
chosenInterval = AlarmManager.INTERVAL_HOUR;
- } else if (updateTimeRate.equals("43200")) {
+ } else if (updateTimeRate.equals(context.getString(R.string.update_time_rate_43200))) {
chosenInterval = AlarmManager.INTERVAL_HALF_DAY;
- } else if (updateTimeRate.equals("86400")) {
+ } else if (updateTimeRate.equals(context.getString(R.string.update_time_rate_86400))) {
chosenInterval = AlarmManager.INTERVAL_DAY;
}
if (current != null && this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) {
this.updateUI(current);
} else {
- // Load remote data (aynchronous)
+ // Load remote data (asynchronous)
// Gets the data from the web.
this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.VISIBLE);
this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.GONE);
final String APIVersion = localContext.getResources().getString(R.string.api_version);
final String urlAPI = localContext.getResources().getString(R.string.uri_api_weather_forecast);
- // TODO: number as resource
- final String url = weatherService.createURIAPIForecast(urlAPI, APIVersion, latitude, longitude, "14");
+ final String url = weatherService.createURIAPIForecast(urlAPI, APIVersion, latitude, longitude, localContext.getString(R.string.weather_preferences_day_forecast_fourteen_day));
final String urlWithoutCache = url.concat("&time=" + System.currentTimeMillis());
final String jsonData = HTTPClient.retrieveDataAsString(new URL(urlWithoutCache));
final SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(this.getApplicationContext());
- // TODO: repeating the same code in Overview, Specific and Current!!!
// 1. Update units of measurement.
// 1.1 Temperature
String tempSymbol;
return R.drawable.weather_showers;
}
},
+ // TODO: I am sometimes receiving this code, there is no documentation about it on the
+ // openweathermap site.... But it exists!!! Some day, try to find out more information about it.
+ // see: http://openweathermap.org/img/w/10dd.png
+ ICON_10dd("10dd") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_showers_scattered;
+ }
+ },
ICON_10d("10d") {
@Override
public int getResourceDrawable() {
import name.gumartinm.weather.information.R;
public class WidgetConfigure extends Activity {
+ private static final String WIDGET_PREFERENCES_NAME = "WIDGET_PREFERENCES";
private int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
@Override
String realKeyPreference = keyPreference + "_" + mAppWidgetId;
// What was saved to permanent storage (or default values if it is the first time)
- final boolean isShowCountry = this.getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE)
+ final boolean isShowCountry = this.getSharedPreferences(WIDGET_PREFERENCES_NAME, Context.MODE_PRIVATE)
.getBoolean(realKeyPreference, false);
// What is shown on the screen
realKeyPreference = keyPreference + "_" + mAppWidgetId;
// What was saved to permanent storage (or default values if it is the first time)
- final int tempValue = this.getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE).getInt(realKeyPreference, 0);
+ final int tempValue = this.getSharedPreferences(WIDGET_PREFERENCES_NAME, Context.MODE_PRIVATE).getInt(realKeyPreference, 0);
// What is shown on the screen
final Spinner tempUnits = (Spinner) this.findViewById(R.id.weather_appwidget_configure_temperature_units);
public void onClickOk(final View view) {
// Save to permanent storage
final SharedPreferences.Editor prefs = this.getSharedPreferences(
- "WIDGET_PREFERENCES",
+ WIDGET_PREFERENCES_NAME,
Context.MODE_PRIVATE).edit();
/******************* Show/hide country field *******************/
public static void deletePreference(final Context context, final int appWidgetId) {
final SharedPreferences.Editor prefs = context.getApplicationContext()
- .getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE).edit();
+ .getSharedPreferences(WIDGET_PREFERENCES_NAME, Context.MODE_PRIVATE).edit();
/******************* Show/hide country field *******************/
String keyPreference = context.getApplicationContext().getString(
public class WidgetIntentService extends IntentService {
private static final String TAG = "WidgetIntentService";
- private static final String WIDGET_PREFERENCES = "WIDGET_PREFERENCES";
+ private static final String WIDGET_PREFERENCES_NAME = "WIDGET_PREFERENCES";
public WidgetIntentService() {
super("WIS-Thread");
String keyPreference = this.getApplicationContext().getString(R.string.widget_preferences_temperature_units_key);
String realKeyPreference = keyPreference + "_" + appWidgetId;
// What was saved to permanent storage (or default values if it is the first time)
- final int tempValue = this.getSharedPreferences(WIDGET_PREFERENCES, Context.MODE_PRIVATE).getInt(realKeyPreference, 0);
+ final int tempValue = this.getSharedPreferences(WIDGET_PREFERENCES_NAME, Context.MODE_PRIVATE).getInt(realKeyPreference, 0);
final String tempSymbol = this.getResources().getStringArray(R.array.weather_preferences_temperature)[tempValue];
if (tempValue == 0) {
tempUnitsConversor = new UnitsConversor(){
keyPreference = this.getApplicationContext().getString(R.string.widget_preferences_country_switch_key);
realKeyPreference = keyPreference + "_" + appWidgetId;
// What was saved to permanent storage (or default values if it is the first time)
- final boolean isCountry = this.getSharedPreferences(WIDGET_PREFERENCES, Context.MODE_PRIVATE)
+ final boolean isCountry = this.getSharedPreferences(WIDGET_PREFERENCES_NAME, Context.MODE_PRIVATE)
.getBoolean(realKeyPreference, false);
-->
<resources>
<string-array name="weather_preferences_day_forecast">
- <item>5</item>
- <item>10</item>
- <item>14</item>
+ <item>@string/weather_preferences_day_forecast_five_day</item>
+ <item>@string/weather_preferences_day_forecast_ten_day</item>
+ <item>@string/weather_preferences_day_forecast_fourteen_day</item>
</string-array>
<string-array name="weather_preferences_day_forecast_human_value">
- <item>5 day forecast</item>
- <item>10 day forecast</item>
- <item>14 day forecast</item>
+ <item>@string/weather_preferences_day_forecast_human_value_five_day</item>
+ <item>@string/weather_preferences_day_forecast_human_value_ten_day</item>
+ <item>@string/weather_preferences_day_forecast_human_value_fourteen_day</item>
</string-array>
<string-array name="weather_preferences_update_time_rate">
- <item>900</item>
- <item>1800</item>
- <item>3600</item>
- <item>43200</item>
- <item>86400</item>
+ <item>@string/update_time_rate_900</item>
+ <item>@string/update_time_rate_1800</item>
+ <item>@string/update_time_rate_3600</item>
+ <item>@string/update_time_rate_43200</item>
+ <item>@string/update_time_rate_86400</item>
</string-array>
<string-array name="weather_preferences_update_time_rate_human_value">
- <item>fifteen minutes</item>
- <item>half hour</item>
- <item>one hour</item>
- <item>half day</item>
- <item>one day</item>
+ <item>@string/weather_preferences_update_time_rate_human_value_fifteen_minutes</item>
+ <item>@string/weather_preferences_update_time_rate_human_value_half_hour</item>
+ <item>@string/weather_preferences_update_time_rate_human_value_one_hour</item>
+ <item>@string/weather_preferences_update_time_rate_human_value_half_day</item>
+ <item>@string/weather_preferences_update_time_rate_human_value_one_day</item>
</string-array>
<string-array name="weather_preferences_refresh_interval">
- <item>300000</item>
- <item>900000</item>
- <item>1800000</item>
- <item>3600000</item>
- <item>7200000</item>
- <item>43200000</item>
- <item>86400000</item>
+ <item>@string/refresh_interval_300000</item>
+ <item>@string/refresh_interval_900000</item>
+ <item>@string/refresh_interval_1800000</item>
+ <item>@string/refresh_interval_3600000</item>
+ <item>@string/refresh_interval_7200000</item>
+ <item>@string/refresh_interval_43200000</item>
+ <item>@string/refresh_interval_86400000</item>
</string-array>
<string-array name="weather_preferences_refresh_interval_human_value">
- <item>five minutes</item>
- <item>fifteen minutes</item>
- <item>half hour</item>
- <item>one hour</item>
- <item>two hours</item>
- <item>half day</item>
- <item>one day</item>
+ <item>@string/weather_preferences_refresh_interval_human_value_five_minutes</item>
+ <item>@string/weather_preferences_refresh_interval_human_value_fifteen_minutes</item>
+ <item>@string/weather_preferences_refresh_interval_human_value_half_hour</item>
+ <item>@string/weather_preferences_refresh_interval_human_value_one_hour</item>
+ <item>@string/weather_preferences_refresh_interval_human_value_two_hours</item>
+ <item>@string/weather_preferences_refresh_interval_human_value_half_day</item>
+ <item>@string/weather_preferences_refresh_interval_human_value_one_day</item>
</string-array>
<string-array name="weather_preferences_temperature">
<item>@string/weather_preferences_temperature_celsius</item>
<string name="text_tab_five_days_forecast">5 DAY FORECAST</string>
<string name="text_tab_ten_days_forecast">10 DAY FORECAST</string>
<string name="text_tab_fourteen_days_forecast">14 DAY FORECAST</string>
+ <string name="text_tab_currently">CURRENTLY</string>
<string name="text_field_sun_rise">SUN RISE</string>
<string name="text_field_sun_set">SUN SET</string>
<string name="text_field_feels_like">FEELS LIKE</string>
<string name="weather_preferences_notifications_switch_key">weather_preferences_notifications_switch</string>
<string name="weather_preferences_update_time_rate_key">weather_preferences_update_time_rate</string>
<string name="weather_preferences_update_time_rate">Update time rate</string>
+ <string name="weather_preferences_update_time_rate_human_value_fifteen_minutes">fifteen minutes</string>
+ <string name="weather_preferences_update_time_rate_human_value_half_hour">half hour</string>
+ <string name="weather_preferences_update_time_rate_human_value_one_hour">one hour</string>
+ <string name="weather_preferences_update_time_rate_human_value_half_day">half day</string>
+ <string name="weather_preferences_update_time_rate_human_value_one_day">one day</string>
+ <string name="weather_preferences_refresh_interval_human_value_five_minutes">five minutes</string>
+ <string name="weather_preferences_refresh_interval_human_value_fifteen_minutes">fifteen minutes</string>
+ <string name="weather_preferences_refresh_interval_human_value_half_hour">half hour</string>
+ <string name="weather_preferences_refresh_interval_human_value_one_hour">one hour</string>
+ <string name="weather_preferences_refresh_interval_human_value_two_hours">two hours</string>
+ <string name="weather_preferences_refresh_interval_human_value_half_day">half day</string>
+ <string name="weather_preferences_refresh_interval_human_value_one_day">one day</string>
<string name="weather_preferences_notifications_temperature_key">weather_preferences_notifications_temperature</string>
<string name="weather_preferences_notifications_temperature">Temperature</string>
<string name="weather_preferences_day_forecast_key">weather_preferences_day_forecast</string>
<string name="weather_preferences_day_forecast">Forecast days number</string>
+ <string name="weather_preferences_day_forecast_human_value_five_day">5 day forecast</string>
+ <string name="weather_preferences_day_forecast_human_value_ten_day">10 day forecast</string>
+ <string name="weather_preferences_day_forecast_human_value_fourteen_day">14 day forecast</string>
<string name="weather_preferences_refresh_interval_key">weather_preferences_refresh_interval</string>
<string name="weather_preferences_refresh_interval">Refresh interval</string>
<string name="weather_preferences_wind_key">weather_preferences_wind</string>
<string name="my_url">http://gumartinm.name</string>
<string name="openweathermap_url">http://openweathermap.org/</string>
<string name="http_client_agent">Android WeatherInformation Agent</string>
-
+ <string name="update_time_rate_900">900</string>
+ <string name="update_time_rate_1800">1800</string>
+ <string name="update_time_rate_3600">3600</string>
+ <string name="update_time_rate_43200">43200</string>
+ <string name="update_time_rate_86400">86400</string>
+ <string name="refresh_interval_300000">300000</string>
+ <string name="refresh_interval_900000">900000</string>
+ <string name="refresh_interval_1800000">1800000</string>
+ <string name="refresh_interval_3600000">3600000</string>
+ <string name="refresh_interval_7200000">7200000</string>
+ <string name="refresh_interval_43200000">43200000</string>
+ <string name="refresh_interval_86400000">86400000</string>
+ <string name="weather_preferences_day_forecast_five_day">5</string>
+ <string name="weather_preferences_day_forecast_ten_day">10</string>
+ <string name="weather_preferences_day_forecast_fourteen_day">14</string>
</resources>
android:entries="@array/weather_preferences_update_time_rate_human_value"
android:entryValues="@array/weather_preferences_update_time_rate"
android:title="@string/weather_preferences_update_time_rate"
- android:defaultValue="900"
+ android:defaultValue="@string/update_time_rate_900"
android:persistent="true"
android:selectable="true"
android:summary="fifteen minutes"