-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the example app structure to make it easy to add new language …
…or theme
- Loading branch information
1 parent
69494d4
commit 05d75bf
Showing
8 changed files
with
262 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
app/src/main/java/com/amrdeveloper/codeviewlibrary/syntax/LanguageManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package com.amrdeveloper.codeviewlibrary.syntax; | ||
|
||
import android.content.Context; | ||
|
||
import com.amrdeveloper.codeview.Code; | ||
import com.amrdeveloper.codeview.CodeView; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class LanguageManager { | ||
|
||
private final Context context; | ||
private final CodeView codeView; | ||
|
||
public LanguageManager(Context context, CodeView codeView) { | ||
this.context = context; | ||
this.codeView = codeView; | ||
} | ||
|
||
public void applyTheme(LanguageName language, ThemeName theme) { | ||
switch (theme) { | ||
case MONOKAI: | ||
applyMonokaiTheme(language); | ||
break; | ||
case NOCTIS_WHITE: | ||
applyNoctisWhiteTheme(language); | ||
break; | ||
case FIVE_COLOR: | ||
applyFiveColorsDarkTheme(language); | ||
break; | ||
case ORANGE_BOX: | ||
applyOrangeBoxTheme(language); | ||
break; | ||
} | ||
} | ||
|
||
public String[] getLanguageKeywords(LanguageName language) { | ||
switch (language) { | ||
case JAVA: return JavaLanguage.getKeywords(context); | ||
case PYTHON: return PythonLanguage.getKeywords(context); | ||
case GO_LANG: return GoLanguage.getKeywords(context); | ||
default: return new String[]{}; | ||
} | ||
} | ||
|
||
public List<Code> getLanguageCodeList(LanguageName language) { | ||
switch (language) { | ||
case JAVA: return JavaLanguage.getCodeList(context); | ||
case PYTHON: return PythonLanguage.getCodeList(context); | ||
case GO_LANG: return GoLanguage.getCodeList(context); | ||
default: return new ArrayList<>(); | ||
} | ||
} | ||
|
||
public Set<Character> getLanguageIndentationStarts(LanguageName language) { | ||
switch (language) { | ||
case JAVA: return JavaLanguage.getIndentationStarts(); | ||
case PYTHON: return PythonLanguage.getIndentationStarts(); | ||
case GO_LANG: return GoLanguage.getIndentationStarts(); | ||
default: return new HashSet<>(); | ||
} | ||
} | ||
|
||
public Set<Character> getLanguageIndentationEnds(LanguageName language) { | ||
switch (language) { | ||
case JAVA: return JavaLanguage.getIndentationEnds(); | ||
case PYTHON: return PythonLanguage.getIndentationEnds(); | ||
case GO_LANG: return GoLanguage.getIndentationEnds(); | ||
default: return new HashSet<>(); | ||
} | ||
} | ||
|
||
private void applyMonokaiTheme(LanguageName language) { | ||
switch (language) { | ||
case JAVA: | ||
JavaLanguage.applyMonokaiTheme(context, codeView); | ||
break; | ||
case PYTHON: | ||
PythonLanguage.applyMonokaiTheme(context, codeView); | ||
break; | ||
case GO_LANG: | ||
GoLanguage.applyMonokaiTheme(context, codeView); | ||
break; | ||
} | ||
} | ||
|
||
private void applyNoctisWhiteTheme(LanguageName language) { | ||
switch (language) { | ||
case JAVA: | ||
JavaLanguage.applyNoctisWhiteTheme(context, codeView); | ||
break; | ||
case PYTHON: | ||
PythonLanguage.applyNoctisWhiteTheme(context, codeView); | ||
break; | ||
case GO_LANG: | ||
GoLanguage.applyNoctisWhiteTheme(context, codeView); | ||
break; | ||
} | ||
} | ||
|
||
private void applyFiveColorsDarkTheme(LanguageName language) { | ||
switch (language) { | ||
case JAVA: | ||
JavaLanguage.applyFiveColorsDarkTheme(context, codeView); | ||
break; | ||
case PYTHON: | ||
PythonLanguage.applyFiveColorsDarkTheme(context, codeView); | ||
break; | ||
case GO_LANG: | ||
GoLanguage.applyFiveColorsDarkTheme(context, codeView); | ||
break; | ||
} | ||
} | ||
|
||
private void applyOrangeBoxTheme(LanguageName language) { | ||
switch (language) { | ||
case JAVA: | ||
JavaLanguage.applyOrangeBoxTheme(context, codeView); | ||
break; | ||
case PYTHON: | ||
PythonLanguage.applyOrangeBoxTheme(context, codeView); | ||
break; | ||
case GO_LANG: | ||
GoLanguage.applyOrangeBoxTheme(context, codeView); | ||
break; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.