From e9fad2d421d6616fd1dd602e18db351fb6e74bd8 Mon Sep 17 00:00:00 2001 From: David van Tonder Date: Sat, 2 Jun 2012 09:27:09 -0400 Subject: Lock screen weather: Simplified 'no-data' layout & refresh indicator This commit simplifies the no-data layout of the lock screen weather by replacing confused Cid, adding "No data" text and hiding the temperatures on the right. It also adds a simple "Refreshing" indicator when the user taps on the weather panel to refresh. Screenshots: Change-Id: Ide0bf3134add99ea0b27b90a36f063c37dddb90b http://dl.dropbox.com/u/50993944/Screenshot_2012-06-02-08-56-36.png http://dl.dropbox.com/u/50993944/Screenshot_2012-06-02-09-51-47.png --- core/res/res/drawable-hdpi/weather_na_cid.png | Bin 4346 -> 0 bytes core/res/res/drawable-mdpi/weather_na_cid.png | Bin 2938 -> 0 bytes core/res/res/drawable-xhdpi/weather_na_cid.png | Bin 4124 -> 0 bytes .../layout-sw600dp/keyguard_screen_status_land.xml | 1 + .../layout-sw600dp/keyguard_screen_status_port.xml | 1 + core/res/res/layout/keyguard_screen_tab_unlock.xml | 3 +- .../res/layout/keyguard_screen_tab_unlock_land.xml | 1 + core/res/res/values/strings.xml | 2 + .../policy/impl/KeyguardStatusViewManager.java | 76 ++++++++++----------- 9 files changed, 45 insertions(+), 39 deletions(-) delete mode 100644 core/res/res/drawable-hdpi/weather_na_cid.png delete mode 100644 core/res/res/drawable-mdpi/weather_na_cid.png delete mode 100644 core/res/res/drawable-xhdpi/weather_na_cid.png diff --git a/core/res/res/drawable-hdpi/weather_na_cid.png b/core/res/res/drawable-hdpi/weather_na_cid.png deleted file mode 100644 index 92759cb..0000000 Binary files a/core/res/res/drawable-hdpi/weather_na_cid.png and /dev/null differ diff --git a/core/res/res/drawable-mdpi/weather_na_cid.png b/core/res/res/drawable-mdpi/weather_na_cid.png deleted file mode 100644 index 52f4e27..0000000 Binary files a/core/res/res/drawable-mdpi/weather_na_cid.png and /dev/null differ diff --git a/core/res/res/drawable-xhdpi/weather_na_cid.png b/core/res/res/drawable-xhdpi/weather_na_cid.png deleted file mode 100644 index daa2bfb..0000000 Binary files a/core/res/res/drawable-xhdpi/weather_na_cid.png and /dev/null differ diff --git a/core/res/res/layout-sw600dp/keyguard_screen_status_land.xml b/core/res/res/layout-sw600dp/keyguard_screen_status_land.xml index c65d019..b8acc9c 100644 --- a/core/res/res/layout-sw600dp/keyguard_screen_status_land.xml +++ b/core/res/res/layout-sw600dp/keyguard_screen_status_land.xml @@ -101,6 +101,7 @@ - + NW + No data Tap to refresh + Refreshing diff --git a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java index 4623526..a9e61d6 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java @@ -89,8 +89,8 @@ class KeyguardStatusViewManager implements OnClickListener { private TextView mOwnerInfoView; private TextView mAlarmStatusView; private TransportControlView mTransportView; - private RelativeLayout mWeatherPanel; - private TextView mWeatherCity, mWeatherCondition, mWeatherLowHigh, mWeatherTemp, mUpdateTime; + private RelativeLayout mWeatherPanel, mWeatherTempsPanel; + private TextView mWeatherCity, mWeatherCondition, mWeatherLowHigh, mWeatherTemp, mWeatherUpdateTime; private ImageView mWeatherImage; private LinearLayout mCalendarPanel; private TextView mCalendarEventTitle, mCalendarEventDetails; @@ -211,7 +211,8 @@ class KeyguardStatusViewManager implements OnClickListener { mWeatherImage = (ImageView) findViewById(R.id.weather_image); mWeatherTemp = (TextView) findViewById(R.id.weather_temp); mWeatherLowHigh = (TextView) findViewById(R.id.weather_low_high); - mUpdateTime = (TextView) findViewById(R.id.update_time); + mWeatherUpdateTime = (TextView) findViewById(R.id.update_time); + mWeatherTempsPanel = (RelativeLayout) findViewById(R.id.weather_temps_panel); // Hide Weather panel view until we know we need to show it. if (mWeatherPanel != null) { @@ -361,6 +362,7 @@ class KeyguardStatusViewManager implements OnClickListener { private void refreshWeather() { final ContentResolver resolver = getContext().getContentResolver(); boolean showWeather = Settings.System.getInt(resolver,Settings.System.LOCKSCREEN_WEATHER, 0) == 1; + if (showWeather) { final long interval = Settings.System.getLong(resolver, Settings.System.WEATHER_UPDATE_INTERVAL, 60); // Default to hourly @@ -395,27 +397,6 @@ class KeyguardStatusViewManager implements OnClickListener { Settings.System.WEATHER_INVERT_LOWHIGH, 0) == 1; if (mWeatherPanel != null) { - if (mWeatherCity != null) { - mWeatherCity.setText(w.city); - mWeatherCity.setVisibility(showLocation ? View.VISIBLE : View.GONE); - } - if (mWeatherCondition != null) { - mWeatherCondition.setText(w.condition); - } - if (mUpdateTime != null) { - Date lastTime = new Date(mWeatherInfo.last_sync); - String date = DateFormat.getDateFormat(getContext()).format(lastTime); - String time = DateFormat.getTimeFormat(getContext()).format(lastTime); - mUpdateTime.setText(date + " " + time); - mUpdateTime.setVisibility(showTimestamp ? View.VISIBLE : View.GONE); - } - if (mWeatherTemp != null) { - mWeatherTemp.setText(w.temp); - } - if (mWeatherLowHigh != null) { - mWeatherLowHigh.setText(invertLowhigh ? w.high + " | " + w.low : w.low + " | " + w.high); - } - if (mWeatherImage != null) { String conditionCode = w.condition_code; String condition_filename = "weather_" + conditionCode; @@ -431,6 +412,26 @@ class KeyguardStatusViewManager implements OnClickListener { mWeatherImage.setImageResource(R.drawable.weather_na); } } + if (mWeatherCity != null) { + mWeatherCity.setText(w.city); + mWeatherCity.setVisibility(showLocation ? View.VISIBLE : View.GONE); + } + if (mWeatherCondition != null) { + mWeatherCondition.setText(w.condition); + mWeatherCondition.setVisibility(View.VISIBLE); + } + if (mWeatherUpdateTime != null) { + Date lastTime = new Date(mWeatherInfo.last_sync); + String date = DateFormat.getDateFormat(getContext()).format(lastTime); + String time = DateFormat.getTimeFormat(getContext()).format(lastTime); + mWeatherUpdateTime.setText(date + " " + time); + mWeatherUpdateTime.setVisibility(showTimestamp ? View.VISIBLE : View.GONE); + } + if (mWeatherTempsPanel != null && mWeatherTemp != null && mWeatherLowHigh != null) { + mWeatherTemp.setText(w.temp); + mWeatherLowHigh.setText(invertLowhigh ? w.high + " | " + w.low : w.low + " | " + w.high); + mWeatherTempsPanel.setVisibility(View.VISIBLE); + } // Show the Weather panel view mWeatherPanel.setVisibility(View.VISIBLE); @@ -442,29 +443,23 @@ class KeyguardStatusViewManager implements OnClickListener { * 'Tap to reload' message */ private void setNoWeatherData() { - final ContentResolver resolver = getContext().getContentResolver(); - boolean useMetric = Settings.System.getInt(resolver, - Settings.System.WEATHER_USE_METRIC, 1) == 1; if (mWeatherPanel != null) { + if (mWeatherImage != null) { + mWeatherImage.setImageResource(R.drawable.weather_na); + } if (mWeatherCity != null) { - mWeatherCity.setText("CM Weather"); //Hard coding this on purpose + mWeatherCity.setText(R.string.weather_no_data); mWeatherCity.setVisibility(View.VISIBLE); } if (mWeatherCondition != null) { mWeatherCondition.setText(R.string.weather_tap_to_refresh); } - if (mUpdateTime != null) { - mUpdateTime.setVisibility(View.GONE); - } - if (mWeatherTemp != null) { - mWeatherTemp.setText(useMetric ? "0°c" : "0°f"); + if (mWeatherUpdateTime != null) { + mWeatherUpdateTime.setVisibility(View.GONE); } - if (mWeatherLowHigh != null) { - mWeatherLowHigh.setText("0° | 0°"); - } - if (mWeatherImage != null) { - mWeatherImage.setImageResource(R.drawable.weather_na_cid); + if (mWeatherTempsPanel != null ) { + mWeatherTempsPanel.setVisibility(View.GONE); } // Show the Weather panel view @@ -1016,6 +1011,11 @@ class KeyguardStatusViewManager implements OnClickListener { if (v == mEmergencyCallButton) { mCallback.takeEmergencyCallAction(); } else if (v == mWeatherPanel) { + // Indicate we are refreshing + if (mWeatherCondition != null) { + mWeatherCondition.setText(R.string.weather_refreshing); + } + mCallback.pokeWakelock(); if (!mHandler.hasMessages(QUERY_WEATHER)) { mHandler.sendEmptyMessage(QUERY_WEATHER); -- cgit v1.1