Skip to content

Commit

Permalink
Merge pull request #2 from didi/master
Browse files Browse the repository at this point in the history
拉取更新代码
  • Loading branch information
HuginChen authored Apr 23, 2019
2 parents 46a5947 + d207092 commit 9c45afb
Show file tree
Hide file tree
Showing 499 changed files with 17,220 additions and 2,789 deletions.
11 changes: 11 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Please complete the following informations.
> Expected behavior and actual behavior.
> Steps to reproduce the problem.
> Android or iOS? OS version? Brand?
> More informations such as error messages and stack traces are welcomed.
请补充如下信息。
> 期望的表现和实际的表现。(如有)
> 问题重现的步骤。(如有)
> Android 还是 iOS?系统版本是多少?手机品牌是什么?(如有)
> 其他的错误信息和堆栈信息如果有也可以一并提供出来。(如有)
3 changes: 1 addition & 2 deletions Android/adb/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.didichuxing.doraemonkit.adb" />
<manifest package="com.didichuxing.doraemonkit.adb" />
6 changes: 6 additions & 0 deletions Android/adb/upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
echo -n "please enter bintray userid ->"
read userid_bintray
echo -n "please enter bintray apikey ->"
read apikey_bintray
../gradlew clean build bintrayUpload -PbintrayUser=${userid_bintray} -PbintrayKey=${apikey_bintray} -PdryRun=false
2 changes: 1 addition & 1 deletion Android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'com.doraemon.compiler.plugin'
apply from: 'doraemonkit.gradle'

android {
compileSdkVersion 26
Expand Down
18 changes: 18 additions & 0 deletions Android/app/doraemonkit.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ext {
// 很多app都会有自己的打包开关,来区分线上包和测试包,可以通过给applyPlugin赋值来区分测试包和线上包
// 线上包不会接入DoraemonKit,测试包会自动接入
applyPlugin = true
}
if (applyPlugin) {
// 引用插件,插件会在编译期把DoraemonKit.install方法插入Application中,前提是用户必须实现自己的Application
apply plugin: 'com.doraemon.compiler.plugin'
// 这里引用正常库
dependencies {
implementation project(":doraemonkit")
}
} else {
// 引用no-op的库
dependencies {
implementation project(":doraemonkit-no-op")
}
}
9 changes: 5 additions & 4 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/dk_app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:icon="@mipmap/dk_app_icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/dk_app_icon"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
Expand All @@ -20,6 +20,7 @@
</activity>

<activity android:name=".WebViewActivity"/>
<activity android:name=".TestActivity"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.didichuxing.doraemondemo;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.os.StrictMode;

Expand All @@ -13,13 +14,14 @@

public class App extends Application {
private static final String TAG = "App";

@Override
public void onCreate() {
super.onCreate();
DoraemonKit.install(this);
DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() {
@Override
public void overrideUrlLoading(String url) {
public void overrideUrlLoading(Context context, String url) {
Intent intent = new Intent(App.this, WebViewActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(WebViewActivity.KEY_URL, url);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package com.didichuxing.doraemondemo;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.didichuxing.doraemonkit.DoraemonKit;
import com.didichuxing.doraemonkit.kit.network.NetworkManager;
import com.didichuxing.doraemonkit.kit.network.common.CommonHeaders;
import com.didichuxing.doraemonkit.kit.network.common.CommonInspectorRequest;
import com.didichuxing.doraemonkit.kit.network.common.CommonInspectorResponse;
import com.didichuxing.doraemonkit.kit.network.common.NetworkPrinterHelper;
import com.didichuxing.doraemonkit.kit.timecounter.TimeCounterManager;
import com.didichuxing.doraemonkit.ui.realtime.RealTimeChartPage;
import com.didichuxing.doraemonkit.ui.realtime.datasource.DataSourceFactory;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand All @@ -26,27 +33,76 @@

public class MainActivity extends AppCompatActivity implements View.OnClickListener {


private OkHttpClient okHttpClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btn_test_urlconnection).setOnClickListener(this);
findViewById(R.id.btn_test_okhttp).setOnClickListener(this);
findViewById(R.id.btn_test_custom).setOnClickListener(this);
findViewById(R.id.btn_test_crash).setOnClickListener(this);
findViewById(R.id.btn_show_hide_icon).setOnClickListener(this);
findViewById(R.id.btn_time_count).setOnClickListener(this);
okHttpClient = new OkHttpClient().newBuilder().build();
}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_test_urlconnection:
requestByPost("http://apis.baidu.com/txapi/weixin/wxhot?num=10&page=1&word=%E7%9B%97%E5%A2%93%E7%AC%94%E8%AE%B0");
if (!NetworkManager.isActive()) {
String title = getString(com.didichuxing.doraemonkit.R.string.dk_kit_network_monitor);
int type = DataSourceFactory.TYPE_NETWORK;
NetworkManager.get().startMonitor();
RealTimeChartPage.openChartPage(title, type, RealTimeChartPage.DEFAULT_REFRESH_INTERVAL, null);
Toast.makeText(this, "click again", Toast.LENGTH_SHORT).show();
return;
}
requestByGet("http://apis.baidu.com/txapi/weixin/wxhot?num=10&page=1&word=%E7%9B%97%E5%A2%93%E7%AC%94%E8%AE%B0");
break;
case R.id.btn_test_okhttp:
if (!NetworkManager.isActive()) {
String title = getString(com.didichuxing.doraemonkit.R.string.dk_kit_network_monitor);
int type = DataSourceFactory.TYPE_NETWORK;
NetworkManager.get().startMonitor();
RealTimeChartPage.openChartPage(title, type, RealTimeChartPage.DEFAULT_REFRESH_INTERVAL, null);
Toast.makeText(this, "click again", Toast.LENGTH_SHORT).show();
return;
}
requestByOkHttp();
break;
case R.id.btn_test_custom:
if (!NetworkManager.isActive()) {
String title = getString(com.didichuxing.doraemonkit.R.string.dk_kit_network_monitor);
int type = DataSourceFactory.TYPE_NETWORK;
NetworkManager.get().startMonitor();
RealTimeChartPage.openChartPage(title, type, RealTimeChartPage.DEFAULT_REFRESH_INTERVAL, null);
Toast.makeText(this, "click again", Toast.LENGTH_SHORT).show();
return;
}
requestByCustom("http://apis.baidu.com/txapi/weixin/wxhot?num=10&page=1&word=%E7%9B%97%E5%A2%93%E7%AC%94%E8%AE%B0");
break;
case R.id.btn_test_crash:
testCrash().length();
break;
case R.id.btn_time_count:
// no-op版本未提供该方法,这里只是方便测试
if (!TimeCounterManager.get().isRunning()) {
TimeCounterManager.get().start();
Toast.makeText(this, "click again", Toast.LENGTH_SHORT).show();
return;
}
startActivity(new Intent(this, TestActivity.class));
break;
case R.id.btn_show_hide_icon:
if (DoraemonKit.isShow()) {
DoraemonKit.hide();
} else {
DoraemonKit.show();
}
break;
default:
break;
}
Expand Down Expand Up @@ -124,10 +180,9 @@ public void run() {
}

public void requestByOkHttp() {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder().get().url("http://www.roundsapp.com/post")
.addHeader("testHead", "hahahah").build();
Call call = client.newCall(request);
Call call = okHttpClient.newCall(request);
//异步调用并设置回调函数
call.enqueue(new Callback() {
@Override
Expand All @@ -149,7 +204,7 @@ public void onResponse(Call call, Response response) throws IOException {
* {@link NetworkPrinterHelper#updateResponse(CommonInspectorResponse)}
* {@link NetworkPrinterHelper#updateResponseBody(int, String)}
*/
public void request(String url) {
public void requestByCustom(String url) {
// obtain id for this request
final int id = NetworkPrinterHelper.obtainRequestId();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.didichuxing.doraemondemo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

/**
* @desc:
*/
public class TestActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
35 changes: 27 additions & 8 deletions Android/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.didichuxing.doraemondemo.MainActivity">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.didichuxing.doraemondemo.MainActivity">

<Button
android:id="@+id/btn_test_urlconnection"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="HttpUrlConnection Test" />
android:text="HttpUrlConnection Test"/>

<Button
android:id="@+id/btn_test_okhttp"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="OkHttp Test" />
android:text="OkHttp Test"/>

<Button
android:id="@+id/btn_test_custom"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="其他网络库 Test"/>

<Button
android:id="@+id/btn_show_hide_icon"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="显示/隐藏入口"/>

<Button
android:id="@+id/btn_time_count"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="页面跳转耗时"/>

<Button
android:id="@+id/btn_test_crash"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Crash Test" />
android:text="模拟 Crash"/>


</LinearLayout>
5 changes: 0 additions & 5 deletions Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

This file was deleted.

This file was deleted.

Binary file removed Android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file not shown.
Binary file not shown.
Binary file removed Android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
1 change: 1 addition & 0 deletions Android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<resources>
<string name="app_name">DoraemonDemo</string>
</resources>
7 changes: 4 additions & 3 deletions Android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.novoda:bintray-release:0.9'
classpath 'com.didichuxing.doraemonkit:compiler:1.0.0'
classpath 'com.didichuxing.doraemonkit:compiler:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -27,3 +27,4 @@ task clean(type: Delete) {
}

tasks.getByPath(":doraemonkit:javadocRelease").enabled = false
tasks.getByPath(":doraemonkit-no-op:javadocRelease").enabled = false
2 changes: 1 addition & 1 deletion Android/compiler-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_1_7
dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:3.2.1'
compile 'com.android.tools.build:gradle:3.0.1'
compile 'org.aspectj:aspectjtools:1.8.6'
compile 'org.aspectj:aspectjrt:1.8.6'
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ class DoraemonPlugin implements Plugin<Project> {
} else {
variants = project.android.libraryVariants
}

project.dependencies {
// TODO this should come transitively
debugCompile 'org.aspectj:aspectjrt:1.8.6'
implementation 'org.aspectj:aspectjrt:1.8.6'
}

variants.all { variant ->
Expand All @@ -44,24 +42,24 @@ class DoraemonPlugin implements Plugin<Project> {
]
log.debug "ajc args: " + Arrays.toString(args)

MessageHandler handler = new MessageHandler(true);
new Main().run(args, handler);
MessageHandler handler = new MessageHandler(true)
new Main().run(args, handler)
for (IMessage message : handler.getMessages(null, true)) {
switch (message.getKind()) {
case IMessage.ABORT:
case IMessage.ERROR:
case IMessage.FAIL:
log.error message.message, message.thrown
break;
break
case IMessage.WARNING:
log.warn message.message, message.thrown
break;
break
case IMessage.INFO:
log.info message.message, message.thrown
break;
break
case IMessage.DEBUG:
log.debug message.message, message.thrown
break;
break
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Android/compiler-plugin/upload.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.novoda.bintray-release'
publish {
def groupProjectID = 'com.didichuxing.doraemonkit'
def artifactProjectID = 'compiler'
def publishVersionID = '1.0.0'
def publishVersionID = '1.0.1'

userOrg = 'doraemonkit'
repoName = 'DoraemonKit'
Expand Down
Loading

0 comments on commit 9c45afb

Please sign in to comment.