Demo add devkit button

This commit is contained in:
pengfei.zhou 2021-07-14 11:51:45 +08:00 committed by osborn
parent 47022fe715
commit 0dfe0d73be
5 changed files with 67 additions and 3 deletions

View File

@ -13,7 +13,7 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".PullableActivity"></activity> <activity android:name=".PullableActivity" />
<activity android:name=".MainActivity"> <activity android:name=".MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -21,6 +21,9 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name=".DoricDebugActivity"
android:theme="@style/Theme.Design.Light.NoActionBar" />
</application> </application>
</manifest> </manifest>

View File

@ -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);
}
}

View File

@ -118,7 +118,7 @@ public class MainActivity extends AppCompatActivity {
tv.setOnClickListener(new View.OnClickListener() { tv.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { 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("source", "assets://src/" + data[position - 1]);
intent.putExtra("alias", data[position - 1].replace(".js", "")); intent.putExtra("alias", data[position - 1].replace(".js", ""));
tv.getContext().startActivity(intent); tv.getContext().startActivity(intent);

View File

@ -7,7 +7,9 @@
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
<application> <application>
<activity android:name=".ui.DoricDevActivity" android:exported="true"/> <activity
android:name=".ui.DoricDevActivity"
android:theme="@style/Theme.Design.Light.NoActionBar" />
<activity android:name=".qrcode.activity.CaptureActivity" /> <activity android:name=".qrcode.activity.CaptureActivity" />
</application> </application>
</manifest> </manifest>

View File

@ -68,6 +68,10 @@ - (BOOL)isSimulator {
return TARGET_OS_SIMULATOR == 1; return TARGET_OS_SIMULATOR == 1;
} }
- (void)onOpenDevkit {
[[DoricDev instance] openDevMode];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) { if (indexPath.row == 0) {
[[DoricDev instance] openDevMode:self]; [[DoricDev instance] openDevMode:self];
@ -79,6 +83,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
alias:self.demoFilePaths[(NSUInteger) indexPath.row] alias:self.demoFilePaths[(NSUInteger) indexPath.row]
extra:nil 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]; [self.navigationController pushViewController:doricViewController animated:NO];
} }