aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDvTonder <david.vantonder@gmail.com>2016-06-06 22:20:38 -0400
committerDanny Baumann <dannybaumann@web.de>2016-06-07 12:00:02 +0200
commite28037aa89b5a7328d986f8001665ef41bf2309d (patch)
tree337a71739963bdc73de45894e6590ec6af7df09d
parentfc8ea240f806aa9c16bc92056db3b158f1480755 (diff)
downloadandroid_packages_apps_LockClock-e28037aa89b5a7328d986f8001665ef41bf2309d.tar.gz
android_packages_apps_LockClock-e28037aa89b5a7328d986f8001665ef41bf2309d.tar.bz2
android_packages_apps_LockClock-e28037aa89b5a7328d986f8001665ef41bf2309d.zip
Handle >5 forecast items in cLock Forecast view
Change-Id: Ifd4891b990d89d1a4c535a3efb9c3db39eae7aab
-rw-r--r--res/layout/forecast_activity.xml24
-rw-r--r--res/layout/forecast_item.xml16
-rw-r--r--res/values/dimens.xml1
-rw-r--r--src/com/cyanogenmod/lockclock/weather/ForecastBuilder.java17
4 files changed, 42 insertions, 16 deletions
diff --git a/res/layout/forecast_activity.xml b/res/layout/forecast_activity.xml
index 25f881c..fe71b1c 100644
--- a/res/layout/forecast_activity.xml
+++ b/res/layout/forecast_activity.xml
@@ -170,14 +170,28 @@
</RelativeLayout>
<LinearLayout
- android:id="@+id/forecast_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="12dip"
- android:layout_marginRight="12dip"
- android:paddingBottom="16dp"
+ android:layout_marginEnd="12dip"
+ android:layout_marginStart="12dip"
android:gravity="center_horizontal"
- android:orientation="horizontal" />
+ android:layout_marginBottom="8dp"
+ android:layout_marginTop="8dp">
+
+ <HorizontalScrollView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fadingEdgeLength="12dp"
+ android:requiresFadingEdge="horizontal"
+ android:scrollbars="none">
+
+ <LinearLayout
+ android:id="@+id/forecast_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" />
+ </HorizontalScrollView>
+ </LinearLayout>
<ProgressBar
android:id="@+id/progress_indicator"
diff --git a/res/layout/forecast_item.xml b/res/layout/forecast_item.xml
index e030889..0741a50 100644
--- a/res/layout/forecast_item.xml
+++ b/res/layout/forecast_item.xml
@@ -18,7 +18,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:orientation="vertical" >
+ xmlns:tools="http://schemas.android.com/tools"
+ android:orientation="vertical">
<TextView
android:id="@+id/forecast_day"
@@ -33,16 +34,13 @@
<ImageView
android:id="@+id/weather_image"
- android:maxWidth="@dimen/forecast_icon_size"
- android:layout_width="wrap_content"
- android:layout_height="0dp"
- android:layout_weight="1"
+ android:layout_width="@dimen/forecast_icon_size"
+ android:layout_height="@dimen/forecast_icon_size"
android:layout_gravity="center_horizontal"
- android:paddingTop="2dp"
- android:paddingBottom="2dp"
- android:scaleType="centerInside"
android:adjustViewBounds="true"
- android:src="@android:drawable/ic_dialog_alert"/>
+ android:padding="2dp"
+ android:scaleType="centerInside"
+ tools:ignore="ContentDescription" />
<TextView
android:id="@+id/weather_temps"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a0b2465..568c47e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -53,4 +53,5 @@
<dimen name="forecast_dialog_width">340dp</dimen>
<dimen name="forecast_icon_size">36dp</dimen>
+ <dimen name="forecast_item_padding_side">10dp</dimen>
</resources>
diff --git a/src/com/cyanogenmod/lockclock/weather/ForecastBuilder.java b/src/com/cyanogenmod/lockclock/weather/ForecastBuilder.java
index 4bb2b84..ed52688 100644
--- a/src/com/cyanogenmod/lockclock/weather/ForecastBuilder.java
+++ b/src/com/cyanogenmod/lockclock/weather/ForecastBuilder.java
@@ -186,8 +186,14 @@ public class ForecastBuilder {
TimeZone MyTimezone = TimeZone.getDefault();
Calendar calendar = new GregorianCalendar(MyTimezone);
int weatherTempUnit = w.getTemperatureUnit();
- // Iterate through the forecasts
- for (DayForecast d : forecasts) {
+ int numForecasts = forecasts.size();
+ int itemSidePadding = context.getResources().getDimensionPixelSize(
+ R.dimen.forecast_item_padding_side);
+
+ // Iterate through the Forecasts
+ for (int count = 0; count < numForecasts; count ++) {
+ DayForecast d = forecasts.get(count);
+
// Load the views
View forecastItem = inflater.inflate(R.layout.forecast_item, null);
@@ -230,6 +236,13 @@ public class ForecastBuilder {
// Add the view
smallPanel.addView(forecastItem,
new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
+
+ // Add a divider to the right for all but the last view
+ if (count < numForecasts - 1) {
+ View divider = new View(context);
+ smallPanel.addView(divider, new LinearLayout.LayoutParams(
+ itemSidePadding, LinearLayout.LayoutParams.MATCH_PARENT));
+ }
}
return true;
}