Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 9b7ee343 authored by sof4jazz's avatar sof4jazz Committed by Michael Bestas
Browse files

Use real calendar colors with adaptive text color (dark/light) (#1091)



Use real calendar colors with adaptive text color (dark/light) depending on brightness of the event background.
A setting allows to toggle between "real event colors" and the classic way of adding a dark overlay with white text.

Authored-by: default avatarsofajazz <thomas.montibeller@headstore.com>
Change-Id: I31e763058015f7f8a7dce7cf1080ade0d7e2fbc5
parent c89bf4b9
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -469,6 +469,8 @@
    <string name="preferences_color_purple" translatable="false">Purple</string>
    <string name="preferences_color_purple" translatable="false">Purple</string>
    <string name="preferences_color_pick">Primary color</string>
    <string name="preferences_color_pick">Primary color</string>


    <string name="preferences_real_event_colors">Use real event colors</string>

    <string name="preferences_pure_black_night_mode">Pure black night mode</string>
    <string name="preferences_pure_black_night_mode">Pure black night mode</string>


    <!-- This is the title of a section in the Settings screen for settings
    <!-- This is the title of a section in the Settings screen for settings
+4 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,10 @@
            app:entries="@array/pref_color_entries"
            app:entries="@array/pref_color_entries"
            app:entryValues="@array/pref_color_values"
            app:entryValues="@array/pref_color_values"
            app:defaultValue="teal" />
            app:defaultValue="teal" />
        <SwitchPreference
            app:key="pref_real_event_colors"
            app:defaultValue="false"
            app:title="@string/preferences_real_event_colors" />
        <ListPreference
        <ListPreference
            app:key="preferences_default_start"
            app:key="preferences_default_start"
            app:defaultValue="-2"
            app:defaultValue="-2"
+4 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,10 @@
            app:entries="@array/pref_color_entries"
            app:entries="@array/pref_color_entries"
            app:entryValues="@array/pref_color_values"
            app:entryValues="@array/pref_color_values"
            app:defaultValue="teal" />
            app:defaultValue="teal" />
        <SwitchPreference
            app:key="pref_real_event_colors"
            app:defaultValue="false"
            app:title="@string/preferences_real_event_colors" />
        <ListPreference
        <ListPreference
            app:key="preferences_default_start"
            app:key="preferences_default_start"
            app:defaultValue="-2"
            app:defaultValue="-2"
+2 −2
Original line number Original line Diff line number Diff line
@@ -178,7 +178,7 @@ public class CalendarColorPickerDialog extends ColorPickerDialog {
                        dismiss();
                        dismiss();
                        break;
                        break;
                    }
                    }
                    mSelectedColor = Utils.getDisplayColorFromColor(
                    mSelectedColor = Utils.getDisplayColorFromColor(activity,
                            cursor.getInt(CALENDARS_INDEX_CALENDAR_COLOR));
                            cursor.getInt(CALENDARS_INDEX_CALENDAR_COLOR));
                    Uri uri = Colors.CONTENT_URI;
                    Uri uri = Colors.CONTENT_URI;
                    String[] args = new String[]{
                    String[] args = new String[]{
@@ -199,7 +199,7 @@ public class CalendarColorPickerDialog extends ColorPickerDialog {
                    do {
                    do {
                        int colorKey = cursor.getInt(COLORS_INDEX_COLOR_KEY);
                        int colorKey = cursor.getInt(COLORS_INDEX_COLOR_KEY);
                        int rawColor = cursor.getInt(COLORS_INDEX_COLOR);
                        int rawColor = cursor.getInt(COLORS_INDEX_COLOR);
                        int displayColor = Utils.getDisplayColorFromColor(rawColor);
                        int displayColor = Utils.getDisplayColorFromColor(activity, rawColor);
                        mColorKeyMap.put(displayColor, colorKey);
                        mColorKeyMap.put(displayColor, colorKey);
                        colors.add(displayColor);
                        colors.add(displayColor);
                    } while (cursor.moveToNext());
                    } while (cursor.moveToNext());
+2 −4
Original line number Original line Diff line number Diff line
@@ -2856,14 +2856,12 @@ public class DayView extends View implements View.OnCreateContextMenuListener,
                    paint.setColor(event.color);
                    paint.setColor(event.color);
                    break;
                    break;
                case Attendees.ATTENDEE_STATUS_DECLINED:
                case Attendees.ATTENDEE_STATUS_DECLINED:
                    paint.setColor(mEventTextColor);
                    paint.setAlpha(Utils.DECLINED_EVENT_TEXT_ALPHA);
                    paint.setAlpha(Utils.DECLINED_EVENT_TEXT_ALPHA);
                    break;
                case Attendees.ATTENDEE_STATUS_NONE: // Your own events
                case Attendees.ATTENDEE_STATUS_NONE: // Your own events
                case Attendees.ATTENDEE_STATUS_ACCEPTED:
                case Attendees.ATTENDEE_STATUS_ACCEPTED:
                case Attendees.ATTENDEE_STATUS_TENTATIVE:
                case Attendees.ATTENDEE_STATUS_TENTATIVE:
                default:
                default:
                    paint.setColor(mEventTextColor);
                    paint.setColor(Utils.getAdaptiveTextColor(mContext, mEventTextColor, event.color));
                    break;
                    break;
            }
            }


@@ -2880,7 +2878,7 @@ public class DayView extends View implements View.OnCreateContextMenuListener,


            layouts[i] = layout;
            layouts[i] = layout;
        }
        }
        layout.getPaint().setAlpha(mEventsAlpha);
        layout.getPaint().setAlpha(Utils.getAdaptiveTextAlpha(mContext, mEventsAlpha, event.color));
        return layout;
        return layout;
    }
    }


Loading