Legacy widget style

pull/14/head
Sam Bosley 13 years ago
parent fc71dc8be0
commit 22776b7928

Binary file not shown.

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 576 B

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="8dip"
android:bottomRightRadius="8dip"/>
<solid
android:color="@color/widget_body_legacy"/>
</shape>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="8dip"
android:topRightRadius="8dip"/>
<gradient
android:centerX="0.5"
android:centerY="0.5"
android:startColor="@color/widget_header_legacy_start"
android:endColor="@color/widget_header_legacy_end"/>
</shape>

@ -39,7 +39,9 @@
<color name="widget_header_dark">#dd000000</color>
<color name="widget_body_light">#ddffffff</color>
<color name="widget_body_dark">#dd000000</color>
<color name="widget_header_legacy_start">#fc1c2334</color>
<color name="widget_header_legacy_end">#fc243455</color>
<color name="widget_body_legacy">#fc1c1c1c</color>
</resources>

@ -189,6 +189,7 @@
<item>black</item>
<item>transparent</item>
<item>transparent-white</item>
<item>legacy-widget</item>
</string-array>
<string-array name="EPr_font_size">

@ -561,6 +561,7 @@
<item>Night</item>
<item>Transparent (White Text)</item>
<item>Transparent (Black Text)</item>
<item>Old Style</item>
</string-array>
<!-- ========================================== Task Management Settings == -->

@ -9,6 +9,7 @@ import com.timsu.astrid.R;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.widget.TasksWidget;
@SuppressWarnings("nls")
public class ThemeService {
@ -20,6 +21,7 @@ public class ThemeService {
public static final String THEME_TRANSPARENT_WHITE = "transparent-white";
public static final String THEME_WIDGET_SAME_AS_APP = "same-as-app";
public static final String THEME_WIDGET_LEGACY = "legacy-widget";
public static final int FLAG_FORCE_DARK = 1;
public static final int FLAG_FORCE_LIGHT = 2;
@ -44,6 +46,8 @@ public class ThemeService {
String preference = Preferences.getStringValue(R.string.p_theme_widget);
if (TextUtils.isEmpty(preference) || THEME_WIDGET_SAME_AS_APP.equals(preference))
return getTheme();
else if (THEME_WIDGET_LEGACY.equals(preference))
return TasksWidget.THEME_LEGACY;
else
return getStyleForSetting(preference);
}

@ -45,6 +45,8 @@ import com.todoroo.astrid.utility.Constants;
public class TasksWidget extends AppWidgetProvider {
public static final int THEME_LEGACY = -1;
static {
AstridDependencyInjector.initialize();
}
@ -174,15 +176,18 @@ public class TasksWidget extends AppWidgetProvider {
task.readFromCursor(cursor);
String textContent = "";
int textColor = context.getResources()
Resources r = context.getResources();
int textColor = r
.getColor(isDarkTheme() ? R.color.widget_text_color_dark : R.color.widget_text_color_light);
if (isLegacyTheme())
textColor = r.getColor(android.R.color.white);
textContent = task.getValue(Task.TITLE);
if(task.isCompleted())
textColor = context.getResources().getColor(R.color.task_list_done);
textColor = r.getColor(R.color.task_list_done);
else if(task.hasDueDate() && task.getValue(Task.DUE_DATE) < DateUtilities.now())
textColor = context.getResources().getColor(R.color.task_list_overdue);
textColor = r.getColor(R.color.task_list_overdue);
RemoteViews row = new RemoteViews(Constants.PACKAGE, R.layout.widget_row);
@ -192,6 +197,8 @@ public class TasksWidget extends AppWidgetProvider {
views.addView(R.id.taskbody, row);
RemoteViews separator = new RemoteViews(Constants.PACKAGE, R.layout.widget_separator);
boolean isLastRow = (i == cursor.getCount() - 1) || (i == numberOfTasks - 1);
if (!isLastRow)
views.addView(R.id.taskbody, separator);
}
for (; i < numberOfTasks; i++) {
@ -260,6 +267,11 @@ public class TasksWidget extends AppWidgetProvider {
return (theme == R.style.Theme || theme == R.style.Theme_Transparent);
}
private boolean isLegacyTheme() {
int theme = ThemeService.getWidgetTheme();
return theme == THEME_LEGACY;
}
@SuppressWarnings("nls")
private void applyThemeToWidget(RemoteViews views) {
int theme = ThemeService.getWidgetTheme();
@ -269,6 +281,16 @@ public class TasksWidget extends AppWidgetProvider {
int bodyColor;
int buttonDrawable;
int separatorColor;
if (isLegacyTheme()) {
views.setInt(R.id.widget_header, "setBackgroundResource", R.drawable.widget_header_legacy);
views.setInt(R.id.taskbody, "setBackgroundResource", R.drawable.widget_body_legacy);
views.setTextColor(R.id.widget_title, r.getColor(android.R.color.white));
views.setInt(R.id.widget_button, "setImageResource", R.drawable.button_plus);
views.setViewVisibility(R.id.widget_header_separator, View.GONE);
return;
}
if (isDarkTheme()) {
headerColor = r.getColor(R.color.widget_header_dark);
titleColor = r.getColor(R.color.widget_text_color_dark);

Loading…
Cancel
Save