forked from didi/DoKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edea679
commit bd34885
Showing
45 changed files
with
1,753 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Android/app/src/main/java/com/didichuxing/doraemondemo/BaseStatusBarActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.didichuxing.doraemondemo; | ||
|
||
import android.app.Activity; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.view.WindowManager; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
/** | ||
* didi Create on 2022/5/25 . | ||
* <p> | ||
* Copyright (c) 2022/5/25 by didiglobal.com. | ||
* | ||
* @author <a href="[email protected]">zhangjun</a> | ||
* @version 1.0 | ||
* @Date 2022/5/25 5:55 下午 | ||
* @Description 用一句话说明文件功能 | ||
*/ | ||
|
||
public class BaseStatusBarActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
preUpdateStatusBar(this); | ||
} | ||
|
||
|
||
private void preUpdateStatusBar(Activity activity) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | ||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); | ||
activity.getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimary)); | ||
} | ||
} | ||
|
||
private void setLightStatusBar() { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
getWindow().getDecorView().setSystemUiVisibility( | ||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); | ||
} | ||
} | ||
|
||
private void setNotLightStatusBar() { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
getWindow().getDecorView().setSystemUiVisibility( | ||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Android/app/src/main/java/com/didichuxing/doraemondemo/EmptyActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.didichuxing.doraemondemo | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.blankj.utilcode.util.ToastUtils | ||
import com.didichuxing.doraemondemo.db.PersonDBHelper | ||
import kotlinx.coroutines.* | ||
|
||
class EmptyActivity : AppCompatActivity() { | ||
companion object { | ||
val TAG = "EmptyActivity" | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_empty) | ||
|
||
} | ||
} |
165 changes: 165 additions & 0 deletions
165
Android/app/src/main/java/com/didichuxing/doraemondemo/MainDoKitActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
package com.didichuxing.doraemondemo | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.view.ViewGroup | ||
import androidx.core.view.children | ||
import com.didichuxing.doraemondemo.mc.MCActivity | ||
import com.didichuxing.doraemondemo.module.CrashTest | ||
import com.didichuxing.doraemondemo.module.DoKitItemView | ||
import com.didichuxing.doraemondemo.module.MethodCostTest | ||
import com.didichuxing.doraemondemo.module.bigbitmap.BigBitmapActivity | ||
import com.didichuxing.doraemondemo.module.db.DataBaseTest | ||
import com.didichuxing.doraemondemo.module.http.FileUploadTest | ||
import com.didichuxing.doraemondemo.module.http.OkHttpMock | ||
import com.didichuxing.doraemondemo.module.http.RetrofitMock | ||
import com.didichuxing.doraemondemo.module.http.URLConnectionMock | ||
import com.didichuxing.doraemondemo.module.leak.LeakActivity | ||
import com.didichuxing.doraemondemo.old.MainDebugActivityOkhttpV3 | ||
import com.didichuxing.doraemonkit.DoKit | ||
import com.didichuxing.doraemonkit.util.ToastUtils | ||
|
||
|
||
/** | ||
* didi Create on 2022/5/25 . | ||
* | ||
* Copyright (c) 2022/5/25 by didiglobal.com. | ||
* | ||
* @author <a href="[email protected]">zhangjun</a> | ||
* @version 1.0 | ||
* @Date 2022/5/25 6:05 下午 | ||
* @Description 用一句话说明文件功能 | ||
*/ | ||
|
||
class MainDoKitActivity : BaseStatusBarActivity() { | ||
|
||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_dokit_main) | ||
val all: ViewGroup = findViewById<ViewGroup>(R.id.all) | ||
|
||
all.children.forEach { | ||
if (it is DoKitItemView) { | ||
val item = it as DoKitItemView | ||
item.setOnClickListener { | ||
onItemClick(item, item.itemText) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
private fun onItemClick(itemView: DoKitItemView, text: String) { | ||
Log.i("TEST", "onItemClick :$text") | ||
when (text) { | ||
//工具入口 | ||
"显示/隐藏快捷入口" -> { | ||
showHideDoKit(); | ||
} | ||
"打开工具窗口" -> { | ||
DoKit.showToolPanel() | ||
} | ||
//平台工具 | ||
"数据Mock测试" -> { | ||
startActivity(Intent(this, EmptyActivity::class.java)) | ||
} | ||
"OkHttp 模拟请求" -> { | ||
OkHttpMock.test() | ||
} | ||
"UrlConnection 模拟请求" -> { | ||
URLConnectionMock.get("https://wanandroid.com/user_article/list/0/json") | ||
} | ||
"retrofit 模拟请求" -> { | ||
RetrofitMock.test() | ||
} | ||
"一机多控测试" -> { | ||
startActivity(Intent(this, MCActivity::class.java)) | ||
} | ||
"自动化测试" -> { | ||
startActivity(Intent(this, MCActivity::class.java)) | ||
} | ||
|
||
//常用工具 | ||
"日志测试" -> { | ||
startActivity(Intent(this, EmptyActivity::class.java)) | ||
} | ||
"跳转其他Activity" -> { | ||
startActivity(Intent(this, EmptyActivity::class.java)) | ||
} | ||
|
||
"系统:WebView" -> { | ||
startActivity(Intent(this, WebViewSystemActivity::class.java)) | ||
} | ||
"X5:WebView" -> { | ||
startActivity(Intent(this, WebViewX5Activity::class.java)) | ||
} | ||
|
||
//LBS | ||
"位置模拟" -> { | ||
startActivity(Intent(this, EmptyActivity::class.java)) | ||
} | ||
"路径模拟" -> { | ||
startActivity(Intent(this, EmptyActivity::class.java)) | ||
} | ||
|
||
//性能工具 | ||
"模拟内存泄漏" -> { | ||
startActivity(Intent(this, LeakActivity::class.java)) | ||
} | ||
|
||
"模拟耗时函数调用" -> { | ||
MethodCostTest.test() | ||
} | ||
|
||
"崩溃模拟" -> { | ||
CrashTest.test() | ||
} | ||
|
||
"创建数据库" -> { | ||
DataBaseTest.test() | ||
} | ||
"文件上传模拟" -> { | ||
FileUploadTest.requestByFile(getActivity(), filesDir, true) | ||
} | ||
"文件下载模拟" -> { | ||
FileUploadTest.requestByFile(getActivity(), filesDir, false) | ||
} | ||
"大图检测模拟" -> { | ||
startActivity(Intent(this, BigBitmapActivity::class.java)) | ||
} | ||
//视觉工具 | ||
"取色器测试" -> { | ||
startActivity(Intent(this, EmptyActivity::class.java)) | ||
} | ||
"标尺对齐测试" -> { | ||
startActivity(Intent(this, EmptyActivity::class.java)) | ||
} | ||
|
||
//其他工具 | ||
"旧版页面入口" -> { | ||
startActivity(Intent(this, MainDebugActivityOkhttpV3::class.java)) | ||
} | ||
else -> { | ||
ToastUtils.showShort("$text") | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
private fun getActivity(): Activity { | ||
return this | ||
} | ||
|
||
private fun showHideDoKit() { | ||
if (DoKit.isMainIconShow) { | ||
DoKit.hide() | ||
} else { | ||
DoKit.show() | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.