Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ce059f4

Browse files
committedJun 7, 2021
Update readme | Example app code
1 parent 2b05058 commit ce059f4

File tree

7 files changed

+37
-38
lines changed

7 files changed

+37
-38
lines changed
 

‎README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ even for your programming language, just config the view with your language keyw
77
and you can change the CodeView theme in the runtime so it's made it easy to support any number of themes,
88
and CodeView has AutoComplete and you can customize it with different keywords and tokenizers.
99

10-
### Demo
10+
## Demo
1111
<p align="center">
1212
<img src="screenshots/python_demo.gif" alt="animated" />
1313
<img src="screenshots/java_demo.gif" alt="animated" />
@@ -16,18 +16,18 @@ and CodeView has AutoComplete and you can customize it with different keywords a
1616
<img src="screenshots/error_line_demo.png" alt="animated" width="242" height="480" />
1717
</p>
1818

19-
### Main Features:
20-
- Can support any programming language you want
21-
- Can support AutoComplete and customize it with different tokenizers and design
22-
- Can support any theme you want and change it in the runtime
23-
- Syntax Highlighter depend on your patterns so you can support any features like TODO comment
24-
- Can support errors and warns with different colors and remove them in the runtime
25-
- Can change highlighter update delay time
19+
- Main Features
20+
- Can support any programming language you want
21+
- Can support AutoComplete and customize it with different tokenizers and design
22+
- Can support any theme you want and change it in the runtime
23+
- Syntax Highlighter depend on your patterns so you can support any features like TODO comment
24+
- Can support errors and warns with different colors and remove them in the runtime
25+
- Can change highlighter update delay time
2626

27-
#### Who uses CodeView?
28-
- [MathScript](https://play.google.com/store/apps/details?id=com.amrdeveloper.mathscript)
27+
- Project that used CodeView
28+
- [MathScript](https://play.google.com/store/apps/details?id=com.amrdeveloper.mathscript)
2929

30-
##### If you use CodeView in an interesting project, I would like to know!
30+
##### If you use CodeView in an interesting project, I would like to know
3131

3232
#### Add CodeView to your project
3333

@@ -48,7 +48,7 @@ dependencies {
4848
}
4949
````
5050

51-
#### Documentation:
51+
#### Documentation
5252
CodeView is based on AppCompatMultiAutoCompleteTextView
5353

5454
Add CodeView on your xml

‎app/src/main/java/com/amrdeveloper/codeviewlibrary/MainActivity.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class MainActivity extends AppCompatActivity {
2121
private int mNextThemeIndex = 2;
2222

2323
//To change themes easily
24-
private Language mCurrentLanguage = Language.JAVA;
24+
private final Language mCurrentLanguage = Language.JAVA;
2525

2626
@Override
2727
protected void onCreate(Bundle savedInstanceState) {
@@ -37,9 +37,8 @@ protected void onCreate(Bundle savedInstanceState) {
3737
}
3838

3939
private void configLanguageAutoComplete() {
40-
//Load current Programming Language
4140
final String[] languageKeywords;
42-
switch (mCurrentLanguage){
41+
switch (mCurrentLanguage) {
4342
case JAVA:
4443
languageKeywords = getResources().getStringArray(R.array.java_keywords);
4544
break;
@@ -78,11 +77,12 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
7877
}
7978

8079
private void changeCodeViewTheme() {
81-
//Change CodeView Theme
82-
if(mNextThemeIndex > 4) {
83-
mNextThemeIndex = 1;
84-
}
80+
if (mNextThemeIndex > 4) mNextThemeIndex = 1;
81+
loadNextTheme();
82+
mNextThemeIndex = mNextThemeIndex + 1;
83+
}
8584

85+
private void loadNextTheme() {
8686
switch (mNextThemeIndex) {
8787
case 1:
8888
SyntaxManager.applyMonokaiTheme(this, mCodeView, mCurrentLanguage);
@@ -96,12 +96,11 @@ private void changeCodeViewTheme() {
9696
SyntaxManager.applyFiveColorsDarkTheme(this, mCodeView, mCurrentLanguage);
9797
Toast.makeText(this, "5 Colors Dark", Toast.LENGTH_SHORT).show();
9898
break;
99-
case 4:
99+
default:
100100
SyntaxManager.applyOrangeBoxTheme(this, mCodeView, mCurrentLanguage);
101101
Toast.makeText(this, "Orange Box", Toast.LENGTH_SHORT).show();
102102
break;
103103
}
104-
105-
mNextThemeIndex = mNextThemeIndex + 1;
106104
}
105+
107106
}

‎app/src/main/java/com/amrdeveloper/codeviewlibrary/syntax/GoSyntaxManager.java renamed to ‎app/src/main/java/com/amrdeveloper/codeviewlibrary/syntax/GoSyntaxUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.util.regex.Pattern;
99

10-
public class GoSyntaxManager {
10+
public class GoSyntaxUtils {
1111

1212
//Language Keywords
1313
private static final Pattern PATTERN_KEYWORDS = Pattern.compile("\\b(break|default|func|interface|case|defer|" +

‎app/src/main/java/com/amrdeveloper/codeviewlibrary/syntax/JavaSyntaxManager.java renamed to ‎app/src/main/java/com/amrdeveloper/codeviewlibrary/syntax/JavaSyntaxUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.util.regex.Pattern;
99

10-
public class JavaSyntaxManager {
10+
public class JavaSyntaxUtils {
1111

1212
//Language Keywords
1313
private static final Pattern PATTERN_KEYWORDS = Pattern.compile("\\b(abstract|boolean|break|byte|case|catch" +

‎app/src/main/java/com/amrdeveloper/codeviewlibrary/syntax/PythonSyntaxManager.java renamed to ‎app/src/main/java/com/amrdeveloper/codeviewlibrary/syntax/PythonSyntaxUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.util.regex.Pattern;
99

10-
public class PythonSyntaxManager {
10+
public class PythonSyntaxUtils {
1111

1212
//Language Keywords
1313
private static final Pattern PATTERN_KEYWORDS = Pattern.compile("\\b(False|await|else|import|pass|None|break|except|in|raise" +

‎app/src/main/java/com/amrdeveloper/codeviewlibrary/syntax/SyntaxManager.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,55 @@ public class SyntaxManager {
99
public static void applyMonokaiTheme(Context context, CodeView codeView, Language language) {
1010
switch (language) {
1111
case JAVA:
12-
JavaSyntaxManager.applyMonokaiTheme(context, codeView);
12+
JavaSyntaxUtils.applyMonokaiTheme(context, codeView);
1313
break;
1414
case PYTHON:
15-
PythonSyntaxManager.applyMonokaiTheme(context, codeView);
15+
PythonSyntaxUtils.applyMonokaiTheme(context, codeView);
1616
break;
1717
case GO_LANG:
18-
GoSyntaxManager.applyMonokaiTheme(context, codeView);
18+
GoSyntaxUtils.applyMonokaiTheme(context, codeView);
1919
break;
2020
}
2121
}
2222

2323
public static void applyNoctisWhiteTheme(Context context, CodeView codeView, Language language) {
2424
switch (language) {
2525
case JAVA:
26-
JavaSyntaxManager.applyNoctisWhiteTheme(context, codeView);
26+
JavaSyntaxUtils.applyNoctisWhiteTheme(context, codeView);
2727
break;
2828
case PYTHON:
29-
PythonSyntaxManager.applyNoctisWhiteTheme(context, codeView);
29+
PythonSyntaxUtils.applyNoctisWhiteTheme(context, codeView);
3030
break;
3131
case GO_LANG:
32-
GoSyntaxManager.applyNoctisWhiteTheme(context, codeView);
32+
GoSyntaxUtils.applyNoctisWhiteTheme(context, codeView);
3333
break;
3434
}
3535
}
3636

3737
public static void applyFiveColorsDarkTheme(Context context, CodeView codeView, Language language) {
3838
switch (language) {
3939
case JAVA:
40-
JavaSyntaxManager.applyFiveColorsDarkTheme(context, codeView);
40+
JavaSyntaxUtils.applyFiveColorsDarkTheme(context, codeView);
4141
break;
4242
case PYTHON:
43-
PythonSyntaxManager.applyFiveColorsDarkTheme(context, codeView);
43+
PythonSyntaxUtils.applyFiveColorsDarkTheme(context, codeView);
4444
break;
4545
case GO_LANG:
46-
GoSyntaxManager.applyFiveColorsDarkTheme(context, codeView);
46+
GoSyntaxUtils.applyFiveColorsDarkTheme(context, codeView);
4747
break;
4848
}
4949
}
5050

5151
public static void applyOrangeBoxTheme(Context context, CodeView codeView, Language language) {
5252
switch (language) {
5353
case JAVA:
54-
JavaSyntaxManager.applyOrangeBoxTheme(context, codeView);
54+
JavaSyntaxUtils.applyOrangeBoxTheme(context, codeView);
5555
break;
5656
case PYTHON:
57-
PythonSyntaxManager.applyOrangeBoxTheme(context, codeView);
57+
PythonSyntaxUtils.applyOrangeBoxTheme(context, codeView);
5858
break;
5959
case GO_LANG:
60-
GoSyntaxManager.applyOrangeBoxTheme(context, codeView);
60+
GoSyntaxUtils.applyOrangeBoxTheme(context, codeView);
6161
break;
6262
}
6363
}

‎codeview/src/androidTest/java/com/amrdeveloper/codeview/ExampleInstrumentedTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.junit.Test;
99
import org.junit.runner.RunWith;
1010

11-
import static org.junit.Assert.*;
11+
import static org.junit.Assert.assertEquals;
1212

1313
/**
1414
* Instrumented test, which will execute on an Android device.

0 commit comments

Comments
 (0)
Please sign in to comment.