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