I'm trying to create custom color palettes for my Android app. I started doing it this way:
public class Theme {
public static final class DARK {
final static int POSITIVE_GREEN = Color.rgb(0, 200, 0);
final static int NEGATIVE_RED = Color.rgb(200, 0, 0);
final static int BACKGROUND_GREEN = Color.argb(255 - 220, 0, 255, 0); //220
final static int BACKGROUND_RED = Color.argb(255 - 220, 255, 0, 0);
}
public static final class PASTEL {
final static int POSITIVE_GREEN = Color.parseColor("#326262");
final static int NEGATIVE_RED = etc
final static int BACKGROUND_GREEN = etc
final static int BACKGROUND_RED = etc
}
}
but realized something was amiss when I wanted to refactor one of the field names. The field names should be abstract in THEME or something, but since these shouldn't be instantiable classes, I can't use the constructor trick suggested here: Why not abstract fields? How should I be doing this?
Use of interfaces seems apppropriate here:
Every theme will implement this interface:
For example:
In general use of public static variable should be limited to some very simple scenarios which is not what you are trying to achieve.
https://docs.oracle.com/javase/tutorial/java/concepts/interface.html