Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
416081bb
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
12 个月 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
416081bb
编写于
12月 25, 2020
作者:
[
[linjizong]
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
f76e5ba3
e58ff9ee
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
612 addition
and
11 deletion
+612
-11
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/App.kt
...va/app/src/debug/java/com/didichuxing/doraemondemo/App.kt
+7
-1
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/dokit/TestSimpleDokitFloatView.kt
...idichuxing/doraemondemo/dokit/TestSimpleDokitFloatView.kt
+53
-0
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/dokit/TestSimpleDokitFloatViewKit.kt
...chuxing/doraemondemo/dokit/TestSimpleDokitFloatViewKit.kt
+27
-0
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/dokit/TestSimpleDokitFragment.java
...dichuxing/doraemondemo/dokit/TestSimpleDokitFragment.java
+58
-0
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/dokit/TestSimpleDokitFragmentKit.kt
...ichuxing/doraemondemo/dokit/TestSimpleDokitFragmentKit.kt
+30
-0
Android/java/app/src/main/res/layout/layout_demo_custom.xml
Android/java/app/src/main/res/layout/layout_demo_custom.xml
+53
-0
Android/java/app/src/main/res/values/strings.xml
Android/java/app/src/main/res/values/strings.xml
+2
-0
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/aop/bigimg/fresco/DokitFrescoPostprocessor.java
...raemonkit/aop/bigimg/fresco/DokitFrescoPostprocessor.java
+7
-1
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/constant/BundleKey.java
.../java/com/didichuxing/doraemonkit/constant/BundleKey.java
+1
-0
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/constant/FragmentIndex.java
...a/com/didichuxing/doraemonkit/constant/FragmentIndex.java
+1
-0
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/BaseFragment.java
...va/com/didichuxing/doraemonkit/kit/core/BaseFragment.java
+7
-8
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/SimpleDokitFragment.java
...didichuxing/doraemonkit/kit/core/SimpleDokitFragment.java
+72
-0
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/SimpleDokitStarter.kt
...om/didichuxing/doraemonkit/kit/core/SimpleDokitStarter.kt
+26
-0
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/SimpleDokitView.java
...com/didichuxing/doraemonkit/kit/core/SimpleDokitView.java
+119
-0
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/UniversalActivity.kt
...com/didichuxing/doraemonkit/kit/core/UniversalActivity.kt
+4
-1
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/ViewSetupHelper.java
...com/didichuxing/doraemonkit/kit/core/ViewSetupHelper.java
+41
-0
Android/java/doraemonkit/src/main/res/drawable-xxhdpi/dk_close_25.png
.../doraemonkit/src/main/res/drawable-xxhdpi/dk_close_25.png
+0
-0
Android/java/doraemonkit/src/main/res/drawable/dk_shape_float_view_bg.xml
...aemonkit/src/main/res/drawable/dk_shape_float_view_bg.xml
+11
-0
Android/java/doraemonkit/src/main/res/layout/dk_fragment_simple_dokit_page.xml
...kit/src/main/res/layout/dk_fragment_simple_dokit_page.xml
+30
-0
Android/java/doraemonkit/src/main/res/layout/dk_layout_simple_dokit_float_view.xml
...src/main/res/layout/dk_layout_simple_dokit_float_view.xml
+63
-0
未找到文件。
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/App.kt
浏览文件 @
416081bb
...
...
@@ -4,6 +4,8 @@ import android.app.Activity
import
android.app.Application
import
android.content.Context
import
androidx.multidex.MultiDex
import
com.didichuxing.doraemondemo.dokit.TestSimpleDokitFloatViewKit
import
com.didichuxing.doraemondemo.dokit.TestSimpleDokitFragmentKit
import
com.didichuxing.doraemondemo.dokit.DemoKit
import
com.didichuxing.doraemonkit.DoraemonKit
import
com.didichuxing.doraemonkit.kit.AbstractKit
...
...
@@ -32,7 +34,11 @@ class App : Application() {
// kits.add(DemoKit())
val
mapKits
:
LinkedHashMap
<
String
,
MutableList
<
AbstractKit
>>
=
linkedMapOf
()
mapKits
[
"业务专区1"
]
=
mutableListOf
<
AbstractKit
>(
DemoKit
())
mapKits
[
"业务专区1"
]
=
mutableListOf
<
AbstractKit
>().
apply
{
add
(
DemoKit
())
add
(
TestSimpleDokitFloatViewKit
())
add
(
TestSimpleDokitFragmentKit
())
}
mapKits
[
"业务专区2"
]
=
mutableListOf
<
AbstractKit
>(
DemoKit
())
DoraemonKit
.
install
(
this
,
mapKits
=
mapKits
,
productId
=
"749a0600b5e48dd77cf8ee680be7b1b7"
)
...
...
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/dokit/TestSimpleDokitFloatView.kt
0 → 100644
浏览文件 @
416081bb
package
com.didichuxing.doraemondemo.dokit
import
android.os.Bundle
import
android.util.Log
import
android.view.View
import
android.widget.CompoundButton
import
android.widget.FrameLayout
import
com.didichuxing.doraemondemo.R
import
com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter
import
com.didichuxing.doraemonkit.kit.core.SimpleDokitView
import
com.didichuxing.doraemonkit.kit.core.ViewSetupHelper
/**
* @Author: changzuozhen
* @Date: 2020-12-22
* 切换全屏与否只需要调整继承关系即可
* @see TestSimpleDokitFragment
* @see TestSimpleDokitFloatView
*
* 悬浮窗,支持折叠
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitView
* 启动工具函数
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter.startFloating
*
* 全屏页面
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitFragment
* 启动工具函数
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter.startFullScreen(java.lang.Class<? extends com.didichuxing.doraemonkit.kit.core.SimpleDokitFragment>, android.content.Context, android.os.Bundle)
*
*/
class
TestSimpleDokitFloatView
:
SimpleDokitView
()
{
override
fun
getLayoutId
():
Int
{
return
R
.
layout
.
layout_demo_custom
}
override
fun
onViewCreated
(
rootView
:
FrameLayout
?)
{
super
.
onViewCreated
(
rootView
)
ViewSetupHelper
.
setupButton
(
rootView
,
R
.
id
.
test1
,
"TestSimpleDokitFragment"
,
View
.
OnClickListener
{
val
bundle
=
Bundle
()
bundle
.
putString
(
"test"
,
"test"
)
SimpleDokitStarter
.
startFullScreen
(
TestSimpleDokitFragment
::
class
.
java
,
context
)
})
// 隐藏
ViewSetupHelper
.
setupButton
(
rootView
,
R
.
id
.
test2
,
""
,
null
)
ViewSetupHelper
.
setupToggleButton
(
rootView
,
R
.
id
.
tb_test1
,
"TB"
,
false
,
CompoundButton
.
OnCheckedChangeListener
{
buttonView
,
isChecked
->
Log
.
d
(
"TEST"
,
"TB $isChecked"
)
})
// 隐藏
ViewSetupHelper
.
setupToggleButton
(
rootView
,
R
.
id
.
tb_test2
,
""
,
false
,
null
)
}
}
\ No newline at end of file
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/dokit/TestSimpleDokitFloatViewKit.kt
0 → 100644
浏览文件 @
416081bb
package
com.didichuxing.doraemondemo.dokit
import
android.content.Context
import
com.didichuxing.doraemondemo.R
import
com.didichuxing.doraemonkit.kit.AbstractKit
import
com.didichuxing.doraemonkit.kit.Category
import
com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter
/**
* @Author: changzuozhen
* @Date: 2020-12-22
*/
class
TestSimpleDokitFloatViewKit
:
AbstractKit
()
{
override
val
category
:
Int
get
()
=
Category
.
BIZ
override
val
name
:
Int
get
()
=
R
.
string
.
dk_kit_simple_float
override
val
icon
:
Int
get
()
=
R
.
mipmap
.
dk_sys_info
override
fun
onClick
(
context
:
Context
?)
{
SimpleDokitStarter
.
startFloating
(
TestSimpleDokitFloatView
::
class
.
java
)
}
override
fun
onAppInit
(
context
:
Context
?)
{
}
}
\ No newline at end of file
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/dokit/TestSimpleDokitFragment.java
0 → 100644
浏览文件 @
416081bb
package
com.didichuxing.doraemondemo.dokit
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.CompoundButton
;
import
androidx.annotation.NonNull
;
import
com.didichuxing.doraemondemo.R
;
import
com.didichuxing.doraemonkit.kit.core.SimpleDokitFragment
;
import
com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter
;
import
com.didichuxing.doraemonkit.kit.core.ViewSetupHelper
;
/**
* @Author: changzuozhen
* @Date: 2020-12-22
* 切换全屏与否只需要调整继承关系即可
* @see TestSimpleDokitFragment
* @see TestSimpleDokitFloatView
* <p>
* 悬浮窗,支持折叠
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitView
* 启动工具函数
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter.startFloating
* <p>
* 全屏页面
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitFragment
* 启动工具函数
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter.startFullScreen(java.lang.Class<? extends com.didichuxing.doraemonkit.kit.core.SimpleDokitFragment>, android.content.Context, android.os.Bundle)
*/
public
class
TestSimpleDokitFragment
extends
SimpleDokitFragment
{
@Override
protected
int
getLayoutId
()
{
return
R
.
layout
.
layout_demo_custom
;
}
@Override
protected
void
onViewCreated
(
@NonNull
View
rootView
)
{
super
.
onViewCreated
(
rootView
);
ViewSetupHelper
.
setupButton
(
rootView
,
R
.
id
.
test1
,
"TestSimpleDokitFragment"
,
v
->
{
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"test"
,
"test"
);
SimpleDokitStarter
.
startFullScreen
(
TestSimpleDokitFragment
.
class
,
getContext
());
});
// 隐藏
ViewSetupHelper
.
setupButton
(
rootView
,
R
.
id
.
test2
,
""
,
v
->
{
});
ViewSetupHelper
.
setupToggleButton
(
rootView
,
R
.
id
.
tb_test1
,
"TB"
,
false
,
(
CompoundButton
buttonView
,
boolean
isChecked
)
->
{
});
// 隐藏
ViewSetupHelper
.
setupToggleButton
(
rootView
,
R
.
id
.
tb_test2
,
""
,
false
,
(
CompoundButton
buttonView
,
boolean
isChecked
)
->
{
});
}
}
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/dokit/TestSimpleDokitFragmentKit.kt
0 → 100644
浏览文件 @
416081bb
package
com.didichuxing.doraemondemo.dokit
import
android.content.Context
import
android.os.Bundle
import
com.didichuxing.doraemondemo.R
import
com.didichuxing.doraemonkit.kit.AbstractKit
import
com.didichuxing.doraemonkit.kit.Category
import
com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter
/**
* @Author: changzuozhen
* @Date: 2020-12-22
*/
class
TestSimpleDokitFragmentKit
:
AbstractKit
()
{
override
val
category
:
Int
get
()
=
Category
.
BIZ
override
val
name
:
Int
get
()
=
R
.
string
.
dk_kit_fullscreen
override
val
icon
:
Int
get
()
=
R
.
mipmap
.
dk_sys_info
override
fun
onClick
(
context
:
Context
?)
{
val
bundle
=
Bundle
()
bundle
.
putString
(
"test"
,
"test"
)
SimpleDokitStarter
.
startFullScreen
(
TestSimpleDokitFragment
::
class
.
java
,
context
)
}
override
fun
onAppInit
(
context
:
Context
?)
{
}
}
\ No newline at end of file
Android/java/app/src/main/res/layout/layout_demo_custom.xml
0 → 100644
浏览文件 @
416081bb
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"20dp"
>
<LinearLayout
android:id=
"@+id/linearLayout"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:orientation=
"vertical"
>
<Button
android:id=
"@+id/test1"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:minWidth=
"1dp"
android:minHeight=
"1dp"
android:text=
"1"
android:textAllCaps=
"false"
/>
<Button
android:id=
"@+id/test2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:minWidth=
"1dp"
android:minHeight=
"1dp"
android:text=
"2"
android:textAllCaps=
"false"
/>
<ToggleButton
android:id=
"@+id/tb_test1"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<ToggleButton
android:id=
"@+id/tb_test2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<EditText
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:hint=
"测试一下键盘焦点"
/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
Android/java/app/src/main/res/values/strings.xml
浏览文件 @
416081bb
...
...
@@ -20,4 +20,6 @@
<string
name=
"app_btn_create_database"
>
创建数据库
</string>
<string
name=
"app_btn_upload_file"
>
上传文件
</string>
<string
name=
"app_btn_download_file"
>
下载文件
</string>
<string
name=
"dk_kit_simple_float"
translatable=
"false"
>
自定义悬浮
</string>
<string
name=
"dk_kit_fullscreen"
translatable=
"false"
>
自定义全屏
</string>
</resources>
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/aop/bigimg/fresco/DokitFrescoPostprocessor.java
浏览文件 @
416081bb
...
...
@@ -11,6 +11,7 @@ import com.blankj.utilcode.util.ConvertUtils;
import
com.didichuxing.doraemonkit.config.PerformanceSpInfoConfig
;
import
com.didichuxing.doraemonkit.kit.largepicture.LargePictureManager
;
import
com.facebook.cache.common.CacheKey
;
import
com.facebook.cache.common.SimpleCacheKey
;
import
com.facebook.common.references.CloseableReference
;
import
com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory
;
import
com.facebook.imagepipeline.nativecode.Bitmaps
;
...
...
@@ -33,6 +34,8 @@ public class DokitFrescoPostprocessor implements Postprocessor {
@Nullable
private
Postprocessor
mOriginalPostprocessor
;
private
Uri
mUri
;
@Nullable
private
CacheKey
mCacheKey
;
public
DokitFrescoPostprocessor
(
Uri
uri
,
Postprocessor
postprocessor
)
{
this
.
mOriginalPostprocessor
=
postprocessor
;
...
...
@@ -108,6 +111,9 @@ public class DokitFrescoPostprocessor implements Postprocessor {
if
(
mOriginalPostprocessor
!=
null
)
{
return
mOriginalPostprocessor
.
getPostprocessorCacheKey
();
}
return
null
;
if
(
mCacheKey
==
null
)
{
mCacheKey
=
new
CacheKeySimple
(
"DokitFrescoPostprocessor"
);
}
return
mCacheKey
;
}
}
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/constant/BundleKey.java
浏览文件 @
416081bb
...
...
@@ -8,6 +8,7 @@ public interface BundleKey {
String
FILE_KEY
=
"file_key"
;
String
DIR_KEY
=
"dir_key"
;
String
FRAGMENT_INDEX
=
"fragment_index"
;
String
CUSTOM_FRAGMENT_CLASS
=
"custom_fragment_class"
;
String
ACCESSIBILITY_DATA
=
"accessibility_data"
;
String
PERFORMANCE_TYPE
=
"performance_type"
;
String
KEY_URL
=
"key_url"
;
...
...
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/constant/FragmentIndex.java
浏览文件 @
416081bb
...
...
@@ -82,4 +82,5 @@ public interface FragmentIndex {
* Dokit 三方库信息
*/
int
FRAGMENT_THIRD_LIBRARY_INFO
=
33
;
int
FRAGMENT_SIMPLE_CUSTOM
=
101
;
}
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/BaseFragment.java
浏览文件 @
416081bb
...
...
@@ -2,6 +2,11 @@ package com.didichuxing.doraemonkit.kit.core;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Toast
;
import
androidx.annotation.IdRes
;
import
androidx.annotation.LayoutRes
;
...
...
@@ -10,16 +15,10 @@ import androidx.annotation.Nullable;
import
androidx.annotation.StringRes
;
import
androidx.fragment.app.Fragment
;
import
android.view.LayoutInflater
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Toast
;
import
com.didichuxing.doraemonkit.kit.main.MainIconDokitView
;
import
com.didichuxing.doraemonkit.widget.dialog.DialogProvider
;
import
com.didichuxing.doraemonkit.widget.dialog.CommonDialogProvider
;
import
com.didichuxing.doraemonkit.widget.dialog.DialogInfo
;
import
com.didichuxing.doraemonkit.widget.dialog.DialogProvider
;
import
com.didichuxing.doraemonkit.widget.dialog.UniversalDialogFragment
;
/**
...
...
@@ -44,7 +43,7 @@ public abstract class BaseFragment extends Fragment {
@Nullable
@Override
final
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
int
id
=
onRequestLayout
();
if
(
id
>
0
)
{
...
...
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/SimpleDokitFragment.java
0 → 100644
浏览文件 @
416081bb
package
com.didichuxing.doraemonkit.kit.core
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.FrameLayout
;
import
androidx.annotation.LayoutRes
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
com.didichuxing.doraemonkit.R
;
import
com.didichuxing.doraemonkit.widget.titlebar.HomeTitleBar
;
/**
* @Author: changzuozhen
* @Date: 2020-12-22
* <p>
* 全屏页面
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitFragment
* 启动工具函数
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter.startFullScreen(java.lang.Class<? extends com.didichuxing.doraemonkit.kit.core.SimpleDokitFragment>, android.content.Context, android.os.Bundle)
*/
public
abstract
class
SimpleDokitFragment
extends
BaseFragment
{
private
static
final
String
TAG
=
"SimpleFragment"
;
public
Bundle
getBundle
()
{
if
(
getActivity
()
==
null
||
getActivity
().
getIntent
()
==
null
||
getActivity
().
getIntent
().
getExtras
()
==
null
)
{
return
null
;
}
return
getActivity
().
getIntent
().
getExtras
();
}
@Nullable
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
rootView
=
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
inflater
.
inflate
(
getLayoutId
(),
(
FrameLayout
)
rootView
.
findViewById
(
R
.
id
.
contentContainer
),
true
);
return
rootView
;
}
@Override
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
initView
();
onViewCreated
(
view
);
}
@Override
protected
int
onRequestLayout
()
{
return
R
.
layout
.
dk_fragment_simple_dokit_page
;
}
protected
void
onViewCreated
(
View
view
)
{
}
abstract
protected
@LayoutRes
int
getLayoutId
();
private
void
initView
()
{
HomeTitleBar
homeTitleBar
=
findViewById
(
R
.
id
.
title_bar
);
homeTitleBar
.
setTitle
(
this
.
getClass
().
getSimpleName
());
homeTitleBar
.
setListener
(
new
HomeTitleBar
.
OnTitleBarClickListener
()
{
@Override
public
void
onRightClick
()
{
getActivity
().
finish
();
}
});
}
}
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/SimpleDokitStarter.kt
0 → 100644
浏览文件 @
416081bb
package
com.didichuxing.doraemonkit.kit.core
import
android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
com.didichuxing.doraemonkit.DoraemonKit
import
com.didichuxing.doraemonkit.constant.BundleKey
import
com.didichuxing.doraemonkit.constant.FragmentIndex
object
SimpleDokitStarter
{
fun
startFloating
(
targetClass
:
Class
<
out
AbsDokitView
?
>?)
=
DokitViewManager
.
getInstance
().
attach
(
DokitIntent
(
targetClass
))
@JvmStatic
@JvmOverloads
fun
startFullScreen
(
targetClass
:
Class
<
out
SimpleDokitFragment
?
>,
context
:
Context
?,
bundle
:
Bundle
?
=
null
)
{
val
ctx
=
context
?:
DoraemonKit
.
APPLICATION
!!
.
applicationContext
ctx
.
startActivity
(
Intent
(
ctx
,
UniversalActivity
::
class
.
java
).
apply
{
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
putExtra
(
BundleKey
.
FRAGMENT_INDEX
,
FragmentIndex
.
FRAGMENT_SIMPLE_CUSTOM
)
putExtra
(
BundleKey
.
CUSTOM_FRAGMENT_CLASS
,
targetClass
)
if
(
bundle
!=
null
)
{
putExtras
(
bundle
)
}
})
}
}
\ No newline at end of file
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/SimpleDokitView.java
0 → 100644
浏览文件 @
416081bb
package
com.didichuxing.doraemonkit.kit.core
;
import
android.content.Context
;
import
android.util.DisplayMetrics
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.CompoundButton
;
import
android.widget.FrameLayout
;
import
android.widget.ImageButton
;
import
android.widget.Switch
;
import
android.widget.TextView
;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
com.didichuxing.doraemonkit.R
;
import
com.didichuxing.doraemonkit.widget.tableview.utils.DensityUtils
;
/**
* @Author: changzuozhen
* @Date: 2020-12-22
* <p>
* 悬浮窗,支持折叠
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitView
* 启动工具函数
* @see com.didichuxing.doraemonkit.kit.core.SimpleDokitStarter.startFloating
*/
public
abstract
class
SimpleDokitView
extends
AbsDokitView
{
private
static
final
String
TAG
=
"SimpleBaseFloatPage"
;
int
mWidth
;
int
mHeight
;
int
mDp50InPx
;
private
WindowManager
mWindowManager
;
private
FrameLayout
mFloatContainer
;
private
Switch
mShowSwitch
;
@Override
public
void
onEnterForeground
()
{
super
.
onEnterForeground
();
getRootView
().
setVisibility
(
View
.
VISIBLE
);
}
@Override
public
void
onEnterBackground
()
{
super
.
onEnterBackground
();
getRootView
().
setVisibility
(
View
.
GONE
);
}
public
void
showContainer
(
boolean
isChecked
)
{
mFloatContainer
.
setVisibility
(
isChecked
?
View
.
VISIBLE
:
View
.
GONE
);
}
@Override
public
void
onCreate
(
Context
context
)
{
mWindowManager
=
(
WindowManager
)
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
);
DisplayMetrics
outMetrics
=
new
DisplayMetrics
();
mWindowManager
.
getDefaultDisplay
().
getMetrics
(
outMetrics
);
mDp50InPx
=
DensityUtils
.
dp2px
(
context
,
50
);
mWidth
=
outMetrics
.
widthPixels
-
mDp50InPx
;
mHeight
=
outMetrics
.
heightPixels
-
mDp50InPx
;
}
@Override
public
View
onCreateView
(
Context
context
,
FrameLayout
rootView
)
{
ConstraintLayout
root
=
(
ConstraintLayout
)
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
dk_layout_simple_dokit_float_view
,
rootView
,
false
);
mFloatContainer
=
root
.
findViewById
(
R
.
id
.
floatContainer
);
mShowSwitch
=
root
.
findViewById
(
R
.
id
.
showHideSwitch
);
TextView
title
=
root
.
findViewById
(
R
.
id
.
floatPageTitle
);
ImageButton
close
=
root
.
findViewById
(
R
.
id
.
floatClose
);
close
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
DokitViewManager
.
getInstance
().
detach
(
SimpleDokitView
.
this
);
}
});
title
.
setText
(
getTag
());
mShowSwitch
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
buttonView
,
boolean
isChecked
)
{
showContainer
(
isChecked
);
}
});
LayoutInflater
.
from
(
context
).
inflate
(
getLayoutId
(),
mFloatContainer
);
return
root
;
}
@Override
public
void
onViewCreated
(
FrameLayout
rootView
)
{
initView
();
}
protected
abstract
int
getLayoutId
();
@Override
public
void
initDokitViewLayoutParams
(
DokitViewLayoutParams
params
)
{
params
.
width
=
DokitViewLayoutParams
.
WRAP_CONTENT
;
params
.
height
=
DokitViewLayoutParams
.
WRAP_CONTENT
;
params
.
gravity
=
Gravity
.
TOP
|
Gravity
.
LEFT
;
params
.
x
=
200
;
params
.
y
=
200
;
}
@Override
public
boolean
onBackPressed
()
{
mShowSwitch
.
setChecked
(
false
);
return
super
.
onBackPressed
();
}
@Override
public
boolean
shouldDealBackKey
()
{
return
true
;
}
private
void
initView
()
{
}
}
\ No newline at end of file
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/UniversalActivity.kt
浏览文件 @
416081bb
...
...
@@ -15,7 +15,6 @@ import com.didichuxing.doraemonkit.kit.gpsmock.GpsMockFragment
import
com.didichuxing.doraemonkit.kit.health.HealthFragment
import
com.didichuxing.doraemonkit.kit.largepicture.LargePictureFragment
import
com.didichuxing.doraemonkit.kit.loginfo.LogInfoSettingFragment
import
com.didichuxing.doraemonkit.kit.webview.CommWebViewFragment
import
com.didichuxing.doraemonkit.kit.network.ui.MockTemplatePreviewFragment
import
com.didichuxing.doraemonkit.kit.network.ui.NetWorkMockFragment
import
com.didichuxing.doraemonkit.kit.network.ui.NetWorkMonitorFragment
...
...
@@ -31,6 +30,7 @@ import com.didichuxing.doraemonkit.kit.toolpanel.DokitMoreFragment
import
com.didichuxing.doraemonkit.kit.weaknetwork.WeakNetworkFragment
import
com.didichuxing.doraemonkit.kit.webdoor.WebDoorDefaultFragment
import
com.didichuxing.doraemonkit.kit.webdoor.WebDoorFragment
import
com.didichuxing.doraemonkit.kit.webview.CommWebViewFragment
/**
* Created by wanglikun on 2018/10/26.
...
...
@@ -79,6 +79,9 @@ open class UniversalActivity : BaseActivity() {
FragmentIndex
.
FRAGMENT_APP_START
->
fragmentClass
=
AppStartInfoFragment
::
class
.
java
FragmentIndex
.
FRAGMENT_DOKIT_MORE
->
fragmentClass
=
DokitMoreFragment
::
class
.
java
FragmentIndex
.
FRAGMENT_DOKIT_MANAGER
->
fragmentClass
=
DokitManagerFragment
::
class
.
java
FragmentIndex
.
FRAGMENT_SIMPLE_CUSTOM
->
if
(
bundle
[
BundleKey
.
CUSTOM_FRAGMENT_CLASS
]
!=
null
)
{
fragmentClass
=
bundle
[
BundleKey
.
CUSTOM_FRAGMENT_CLASS
]
as
Class
<
out
BaseFragment
?
>?
}
else
->
{
}
}
...
...
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/core/ViewSetupHelper.java
0 → 100644
浏览文件 @
416081bb
package
com.didichuxing.doraemonkit.kit.core
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.widget.CompoundButton
;
import
android.widget.TextView
;
import
android.widget.ToggleButton
;
public
final
class
ViewSetupHelper
{
private
ViewSetupHelper
()
{
}
public
static
void
setupButton
(
View
container
,
int
viewId
,
String
title
,
View
.
OnClickListener
onBtnClick
)
{
TextView
button
=
(
TextView
)
container
.
findViewById
(
viewId
);
if
(
TextUtils
.
isEmpty
(
title
))
{
button
.
setVisibility
(
View
.
GONE
);
}
else
{
button
.
setText
(
title
);
button
.
setVisibility
(
View
.
VISIBLE
);
button
.
setOnClickListener
(
onBtnClick
);
}
}
public
static
void
setVisible
(
View
container
,
int
viewId
,
boolean
visible
)
{
container
.
findViewById
(
viewId
).
setVisibility
(
visible
?
View
.
VISIBLE
:
View
.
GONE
);
}
public
static
void
setupToggleButton
(
View
container
,
int
viewId
,
String
title
,
boolean
checked
,
CompoundButton
.
OnCheckedChangeListener
onCheckedChangeListener
)
{
ToggleButton
toggleButton
=
(
ToggleButton
)
container
.
findViewById
(
viewId
);
if
(
TextUtils
.
isEmpty
(
title
))
{
toggleButton
.
setVisibility
(
View
.
GONE
);
}
else
{
toggleButton
.
setVisibility
(
View
.
VISIBLE
);
toggleButton
.
setTextOn
(
title
+
" ON"
);
toggleButton
.
setTextOff
(
title
+
" OFF"
);
toggleButton
.
setChecked
(
checked
);
toggleButton
.
setOnCheckedChangeListener
(
onCheckedChangeListener
);
onCheckedChangeListener
.
onCheckedChanged
(
toggleButton
,
checked
);
}
}
}
Android/java/doraemonkit/src/main/res/drawable-xxhdpi/dk_close_25.png
0 → 100644
浏览文件 @
416081bb
745 字节
Android/java/doraemonkit/src/main/res/drawable/dk_shape_float_view_bg.xml
0 → 100644
浏览文件 @
416081bb
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"#AAEEEEEE"
/>
<corners
android:radius=
"5dp"
/>
<padding
android:bottom=
"1px"
android:left=
"1px"
android:right=
"1px"
android:top=
"1px"
/>
</shape>
Android/java/doraemonkit/src/main/res/layout/dk_fragment_simple_dokit_page.xml
0 → 100644
浏览文件 @
416081bb
<?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"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/dk_color_FFFFFF"
android:orientation=
"vertical"
>
<com.didichuxing.doraemonkit.widget.titlebar.HomeTitleBar
android:id=
"@+id/title_bar"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:dkIcon=
"@mipmap/dk_close_icon_big"
app:dkTitle=
""
/>
<FrameLayout
android:id=
"@+id/contentContainer"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#00FFFFFF"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/title_bar"
tools:background=
"#3900FFFF"
>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
Android/java/doraemonkit/src/main/res/layout/dk_layout_simple_dokit_float_view.xml
0 → 100644
浏览文件 @
416081bb
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/dk_shape_float_view_bg"
android:clipChildren=
"false"
android:minWidth=
"50dp"
android:minHeight=
"50dp"
>
<ImageButton
android:id=
"@+id/floatClose"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"5dp"
android:layout_marginLeft=
"5dp"
android:background=
"@drawable/dk_close_25"
app:layout_constraintBottom_toBottomOf=
"@+id/showHideSwitch"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/showHideSwitch"
/>
<Switch
android:id=
"@+id/showHideSwitch"
android:layout_width=
"40dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"15dp"
android:layout_marginLeft=
"15dp"
android:layout_marginEnd=
"5dp"
android:layout_marginRight=
"5dp"
android:checked=
"true"
android:minHeight=
"5dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0"
app:layout_constraintStart_toEndOf=
"@id/floatClose"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/floatPageTitle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"#ff000000"
android:textSize=
"10sp"
android:textStyle=
"bold"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0"
app:layout_constraintStart_toStartOf=
"@id/floatClose"
app:layout_constraintTop_toBottomOf=
"@id/floatClose"
tools:text=
"title"
/>
<FrameLayout
android:id=
"@+id/floatContainer"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"#00FFFFFF"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/floatPageTitle"
tools:layout_width=
"200dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录