update app widget style

This commit is contained in:
Jimmy Shih
2012-10-08 15:22:39 -07:00
parent dfab60c2eb
commit 4792ff6d3e
4 changed files with 18 additions and 22 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

+2 -2
View File
@@ -29,7 +29,7 @@ limitations under the License.
<LinearLayout style="@style/TrackWidgetItemContainer4x4" > <LinearLayout style="@style/TrackWidgetItemContainer4x4" >
<TextView <TextView
android:id="@+id/track_widget_item1_label" android:id="@+id/track_widget_item1_label"
style="@style/TrackWidgetLabel4x4" /> style="@style/TrackWidgetLabel4x3" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3" > <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
<TextView <TextView
android:id="@+id/track_widget_item1_value" android:id="@+id/track_widget_item1_value"
@@ -59,7 +59,7 @@ limitations under the License.
<LinearLayout style="@style/TrackWidgetItemContainer4x4" > <LinearLayout style="@style/TrackWidgetItemContainer4x4" >
<TextView <TextView
android:id="@+id/track_widget_item3_label" android:id="@+id/track_widget_item3_label"
style="@style/TrackWidgetLabel4x4" /> style="@style/TrackWidgetLabel4x3" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3" > <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
<TextView <TextView
android:id="@+id/track_widget_item3_value" android:id="@+id/track_widget_item3_value"
+1 -5
View File
@@ -313,10 +313,6 @@ limitations under the License.
<style name="TrackWidgetLabel4x3" parent="@style/TrackWidgetLabel"> <style name="TrackWidgetLabel4x3" parent="@style/TrackWidgetLabel">
<item name="android:textSize">14dp</item> <item name="android:textSize">14dp</item>
</style> </style>
<!-- track widget label 4x4 -->
<style name="TrackWidgetLabel4x4" parent="@style/TrackWidgetLabel">
<item name="android:textSize">18dp</item>
</style>
<!-- track widget logo --> <!-- track widget logo -->
<style name="TrackWidgetLogo"> <style name="TrackWidgetLogo">
<item name="android:layout_alignParentRight">true</item> <item name="android:layout_alignParentRight">true</item>
@@ -392,7 +388,7 @@ limitations under the License.
</style> </style>
<!-- track widget value container 4x3 --> <!-- track widget value container 4x3 -->
<style name="TrackWidgetValueContainer4x3" parent="@style/TrackWidgetValueContainer"> <style name="TrackWidgetValueContainer4x3" parent="@style/TrackWidgetValueContainer">
<item name="android:layout_marginTop">0dp</item> <item name="android:layout_marginTop">-2dp</item>
</style> </style>
<!-- track widget vertical line --> <!-- track widget vertical line -->
<style name="TrackWidgetVerticalLine"> <style name="TrackWidgetVerticalLine">
@@ -56,7 +56,7 @@ public class TrackWidgetProvider extends AppWidgetProvider {
// Array of appwidget id to height size in cells // Array of appwidget id to height size in cells
private static final SparseIntArray HEIGHT_SIZE = new SparseIntArray(); private static final SparseIntArray HEIGHT_SIZE = new SparseIntArray();
private static final int DEFAULT_HEIGHT = 2; private static final int DEFAULT_SIZE = 2;
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
@@ -74,7 +74,7 @@ public class TrackWidgetProvider extends AppWidgetProvider {
new ComponentName(context, TrackWidgetProvider.class)); new ComponentName(context, TrackWidgetProvider.class));
for (int appWidgetId : appWidgetIds) { for (int appWidgetId : appWidgetIds) {
RemoteViews remoteViews = getRemoteViews( RemoteViews remoteViews = getRemoteViews(
context, trackId, HEIGHT_SIZE.get(appWidgetId, DEFAULT_HEIGHT)); context, trackId, HEIGHT_SIZE.get(appWidgetId, DEFAULT_SIZE));
appWidgetManager.updateAppWidget(appWidgetId, remoteViews); appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
} }
} }
@@ -84,24 +84,24 @@ public class TrackWidgetProvider extends AppWidgetProvider {
@Override @Override
public void onAppWidgetOptionsChanged( public void onAppWidgetOptionsChanged(
Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) { Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
int heightSize; if (newOptions != null) {
if (newOptions == null) { int size;
heightSize = 2;
} else {
int height = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT); int height = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
if (height >= FOUR_CELLS) { if (height == 0) {
heightSize = 4; size = 2;
} else if (height >= FOUR_CELLS) {
size = 4;
} else if (height >= THREE_CELLS) { } else if (height >= THREE_CELLS) {
heightSize = 3; size = 3;
} else if (height >= TWO_CELLS) { } else if (height >= TWO_CELLS) {
heightSize = 2; size = 2;
} else { } else {
heightSize = 1; size = 1;
} }
HEIGHT_SIZE.put(appWidgetId, size);
RemoteViews remoteViews = getRemoteViews(context, -1L, size);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
} }
HEIGHT_SIZE.put(appWidgetId, heightSize);
RemoteViews remoteViews = getRemoteViews(context, -1L, heightSize);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
} }
/** /**
@@ -114,7 +114,7 @@ public class TrackWidgetProvider extends AppWidgetProvider {
public static void updateAppWidget( public static void updateAppWidget(
Context context, AppWidgetManager appWidgetManager, int appWidgetId) { Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
RemoteViews remoteViews = getRemoteViews( RemoteViews remoteViews = getRemoteViews(
context, -1L, HEIGHT_SIZE.get(appWidgetId, DEFAULT_HEIGHT)); context, -1L, HEIGHT_SIZE.get(appWidgetId, DEFAULT_SIZE));
appWidgetManager.updateAppWidget(appWidgetId, remoteViews); appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
} }