Added preference for choosing widget theme

pull/14/head
Sam Bosley 13 years ago
parent 0d67506434
commit 8e7a8f5c97

@ -167,6 +167,7 @@
<string name="p_beastMode">beastMode</string>
<string name="p_transparent_deprecated">transparent</string>
<string name="p_theme">theme</string>
<string name="p_theme_widget">theme_widget</string>
<string name="p_voiceInputEnabled">voiceInputEnabled</string>
<string name="p_voiceInputCreatesTask">voiceInputCreatesTask</string>
<string name="p_voiceRemindersEnabled">voiceRemindersEnabled</string>
@ -180,6 +181,16 @@
<item>transparent-white</item>
</string-array>
<string-array name="EPr_theme_widget_settings">
<!-- theme_settings: options for preference menu -->
<item>same-as-app</item>
<item>white</item>
<item>white-red</item>
<item>black</item>
<item>transparent</item>
<item>transparent-white</item>
</string-array>
<string-array name="EPr_font_size">
<!-- font_size: options for preference menu -->
<item>10</item>

@ -533,6 +533,8 @@
<!-- Preference: Theme Description (android 1.6) -->
<string name="EPr_theme_desc_unsupported">Setting requires Android 2.0+</string>
<string name="EPr_theme_widget_title">Widget Theme</string>
<!-- Preference screen: all task row settings -->
<string name="EPr_taskRowPrefs_title">Task Row Appearance</string>
@ -552,6 +554,15 @@
<item>Transparent (Black Text)</item>
</string-array>
<string-array name="EPr_themes_widget">
<item>Same as app</item>
<item>Day - Blue</item>
<item>Day - Red</item>
<item>Night</item>
<item>Transparent (White Text)</item>
<item>Transparent (Black Text)</item>
</string-array>
<!-- ========================================== Task Management Settings == -->
<!-- Preference Screen Header: Old Task Management -->

@ -51,6 +51,12 @@
android:entryValues="@array/EPr_theme_settings"
android:title="@string/EPr_theme_title" />
<com.todoroo.astrid.ui.MultilineListPreference
android:key="@string/p_theme_widget"
android:entries="@array/EPr_themes_widget"
android:entryValues="@array/EPr_theme_widget_settings"
android:title="@string/EPr_theme_widget_title" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/p_showSmartConfirmation_key"
android:title="@string/EPr_showSmartConfirmation_title"

@ -56,6 +56,7 @@ import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.voice.VoiceInputAssistant;
import com.todoroo.astrid.voice.VoiceOutputService;
import com.todoroo.astrid.welcome.tutorial.WelcomeWalkthrough;
import com.todoroo.astrid.widget.TasksWidget;
/**
* Displays the preference screen for users to edit their preferences
@ -327,6 +328,19 @@ public class EditPreferences extends TodorooPreferenceActivity {
preference.setSummary(getString(R.string.EPr_theme_desc,
r.getStringArray(R.array.EPr_themes)[index]));
}
} else if (r.getString(R.string.p_theme_widget).equals(preference.getKey())) {
if(AndroidUtilities.getSdkVersion() < 5) {
preference.setEnabled(false);
preference.setSummary(R.string.EPr_theme_desc_unsupported);
} else {
int index = 0;
if(value instanceof String && !TextUtils.isEmpty((String)value))
index = AndroidUtilities.indexOf(r.getStringArray(R.array.EPr_theme_widget_settings), (String)value);
if (index < 0)
index = 0;
preference.setSummary(getString(R.string.EPr_theme_desc,
r.getStringArray(R.array.EPr_themes_widget)[index]));
}
}
// pp preferences
@ -398,6 +412,14 @@ public class EditPreferences extends TodorooPreferenceActivity {
}
});
findPreference(getString(R.string.p_theme_widget)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
TasksWidget.updateWidgets(EditPreferences.this);
return true;
}
});
findPreference(getString(R.string.p_statistics)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {

@ -706,9 +706,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
R.anim.slide_right_in, R.anim.slide_right_out);
}
getActivity().startActivity(getActivity().getIntent());
ContextManager.getContext().startService(
new Intent(ContextManager.getContext(),
TasksWidget.WidgetUpdateService.class));
TasksWidget.updateWidgets(getActivity());
} else if (resultCode == SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE) {
Preferences.setLong(SyncActionHelper.PREF_LAST_AUTO_SYNC, 0); // Forces autosync to occur after login
}
@ -1214,9 +1212,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
editor.putInt(SortHelper.PREF_SORT_FLAGS, flags);
editor.putInt(SortHelper.PREF_SORT_SORT, sort);
editor.commit();
ContextManager.getContext().startService(
new Intent(ContextManager.getContext(),
TasksWidget.WidgetUpdateService.class));
TasksWidget.updateWidgets(ContextManager.getContext());
}
try {

@ -2,6 +2,7 @@ package com.todoroo.astrid.service;
import android.app.Activity;
import android.graphics.PixelFormat;
import android.text.TextUtils;
import android.view.WindowManager;
import com.timsu.astrid.R;
@ -18,6 +19,8 @@ public class ThemeService {
public static final String THEME_TRANSPARENT = "transparent";
public static final String THEME_TRANSPARENT_WHITE = "transparent-white";
public static final String THEME_WIDGET_SAME_AS_APP = "same-as-app";
public static final int FLAG_FORCE_DARK = 1;
public static final int FLAG_FORCE_LIGHT = 2;
public static final int FLAG_INVERT = 3;
@ -34,13 +37,25 @@ public class ThemeService {
public static int getTheme() {
String preference = Preferences.getStringValue(R.string.p_theme);
if(THEME_BLACK.equals(preference))
return getStyleForSetting(preference);
}
public static int getWidgetTheme() {
String preference = Preferences.getStringValue(R.string.p_theme_widget);
if (TextUtils.isEmpty(preference) || THEME_WIDGET_SAME_AS_APP.equals(preference))
return getTheme();
else
return getStyleForSetting(preference);
}
private static int getStyleForSetting(String setting) {
if(THEME_BLACK.equals(setting))
return R.style.Theme;
else if(THEME_TRANSPARENT.equals(preference))
else if(THEME_TRANSPARENT.equals(setting))
return R.style.Theme_Transparent;
else if(THEME_TRANSPARENT_WHITE.equals(preference))
else if(THEME_TRANSPARENT_WHITE.equals(setting))
return R.style.Theme_TransparentWhite;
else if (THEME_WHITE_RED.equals(preference))
else if (THEME_WHITE_RED.equals(setting))
return R.style.Theme_White;
else
return R.style.Theme_White_Blue;

@ -256,13 +256,13 @@ public class TasksWidget extends AppWidgetProvider {
}
private boolean isDarkTheme() {
int theme = ThemeService.getTheme();
int theme = ThemeService.getWidgetTheme();
return (theme == R.style.Theme || theme == R.style.Theme_Transparent);
}
@SuppressWarnings("nls")
private void applyThemeToWidget(RemoteViews views) {
int theme = ThemeService.getTheme();
int theme = ThemeService.getWidgetTheme();
Resources r = getResources();
int headerColor;
int titleColor;
@ -289,6 +289,10 @@ public class TasksWidget extends AppWidgetProvider {
separatorColor = r.getColor(R.color.dark_blue_theme_color);
}
if (theme == R.style.Theme_Transparent || theme == R.style.Theme_TransparentWhite) {
bodyColor = headerColor = r.getColor(android.R.color.transparent);
}
views.setInt(R.id.widget_header, "setBackgroundColor", headerColor);
views.setTextColor(R.id.widget_title, titleColor);
views.setInt(R.id.taskbody, "setBackgroundColor", bodyColor);

Loading…
Cancel
Save