Schedule Event Color
This commit is contained in:
@@ -140,7 +140,7 @@ public class ScheduleFragment extends Fragment implements
|
||||
start.setTimeInMillis(e.getStartDate());
|
||||
|
||||
WeekViewEvent weekViewEvent = new WeekViewEvent(e.getModuleId()+"/"+e.getId(), e.getTitle(), e.getLocation(), start, end);
|
||||
weekViewEvent.setColor(e.getColor());
|
||||
weekViewEvent.setColor(e.getColor(getContext()));
|
||||
events.add(weekViewEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package de.sebse.fuplanner.services.kvv.types;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import com.google.android.gms.common.internal.Objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -8,6 +11,9 @@ import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import de.sebse.fuplanner.tools.ColorRGB;
|
||||
|
||||
public class Event implements Serializable {
|
||||
@@ -60,7 +66,7 @@ public class Event implements Serializable {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public ColorRGB getColor() {
|
||||
public ColorRGB getColor(@Nullable Context context) {
|
||||
MessageDigest digest;
|
||||
try {
|
||||
digest = MessageDigest.getInstance("SHA-256");
|
||||
@@ -79,8 +85,21 @@ public class Event implements Serializable {
|
||||
|
||||
// range for more beautiful colors
|
||||
h = h / 30 * 30;
|
||||
|
||||
boolean nightMode = false;
|
||||
if (context != null) {
|
||||
int currentNightMode = context.getResources().getConfiguration().uiMode
|
||||
& Configuration.UI_MODE_NIGHT_MASK;
|
||||
if (currentNightMode == Configuration.UI_MODE_NIGHT_YES) {
|
||||
nightMode = true;
|
||||
}
|
||||
}
|
||||
int s = 100;
|
||||
int v = 80;
|
||||
if (nightMode) {
|
||||
s = 60;
|
||||
v = 100;
|
||||
}
|
||||
|
||||
return hsvToRgb(h/360.0, s/100.0, v/100.0);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
app:showNowLine="true"
|
||||
app:headerColumnTextColor="@color/fuHeaderText3"
|
||||
android:background="@color/fuBackgroundShadowed"
|
||||
app:eventTextColor="@color/colorFUWhite"
|
||||
app:eventTextColor="@color/fuBackgroundHighContrast"
|
||||
app:headerRowBackgroundColor="@color/fuBackgroundShadowed"
|
||||
app:futureWeekendBackgroundColor="@color/fuWeekendFuture"
|
||||
app:pastWeekendBackgroundColor="@color/fuWeekendPast"
|
||||
|
||||
Reference in New Issue
Block a user