From 0dfe0d73be638556028391f4bd1a8c6f28b1640b Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 14 Jul 2021 11:51:45 +0800 Subject: [PATCH] Demo add devkit button --- .../app/src/main/AndroidManifest.xml | 5 +- .../pub/doric/demo/DoricDebugActivity.java | 53 +++++++++++++++++++ .../java/pub/doric/demo/MainActivity.java | 2 +- .../devkit/src/main/AndroidManifest.xml | 4 +- doric-iOS/Example/Example/ViewController.m | 6 +++ 5 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 doric-android/app/src/main/java/pub/doric/demo/DoricDebugActivity.java diff --git a/doric-android/app/src/main/AndroidManifest.xml b/doric-android/app/src/main/AndroidManifest.xml index d35dadc4..ac223bc3 100644 --- a/doric-android/app/src/main/AndroidManifest.xml +++ b/doric-android/app/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + @@ -21,6 +21,9 @@ + \ No newline at end of file diff --git a/doric-android/app/src/main/java/pub/doric/demo/DoricDebugActivity.java b/doric-android/app/src/main/java/pub/doric/demo/DoricDebugActivity.java new file mode 100644 index 00000000..e08681fb --- /dev/null +++ b/doric-android/app/src/main/java/pub/doric/demo/DoricDebugActivity.java @@ -0,0 +1,53 @@ +/* + * Copyright [2019] [Doric.Pub] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package pub.doric.demo; + + +import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.Nullable; + +import pub.doric.DoricActivity; +import pub.doric.devkit.DoricDev; +import pub.doric.navbar.BaseDoricNavBar; + +/** + * @Description: pub.doric.demo + * @Author: pengfei.zhou + * @CreateDate: 2021/7/14 + */ +public class DoricDebugActivity extends DoricActivity { + @Override + protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + BaseDoricNavBar doricNavBar = findViewById(R.id.doric_nav_bar); + TextView textView = new TextView(this); + textView.setText("Devkit"); + textView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + DoricDev.getInstance().openDevMode(); + } + }); + textView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT)); + doricNavBar.setRight(textView); + } +} diff --git a/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java b/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java index 8dc1ed2a..1a69a3ce 100644 --- a/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java +++ b/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java @@ -118,7 +118,7 @@ public class MainActivity extends AppCompatActivity { tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(tv.getContext(), DoricActivity.class); + Intent intent = new Intent(tv.getContext(), DoricDebugActivity.class); intent.putExtra("source", "assets://src/" + data[position - 1]); intent.putExtra("alias", data[position - 1].replace(".js", "")); tv.getContext().startActivity(intent); diff --git a/doric-android/devkit/src/main/AndroidManifest.xml b/doric-android/devkit/src/main/AndroidManifest.xml index ccc60c70..c99562c9 100644 --- a/doric-android/devkit/src/main/AndroidManifest.xml +++ b/doric-android/devkit/src/main/AndroidManifest.xml @@ -7,7 +7,9 @@ - + diff --git a/doric-iOS/Example/Example/ViewController.m b/doric-iOS/Example/Example/ViewController.m index d50d8a87..01825e0a 100644 --- a/doric-iOS/Example/Example/ViewController.m +++ b/doric-iOS/Example/Example/ViewController.m @@ -68,6 +68,10 @@ - (BOOL)isSimulator { return TARGET_OS_SIMULATOR == 1; } +- (void)onOpenDevkit { + [[DoricDev instance] openDevMode]; +} + - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0) { [[DoricDev instance] openDevMode:self]; @@ -79,6 +83,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath alias:self.demoFilePaths[(NSUInteger) indexPath.row] extra:nil ]; + UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:@"Devkit" style:UIBarButtonItemStylePlain target:self action:@selector(onOpenDevkit)]; + doricViewController.navigationItem.rightBarButtonItem = rightBarItem; [self.navigationController pushViewController:doricViewController animated:NO]; }