From 33cd29136d07448302531dabe9dd1b3cc18e09c9 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 1 Dec 2011 12:54:56 +1300 Subject: [PATCH] Tweak widget layout. --- res/drawable/show_upcoming_widget_row_bg.xml | 19 ---------- res/drawable/show_upcoming_widget_shape.xml | 16 --------- res/layout/show_upcoming_widget_base_row.xml | 4 +-- res/layout/show_upcoming_widget_custom_row.xml | 42 ++++++++++------------ res/layout/show_upcoming_widget_layout.xml | 5 ++- res/values/strings.xml | 1 + res/values/widget_dimensions.xml | 8 +++++ res/xml/show_upcoming_widget_info.xml | 6 ++-- .../acal/desktop/ShowUpcomingRowLayout.java | 23 ++++++------ .../acal/desktop/ShowUpcomingWidgetProvider.java | 36 ++++++++++--------- 10 files changed, 66 insertions(+), 94 deletions(-) delete mode 100644 res/drawable/show_upcoming_widget_row_bg.xml delete mode 100644 res/drawable/show_upcoming_widget_shape.xml rewrite res/layout/show_upcoming_widget_custom_row.xml (67%) create mode 100644 res/values/widget_dimensions.xml diff --git a/res/drawable/show_upcoming_widget_row_bg.xml b/res/drawable/show_upcoming_widget_row_bg.xml deleted file mode 100644 index 5955f15..0000000 --- a/res/drawable/show_upcoming_widget_row_bg.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/drawable/show_upcoming_widget_shape.xml b/res/drawable/show_upcoming_widget_shape.xml deleted file mode 100644 index 19c8eba..0000000 --- a/res/drawable/show_upcoming_widget_shape.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/res/layout/show_upcoming_widget_base_row.xml b/res/layout/show_upcoming_widget_base_row.xml index 80b20be..05c7d41 100644 --- a/res/layout/show_upcoming_widget_base_row.xml +++ b/res/layout/show_upcoming_widget_base_row.xml @@ -1,8 +1,8 @@ - - - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/res/layout/show_upcoming_widget_layout.xml b/res/layout/show_upcoming_widget_layout.xml index 55709cc..7466324 100644 --- a/res/layout/show_upcoming_widget_layout.xml +++ b/res/layout/show_upcoming_widget_layout.xml @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index dcc8a16..815c018 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -299,4 +299,5 @@ aCal is "Free Software" (that\'s "free" as in "freedom") which is licensed under the General Public License v3 or later. You can download <a href="http://gitorious.org/acal">the source code for aCal from Gitorious</a> Task marked as completed. Task was deleted. + end \ No newline at end of file diff --git a/res/values/widget_dimensions.xml b/res/values/widget_dimensions.xml new file mode 100644 index 0000000..d5cca12 --- /dev/null +++ b/res/values/widget_dimensions.xml @@ -0,0 +1,8 @@ + + + 18dp + 294dp + 296dp + 74dp + 13.5dp + \ No newline at end of file diff --git a/res/xml/show_upcoming_widget_info.xml b/res/xml/show_upcoming_widget_info.xml index a92449c..cf5dcab 100644 --- a/res/xml/show_upcoming_widget_info.xml +++ b/res/xml/show_upcoming_widget_info.xml @@ -1,7 +1,7 @@ + android:minHeight="@dimen/widgetFullHeight" + android:minWidth="@dimen/widgetFullWidth" + android:updatePeriodMillis="1800000" > \ No newline at end of file diff --git a/src/com/morphoss/acal/desktop/ShowUpcomingRowLayout.java b/src/com/morphoss/acal/desktop/ShowUpcomingRowLayout.java index 3a949fa..3857ade 100644 --- a/src/com/morphoss/acal/desktop/ShowUpcomingRowLayout.java +++ b/src/com/morphoss/acal/desktop/ShowUpcomingRowLayout.java @@ -14,27 +14,29 @@ import com.morphoss.acal.R; public class ShowUpcomingRowLayout extends LinearLayout { public static final String BGCOLORMETHOD = "setBGColour"; - public static final int WIDTH = 298; - public static final int HEIGHT = 23; + public static float WIDTH; + public static float HEIGHT; public ShowUpcomingRowLayout(Context context, AttributeSet attrs) { super(context, attrs); + WIDTH=context.getResources().getDimension(R.dimen.widgetRowWidth); + HEIGHT=context.getResources().getDimension(R.dimen.widgetRowHeight); } public ShowUpcomingRowLayout(Context context) { super(context); + WIDTH=context.getResources().getDimension(R.dimen.widgetRowWidth); + HEIGHT=context.getResources().getDimension(R.dimen.widgetRowHeight); } - public Bitmap setData(ContentValues cv, String date, String time) { + public Bitmap setData(ContentValues cv, String dateTimeText) { int colour = cv.getAsInteger(ShowUpcomingWidgetProvider.FIELD_COLOUR); float dip = this.getResources().getDisplayMetrics().density; - TextView dateView =(TextView)this.findViewById(R.id.upcoming_date); TextView timeView =(TextView)this.findViewById(R.id.upcoming_time); TextView sumView =(TextView)this.findViewById(R.id.upcoming_summary); - dateView.setText(date); dateView.setTextColor(AcalTheme.pickForegroundForBackground(colour&0x33FFFFFF)); - timeView.setText(time); timeView.setTextColor(AcalTheme.pickForegroundForBackground(colour&0x33FFFFFF)); + timeView.setText(dateTimeText); timeView.setTextColor(AcalTheme.pickForegroundForBackground(colour&0x33FFFFFF)); sumView.setText(cv.getAsString(ShowUpcomingWidgetProvider.FIELD_SUMMARY)); sumView.setTextColor(AcalTheme.pickForegroundForBackground(colour&0x33FFFFFF)); @@ -42,11 +44,10 @@ public class ShowUpcomingRowLayout extends LinearLayout { GradientDrawable shape = new BackgroundShape(new int[] {(0x33FFFFFF&colour), (0x88000000|colour)}, (int)(HEIGHT/2*dip)); this.setBackgroundDrawable(shape); - - - - this.measure((int)(WIDTH*dip),(int)(HEIGHT*dip)); - this.layout(0, 0, (int)(WIDTH*dip),(int)(HEIGHT*dip)); +// this.measure((int)(WIDTH*dip),(int)(HEIGHT*dip)); +// this.layout(0, 0, (int)(WIDTH*dip),(int)(HEIGHT*dip)); + this.measure((int)WIDTH,(int)HEIGHT); + this.layout(0, 0, (int)WIDTH,(int)HEIGHT); this.setDrawingCacheEnabled(true); //Bitmap returnedBitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(),Bitmap.Config.ARGB_4444); diff --git a/src/com/morphoss/acal/desktop/ShowUpcomingWidgetProvider.java b/src/com/morphoss/acal/desktop/ShowUpcomingWidgetProvider.java index 3ac9248..726408a 100644 --- a/src/com/morphoss/acal/desktop/ShowUpcomingWidgetProvider.java +++ b/src/com/morphoss/acal/desktop/ShowUpcomingWidgetProvider.java @@ -3,6 +3,7 @@ package com.morphoss.acal.desktop; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.List; +import java.util.TimeZone; import android.app.AlarmManager; import android.app.PendingIntent; @@ -16,7 +17,6 @@ import android.content.SharedPreferences; import android.database.Cursor; import android.database.DatabaseUtils; import android.database.sqlite.SQLiteDatabase; -import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import android.view.LayoutInflater; @@ -37,7 +37,7 @@ public class ShowUpcomingWidgetProvider extends AppWidgetProvider { public static final String TAG = "acal ShowUpcomingWidgetProvider"; - public static final int NUMBER_OF_EVENTS_TO_SHOW = 3; + public static final int NUMBER_OF_EVENTS_TO_SHOW = 4; public static final int NUM_DAYS_TO_LOOK_AHEAD = 7; public static final String TABLE = "show_upcoming_widget_data"; @@ -91,8 +91,8 @@ public class ShowUpcomingWidgetProvider extends AppWidgetProvider { for (int i = 0; i