-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efa4d64
commit 7256dff
Showing
140 changed files
with
10,180 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Base .gitignore taken from "https://raw.githubusercontent.com/github/gitignore/master/Android.gitignore" | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# Intellij | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/libraries | ||
.idea/ | ||
|
||
# Keystore files | ||
*.jks | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
.idea/vcs.xml | ||
.idea/misc.xml |
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 @@ | ||
/build |
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,43 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '25.0.2' | ||
defaultConfig { | ||
applicationId "com.pddstudio.highlightjs.demo" | ||
minSdkVersion 16 | ||
targetSdkVersion 25 | ||
versionCode 2 | ||
versionName "1.0.1" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
packagingOptions { | ||
exclude 'META-INF/LICENSE.txt' | ||
exclude 'META-INF/LICENSE' | ||
exclude 'META-INF/NOTICE.txt' | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
compile project(':library') | ||
|
||
compile 'org.kohsuke:github-api:1.82' | ||
compile 'com.android.support:appcompat-v7:25.2.0' | ||
compile 'com.android.support:recyclerview-v7:25.2.0' | ||
compile 'com.android.support:design:25.2.0' | ||
|
||
//testing dependencies | ||
testCompile 'junit:junit:4.12' | ||
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' | ||
androidTestCompile 'com.android.support.test:runner:0.5' | ||
androidTestCompile 'com.android.support:support-annotations:25.2.0' | ||
} |
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,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /home/pddstudio/Android/Sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
29 changes: 29 additions & 0 deletions
29
app/src/androidTest/java/com/pddstudio/highlightjs/demo/ExampleInstrumentationTest.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,29 @@ | ||
package com.pddstudio.highlightjs.demo; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.filters.MediumTest; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@MediumTest | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentationTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.pddstudio.highlightjs.demo", appContext.getPackageName()); | ||
} | ||
} |
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,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.pddstudio.highlightjs.demo"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".SyntaxActivity"></activity> | ||
</application> | ||
|
||
</manifest> |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/pddstudio/highlightjs/demo/MainActivity.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,20 @@ | ||
package com.pddstudio.highlightjs.demo; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.pddstudio.highlightjs.demo.fragments.FilesListFragment; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
getSupportFragmentManager() | ||
.beginTransaction() | ||
.replace(R.id.activity_main, FilesListFragment.newInstance()) | ||
.commit(); | ||
} | ||
|
||
} |
127 changes: 127 additions & 0 deletions
127
app/src/main/java/com/pddstudio/highlightjs/demo/SyntaxActivity.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,127 @@ | ||
package com.pddstudio.highlightjs.demo; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.v4.widget.SwipeRefreshLayout; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.Menu; | ||
import android.view.MenuInflater; | ||
import android.view.MenuItem; | ||
import android.widget.Toast; | ||
|
||
import com.pddstudio.highlightjs.HighlightJsView; | ||
import com.pddstudio.highlightjs.demo.utils.FileObject; | ||
import com.pddstudio.highlightjs.demo.utils.ThemeChangerDialog; | ||
import com.pddstudio.highlightjs.models.Language; | ||
import com.pddstudio.highlightjs.models.Theme; | ||
|
||
import java.util.Random; | ||
|
||
public class SyntaxActivity extends AppCompatActivity implements | ||
SwipeRefreshLayout.OnRefreshListener, | ||
HighlightJsView.OnThemeChangedListener, | ||
ThemeChangerDialog.ThemeChangeListener { | ||
|
||
private SwipeRefreshLayout swipeRefreshLayout; | ||
private HighlightJsView highlightJsView; | ||
private FileObject fileObject; | ||
|
||
private ThemeChangerDialog themeChangerDialog; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_syntax); | ||
fileObject = (FileObject) getIntent().getExtras().getSerializable("fileObject"); | ||
if(getActionBar() != null) { | ||
getActionBar().setTitle(fileObject.getAbsoluteFilePath()); | ||
getActionBar().setDisplayHomeAsUpEnabled(true); | ||
} | ||
if(getSupportActionBar() != null) { | ||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||
getSupportActionBar().setTitle(fileObject.getAbsoluteFilePath()); | ||
} | ||
//set and assign swipe refresh listener | ||
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); | ||
swipeRefreshLayout.setOnRefreshListener(this); | ||
//find and instantiate the view | ||
highlightJsView = (HighlightJsView) findViewById(R.id.highlight_view); | ||
//register theme change listener | ||
highlightJsView.setOnThemeChangedListener(this); | ||
//change theme and set language to auto detect | ||
highlightJsView.setTheme(Theme.ARDUINO_LIGHT); | ||
highlightJsView.setHighlightLanguage(Language.JAVA); | ||
highlightJsView.setShowLineNumbers(false); | ||
//load the source | ||
highlightJsView.setSource(fileObject.getUrl()); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
themeChangerDialog = new ThemeChangerDialog(this); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
new MenuInflater(this).inflate(R.menu.menu_theme_switch, menu); | ||
return super.onCreateOptionsMenu(menu); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case android.R.id.home: | ||
onBackPressed(); | ||
break; | ||
case R.id.menu_switch_theme: | ||
themeChangerDialog.show(this); | ||
break; | ||
case R.id.menu_check_line_numbers: | ||
item.setChecked(!item.isChecked()); | ||
onShowLineNumbersToggled(item.isChecked()); | ||
break; | ||
case R.id.menu_check_zoom: | ||
item.setChecked(!item.isChecked()); | ||
onZoomSupportToggled(item.isChecked()); | ||
break; | ||
default: | ||
break; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
private void onShowLineNumbersToggled(boolean enableLineNumbers) { | ||
highlightJsView.setShowLineNumbers(enableLineNumbers); | ||
highlightJsView.refresh(); | ||
} | ||
|
||
private void onZoomSupportToggled(boolean enableZooming) { | ||
highlightJsView.setZoomSupportEnabled(enableZooming); | ||
highlightJsView.refresh(); | ||
} | ||
|
||
@Override | ||
public void onRefresh() { | ||
swipeRefreshLayout.setRefreshing(true); | ||
highlightJsView.setTheme(getRandom(Theme.values())); | ||
highlightJsView.refresh(); | ||
} | ||
|
||
private <T> T getRandom(T... items) { | ||
return items[new Random().nextInt(items.length)]; | ||
} | ||
|
||
@Override | ||
public void onThemeChanged(@NonNull Theme theme) { | ||
swipeRefreshLayout.setRefreshing(false); | ||
Toast.makeText(this, "Theme: " + theme.name(), Toast.LENGTH_SHORT).show(); | ||
} | ||
|
||
@Override | ||
public void onChangeTheme(@NonNull Theme theme) { | ||
highlightJsView.setTheme(theme); | ||
highlightJsView.refresh(); | ||
} | ||
|
||
} |
Oops, something went wrong.