Merge branch 'feature/debug' of code.aliyun.com:pengfeizhou/doric into debug/ios

This commit is contained in:
Insomnia 2019-10-31 20:28:05 +08:00
commit b9536168f2
7 changed files with 85 additions and 9 deletions

View File

@ -15,22 +15,26 @@
*/ */
package pub.doric.demo; package pub.doric.demo;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.KeyEvent;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import androidx.appcompat.app.AppCompatActivity;
import java.io.IOException;
import pub.doric.DevPanel;
import pub.doric.Doric; import pub.doric.Doric;
import pub.doric.DoricContext; import pub.doric.DoricContext;
import pub.doric.dev.LocalServer; import pub.doric.dev.LocalServer;
import pub.doric.utils.DoricUtils; import pub.doric.utils.DoricUtils;
import java.io.IOException;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private DevPanel mDevPanel = new DevPanel();
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -47,4 +51,12 @@ public class MainActivity extends AppCompatActivity {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (KeyEvent.KEYCODE_MENU == event.getKeyCode()) {
mDevPanel.show(getSupportFragmentManager(), "DevPanel");
}
return super.onKeyDown(keyCode, event);
}
} }

View File

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="com.github.penfeizhou.doricdemo.pub.doric.demo.MainActivity"> tools:context=".MainActivity">
<FrameLayout <FrameLayout
android:id="@+id/root" android:id="@+id/root"

View File

@ -49,9 +49,11 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
api 'com.github.pengfeizhou:jsc4a:0.1.0' api 'com.github.pengfeizhou:jsc4a:0.1.0'
implementation 'com.squareup.okhttp3:okhttp:4.2.1' implementation 'com.squareup.okhttp3:okhttp:4.2.1'
implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.0.1' implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.1.0'
api 'org.nanohttpd:nanohttpd:2.3.1' api 'org.nanohttpd:nanohttpd:2.3.1'
implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.code.gson:gson:2.8.6'
api "com.google.android.material:material:1.0.0"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'

View File

@ -0,0 +1,28 @@
package pub.doric;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public class DevPanel extends BottomSheetDialogFragment {
public DevPanel() {
}
@Nullable
@Override
public View onCreateView(
@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState
) {
return inflater.inflate(R.layout.layout_dev, container, false);
}
}

View File

@ -67,8 +67,8 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
private void initJSExecutor() { private void initJSExecutor() {
// mDoricJSE = new DoricNativeJSExecutor(); mDoricJSE = new DoricNativeJSExecutor();
mDoricJSE = new DoricRemoteJSExecutor(); // mDoricJSE = new DoricRemoteJSExecutor();
mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_LOG, new JavaFunction() { mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_LOG, new JavaFunction() {
@Override @Override
public JavaValue exec(JSDecoder[] args) { public JavaValue exec(JSDecoder[] args) {

View File

@ -166,7 +166,7 @@ public class RemoteJSExecutor {
webSocket.send(gson.toJson(jo)); webSocket.send(gson.toJson(jo));
LockSupport.park(Thread.currentThread()); LockSupport.park(Thread.currentThread());
return null; return temp;
} }
public void destroy() { public void destroy() {

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/menu1_text_view"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
android:text="Debug via Visual Studio Code"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#cccccc" />
<TextView
android:id="@+id/menu2_text_view"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
android:text="Enable Hot Reload"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/menu1_text_view" />
</LinearLayout>