Resolve colors correctly

Closes #157
pull/189/head
Alex Baker 11 years ago
parent 4bf6610377
commit 50f8c0411a

@ -9,7 +9,6 @@ import android.app.AlertDialog;
import android.content.ContentUris; import android.content.ContentUris;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.net.Uri; import android.net.Uri;
@ -34,7 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.InjectingActivity; import org.tasks.injection.InjectingActivity;
import org.tasks.preferences.Preferences; import org.tasks.preferences.ActivityPreferences;
import org.tasks.preferences.ResourceResolver; import org.tasks.preferences.ResourceResolver;
import java.io.InputStream; import java.io.InputStream;
@ -57,7 +56,7 @@ public class MissedCallActivity extends InjectingActivity {
@Inject StartupService startupService; @Inject StartupService startupService;
@Inject TaskService taskService; @Inject TaskService taskService;
@Inject Preferences preferences; @Inject ActivityPreferences preferences;
@Inject ResourceResolver resourceResolver; @Inject ResourceResolver resourceResolver;
private final OnClickListener dismissListener = new OnClickListener() { private final OnClickListener dismissListener = new OnClickListener() {
@ -113,6 +112,7 @@ public class MissedCallActivity extends InjectingActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
preferences.applyTranslucentDialogTheme();
startupService.onStartupApplication(this); startupService.onStartupApplication(this);
setContentView(R.layout.missed_call_activity); setContentView(R.layout.missed_call_activity);
@ -124,7 +124,7 @@ public class MissedCallActivity extends InjectingActivity {
String timeString = intent.getStringExtra(EXTRA_TIME); String timeString = intent.getStringExtra(EXTRA_TIME);
long contactId = intent.getExtras().getLong(EXTRA_CONTACT_ID); long contactId = intent.getExtras().getLong(EXTRA_CONTACT_ID);
int color = resourceResolver.getResource(R.attr.asThemeTextColor); int color = resourceResolver.getData(R.attr.asThemeTextColor);
returnCallButton = (TextView) findViewById(R.id.call_now); returnCallButton = (TextView) findViewById(R.id.call_now);
callLaterButton = (TextView) findViewById(R.id.call_later); callLaterButton = (TextView) findViewById(R.id.call_later);
@ -151,9 +151,8 @@ public class MissedCallActivity extends InjectingActivity {
} }
} }
Resources r = getResources(); returnCallButton.setBackgroundColor(color);
returnCallButton.setBackgroundColor(r.getColor(color)); callLaterButton.setBackgroundColor(color);
callLaterButton.setBackgroundColor(r.getColor(color));
addListeners(); addListeners();

@ -20,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.InjectingActivity; import org.tasks.injection.InjectingActivity;
import org.tasks.preferences.ActivityPreferences;
import org.tasks.preferences.ResourceResolver; import org.tasks.preferences.ResourceResolver;
import java.util.ArrayList; import java.util.ArrayList;
@ -33,6 +34,7 @@ public class CalendarAlarmListCreator extends InjectingActivity {
public static final String TOKEN_LIST_NAME = "listName"; //$NON-NLS-1$ public static final String TOKEN_LIST_NAME = "listName"; //$NON-NLS-1$
@Inject TagDataService tagDataService; @Inject TagDataService tagDataService;
@Inject ActivityPreferences preferences;
@Inject ResourceResolver resourceResolver; @Inject ResourceResolver resourceResolver;
private ArrayList<String> names; private ArrayList<String> names;
@ -63,6 +65,7 @@ public class CalendarAlarmListCreator extends InjectingActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
preferences.applyTranslucentDialogTheme();
setContentView(R.layout.calendar_alarm_list_creator); setContentView(R.layout.calendar_alarm_list_creator);
Intent intent = getIntent(); Intent intent = getIntent();
@ -85,7 +88,7 @@ public class CalendarAlarmListCreator extends InjectingActivity {
TextView dialogView = (TextView) findViewById(R.id.reminder_message); TextView dialogView = (TextView) findViewById(R.id.reminder_message);
StringBuilder builder = new StringBuilder(getString(R.string.CRA_created_list_dialog, tagName)); StringBuilder builder = new StringBuilder(getString(R.string.CRA_created_list_dialog, tagName));
String attendeesString = buildAttendeesString(); String attendeesString = buildAttendeesString();
int color = resourceResolver.getResource(R.attr.asThemeTextColor); int color = resourceResolver.getData(R.attr.asThemeTextColor);
String title; String title;
if (!TextUtils.isEmpty(attendeesString)) { if (!TextUtils.isEmpty(attendeesString)) {
@ -93,11 +96,11 @@ public class CalendarAlarmListCreator extends InjectingActivity {
.append(attendeesString) .append(attendeesString)
.append(" ") //$NON-NLS-1$ .append(" ") //$NON-NLS-1$
.append(getString(R.string.CRA_invitation_prompt)); .append(getString(R.string.CRA_invitation_prompt));
inviteAll.setBackgroundColor(getResources().getColor(color)); inviteAll.setBackgroundColor(color);
title = getString(R.string.CRA_share_list_title); title = getString(R.string.CRA_share_list_title);
} else { } else {
title = getString(R.string.CRA_list_created_title); title = getString(R.string.CRA_list_created_title);
moreOptions.setBackgroundColor(getResources().getColor(color)); moreOptions.setBackgroundColor(color);
inviteAll.setVisibility(View.GONE); inviteAll.setVisibility(View.GONE);
ignoreButton.setVisibility(View.GONE); ignoreButton.setVisibility(View.GONE);
ignoreSettingsButton.setVisibility(View.GONE); ignoreSettingsButton.setVisibility(View.GONE);

@ -25,7 +25,7 @@ import com.todoroo.astrid.tags.TagFilterExposer;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.InjectingActivity; import org.tasks.injection.InjectingActivity;
import org.tasks.preferences.Preferences; import org.tasks.preferences.ActivityPreferences;
import org.tasks.preferences.ResourceResolver; import org.tasks.preferences.ResourceResolver;
import javax.inject.Inject; import javax.inject.Inject;
@ -50,7 +50,7 @@ public class CalendarReminderActivity extends InjectingActivity {
@Inject StartupService startupService; @Inject StartupService startupService;
@Inject TagDataService tagDataService; @Inject TagDataService tagDataService;
@Inject Preferences preferences; @Inject ActivityPreferences preferences;
@Inject ResourceResolver resourceResolver; @Inject ResourceResolver resourceResolver;
private String eventName; private String eventName;
@ -110,7 +110,7 @@ public class CalendarReminderActivity extends InjectingActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
preferences.applyTranslucentDialogTheme();
startupService.onStartupApplication(this); startupService.onStartupApplication(this);
setContentView(R.layout.calendar_reminder_activity); setContentView(R.layout.calendar_reminder_activity);
@ -147,7 +147,7 @@ public class CalendarReminderActivity extends InjectingActivity {
dialogView.setText(speechText); dialogView.setText(speechText);
createListButton.setBackgroundColor(resourceResolver.getResource(R.attr.asThemeTextColor)); createListButton.setBackgroundColor(resourceResolver.getData(R.attr.asThemeTextColor));
if (fromPostpone) { if (fromPostpone) {
postponeButton.setVisibility(View.GONE); postponeButton.setVisibility(View.GONE);

@ -39,6 +39,10 @@ public class ActivityPreferences extends Preferences {
applyTheme(isDarkTheme() ? R.style.Tasks_Dialog : R.style.Tasks_Dialog_Light); applyTheme(isDarkTheme() ? R.style.Tasks_Dialog : R.style.Tasks_Dialog_Light);
} }
public void applyTranslucentDialogTheme() {
applyTheme(R.style.ReminderDialog);
}
private void applyTheme(int theme) { private void applyTheme(int theme) {
activity.setTheme(theme); activity.setTheme(theme);
activity.getWindow().setFormat(PixelFormat.RGBA_8888); activity.getWindow().setFormat(PixelFormat.RGBA_8888);

@ -20,6 +20,10 @@ public class ResourceResolver {
return getResource(activity, attr); return getResource(activity, attr);
} }
public int getData(int attr) {
return getData(activity, attr);
}
public static int getResource(Activity activity, int attr) { public static int getResource(Activity activity, int attr) {
TypedValue typedValue = new TypedValue(); TypedValue typedValue = new TypedValue();
activity.getTheme().resolveAttribute(attr, typedValue, true); activity.getTheme().resolveAttribute(attr, typedValue, true);

@ -234,6 +234,7 @@
<item name="android:windowIsFloating">true</item> <item name="android:windowIsFloating">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="asThemeTextColor">@color/dark_blue_theme_color</item>
</style> </style>
<!--=============================================== TaskListActivity == --> <!--=============================================== TaskListActivity == -->

Loading…
Cancel
Save