import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Calendar;
+import java.util.Date;
import java.util.Locale;
import de.example.exampletdd.httpclient.CustomHTTPClient;
public class WidgetIntentService extends IntentService {
private static final String TAG = "WidgetIntentService";
-
+ private static final long UPDATE_TIME_RATE = 86400000L;
public WidgetIntentService() {
super("WIS-Thread");
protected void onHandleIntent(final Intent intent) {
Log.i(TAG, "onHandleIntent");
final int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
- final boolean isUpdateByApp = intent.getBooleanExtra("updateByApp", false);
+ final boolean isForceRefreshAppWidget = intent.getBooleanExtra("forceRefreshAppWidget", false);
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
// Nothing to do. Something went wrong. Show error.
this.updateWidget(view, appWidgetId);
return;
}
-
- if (isUpdateByApp) {
- this.updateByApp(weatherLocation, appWidgetId);
- } else {
- this.updateByTimeout(weatherLocation, appWidgetId);
- }
-
- }
-
- private void updateByApp(final WeatherLocation weatherLocation, final int appWidgetId) {
- final PermanentStorage store = new PermanentStorage(this.getApplicationContext());
- final Current current = store.getCurrent();
-
- this.updateWidget(current, weatherLocation, appWidgetId);
- }
-
- private void updateByTimeout(final WeatherLocation weatherLocation, final int appWidgetId) {
-
- final Current current = this.getRemoteCurrent(weatherLocation);
-
- this.updateWidget(current, weatherLocation, appWidgetId);
- }
-
- private void updateWidget(final Current current, final WeatherLocation weatherLocation, final int appWidgetId) {
- if (current != null) {
- final RemoteViews view = this.makeView(current, weatherLocation, appWidgetId);
- this.updateWidget(view, appWidgetId);
+ // TODO: improve this code. Too tired right now...
+ if (!isForceRefreshAppWidget && this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) {
+ RemoteViews view;
+
+ final PermanentStorage store = new PermanentStorage(this.getApplicationContext());
+ final Current current = store.getCurrent();
+ if (current != null) {
+ // Update UI.
+ view = this.makeView(current, weatherLocation, appWidgetId);
+ } else {
+ // Show error.
+ view = this.makeErrorView(appWidgetId);
+ }
+ this.updateWidget(view, appWidgetId);
} else {
- // Show error.
- final RemoteViews view = this.makeErrorView(appWidgetId);
- this.updateWidget(view, appWidgetId);
+ RemoteViews view;
+
+ final Current current = this.getRemoteCurrent(weatherLocation);
+ if (current != null) {
+ // Update UI.
+ view = this.makeView(current, weatherLocation, appWidgetId);
+ } else {
+ // Show error.
+ view = this.makeErrorView(appWidgetId);
+ }
+ this.updateWidget(view, appWidgetId);
}
}
-
-
private Current getRemoteCurrent(final WeatherLocation weatherLocation) {
// TODO: repeating the same code in Overview, Specific and Current!!!
// 1. Update units of measurement.
- String tempSymbol;
+
UnitsConversor tempUnitsConversor;
- String keyPreference = this.getApplicationContext().getString(R.string.widget_preferences_temperature_key);
+ 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 String tempValue = this.getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE)
- .getString(realKeyPreference, this.getString(R.string.weather_preferences_temperature_celsius));
- final String[] values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- if (tempValue.equals(values[0])) {
- tempSymbol = values[0];
+ final int tempValue = this.getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE).getInt(realKeyPreference, 0);
+ final String tempSymbol = this.getResources().getStringArray(R.array.weather_preferences_temperature)[tempValue];
+ if (tempValue == 0) {
tempUnitsConversor = new UnitsConversor(){
@Override
}
};
- } else if (tempValue.equals(values[1])) {
- tempSymbol = values[1];
+ } else if (tempValue == 1) {
tempUnitsConversor = new UnitsConversor(){
@Override
};
} else {
- tempSymbol = values[2];
tempUnitsConversor = new UnitsConversor(){
@Override
final AppWidgetManager manager = AppWidgetManager.getInstance(this.getApplicationContext());
manager.updateAppWidget(appWidgetId, remoteView);
}
+
+ private boolean isDataFresh(final Date lastUpdate) {
+ if (lastUpdate == null) {
+ return false;
+ }
+
+ final Date currentTime = new Date();
+ if (((currentTime.getTime() - lastUpdate.getTime())) < UPDATE_TIME_RATE) {
+ return true;
+ }
+
+ return false;
+ }
// private void updateWidgets(final RemoteViews remoteView) {
//
// 4. If is new data (new location) update widgets.
if (weatherLocation.getIsNew()) {
- final ComponentName widgets = new ComponentName(context.getApplicationContext(), WidgetProvider.class);
- final AppWidgetManager manager = AppWidgetManager.getInstance(context.getApplicationContext());
- final int[] appWidgetIds = manager.getAppWidgetIds(widgets);
- for (final int appWidgetId : appWidgetIds) {
- final Intent intentWidget = new Intent(context.getApplicationContext(), WidgetIntentService.class);
- intentWidget.putExtra("updateByApp", true);
- intentWidget.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- context.getApplicationContext().startService(intentWidget);
- }
+ WidgetProvider.updateAllAppWidgets(context);
}
// 5. Update location data.
import android.app.ActionBar;
import android.app.Activity;
import android.appwidget.AppWidgetManager;
+import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
+import android.widget.CompoundButton;
+import android.widget.Spinner;
+import android.widget.Switch;
+
import de.example.exampletdd.R;
public class WidgetConfigure extends Activity {
private int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
- private View.OnClickListener mOnClickListener;
@Override
- public void onCreate(final Bundle icicle) {
- super.onCreate(icicle);
+ public void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
// Find the widget id from the intent.
final Intent intent = getIntent();
// Set the view layout resource to use.
this.setContentView(R.layout.appwidget_configure);
+ /******************* Show/hide country field *******************/
+ String keyPreference = this.getApplicationContext().getString(
+ R.string.widget_preferences_country_switch_key);
+ 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)
+ .getBoolean(realKeyPreference, false);
+
+ // What is shown on the screen
+ final Switch countrySwitch = (Switch) this.findViewById(R.id.weather_appwidget_configure_country);
+ countrySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
+ @Override
+ public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
+ if (isChecked) {
+ buttonView.setText(WidgetConfigure.this.getString(R.string.widget_preferences_country_switch_on_summary));
+ } else {
+ buttonView.setText(WidgetConfigure.this.getString(R.string.widget_preferences_country_switch_off_summary));
+ }
+ }
+ });
+ if (isShowCountry) {
+ countrySwitch.setChecked(true);
+ countrySwitch.setText(this.getString(R.string.widget_preferences_country_switch_on_summary));
+ } else {
+ countrySwitch.setChecked(false);
+ countrySwitch.setText(this.getString(R.string.widget_preferences_country_switch_off_summary));
+ }
- mOnClickListener = new View.OnClickListener() {
- public void onClick(View v) {
+ /********************* Temperature units **********************/
+ keyPreference = this.getApplicationContext().getString(
+ R.string.widget_preferences_temperature_units_key);
+ realKeyPreference = keyPreference + "_" + mAppWidgetId;
- // Save to permanent storage
+ // 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);
- // Push widget update to surface with newly set prefix
- final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(
- WidgetConfigure.this.getApplicationContext());
- WidgetProvider.updateAppWidget(
- WidgetConfigure.this.getApplicationContext(),
- appWidgetManager,
- mAppWidgetId);
+ // What is shown on the screen
+ final Spinner tempUnits = (Spinner) this.findViewById(R.id.weather_appwidget_configure_temperature_units);
+ tempUnits.setSelection(tempValue);
- // Make sure we pass back the original appWidgetId
- final Intent resultValue = new Intent();
- resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
- WidgetConfigure.this.setResult(RESULT_OK, resultValue);
- finish();
- }
- };
- // Bind the action for the save button.
- this.findViewById(R.id.weather_appwidget_configure_save_button).setOnClickListener(mOnClickListener);
+ /**
+ * android:saveEnabled
+ * Controls whether the saving of this view's state is enabled (that is, whether its onSaveInstanceState() method will be called).
+ *
+ * After onStart the onSaveInstanceState method will be called for every widget, so
+ * I do not need to do anything else to retrieve the UI's state after changing orientation.
+ *
+ * I do not know if this is a good pattern, it does not look like that. I guess, I should use
+ * on Resume instead of onCreate/onStart and implement my own onSaveInstanceState method.
+ * But I am tired...
+ */
}
-
+
@Override
public void onResume() {
super.onResume();
final ActionBar actionBar = this.getActionBar();
actionBar.setTitle(this.getString(R.string.widget_preferences_action_settings));
}
+
+
+ public void onClickRefresh(final View view) {
+ // Push widget update to surface
+ WidgetProvider.forceRefreshAppWidget(this.getApplicationContext(), mAppWidgetId);
+ }
+
+ public void onClickOk(final View view) {
+ // Save to permanent storage
+ final SharedPreferences.Editor prefs = this.getSharedPreferences(
+ "WIDGET_PREFERENCES",
+ Context.MODE_PRIVATE).edit();
+
+ /******************* Show/hide country field *******************/
+ // What is shown on the screen
+ final Switch countrySwitch = (Switch) this.findViewById(R.id.weather_appwidget_configure_country);
+ String keyPreference = this.getApplicationContext().getString(
+ R.string.widget_preferences_country_switch_key);
+ String realKeyPreference = keyPreference + "_" + mAppWidgetId;
+ prefs.putBoolean(realKeyPreference, countrySwitch.isChecked());
+
+ /********************* Temperature units **********************/
+ // What is shown on the screen
+ final Spinner tempUnits = (Spinner) this.findViewById(R.id.weather_appwidget_configure_temperature_units);
+ keyPreference = this.getApplicationContext().getString(
+ R.string.widget_preferences_temperature_units_key);
+ realKeyPreference = keyPreference + "_" + mAppWidgetId;
+ prefs.putInt(realKeyPreference, tempUnits.getSelectedItemPosition());
+
+ /****************** Saving to permanent storage ***************/
+ prefs.commit();
+
+ // Push widget update to surface with newly set prefix
+ WidgetProvider.updateAppWidget(this.getApplicationContext(), mAppWidgetId);
+
+ // Make sure we pass back the original appWidgetId
+ final Intent resultValue = new Intent();
+ resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
+ this.setResult(RESULT_OK, resultValue);
+ finish();
+ }
+
+ public static void deletePreference(final Context context, final int appWidgetId) {
+ final SharedPreferences.Editor prefs = context.getApplicationContext()
+ .getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE).edit();
+
+ /******************* Show/hide country field *******************/
+ String keyPreference = context.getApplicationContext().getString(
+ R.string.widget_preferences_country_switch_key);
+ String realKeyPreference = keyPreference + "_" + appWidgetId;
+ prefs.remove(realKeyPreference);
+
+ /********************* Temperature units **********************/
+ keyPreference = context.getApplicationContext().getString(
+ R.string.widget_preferences_temperature_units_key);
+ realKeyPreference = keyPreference + "_" + appWidgetId;
+ prefs.remove(realKeyPreference);
+
+ /****************** Updating permanent storage ***************/
+ prefs.commit();
+ }
}
+++ /dev/null
-package de.example.exampletdd.widget;
-
-import android.appwidget.AppWidgetManager;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.os.Bundle;
-import android.preference.ListPreference;
-import android.preference.PreferenceFragment;
-import android.preference.SwitchPreference;
-import de.example.exampletdd.R;
-
-/**
- * TODO:
- * IT DOES NOT WORK IF USER IS WORKING WITH TWO OR MORE WIDGET PREFERENCE WINDOWS AT THE SAME TIME
- * (hopefully nobody will realize...)
- * How to implement custom preference activities (no extending from PreferenceActivity or PreferenceFragment)
- * without pain?
- */
-public class WidgetPreferences extends PreferenceFragment implements OnSharedPreferenceChangeListener {
- private int mAppWidgetId;
- private boolean mIsCountry;
- private String mTempUnits;
-
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Do not retain this fragment across configuration changes because I am tired for following
- // the fragment lifecycle (I am going to loose the instance field values but I DON'T CARE!!!)
- this.setRetainInstance(false);
-
- final Bundle bundle = this.getArguments();
- mAppWidgetId = bundle.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
-
- // Load the preferences from an XML resource
- this.addPreferencesFromResource(R.xml.appwidget_preferences);
-
-
- /******************* Show/hide country field *******************/
- String keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.widget_preferences_country_switch_key);
- String realKeyPreference = keyPreference + "_" + mAppWidgetId;
-
- // What was saved to permanent storage (or default values if it is the first time)
- final boolean countryValue = this.getActivity().getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE)
- .getBoolean(realKeyPreference, false);
-
- // Update temporal value
- mIsCountry = countryValue;
-
- // What is shown on the screen
- final SwitchPreference countryPref = (SwitchPreference) this.findPreference(keyPreference);
- countryPref.setChecked(countryValue);
-
- /********************* Temperature units **********************/
- final String[] values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- final String[] humanValues = this.getResources().getStringArray(R.array.weather_preferences_temperature_human_value);
-
- keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.widget_preferences_temperature_key);
- realKeyPreference = keyPreference + "_" + mAppWidgetId;
-
-
- // What was saved to permanent storage (or default values if it is the first time)
- final String tempValue = this.getActivity().getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE)
- .getString(realKeyPreference, this.getString(R.string.weather_preferences_temperature_celsius));
- String humanValue = this.getString(R.string.weather_preferences_temperature_celsius_human_value);
- int index = 0;
- if (tempValue.equals(values[0])) {
- index = 0;
- humanValue = humanValues[0];
- } else if (tempValue.equals(values[1])) {
- index = 1;
- humanValue = humanValues[1];
- } else if (tempValue.equals(values[2])) {
- index = 2;
- humanValue = humanValues[2];
- }
-
- // Update temporal value
- mTempUnits = tempValue;
-
- // What is shown on the screen
- final ListPreference listPref = (ListPreference) this.findPreference(keyPreference);
- listPref.setSummary(humanValue);
- listPref.setValueIndex(index);
- listPref.setValue(tempValue);
- }
-
- @Override
- public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key) {
-
- /******************* Show/hide country field *******************/
- String keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.widget_preferences_country_switch_key);
- if (key.equals(keyPreference)) {
- // What is shown on the screen
- final SwitchPreference preference = (SwitchPreference) this.findPreference(key);
- // Update temporal value
- mIsCountry = preference.isChecked();
-
- return;
- }
-
- /********************* Temperature units **********************/
- keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.widget_preferences_temperature_key);
- if (key.equals(keyPreference)) {
- final String[] values = this.getResources().getStringArray(
- R.array.weather_preferences_temperature);
- final String[] humanValues = this.getResources().getStringArray(
- R.array.weather_preferences_temperature_human_value);
-
- // What is shown on the screen
- final ListPreference listPref = (ListPreference) this.findPreference(key);
- final String value = listPref.getValue();
- String humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- }
- // Update data on screen
- listPref.setSummary(humanValue);
-
- // Update temporal value
- mTempUnits = value;
-
- return;
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- this.getPreferenceManager().getSharedPreferences()
- .registerOnSharedPreferenceChangeListener(this);
- }
-
- @Override
- public void onPause() {
- super.onPause();
- this.getPreferenceManager().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(this);
- }
-
- public void onSavePreferences() {
- final SharedPreferences.Editor prefs =
- this.getActivity().getSharedPreferences(
- "WIDGET_PREFERENCES",
- Context.MODE_PRIVATE).edit();
-
- /******************* Show/hide country field *******************/
- String keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.widget_preferences_country_switch_key);
- String realKeyPreference = keyPreference + "_" + mAppWidgetId;
- prefs.putBoolean(realKeyPreference, mIsCountry);
-
-
- /********************* Temperature units **********************/
- keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.widget_preferences_temperature_key);
- realKeyPreference = keyPreference + "_" + mAppWidgetId;
- prefs.putString(realKeyPreference, mTempUnits);
-
- // Saving to permanent storage.
- prefs.commit();
- }
-
- public static void deletePreference(final Context context, final int appWidgetId) {
- final String keyPreference = context.getApplicationContext().getString(
- R.string.widget_preferences_temperature_key);
- final String realKeyPreference = keyPreference + "_" + appWidgetId;
-
- final SharedPreferences.Editor prefs = context.getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE).edit();
- prefs.remove(realKeyPreference);
- prefs.commit();
- }
-}
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.appwidget.AppWidgetProviderInfo;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
// To prevent any ANR timeouts, we perform the update in a service
final Intent intent = new Intent(context.getApplicationContext(), WidgetIntentService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- intent.putExtra("updateByApp", false);
+ intent.putExtra("forceRefreshAppWidget", true);
context.startService(intent);
}
}
// When the user deletes the widget, delete the preference associated with it.
final int N = appWidgetIds.length;
for (int i=0; i<N; i++) {
- WidgetPreferences.deletePreference(context, appWidgetIds[i]);
+ WidgetConfigure.deletePreference(context, appWidgetIds[i]);
}
}
-
- static void updateAppWidget(final Context context, final AppWidgetManager appWidgetManager, final int appWidgetId) {
+
+ static void updateAppWidget(final Context context, final int appWidgetId) {
+ final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context.getApplicationContext());
+
+ updateAppWidget(context, appWidgetManager, appWidgetId);
+ }
+
+ static void forceRefreshAppWidget(final Context context, final int appWidgetId) {
+ final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context.getApplicationContext());
+
+ int widgetId;
+ Bundle myOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
+
+ // Get the value of OPTION_APPWIDGET_HOST_CATEGORY
+ int category = myOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
+
+ // If the value is WIDGET_CATEGORY_KEYGUARD, it's a lockscreen widget
+ boolean isKeyguard = category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
+
+ // Once you know the widget's category, you can optionally load a different base layout, set different
+ // properties, and so on. For example:
+ //int baseLayout = isKeyguard ? R.layout.keyguard_widget_layout : R.layout.widget_layout;
+
+ // Construct the RemoteViews object. It takes the package name (in our case, it's our
+ // package, but it needs this because on the other side it's the widget host inflating
+ // the layout from our package).
+ //final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget);
+
+ final Intent intent = new Intent(context.getApplicationContext(), WidgetIntentService.class);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ intent.putExtra("forceRefreshAppWidget", true);
+ context.startService(intent);
+ }
+
+ public static void updateAllAppWidgets(final Context context) {
+ final ComponentName widgets = new ComponentName(context.getApplicationContext(), WidgetProvider.class);
+ final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context.getApplicationContext());
+
+ final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(widgets);
+ for (final int appWidgetId : appWidgetIds) {
+ updateAppWidget(context.getApplicationContext(), appWidgetManager, appWidgetId);
+ }
+ }
+
+ private static void updateAppWidget(final Context context, final AppWidgetManager appWidgetManager, final int appWidgetId) {
int widgetId;
Bundle myOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
// If the value is WIDGET_CATEGORY_KEYGUARD, it's a lockscreen widget
boolean isKeyguard = category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
-
- // Once you know the widget's category, you can optionally load a different base layout, set different
+
+ // Once you know the widget's category, you can optionally load a different base layout, set different
// properties, and so on. For example:
//int baseLayout = isKeyguard ? R.layout.keyguard_widget_layout : R.layout.widget_layout;
-
+
// Construct the RemoteViews object. It takes the package name (in our case, it's our
// package, but it needs this because on the other side it's the widget host inflating
// the layout from our package).
//final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget);
-
+
final Intent intent = new Intent(context.getApplicationContext(), WidgetIntentService.class);
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- intent.putExtra("updateByApp", true);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ intent.putExtra("forceRefreshAppWidget", false);
context.startService(intent);
}
}
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
+ android:onClick="onClickOk"
android:text="@android:string/ok" />
</LinearLayout>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="Country"
+ android:text="@string/widget_preferences_country"
android:padding="5dp"
android:layout_gravity="start" />
<Switch android:id="@+id/weather_appwidget_configure_country"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:text="Country field"
- android:textOff="HIDE"
- android:textOn="SHOW" />
+ android:checked="false"
+ android:text="@string/widget_preferences_country_switch_off_summary"
+ android:textOff="@string/widget_preferences_country_switch_off"
+ android:textOn="@string/widget_preferences_country_switch_on" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="Temperature units"
+ android:text="@string/widget_preferences_temperature_units"
android:padding="5dp"
android:layout_gravity="start" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="Refresh"
+ android:text="@string/widget_preferences_button_refresh"
android:padding="5dp"
android:layout_gravity="start" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="Refresh data"
+ android:text="@string/widget_configure_button_refresh_summary"
android:padding="5dp"
android:layout_gravity="start" />
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textAlignment="center"
- android:text="Refresh"/>
+ android:onClick="onClickRefresh"
+ android:text="@string/widget_preferences_button_refresh"/>
</GridLayout>
<!-- Widget Preferences Activity -->
<string name="widget_preferences_action_settings">Settings</string>
<string name="widget_preferences_button_refresh">Refresh</string>
+ <string name="widget_configure_button_refresh_summary">Refresh values</string>
+ <string name="widget_preferences_temperature_units">Temperature units</string>
+ <string name="widget_preferences_temperature_units_key">widget_preferences_temperature</string>
<string name="widget_preferences_country">Country</string>
- <string name="widget_preferences_units">Units</string>
- <string name="widget_preferences_temperature_key">widget_preferences_temperature</string>
- <string name="widget_preferences_country_switch_key">widget_preferences_countries_switch</string>
- <string name="widget_preferences_country_switch_off_summary">Hide</string>
- <string name="widget_preferences_country_switch_on_summary">Show</string>
+ <string name="widget_preferences_country_switch_key">widget_preferences_country_switch</string>
+ <string name="widget_preferences_country_switch_off_summary">Hide country</string>
+ <string name="widget_preferences_country_switch_on_summary">Show country</string>
<string name="widget_preferences_country_switch_off">OFF</string>
<string name="widget_preferences_country_switch_on">ON</string>
android:disableDependentsState="false"
android:persistent="true"/>
</PreferenceCategory>
- <PreferenceCategory android:title="@string/widget_preferences_units">
- <ListPreference android:key="@string/widget_preferences_temperature_key"
+ <PreferenceCategory android:title="@string/widget_preferences_temperature_units">
+ <ListPreference android:key="@string/widget_preferences_temperature_units_key"
android:title="@string/weather_preferences_temperature"
android:summary="@string/weather_preferences_temperature_celsius_human_value"
android:entries="@array/weather_preferences_temperature_human_value"