mirror of https://codeberg.org/gitnex/GitNex.git
Add syntax highlighting colors via color theme
This commit is contained in:
parent
1e16505414
commit
aaa3e3d8c8
|
@ -0,0 +1,48 @@
|
||||||
|
package org.mian.gitnex.helpers.codeeditor.theme;
|
||||||
|
|
||||||
|
import androidx.annotation.ColorRes;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.helpers.codeeditor.languages.LanguageElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author M M Arif
|
||||||
|
*/
|
||||||
|
public class BlueMoonDarkTheme implements Theme {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ColorRes
|
||||||
|
public int getColor(LanguageElement element) {
|
||||||
|
switch (element) {
|
||||||
|
case HEX:
|
||||||
|
case NUMBER:
|
||||||
|
case KEYWORD:
|
||||||
|
case OPERATION:
|
||||||
|
case GENERIC:
|
||||||
|
return R.color.moon_dark_blue;
|
||||||
|
case CHAR:
|
||||||
|
case STRING:
|
||||||
|
return R.color.moon_dark_turquoise;
|
||||||
|
case SINGLE_LINE_COMMENT:
|
||||||
|
case MULTI_LINE_COMMENT:
|
||||||
|
return R.color.moon_dark_grey;
|
||||||
|
case ATTRIBUTE:
|
||||||
|
case TODO_COMMENT:
|
||||||
|
case ANNOTATION:
|
||||||
|
return R.color.moon_deep_sky_blue;
|
||||||
|
default:
|
||||||
|
return R.color.moon_dark_white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ColorRes
|
||||||
|
public int getDefaultColor() {
|
||||||
|
return R.color.moon_dark_white;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ColorRes
|
||||||
|
public int getBackgroundColor() {
|
||||||
|
return R.color.moon_dark_black;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.mian.gitnex.helpers.codeeditor.theme;
|
||||||
|
|
||||||
|
import androidx.annotation.ColorRes;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.helpers.codeeditor.languages.LanguageElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author M M Arif
|
||||||
|
*/
|
||||||
|
public class BlueMoonTheme implements Theme {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ColorRes
|
||||||
|
public int getColor(LanguageElement element) {
|
||||||
|
switch (element) {
|
||||||
|
case HEX:
|
||||||
|
case NUMBER:
|
||||||
|
case KEYWORD:
|
||||||
|
case OPERATION:
|
||||||
|
case GENERIC:
|
||||||
|
return R.color.moon_dark_blue;
|
||||||
|
case CHAR:
|
||||||
|
case STRING:
|
||||||
|
return R.color.moon_dark_turquoise;
|
||||||
|
case SINGLE_LINE_COMMENT:
|
||||||
|
case MULTI_LINE_COMMENT:
|
||||||
|
return R.color.moon_dark_grey;
|
||||||
|
case ATTRIBUTE:
|
||||||
|
case TODO_COMMENT:
|
||||||
|
case ANNOTATION:
|
||||||
|
return R.color.moon_deep_sky_blue;
|
||||||
|
default:
|
||||||
|
return R.color.moon_dark_black;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ColorRes
|
||||||
|
public int getDefaultColor() {
|
||||||
|
return R.color.moon_dark_black;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ColorRes
|
||||||
|
public int getBackgroundColor() {
|
||||||
|
return R.color.moon_background_grey;
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,8 +23,6 @@ public class FiveColorsDarkTheme implements Theme {
|
||||||
case CHAR:
|
case CHAR:
|
||||||
case STRING:
|
case STRING:
|
||||||
return R.color.five_dark_yellow;
|
return R.color.five_dark_yellow;
|
||||||
case BUILTIN:
|
|
||||||
return R.color.five_dark_white;
|
|
||||||
case SINGLE_LINE_COMMENT:
|
case SINGLE_LINE_COMMENT:
|
||||||
case MULTI_LINE_COMMENT:
|
case MULTI_LINE_COMMENT:
|
||||||
return R.color.five_dark_grey;
|
return R.color.five_dark_grey;
|
||||||
|
|
|
@ -23,8 +23,6 @@ public class FiveColorsTheme implements Theme {
|
||||||
case CHAR:
|
case CHAR:
|
||||||
case STRING:
|
case STRING:
|
||||||
return R.color.five_yellow;
|
return R.color.five_yellow;
|
||||||
case BUILTIN:
|
|
||||||
return R.color.five_dark_black;
|
|
||||||
case SINGLE_LINE_COMMENT:
|
case SINGLE_LINE_COMMENT:
|
||||||
case MULTI_LINE_COMMENT:
|
case MULTI_LINE_COMMENT:
|
||||||
return R.color.five_dark_grey;
|
return R.color.five_dark_grey;
|
||||||
|
|
|
@ -4,21 +4,31 @@ import android.content.Context;
|
||||||
import androidx.annotation.ColorRes;
|
import androidx.annotation.ColorRes;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.codeeditor.languages.LanguageElement;
|
import org.mian.gitnex.helpers.codeeditor.languages.LanguageElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author qwerty287
|
* @author qwerty287
|
||||||
|
* @author M M Arif
|
||||||
*/
|
*/
|
||||||
public interface Theme {
|
public interface Theme {
|
||||||
|
|
||||||
FiveColorsTheme FIVE_COLORS = new FiveColorsTheme();
|
FiveColorsTheme FIVE_COLORS = new FiveColorsTheme();
|
||||||
|
|
||||||
FiveColorsDarkTheme FIVE_COLORS_DARK = new FiveColorsDarkTheme();
|
FiveColorsDarkTheme FIVE_COLORS_DARK = new FiveColorsDarkTheme();
|
||||||
|
BlueMoonTheme BLUE_MOON_THEME = new BlueMoonTheme();
|
||||||
|
BlueMoonDarkTheme BLUE_MOON_DARK_THEME = new BlueMoonDarkTheme();
|
||||||
|
|
||||||
static Theme getDefaultTheme(Context context) {
|
static Theme getDefaultTheme(Context context) {
|
||||||
return AppUtil.getColorFromAttribute(context, R.attr.isDark) == 1
|
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||||
? FIVE_COLORS_DARK
|
if (tinyDB.getInt("ceColorId") == 0) {
|
||||||
: FIVE_COLORS;
|
return AppUtil.getColorFromAttribute(context, R.attr.isDark) == 1
|
||||||
|
? FIVE_COLORS_DARK
|
||||||
|
: FIVE_COLORS;
|
||||||
|
} else {
|
||||||
|
return AppUtil.getColorFromAttribute(context, R.attr.isDark) == 1
|
||||||
|
? BLUE_MOON_DARK_THEME
|
||||||
|
: BLUE_MOON_THEME;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ColorRes
|
@ColorRes
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- five o clock colors -->
|
||||||
|
<color name="five_dark_black">#252526</color>
|
||||||
|
<color name="five_dark_blue">#267ae9</color>
|
||||||
|
<color name="five_dark_yellow">#fde92f</color>
|
||||||
|
<color name="five_dark_purple">#eb84f3</color>
|
||||||
|
<color name="five_dark_grey">#a9b1ae</color>
|
||||||
|
<color name="five_dark_white">#ffffff</color>
|
||||||
|
<color name="gold">#e6b121</color>
|
||||||
|
<color name="five_yellow">#fdc92f</color>
|
||||||
|
<color name="five_background_grey">#f5f2f0</color>
|
||||||
|
|
||||||
|
<!-- blue moon colors -->
|
||||||
|
<color name="moon_dark_black">#252526</color>
|
||||||
|
<color name="moon_dark_blue">#1E90FF</color>
|
||||||
|
<color name="moon_dark_aquamarine">#7FFFD4</color>
|
||||||
|
<color name="moon_dark_turquoise">#40E0D0</color>
|
||||||
|
<color name="moon_dark_grey">#B0C4DE</color>
|
||||||
|
<color name="moon_dark_white">#ffffff</color>
|
||||||
|
<color name="moon_deep_sky_blue">#00BFFF</color>
|
||||||
|
<color name="moon_background_grey">#f5f2f0</color>
|
||||||
|
</resources>
|
|
@ -65,15 +65,4 @@
|
||||||
<color name="pitchBlackThemeGeneralBackgroundColor">#151515</color>
|
<color name="pitchBlackThemeGeneralBackgroundColor">#151515</color>
|
||||||
<color name="pitchBlackThemeColorSecondary">#161918</color>
|
<color name="pitchBlackThemeColorSecondary">#161918</color>
|
||||||
<color name="pitchBlackThemeCardBackground">#0C0C0C</color>
|
<color name="pitchBlackThemeCardBackground">#0C0C0C</color>
|
||||||
|
|
||||||
<!-- code editor colors -->
|
|
||||||
<color name="five_dark_black">#252526</color>
|
|
||||||
<color name="five_dark_blue">#267ae9</color>
|
|
||||||
<color name="five_dark_yellow">#fde92f</color>
|
|
||||||
<color name="five_dark_purple">#eb84f3</color>
|
|
||||||
<color name="five_dark_grey">#a9b1ae</color>
|
|
||||||
<color name="five_dark_white">#ffffff</color>
|
|
||||||
<color name="gold">#e6b121</color>
|
|
||||||
<color name="five_yellow">#fdc92f</color>
|
|
||||||
<color name="five_background_grey">#f5f2f0</color>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
|
|
||||||
<string-array name="ceColors">
|
<string-array name="ceColors">
|
||||||
<item>Five O Clock</item>
|
<item>Five O Clock</item>
|
||||||
<item>Monro</item>
|
<item>Blue Moon</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="ceIndentation">
|
<string-array name="ceIndentation">
|
||||||
|
|
Loading…
Reference in New Issue