Skip to content

Commit

Permalink
'高亮代码编辑器'
Browse files Browse the repository at this point in the history
  • Loading branch information
qiusunshine committed Sep 10, 2021
1 parent 613817d commit e78ceb3
Show file tree
Hide file tree
Showing 70 changed files with 10,849 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

3、Adblock Plus广告拦截订阅

4、播放器
4、视频播放器

5、Dlan投屏

6、网页投屏

7、多线程文件下载
7、多线程文件下载(支持m3u8合并为mp4)

8、高亮代码编辑器

...

Expand Down
1 change: 1 addition & 0 deletions editor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
47 changes: 47 additions & 0 deletions editor/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28



defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
dataBinding {
enabled = true
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// javaCompileOptions {
// annotationProcessorOptions {
// includeCompileClasspath = true
// }
// }

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation project(":code-editor")
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
implementation "androidx.legacy:legacy-preference-v14:1.0.0"
implementation('androidx.core:core:1.3.0')
api 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
}
21 changes: 21 additions & 0 deletions editor/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# 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 *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
2 changes: 2 additions & 0 deletions editor/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hiker.editor" />
Binary file added editor/src/main/assets/fonts/Source_Code_Pro.ttf
Binary file not shown.
Binary file added editor/src/main/assets/fonts/droid_sans_mono.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added editor/src/main/assets/fonts/roboto.ttf
Binary file not shown.
Binary file added editor/src/main/assets/fonts/roboto_light.ttf
Binary file not shown.
53 changes: 53 additions & 0 deletions editor/src/main/assets/templates/AlertDialog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//AlertDialog.Builder Template

var AlertDialog = android.app.AlertDialog;
var ScrollView = android.widget.ScrollView;
var LinearLayout = android.widget.LinearLayout;
var TextView = android.widget.TextView;
var Color = android.graphics.Color;
var EditText = android.widget.EditText;
var ViewGroup = android.view.ViewGroup;
var DialogInterface = android.content.DialogInterface;

var alert = new AlertDialog.Builder(ctx);
alert.setTitle("Hello Sun");

var scroll = new ScrollView(ctx);
var layout = new LinearLayout(ctx);
layout.setOrientation(1);

var note = new TextView(ctx);
note.setText("It is now daytime :D");
note.setTextColor(Color.WHITE);
note.setTextSize(20);

var sethealth = new EditText(ctx);
sethealth.setHint("Set Health");

var params = new ViewGroup.LayoutParams(-2, -2);

layout.addView(note, params);
layout.addView(sethealth, params);

alert.setView(layout);

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
onClick: function(view) {
Player.setHealth(sethealth.getText().toString());
}
});

alert.setNegativeButton("Ok (Don't set health)", new DialogInterface.OnClickListener() {
onClick: function(view) {
//nothing
}
});

alert.setNeutralButton("Set time to night", new DialogInterface.OnClickListener() {
onClick: function(view) {
Level.setTime(13500);
}
});

var dialog = alert.create();
dialog.show();
47 changes: 47 additions & 0 deletions editor/src/main/assets/templates/Button.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//Custom UI Setup:

var GUI;
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();

var Runnable = java.lang.Runnable;
var LinearLayout = android.widget.LinearLayout;
var Button = android.widget.Button;
var View = android.view.View;
var PopupWindow = android.widget.PopupWindow;
var RelativeLayout = android.widget.RelativeLayout;
var ColorDrawable = android.graphics.drawable.ColorDrawable;
var Color = android.graphics.Color;
var Gravity = android.view.Gravity;

function newLevel() {
ctx.runOnUiThread(new Runnable({ run: function(){
try {
var layout = new LinearLayout(ctx);
layout.setOrientation(1);

var button = new Button(ctx);
button.setText("Button");
button.setOnClickListener(new View.OnClickListener({
onClick: function(view) {
//Your Code;
}
}));
layout.addView(button);

GUI = new PopupWindow(layout, RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
GUI.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
GUI.showAtLocation(ctx.getWindow().getDecorView(), Gravity.RIGHT | Gravity.TOP, 0, 0);
} catch (err) {
print("An error occured: " + err);
}
}}));
}

function leaveGame() {
ctx.runOnUiThread(new Runnable({ run: function(){
if(GUI != null) {
GUI.dismiss();
GUI = null;
}
}}));
}
13 changes: 13 additions & 0 deletions editor/src/main/assets/templates/ButtonWidget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//Standard Custom UI Template:

var Button = android.widget.Button;
var View = android.view.View;

var button = new Button(ctx);
button.setText("Button");
button.setOnClickListener(new View.OnClickListener({
onClick: function(view){
//Your Code
}
}));
layout.addView(button);
22 changes: 22 additions & 0 deletions editor/src/main/assets/templates/ButtonWithTouchListener.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//Custom UI with OnTouchListener Template:

var Button = android.widget.Button;
var View = android.view.View;

var active = false;
var button = new Button(ctx);
button.setText("Button");
button.setOnTouchListener(new View.OnTouchListener({
onClick: function(v, event){
switch(event.getAction()) {
case 0:
active = true;
break;
case 1:
active = false;
break;
}
return true;
}
}));
layout.addView(button);
19 changes: 19 additions & 0 deletions editor/src/main/assets/templates/CheckBoxWidget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//CheckBox Template:

var CheckBox = android.widget.CheckBox;
var View = android.view.View;

var checked = false;
var button = new CheckBox(ctx);
button.setText("Button");
button.setChecked(checked);
button.setOnClickListener(new View.OnClickListener({
onClick: function(view){
if(!checked) {
checked = true;
} else {
checked = false;
}
}
}));
layout.addView(button);
14 changes: 14 additions & 0 deletions editor/src/main/assets/templates/ImageWidget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//ImageView Template:

var BitmapFactory = android.graphics.BitmapFactory;
var BitmapDrawable = android.graphics.drawable.BitmapDrawable;
var ImageView = android.widget.ImageView;

var directory = new BitmapFactory.decodeFile("Your Directory");
var img = new BitmapDrawable(directory);
var image = new ImageView(ctx);
image.setImageBitmap(img);

//If you want this image to do something, put your OnClickListener here
//If you don't want this image to do anything, do this:
yourPopupWindowVariable.setTouchable(false);
119 changes: 119 additions & 0 deletions editor/src/main/assets/templates/Menu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
//Custom UI + Menu Setup:

var GUI;
var menu;
var exitUI;

var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
var Runnable = java.lang.Runnable;
var LinearLayout = android.widget.LinearLayout;
var Button = android.widget.Button;
var View = android.view.View;
var PopupWindow = android.widget.PopupWindow;
var RelativeLayout = android.widget.RelativeLayout;
var ColorDrawable = android.graphics.drawable.ColorDrawable;
var Color = android.graphics.Color;
var Gravity = android.view.Gravity;
var ScrollView = android.widget.ScrollView;

function dip2px(dips) {
return Math.ceil(dips * ctx.getResources().getDisplayMetrics().density);
}

function newLevel() {
ctx.runOnUiThread(new Runnable({ run: function(){
try {
var layout = new LinearLayout(ctx);
layout.setOrientation(1);

var menuBtn = new Button(ctx);
menuBtn.setText("Menu");
menuBtn.setOnClickListener(new View.OnClickListener({
onClick: function(view){
mainMenu();
}
}));
layout.addView(menuBtn);

GUI = new PopupWindow(layout, RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
GUI.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
GUI.showAtLocation(ctx.getWindow().getDecorView(), Gravity.RIGHT | Gravity.BOTTOM, 0, 0);
} catch (err) {
print("An error occured: " + err);
}
}}));
}

function mainMenu() {
ctx.runOnUiThread(new Runnable({ run: function(){
try {
var menuLayout = new LinearLayout(ctx);
var menuScroll = new ScrollView(ctx);
var menuLayout1 = new LinearLayout(ctx);
menuLayout.setOrientation(1);
menuLayout1.setOrientation(1);

menuScroll.addView(menuLayout);
menuLayout1.addView(menuScroll);

var button = new Button(ctx);
button.setText("Button");
button.setOnClickListener(new View.OnClickListener({
onClick: function(view){
//Your Code
}
}));
menuLayout.addView(button);

//Add more buttons in this section

menu = new PopupWindow(menuLayout1, ctx.getWindowManager().getDefaultDisplay().getWidth()/2, ctx.getWindowManager().getDefaultDisplay().getHeight());
menu.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
menu.showAtLocation(ctx.getWindow().getDecorView(), Gravity.RIGHT | Gravity.TOP, 0, 0);
} catch (error) {
print("An error occured: " + error);
}
}}));
}

function exit() {
ctx.runOnUiThread(new Runnable({ run: function(){
try {
var xLayout = new LinearLayout(ctx);

var xButton = new Button(ctx);
xButton.setText("x");
xButton.setTextColor(Color.WHITE);
xButton.setOnClickListener(new View.OnClickListener({
onClick: function(view){
exitUI.dismiss();
menu.dismiss();
}
}));
xLayout.addView(xButton);

exitUI = new PopupWindow(xLayout, dip2px(40), dip2px(40));
exitUI.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
exitUI.showAtLocation(ctx.getWindow().getDecorView(), Gravity.RIGHT | Gravity.TOP, 0, 0);
} catch (exception) {
print(exception);
}
}}));
}

function leaveGame() {
ctx.runOnUiThread(new Runnable({ run: function(){
if(GUI != null) {
GUI.dismiss();
GUI = null;
}
if(menu != null) {
menu.dismiss();
menu = null;
}
if(exitUI != null) {
exitUI.dismiss();
exitUI = null;
}
}}));
}
Loading

0 comments on commit e78ceb3

Please sign in to comment.