Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MobileManager
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wang Xu
MobileManager
Commits
616ba36e
Commit
616ba36e
authored
Apr 09, 2020
by
Baoxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: 本地完成应用使用情况界面(暂时屏蔽)
parent
30b6389c
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
566 additions
and
107 deletions
+566
-107
AndroidManifest.xml
Launcher3/AndroidManifest.xml
+2
-1
ic_expand_less_24dp.xml
Launcher3/res/drawable/ic_expand_less_24dp.xml
+5
-0
ic_expand_more.xml
Launcher3/res/drawable/ic_expand_more.xml
+5
-0
activity_use_app.xml
Launcher3/res/layout/activity_use_app.xml
+26
-36
item_app_list.xml
Launcher3/res/layout/item_app_list.xml
+145
-0
strings.xml
Launcher3/res/values/strings.xml
+4
-3
BaseContainerView.java
Launcher3/src/com/android/launcher3/BaseContainerView.java
+1
-0
TreeAdapter.java
...c/com/android/launcher3/function/adapter/TreeAdapter.java
+175
-0
TreeStateChangeListener.java
...d/launcher3/function/adapter/TreeStateChangeListener.java
+9
-0
AppUseActivity.kt
.../com/android/launcher3/function/setting/AppUseActivity.kt
+119
-51
DialogUIUtils.java
...a/com/secspace/lib/common/dialog/other/DialogUIUtils.java
+1
-0
WorkManager.kt
...main/java/com/secspace/lib/common/function/WorkManager.kt
+2
-1
UseAppListEntity.kt
...m/secspace/lib/common/function/entity/UseAppListEntity.kt
+16
-0
AppUseProgress.java
...com/secspace/lib/common/function/view/AppUseProgress.java
+9
-0
UseTimeProgress.java
...om/secspace/lib/common/function/view/UseTimeProgress.java
+20
-15
Utils.kt
...mmon/src/main/java/com/secspace/lib/common/utils/Utils.kt
+27
-0
No files found.
Launcher3/AndroidManifest.xml
View file @
616ba36e
...
@@ -109,7 +109,8 @@
...
@@ -109,7 +109,8 @@
<activity
<activity
android:name=
".function.setting.AppUseActivity"
android:name=
".function.setting.AppUseActivity"
android:excludeFromRecents=
"true"
android:excludeFromRecents=
"true"
android:theme=
"@style/SettingTheme"
></activity>
android:theme=
"@style/SettingTheme"
android:configChanges=
"orientation|keyboardHidden"
></activity>
<activity
<activity
android:name=
".ManagerAuthActivity"
android:name=
".ManagerAuthActivity"
...
...
Launcher3/res/drawable/ic_expand_less_24dp.xml
0 → 100644
View file @
616ba36e
<vector
android:height=
"24dp"
android:tint=
"#E5E5E5"
android:viewportHeight=
"24.0"
android:viewportWidth=
"24.0"
android:width=
"24dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillColor=
"#FF000000"
android:pathData=
"M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"
/>
</vector>
Launcher3/res/drawable/ic_expand_more.xml
0 → 100644
View file @
616ba36e
<vector
android:height=
"24dp"
android:tint=
"#E5E5E5"
android:viewportHeight=
"24.0"
android:viewportWidth=
"24.0"
android:width=
"24dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillColor=
"#FF000000"
android:pathData=
"M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"
/>
</vector>
Launcher3/res/layout/activity_use_app.xml
View file @
616ba36e
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
android:id=
"@+id/tv_setting_title"
android:id=
"@+id/tv_setting_title"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:layout_height=
"48dp"
android:background=
"#F
FF2F2F2
"
android:background=
"#F
6F6F6
"
android:drawableStart=
"@mipmap/ic_back"
android:drawableStart=
"@mipmap/ic_back"
android:drawablePadding=
"10dp"
android:drawablePadding=
"10dp"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
...
@@ -22,6 +22,11 @@
...
@@ -22,6 +22,11 @@
android:textColor=
"#363636"
android:textColor=
"#363636"
android:textSize=
"16sp"
/>
android:textSize=
"16sp"
/>
<android.support.v4.widget.NestedScrollView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:scrollbars=
"none"
>
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
...
@@ -41,7 +46,6 @@
...
@@ -41,7 +46,6 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"48dp"
android:layout_height=
"48dp"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:onClick=
"close"
android:textColor=
"#363636"
android:textColor=
"#363636"
android:textSize=
"16sp"
/>
android:textSize=
"16sp"
/>
...
@@ -52,19 +56,21 @@
...
@@ -52,19 +56,21 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"10dp"
android:layout_marginLeft=
"10dp"
android:layout_marginBottom
=
"10dp"
android:layout_marginRight
=
"10dp"
android:layout_marginRight=
"10
dp"
/>
android:layout_marginBottom=
"6
dp"
/>
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:layout_height=
"40dp"
android:layout_margin=
"10dp"
android:layout_marginLeft=
"10dp"
android:layout_marginTop=
"6dp"
android:layout_marginRight=
"10dp"
android:background=
"@drawable/select_date_select"
android:background=
"@drawable/select_date_select"
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
>
<TextView
<TextView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"48dp
"
android:layout_height=
"match_parent
"
android:drawablePadding=
"10dp"
android:drawablePadding=
"10dp"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:paddingLeft=
"16dp"
android:paddingLeft=
"16dp"
...
@@ -82,7 +88,7 @@
...
@@ -82,7 +88,7 @@
<TextView
<TextView
android:id=
"@+id/tv_date_start"
android:id=
"@+id/tv_date_start"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"48dp
"
android:layout_height=
"match_parent
"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:gravity=
"center"
android:gravity=
"center"
android:text=
"开始时间"
android:text=
"开始时间"
...
@@ -100,7 +106,7 @@
...
@@ -100,7 +106,7 @@
<TextView
<TextView
android:id=
"@+id/tv_date_end"
android:id=
"@+id/tv_date_end"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"48dp
"
android:layout_height=
"match_parent
"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:gravity=
"center"
android:gravity=
"center"
android:text=
"结束时间"
android:text=
"结束时间"
...
@@ -108,46 +114,30 @@
...
@@ -108,46 +114,30 @@
android:textSize=
"15sp"
/>
android:textSize=
"15sp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:layout_marginLeft=
"10dp"
android:layout_marginRight=
"10dp"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
>
<TextView
<TextView
android:id=
"@+id/tv_app_use_total_time"
android:id=
"@+id/tv_app_use_total_time"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"48dp"
android:layout_height=
"40dp"
android:layout_gravity=
"center_vertical"
android:layout_marginLeft=
"10dp"
android:layout_marginRight=
"10dp"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:onClick=
"close"
android:textColor=
"#363636"
android:textColor=
"#363636"
android:textSize=
"16sp"
/>
android:textSize=
"16sp"
/>
<com.qmuiteam.qmui.widget.QMUIEmptyView
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"48dp"
android:onClick=
"more"
android:drawableEnd=
"@drawable/ic_chevron_right_gray_24dp"
android:gravity=
"center_vertical"
android:text=
"@string/edu_item_app_use_more"
android:textColor=
"#ABABAB"
android:textSize=
"15sp"
/>
</LinearLayout>
<com.secspace.lib.common.function.view.UseTimeProgress
<com.secspace.lib.common.function.view.UseTimeProgress
android:id=
"@+id/use_time_progress"
android:id=
"@+id/use_time_progress"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"10dp"
android:layout_marginLeft=
"10dp"
android:layout_marginRight=
"10dp"
/>
android:layout_marginRight=
"10dp"
/>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/rv_tree"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:visibility=
"visible"
/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
Launcher3/res/layout/item_app_list.xml
0 → 100644
View file @
616ba36e
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"35dp"
android:background=
"@color/bg_white"
>
<LinearLayout
android:id=
"@+id/item_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"horizontal"
>
<ImageView
android:id=
"@+id/item_icon"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"10dp"
tools:src=
"@mipmap/ic_launcher_home"
/>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
android:gravity=
"bottom"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/item_tv_app_name"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:textColor=
"#363636"
android:text=
"微信"
android:textSize=
"14sp"
/>
<TextView
android:id=
"@+id/item_tv_app_count"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:textColor=
"#363636"
android:text=
"(21次)"
android:textSize=
"14sp"
/>
<Space
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
<TextView
android:id=
"@+id/item_tv_app_time"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:textColor=
"#363636"
android:text=
"20分钟"
android:textSize=
"14sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:layout_weight=
"1"
>
<com.secspace.lib.common.function.view.UseTimeProgress
android:id=
"@+id/item_use_time_progress"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:layout_gravity=
"center"
android:layout_marginTop=
"5dp"
/>
</LinearLayout>
</LinearLayout>
<ImageView
android:id=
"@+id/item_indicator"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"10dp"
tools:src=
"@mipmap/ic_launcher_home"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/item_child"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"horizontal"
>
<Space
android:layout_width=
"35dp"
android:layout_height=
"35dp"
/>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/item_tv_app_details_start"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"match_parent"
android:gravity=
"center"
android:textColor=
"#ACACAC"
android:text=
"2020-04-07 17:33"
android:textSize=
"14sp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:textColor=
"#ACACAC"
android:layout_margin=
"10dp"
android:text=
"-"
android:textSize=
"14sp"
/>
<TextView
android:id=
"@+id/item_tv_app_details_end"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"match_parent"
android:gravity=
"center"
android:textColor=
"#ACACAC"
android:text=
"2020-04-07 17:33"
android:textSize=
"14sp"
/>
</LinearLayout>
<Space
android:layout_width=
"35dp"
android:layout_height=
"35dp"
/>
</LinearLayout>
</FrameLayout>
Launcher3/res/values/strings.xml
View file @
616ba36e
...
@@ -380,9 +380,10 @@
...
@@ -380,9 +380,10 @@
<string
name=
"edu_item_input_encryted_title"
>
请输入密保答案用于修改密码
</string>
<string
name=
"edu_item_input_encryted_title"
>
请输入密保答案用于修改密码
</string>
<string
name=
"edu_item_app_use_title"
>
应用使用情况
</string>
<string
name=
"edu_item_app_use_title"
>
应用使用情况
</string>
<string
name=
"edu_item_app_use_last_day"
>
最近一天使用时长: %1$s
分钟
</string>
<string
name=
"edu_item_app_use_last_day"
>
最近一天使用时长: %1$s
</string>
<string
name=
"edu_item_app_use_more"
>
生成报告
</string>
<string
name=
"edu_item_app_use_more"
>
生成报告
</string>
<string
name=
"edu_item_app_use_total"
>
使用总时长: %1$s分钟
</string>
<string
name=
"edu_item_app_use_total"
>
使用总时长: %1$s
</string>
<string
name=
"edu_item_app_use_count"
>
(%1$d次)
</string>
<string
name=
"edu_item_app_use_time"
>
%1$s
</string>
</resources>
</resources>
Launcher3/src/com/android/launcher3/BaseContainerView.java
View file @
616ba36e
...
@@ -205,6 +205,7 @@ public abstract class BaseContainerView extends FrameLayout
...
@@ -205,6 +205,7 @@ public abstract class BaseContainerView extends FrameLayout
if
(
distance
<
viewConfig
.
getScaledTouchSlop
())
{
if
(
distance
<
viewConfig
.
getScaledTouchSlop
())
{
// The background was clicked, so just go home
// The background was clicked, so just go home
Launcher
.
getLauncher
(
getContext
()).
showWorkspace
(
true
);
Launcher
.
getLauncher
(
getContext
()).
showWorkspace
(
true
);
Launcher
.
forceReload
();
return
true
;
return
true
;
}
}
}
}
...
...
Launcher3/src/com/android/launcher3/function/adapter/TreeAdapter.java
0 → 100644
View file @
616ba36e
package
com
.
android
.
launcher3
.
function
.
adapter
;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
com.android.launcher3.R
;
import
com.secspace.lib.common.function.entity.UseAppListEntity
;
import
com.secspace.lib.common.function.view.UseTimeProgress
;
import
java.util.LinkedList
;
import
java.util.List
;
import
static
com
.
secspace
.
lib
.
common
.
utils
.
UtilsKt
.
formatDateTime
;
public
class
TreeAdapter
extends
RecyclerView
.
Adapter
<
TreeAdapter
.
ViewHolder
>
implements
TreeStateChangeListener
{
private
final
static
int
ITEM_STATE_CLOSE
=
0
;
private
final
static
int
ITEM_STATE_OPEN
=
1
;
private
Context
mContext
;
private
List
<
UseAppListEntity
>
mList
;
private
float
totalTime
;
public
TreeAdapter
(
Context
context
,
List
<
UseAppListEntity
>
list
,
long
totalTime
)
{
initList
(
list
,
0
);
this
.
totalTime
=
totalTime
;
this
.
mList
=
new
LinkedList
<>();
this
.
mContext
=
context
;
this
.
mList
.
addAll
(
list
);
}
private
void
initList
(
List
<
UseAppListEntity
>
list
,
int
itemLevel
)
{
if
(
list
==
null
||
list
.
size
()
<=
0
)
return
;
for
(
UseAppListEntity
item:
list
)
{
item
.
setItemLevel
(
itemLevel
);
if
(
item
.
getChild
()
!=
null
&&
item
.
getChild
().
size
()
>
0
)
{
initList
(
item
.
getChild
(),
itemLevel
+
1
);
}
}
}
@NonNull
@Override
public
ViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
viewGroup
,
int
i
)
{
return
new
ViewHolder
(
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
item_app_list
,
viewGroup
,
false
));
}
@Override
public
void
onBindViewHolder
(
@NonNull
final
ViewHolder
viewHolder
,
int
i
)
{
final
UseAppListEntity
treeItem
=
mList
.
get
(
i
);
viewHolder
.
mAppName
.
setText
(
treeItem
.
getAppName
());
viewHolder
.
mCount
.
setText
(
String
.
format
(
mContext
.
getString
(
R
.
string
.
edu_item_app_use_count
),
treeItem
.
getCount
()));
viewHolder
.
mUseTime
.
setText
(
String
.
format
(
mContext
.
getString
(
R
.
string
.
edu_item_app_use_time
),
formatDateTime
(
treeItem
.
getUseTime
())));
if
(
treeItem
.
getItemLevel
()
==
0
){
viewHolder
.
mParent
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
mChild
.
setVisibility
(
View
.
GONE
);
viewHolder
.
mIndicator
.
setVisibility
(
View
.
VISIBLE
);
if
(
treeItem
.
getItemState
()
==
ITEM_STATE_OPEN
)
{
viewHolder
.
mIndicator
.
setImageResource
(
R
.
drawable
.
ic_expand_more
);
}
else
{
viewHolder
.
mIndicator
.
setImageResource
(
R
.
drawable
.
ic_expand_less_24dp
);
}
if
(
treeItem
.
getIcon
()
!=
null
){
viewHolder
.
mIcon
.
setImageDrawable
(
treeItem
.
getIcon
());
}
viewHolder
.
mProgress
.
setProgress
(
treeItem
.
getUseTime
()/
totalTime
*
100
,
treeItem
.
getAppName
());
}
else
{
viewHolder
.
mParent
.
setVisibility
(
View
.
GONE
);
viewHolder
.
mChild
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
mStartTime
.
setText
(
treeItem
.
getStartTime
());
viewHolder
.
mEndTime
.
setText
(
treeItem
.
getEndTime
());
viewHolder
.
mChild
.
setBackgroundColor
(
0xFFF2F2F2
);
}
if
(
treeItem
.
getChild
()
!=
null
&&
treeItem
.
getChild
().
size
()
>
0
)
{
if
(
treeItem
.
getItemState
()
==
ITEM_STATE_OPEN
)
{
viewHolder
.
mIndicator
.
setImageResource
(
R
.
drawable
.
ic_expand_more
);
}
else
{
viewHolder
.
mIndicator
.
setImageResource
(
R
.
drawable
.
ic_expand_less_24dp
);
}
}
viewHolder
.
itemView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
treeItem
.
getItemState
()
==
ITEM_STATE_CLOSE
)
{
onOpen
(
treeItem
,
viewHolder
.
getAdapterPosition
());
}
else
{
onClose
(
treeItem
,
viewHolder
.
getAdapterPosition
());
}
}
});
}
@Override
public
int
getItemCount
()
{
return
mList
.
size
();
}
private
void
closeChild
(
UseAppListEntity
entity
)
{
if
(
entity
.
getChild
()
!=
null
)
{
for
(
UseAppListEntity
child:
entity
.
getChild
())
{
child
.
setItemState
(
ITEM_STATE_CLOSE
);
closeChild
(
child
);
}
}
}
@Override
public
void
onOpen
(
UseAppListEntity
entity
,
int
position
)
{
if
(
entity
.
getChild
()
!=
null
&&
entity
.
getChild
().
size
()
>
0
)
{
mList
.
addAll
(
position
+
1
,
entity
.
getChild
());
entity
.
setItemState
(
ITEM_STATE_OPEN
);
notifyItemRangeInserted
(
position
+
1
,
entity
.
getChild
().
size
());
notifyItemChanged
(
position
);
}
}
@Override
public
void
onClose
(
UseAppListEntity
entity
,
int
position
)
{
if
(
entity
.
getChild
()
!=
null
&&
entity
.
getChild
().
size
()
>
0
)
{
int
nextSameOrHigherLevelNodePosition
=
mList
.
size
()
-
1
;
if
(
mList
.
size
()
>
position
+
1
)
{
for
(
int
i
=
position
+
1
;
i
<
mList
.
size
();
i
++)
{
if
(
mList
.
get
(
i
).
getItemLevel
()
<=
mList
.
get
(
position
).
getItemLevel
())
{
nextSameOrHigherLevelNodePosition
=
i
-
1
;
break
;
}
}
closeChild
(
mList
.
get
(
position
));
if
(
nextSameOrHigherLevelNodePosition
>
position
)
{
mList
.
subList
(
position
+
1
,
nextSameOrHigherLevelNodePosition
+
1
).
clear
();
entity
.
setItemState
(
ITEM_STATE_CLOSE
);
notifyItemRangeRemoved
(
position
+
1
,
nextSameOrHigherLevelNodePosition
-
position
);
notifyItemChanged
(
position
);
}
}
}
}
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
LinearLayout
mParent
;
ImageView
mIcon
;
TextView
mAppName
;
TextView
mCount
;
TextView
mUseTime
;
UseTimeProgress
mProgress
;
ImageView
mIndicator
;
LinearLayout
mChild
;
TextView
mStartTime
;
TextView
mEndTime
;
ViewHolder
(
@NonNull
View
itemView
)
{
super
(
itemView
);
mParent
=
itemView
.
findViewById
(
R
.
id
.
item_parent
);
mChild
=
itemView
.
findViewById
(
R
.
id
.
item_child
);
mIcon
=
itemView
.
findViewById
(
R
.
id
.
item_icon
);
mAppName
=
itemView
.
findViewById
(
R
.
id
.
item_tv_app_name
);
mCount
=
itemView
.
findViewById
(
R
.
id
.
item_tv_app_count
);
mUseTime
=
itemView
.
findViewById
(
R
.
id
.
item_tv_app_time
);
mProgress
=
itemView
.
findViewById
(
R
.
id
.
item_use_time_progress
);
mIndicator
=
itemView
.
findViewById
(
R
.
id
.
item_indicator
);
mStartTime
=
itemView
.
findViewById
(
R
.
id
.
item_tv_app_details_start
);
mEndTime
=
itemView
.
findViewById
(
R
.
id
.
item_tv_app_details_end
);
}
}
}
Launcher3/src/com/android/launcher3/function/adapter/TreeStateChangeListener.java
0 → 100644
View file @
616ba36e
package
com
.
android
.
launcher3
.
function
.
adapter
;
import
com.secspace.lib.common.function.entity.UseAppListEntity
;
public
interface
TreeStateChangeListener
{
void
onOpen
(
UseAppListEntity
entity
,
int
position
);
void
onClose
(
UseAppListEntity
entity
,
int
position
);
}
Launcher3/src/com/android/launcher3/function/setting/AppUseActivity.kt
View file @
616ba36e
...
@@ -2,16 +2,20 @@ package com.android.launcher3.function.setting
...
@@ -2,16 +2,20 @@ package com.android.launcher3.function.setting
import
android.content.Context
import
android.content.Context
import
android.os.Bundle
import
android.os.Bundle
import
android.support.v7.widget.DividerItemDecoration
import
android.support.v7.widget.LinearLayoutManager
import
android.util.Log
import
android.util.Log
import
android.view.View
import
android.view.View
import
com.android.launcher3.BaseActivity
import
com.android.launcher3.BaseActivity
import
com.android.launcher3.R
import
com.android.launcher3.R
import
com.android.launcher3.function.adapter.TreeAdapter
import
com.bigkoo.pickerview.builder.TimePickerBuilder
import
com.bigkoo.pickerview.builder.TimePickerBuilder
import
com.bigkoo.pickerview.listener.OnTimeSelectListener
import
com.bigkoo.pickerview.listener.OnTimeSelectListener
import
com.bigkoo.pickerview.view.TimePickerView
import
com.secspace.lib.common.function.database.DatabaseManager
import
com.secspace.lib.common.function.database.DatabaseManager
import
com.secspace.lib.common.function.entity.UseAppEntity
import
com.secspace.lib.common.function.entity.UseAppEntity
import
com.secspace.lib.common.function.entity.UseAppListEntity
import
com.secspace.lib.common.function.model.UseTime
import
com.secspace.lib.common.function.model.UseTime
import
com.secspace.lib.common.utils.*
import
kotlinx.android.synthetic.main.activity_setting.tv_setting_title
import
kotlinx.android.synthetic.main.activity_setting.tv_setting_title
import
kotlinx.android.synthetic.main.activity_use_app.*
import
kotlinx.android.synthetic.main.activity_use_app.*
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
...
@@ -25,17 +29,19 @@ import kotlin.collections.ArrayList
...
@@ -25,17 +29,19 @@ import kotlin.collections.ArrayList
class
AppUseActivity
:
BaseActivity
()
{
class
AppUseActivity
:
BaseActivity
()
{
private
var
TAG
:
String
?
=
"TagAppUseActivity"
private
var
TAG
:
String
?
=
"TagAppUseActivity"
private
var
mContext
:
Context
?
=
null
private
lateinit
var
mContext
:
Context
private
var
defaultUseAppEntitys
:
ArrayList
<
UseAppEntity
>?
=
null
private
lateinit
var
defaultUseAppEntitys
:
ArrayList
<
UseAppEntity
>
private
var
defaultStartTime
:
Long
=
0
private
var
defaultStartTime
:
Long
=
0
private
var
defaultEndTime
:
Long
=
0
private
var
defaultEndTime
:
Long
=
0
private
var
defaultTotalTime
=
0L
private
var
defaultTotalTime
=
0L
private
var
selectStartTime
:
Long
=
0
private
var
selectStartTime
:
Long
=
0
private
var
selectEndTime
:
Long
=
0
private
var
selectEndTime
:
Long
=
0
private
var
selectUseAppEntitys
:
ArrayList
<
UseAppEntity
>?
=
null
private
lateinit
var
selectUseAppEntitys
:
ArrayList
<
UseAppEntity
>
private
var
selectTotalTime
:
Long
=
0
private
var
selectTotalTime
:
Long
=
0
private
lateinit
var
selectEntity
:
LinkedList
<
UseAppListEntity
>
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
setAndroidNativeLightStatusBar
(
true
)
setAndroidNativeLightStatusBar
(
true
)
...
@@ -43,11 +49,7 @@ class AppUseActivity : BaseActivity() {
...
@@ -43,11 +49,7 @@ class AppUseActivity : BaseActivity() {
mContext
=
this
mContext
=
this
initView
()
initView
()
initSelector
()
initSelector
()
if
(
defaultUseAppEntitys
==
null
)
{
defaultLoadData
()
defaultLoadData
()
}
else
{
initChart
()
}
}
}
private
fun
defaultLoadData
()
{
private
fun
defaultLoadData
()
{
...
@@ -56,13 +58,12 @@ class AppUseActivity : BaseActivity() {
...
@@ -56,13 +58,12 @@ class AppUseActivity : BaseActivity() {
defaultUseAppEntitys
=
ArrayList
()
defaultUseAppEntitys
=
ArrayList
()
defaultTotalTime
=
0L
defaultTotalTime
=
0L
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
mContext
?.
let
{
it
->
val
useAppDao
=
DatabaseManager
.
getInstance
(
mContext
).
getUseAppDao
()
val
useAppDao
=
DatabaseManager
.
getInstance
(
it
).
getUseAppDao
()
val
useTimeDao
=
DatabaseManager
.
getInstance
(
mContext
).
getUseTimeDao
()
val
useTimeDao
=
DatabaseManager
.
getInstance
(
it
).
getUseTimeDao
()
val
useApps
=
useAppDao
?.
queryAll
()
val
useApps
=
useAppDao
?.
queryAll
()
val
useTimes
=
useTimeDao
?.
queryByTime
(
defaultStartTime
,
defaultEndTime
)
val
useTimes
=
useTimeDao
?.
queryByTime
(
defaultStartTime
,
defaultEndTime
)
if
(
useApps
==
null
)
{
if
(
useApps
==
null
)
{
return
@let
return
@launch
}
}
Log
.
i
(
TAG
,
"useApps: ${useApps.size} useTimes: ${useTimes?.size}"
)
Log
.
i
(
TAG
,
"useApps: ${useApps.size} useTimes: ${useTimes?.size}"
)
val
tempEntitys
=
ArrayList
<
UseAppEntity
>()
val
tempEntitys
=
ArrayList
<
UseAppEntity
>()
...
@@ -84,31 +85,34 @@ class AppUseActivity : BaseActivity() {
...
@@ -84,31 +85,34 @@ class AppUseActivity : BaseActivity() {
}
}
tempEntitys
.
groupBy
{
tempEntitys
.
groupBy
{
it
.
appPackage
it
.
appPackage
}.
values
.
flatten
().
forEach
{
useAppEntity
->
}.
forEach
{
useApps
.
forEach
{
var
tempTotalTime
=
0L
if
(
it
.
appPackage
==
useAppEntity
.
appPackage
)
{
it
.
value
.
forEach
{
temp
->
useAppEntity
.
appName
=
it
.
appName
defaultTotalTime
+=
temp
.
useTime
tempTotalTime
+=
temp
.
useTime
}
}
val
tempUseAppEntity
=
UseAppEntity
(
it
.
key
,
getApplicationName
(
mContext
,
it
.
key
),
tempTotalTime
)
defaultUseAppEntitys
.
add
(
tempUseAppEntity
)
}
}
defaultUseAppEntitys
?.
add
(
useAppEntity
)
defaultTotalTime
+=
useAppEntity
.
useTime
}
// 根据使用时间降序排列
// 根据使用时间降序排列
defaultUseAppEntitys
!!
.
sortByDescending
{
it
.
useTime
}
defaultUseAppEntitys
.
sortByDescending
{
it
.
useTime
}
if
(
defaultUseAppEntitys
!!
.
size
>
4
)
{
if
(
defaultUseAppEntitys
.
size
>
4
)
{
val
tempAppEntity
=
UseAppEntity
(
""
,
""
,
0
)
val
tempAppEntity
=
UseAppEntity
(
""
,
""
,
0
)
for
(
i
in
4
..
defaultUseAppEntitys
!!
.
size
)
{
for
(
i
in
4
..
defaultUseAppEntitys
.
size
)
{
tempAppEntity
.
appPackage
=
"Other"
tempAppEntity
.
appPackage
=
"Other"
tempAppEntity
.
appName
=
"其他"
tempAppEntity
.
appName
=
"其他"
tempAppEntity
.
useTime
=
tempAppEntity
.
useTime
+
defaultUseAppEntitys
!!
[
i
-
1
].
useTime
tempAppEntity
.
useTime
=
tempAppEntity
.
useTime
+
defaultUseAppEntitys
[
i
-
1
].
useTime
}
defaultUseAppEntitys
[
3
]
=
tempAppEntity
for
(
i
in
defaultUseAppEntitys
.
size
downTo
5
)
{
defaultUseAppEntitys
.
removeAt
(
i
-
1
)
}
}
defaultUseAppEntitys
!!
[
3
]
=
tempAppEntity
defaultUseAppEntitys
!!
.
removeAt
(
4
)
}
}
withContext
(
Dispatchers
.
Main
)
{
withContext
(
Dispatchers
.
Main
)
{
initChart
()
initChart
()
}
}
}
}
}
}
}
...
@@ -117,11 +121,24 @@ class AppUseActivity : BaseActivity() {
...
@@ -117,11 +121,24 @@ class AppUseActivity : BaseActivity() {
}
}
private
fun
initChart
()
{
private
fun
initChart
()
{
tv_app_use_time
.
text
=
String
.
format
(
getString
(
R
.
string
.
edu_item_app_use_last_day
),
defaultTotalTime
)
tv_app_use_time
.
text
=
String
.
format
(
getString
(
R
.
string
.
edu_item_app_use_last_day
),
formatDateTime
(
defaultTotalTime
)
)
time_progress
.
setData
(
defaultUseAppEntitys
,
defaultTotalTime
)
time_progress
.
setData
(
defaultUseAppEntitys
,
defaultTotalTime
)
time_progress
.
initAnimation
()
time_progress
.
initAnimation
()
}
}
private
fun
initRecyclerView
()
{
val
treeAdapter
=
TreeAdapter
(
this
,
selectEntity
,
selectTotalTime
)
val
layoutManager
=
object
:
LinearLayoutManager
(
this
){
override
fun
canScrollVertically
():
Boolean
{
return
false
}
}
rv_tree
.
layoutManager
=
layoutManager
rv_tree
.
addItemDecoration
(
DividerItemDecoration
(
this
,
DividerItemDecoration
.
VERTICAL
))
rv_tree
.
adapter
=
treeAdapter
}
private
fun
initSelector
()
{
private
fun
initSelector
()
{
val
format
=
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
US
)
val
format
=
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
US
)
selectEndTime
=
System
.
currentTimeMillis
()
selectEndTime
=
System
.
currentTimeMillis
()
...
@@ -142,8 +159,8 @@ class AppUseActivity : BaseActivity() {
...
@@ -142,8 +159,8 @@ class AppUseActivity : BaseActivity() {
TimePickerBuilder
(
this
,
OnTimeSelectListener
{
date
,
_
->
TimePickerBuilder
(
this
,
OnTimeSelectListener
{
date
,
_
->
selectStartTime
=
date
.
time
selectStartTime
=
date
.
time
tv_date_start
.
text
=
format
.
format
(
Date
(
selectStartTime
))
tv_date_start
.
text
=
format
.
format
(
Date
(
selectStartTime
))
Log
.
e
(
TAG
,
"开始选择:${selectStartTime}"
)
selectLoadData
()
selectLoadData
()
loadDetails
()
}).
setRangDate
(
startDate
,
endDate
)
}).
setRangDate
(
startDate
,
endDate
)
.
setDate
(
startSelectDate
)
.
setDate
(
startSelectDate
)
.
build
().
show
()
.
build
().
show
()
...
@@ -153,14 +170,15 @@ class AppUseActivity : BaseActivity() {
...
@@ -153,14 +170,15 @@ class AppUseActivity : BaseActivity() {
TimePickerBuilder
(
this
,
OnTimeSelectListener
{
date
,
_
->
TimePickerBuilder
(
this
,
OnTimeSelectListener
{
date
,
_
->
selectEndTime
=
date
.
time
selectEndTime
=
date
.
time
tv_date_end
.
text
=
format
.
format
(
Date
(
selectEndTime
))
tv_date_end
.
text
=
format
.
format
(
Date
(
selectEndTime
))
Log
.
e
(
TAG
,
"结束选择:${selectEndTime}"
)
selectLoadData
()
selectLoadData
()
loadDetails
()
}).
setRangDate
(
startDate
,
endDate
)
}).
setRangDate
(
startDate
,
endDate
)
.
setDate
(
nowDate
)
.
setDate
(
nowDate
)
.
build
().
show
()
.
build
().
show
()
}
}
selectLoadData
()
selectLoadData
()
loadDetails
()
}
}
fun
close
(
view
:
View
?)
{
fun
close
(
view
:
View
?)
{
...
@@ -170,17 +188,16 @@ class AppUseActivity : BaseActivity() {
...
@@ -170,17 +188,16 @@ class AppUseActivity : BaseActivity() {
private
fun
selectLoadData
()
{
private
fun
selectLoadData
()
{
selectUseAppEntitys
=
ArrayList
()
selectUseAppEntitys
=
ArrayList
()
selectTotalTime
=
0L
selectTotalTime
=
0L
var
tempTotalTime
=
0L
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
mContext
?.
let
{
it
->
val
useAppDao
=
DatabaseManager
.
getInstance
(
mContext
).
getUseAppDao
()
val
useAppDao
=
DatabaseManager
.
getInstance
(
it
).
getUseAppDao
()
val
useTimeDao
=
DatabaseManager
.
getInstance
(
mContext
).
getUseTimeDao
()
val
useTimeDao
=
DatabaseManager
.
getInstance
(
it
).
getUseTimeDao
()
val
useApps
=
useAppDao
?.
queryAll
()
val
useApps
=
useAppDao
?.
queryAll
()
val
useTimes
=
useTimeDao
?.
queryByTime
(
selectStartTime
,
selectEndTime
)
val
useTimes
=
useTimeDao
?.
queryByTime
(
selectStartTime
,
selectEndTime
)
if
(
useApps
==
null
)
{
if
(
useApps
==
null
)
{
return
@let
return
@launch
}
}
Log
.
i
(
TAG
,
"useApps: ${useApps.size} useTimes: ${useTimes?.size}"
)
Log
.
i
(
TAG
,
"useApps: ${useApps.size} useTimes: ${useTimes?.size}"
)
val
tempEntitys
=
ArrayList
<
UseAppEntity
>()
useTimes
?.
map
<
UseTime
,
UseTime
>
{
useTime
->
useTimes
?.
map
<
UseTime
,
UseTime
>
{
useTime
->
if
(
useTime
.
useStartTime
<
selectStartTime
)
{
if
(
useTime
.
useStartTime
<
selectStartTime
)
{
useTime
.
useStartTime
=
selectStartTime
useTime
.
useStartTime
=
selectStartTime
...
@@ -193,25 +210,21 @@ class AppUseActivity : BaseActivity() {
...
@@ -193,25 +210,21 @@ class AppUseActivity : BaseActivity() {
useApps
.
any
{
useApp
->
useApps
.
any
{
useApp
->
useApp
.
appPackage
==
useTime
.
appPackage
useApp
.
appPackage
==
useTime
.
appPackage
}
}
}
?.
forEach
{
useTime
->
}
?.
groupBy
{
val
useApp
=
UseAppEntity
(
useTime
.
appPackage
,
""
,
(
useTime
.
useEndTime
-
useTime
.
useStartTime
)
/
1000
/
60
)
tempEntitys
.
add
(
useApp
)
}
tempEntitys
.
groupBy
{
it
.
appPackage
it
.
appPackage
}.
values
.
flatten
().
forEach
{
useAppEntity
->
}
?.
forEach
{
useApps
.
forEach
{
it
.
value
.
forEach
{
temp
->
if
(
it
.
appPackage
==
useAppEntity
.
appPackage
)
{
tempTotalTime
+=
((
temp
.
useEndTime
-
temp
.
useStartTime
)
/
1000
/
60
)
useAppEntity
.
appName
=
it
.
appName
}
}
}
selectUseAppEntitys
?.
add
(
useAppEntity
)
val
tempUseAppEntity
=
UseAppEntity
(
it
.
key
,
getApplicationName
(
mContext
,
it
.
key
),
tempTotalTime
)
selectTotalTime
+=
useAppEntity
.
useTime
selectUseAppEntitys
.
add
(
tempUseAppEntity
)
}
}
selectTotalTime
=
tempTotalTime
Log
.
e
(
TAG
,
"selectLoadData selectTotalTime:$selectTotalTime"
)
// 根据使用时间降序排列
// 根据使用时间降序排列
selectUseAppEntitys
!!
.
sortByDescending
{
it
.
useTime
}
selectUseAppEntitys
.
sortByDescending
{
it
.
useTime
}
withContext
(
Dispatchers
.
Main
)
{
withContext
(
Dispatchers
.
Main
)
{
tv_app_use_total_time
.
text
=
String
.
format
(
getString
(
R
.
string
.
edu_item_app_use_total
),
selectTotalTime
)
tv_app_use_total_time
.
text
=
String
.
format
(
getString
(
R
.
string
.
edu_item_app_use_total
),
formatDateTime
(
selectTotalTime
)
)
val
allTime
:
Float
=
((
selectEndTime
-
selectStartTime
)
/
1000
/
60
).
toFloat
()
val
allTime
:
Float
=
((
selectEndTime
-
selectStartTime
)
/
1000
/
60
).
toFloat
()
val
showTime
=
selectTotalTime
/
allTime
*
100
val
showTime
=
selectTotalTime
/
allTime
*
100
Log
.
e
(
TAG
,
"showTime = $showTime , allTime = $allTime"
)
Log
.
e
(
TAG
,
"showTime = $showTime , allTime = $allTime"
)
...
@@ -219,10 +232,65 @@ class AppUseActivity : BaseActivity() {
...
@@ -219,10 +232,65 @@ class AppUseActivity : BaseActivity() {
}
}
}
}
}
}
}
fun
more
(
view
:
View
)
{}
private
fun
loadDetails
()
{
selectEntity
=
LinkedList
()
selectTotalTime
=
0L
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
val
useAppDao
=
DatabaseManager
.
getInstance
(
mContext
).
getUseAppDao
()
val
useTimeDao
=
DatabaseManager
.
getInstance
(
mContext
).
getUseTimeDao
()
val
useApps
=
useAppDao
?.
queryAll
()
val
useTimes
=
useTimeDao
?.
queryByTime
(
selectStartTime
,
selectEndTime
)
if
(
useApps
==
null
)
{
return
@launch
}
Log
.
i
(
TAG
,
"loadDetails useApps: ${useApps.size} useTimes: ${useTimes?.size}"
)
var
tempTotalTimes
=
0L
val
tempUseApps
=
LinkedList
<
UseAppListEntity
>()
useTimes
?.
map
<
UseTime
,
UseTime
>
{
useTime
->
if
(
useTime
.
useStartTime
<
selectStartTime
)
{
useTime
.
useStartTime
=
selectStartTime
}
if
(
useTime
.
useEndTime
>
selectEndTime
)
{
useTime
.
useEndTime
=
selectEndTime
}
useTime
}
?.
filter
{
useTime
->
useApps
.
any
{
useApp
->
useApp
.
appPackage
==
useTime
.
appPackage
}
}
?.
groupBy
{
it
.
appPackage
}
?.
forEach
{
map
->
val
appList
=
UseAppListEntity
(
0
)
appList
.
appPackage
=
map
.
key
appList
.
count
=
map
.
value
.
size
.
toLong
()
val
useAppsChild
=
LinkedList
<
UseAppListEntity
>()
map
.
value
.
forEach
{
val
tempAppList
=
UseAppListEntity
(
1
)
tempAppList
.
startTime
=
formatDate2MdHm
(
it
.
useStartTime
)
tempAppList
.
endTime
=
formatDate2MdHm
(
it
.
useEndTime
)
useAppsChild
.
add
(
tempAppList
)
appList
.
useTime
+=
((
it
.
useEndTime
-
it
.
useStartTime
)
/
1000
/
60
)
}
tempTotalTimes
+=
appList
.
useTime
appList
.
child
=
useAppsChild
tempUseApps
.
add
(
appList
)
}
selectTotalTime
=
tempTotalTimes
Log
.
e
(
TAG
,
"loadDetails selectTotalTime:$selectTotalTime"
)
tempUseApps
.
forEach
{
it
.
icon
=
getApplicationIcon
(
mContext
,
it
.
appPackage
)
it
.
appName
=
getApplicationName
(
mContext
,
it
.
appPackage
)
}
selectEntity
.
clear
()
selectEntity
.
addAll
(
tempUseApps
)
selectEntity
.
sortByDescending
{
it
.
useTime
}
withContext
(
Dispatchers
.
Main
)
{
initRecyclerView
()
}
}
}
}
}
...
...
lib_common/src/main/java/com/secspace/lib/common/dialog/other/DialogUIUtils.java
View file @
616ba36e
...
@@ -209,6 +209,7 @@ public class DialogUIUtils {
...
@@ -209,6 +209,7 @@ public class DialogUIUtils {
CharSequence
sure
,
CharSequence
cancel
,
boolean
isVertical
,
boolean
cancleable
,
boolean
outsideTouchable
,
DialogUIListener
listener
)
{
CharSequence
sure
,
CharSequence
cancel
,
boolean
isVertical
,
boolean
cancleable
,
boolean
outsideTouchable
,
DialogUIListener
listener
)
{
return
DialogAssigner
.
getInstance
().
assignAlertPasswordCanVer
(
activity
,
title
,
msg
,
thirdTx
,
hint1
,
hint2
,
sure
,
cancel
,
isVertical
,
cancleable
,
outsideTouchable
,
listener
);
return
DialogAssigner
.
getInstance
().
assignAlertPasswordCanVer
(
activity
,
title
,
msg
,
thirdTx
,
hint1
,
hint2
,
sure
,
cancel
,
isVertical
,
cancleable
,
outsideTouchable
,
listener
);
}
}
/**
/**
* 短时间中下位置显示。线程安全,可以在非UI线程调用。
* 短时间中下位置显示。线程安全,可以在非UI线程调用。
*/
*/
...
...
lib_common/src/main/java/com/secspace/lib/common/function/WorkManager.kt
View file @
616ba36e
...
@@ -68,7 +68,8 @@ object WorkManager {
...
@@ -68,7 +68,8 @@ object WorkManager {
}
}
// LoadingDialog.getInstance(launcher).show("切换中")
// LoadingDialog.getInstance(launcher).show("切换中")
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
openAccessibility
(
launcher
)
// TODO 暂时屏蔽
// openAccessibility(launcher)
SwitchInMdm
.
onInit
(
launcher
)
SwitchInMdm
.
onInit
(
launcher
)
activate
(
launcher
)
activate
(
launcher
)
withContext
(
Dispatchers
.
Main
){
withContext
(
Dispatchers
.
Main
){
...
...
lib_common/src/main/java/com/secspace/lib/common/function/entity/UseAppListEntity.kt
0 → 100644
View file @
616ba36e
package
com.secspace.lib.common.function.entity
import
android.graphics.drawable.Drawable
data class
UseAppListEntity
(
var
itemLevel
:
Int
)
{
var
appName
:
String
=
""
var
appPackage
:
String
=
""
var
icon
:
Drawable
?
=
null
var
useTime
:
Long
=
0
var
count
:
Long
=
0
var
startTime
:
String
=
""
var
endTime
:
String
=
""
var
itemState
:
Int
=
0
var
child
:
List
<
UseAppListEntity
>?
=
null
}
\ No newline at end of file
lib_common/src/main/java/com/secspace/lib/common/function/view/AppUseProgress.java
View file @
616ba36e
...
@@ -104,6 +104,15 @@ public class AppUseProgress extends View {
...
@@ -104,6 +104,15 @@ public class AppUseProgress extends View {
paintColors
.
add
(
0xFF9BFA13
);
paintColors
.
add
(
0xFF9BFA13
);
paintColors
.
add
(
0xFFFAB613
);
paintColors
.
add
(
0xFFFAB613
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
paintColors
.
add
(
0xFFE5E5E5
);
}
}
public
void
setData
(
List
<
UseAppEntity
>
useAppEntities
,
long
allTime
)
{
public
void
setData
(
List
<
UseAppEntity
>
useAppEntities
,
long
allTime
)
{
...
...
lib_common/src/main/java/com/secspace/lib/common/function/view/UseTimeProgress.java
View file @
616ba36e
...
@@ -8,6 +8,7 @@ import android.graphics.Rect;
...
@@ -8,6 +8,7 @@ import android.graphics.Rect;
import
android.graphics.RectF
;
import
android.graphics.RectF
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.util.TypedValue
;
import
android.util.TypedValue
;
import
android.view.View
;
import
android.view.View
;
import
android.view.animation.LinearInterpolator
;
import
android.view.animation.LinearInterpolator
;
...
@@ -33,7 +34,7 @@ public class UseTimeProgress extends View {
...
@@ -33,7 +34,7 @@ public class UseTimeProgress extends View {
*/
*/
private
float
mProgress
;
private
float
mProgress
;
//描述文字的高度
//描述文字的高度
private
float
textHeight
;
//
private float textHeight;
//描述文字的高度
//描述文字的高度
private
float
textWidth
;
private
float
textWidth
;
...
@@ -127,11 +128,8 @@ public class UseTimeProgress extends View {
...
@@ -127,11 +128,8 @@ public class UseTimeProgress extends View {
progressHeight
=
dp2px
(
6
);
progressHeight
=
dp2px
(
6
);
roundRectRadius
=
dp2px
(
3
);
roundRectRadius
=
dp2px
(
3
);
textPaintSize
=
sp2px
(
10
);
textPaintSize
=
sp2px
(
10
);
textHeight
=
dp2px
(
10
);
// textHeight = dp2px(10);
progressMarginTop
=
dp2px
(
4
);
// progressMarginTop = dp2px(4);
//view真实的高度
mViewHeight
=
(
int
)
(
progressMarginTop
+
progressPaintWidth
*
2
+
progressHeight
);
}
}
...
@@ -214,7 +212,7 @@ public class UseTimeProgress extends View {
...
@@ -214,7 +212,7 @@ public class UseTimeProgress extends View {
switch
(
mode
)
{
switch
(
mode
)
{
case
MeasureSpec
.
UNSPECIFIED
:
case
MeasureSpec
.
UNSPECIFIED
:
case
MeasureSpec
.
AT_MOST
:
case
MeasureSpec
.
AT_MOST
:
mHeight
=
mView
Height
;
mHeight
=
progressMarginTop
+
progressPaintWidth
*
2
+
progress
Height
;
break
;
break
;
case
MeasureSpec
.
EXACTLY
:
case
MeasureSpec
.
EXACTLY
:
mHeight
=
height
;
mHeight
=
height
;
...
@@ -226,7 +224,7 @@ public class UseTimeProgress extends View {
...
@@ -226,7 +224,7 @@ public class UseTimeProgress extends View {
@Override
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
protected
void
onDraw
(
Canvas
canvas
)
{
super
.
onDraw
(
canvas
);
super
.
onDraw
(
canvas
);
mWidth
=
getMeasuredWidth
();
//绘制文字
//绘制文字
// drawText(canvas, textString);
// drawText(canvas, textString);
//背景
//背景
...
@@ -237,16 +235,17 @@ public class UseTimeProgress extends View {
...
@@ -237,16 +235,17 @@ public class UseTimeProgress extends View {
private
void
drawBgProgress
(
Canvas
canvas
)
{
private
void
drawBgProgress
(
Canvas
canvas
)
{
bgRectF
.
left
=
0
;
bgRectF
.
left
=
0
;
bgRectF
.
top
=
textHeight
+
progressMarginTop
;
bgRectF
.
top
=
progressMarginTop
;
bgRectF
.
right
=
this
.
getMeasuredWidth
();
bgRectF
.
right
=
this
.
getMeasuredWidth
();
bgRectF
.
bottom
=
bgRectF
.
top
+
progressHeight
;
bgRectF
.
bottom
=
bgRectF
.
top
+
progressHeight
;
canvas
.
drawRoundRect
(
bgRectF
,
roundRectRadius
,
roundRectRadius
,
bgPaint
);
canvas
.
drawRoundRect
(
bgRectF
,
roundRectRadius
,
roundRectRadius
,
bgPaint
);
Log
.
e
(
"TAG1"
,
" this.getMeasuredWidth():"
+
this
.
getMeasuredWidth
());
}
}
private
void
drawProgress
(
Canvas
canvas
)
{
private
void
drawProgress
(
Canvas
canvas
)
{
progressRectF
.
left
=
0
;
progressRectF
.
left
=
0
;
progressRectF
.
top
=
textHeight
+
progressMarginTop
;
progressRectF
.
top
=
progressMarginTop
;
progressRectF
.
right
=
currentProgress
;
progressRectF
.
right
=
mProgress
*
this
.
getMeasuredWidth
()
/
100
;
progressRectF
.
bottom
=
progressRectF
.
top
+
progressHeight
;
progressRectF
.
bottom
=
progressRectF
.
top
+
progressHeight
;
canvas
.
drawRoundRect
(
progressRectF
,
roundRectRadius
,
roundRectRadius
,
progressPaint
);
canvas
.
drawRoundRect
(
progressRectF
,
roundRectRadius
,
roundRectRadius
,
progressPaint
);
}
}
...
@@ -261,7 +260,7 @@ public class UseTimeProgress extends View {
...
@@ -261,7 +260,7 @@ public class UseTimeProgress extends View {
textRect
.
left
=
(
int
)
moveDis
;
textRect
.
left
=
(
int
)
moveDis
;
textRect
.
top
=
0
;
textRect
.
top
=
0
;
textRect
.
right
=
(
int
)
(
textPaint
.
measureText
(
textString
)
+
moveDis
);
textRect
.
right
=
(
int
)
(
textPaint
.
measureText
(
textString
)
+
moveDis
);
textRect
.
bottom
=
(
int
)
textHeight
;
//
textRect.bottom = (int) textHeight;
Paint
.
FontMetricsInt
fontMetrics
=
textPaint
.
getFontMetricsInt
();
Paint
.
FontMetricsInt
fontMetrics
=
textPaint
.
getFontMetricsInt
();
int
baseline
=
(
textRect
.
bottom
+
textRect
.
top
-
fontMetrics
.
bottom
-
fontMetrics
.
top
)
/
2
;
int
baseline
=
(
textRect
.
bottom
+
textRect
.
top
-
fontMetrics
.
bottom
-
fontMetrics
.
top
)
/
2
;
//文字绘制到整个布局的中心位置
//文字绘制到整个布局的中心位置
...
@@ -281,8 +280,6 @@ public class UseTimeProgress extends View {
...
@@ -281,8 +280,6 @@ public class UseTimeProgress extends View {
@Override
@Override
public
void
onAnimationUpdate
(
ValueAnimator
valueAnimator
)
{
public
void
onAnimationUpdate
(
ValueAnimator
valueAnimator
)
{
float
value
=
(
float
)
valueAnimator
.
getAnimatedValue
();
float
value
=
(
float
)
valueAnimator
.
getAnimatedValue
();
textString
=
"已售"
+
formatNum
((
int
)
value
)
+
"%"
;
textWidth
=
textPaint
.
measureText
(
textString
);
currentProgress
=
value
*
mWidth
/
100
;
currentProgress
=
value
*
mWidth
/
100
;
if
(
progressListener
!=
null
)
{
if
(
progressListener
!=
null
)
{
progressListener
.
currentProgressListener
(
value
);
progressListener
.
currentProgressListener
(
value
);
...
@@ -318,8 +315,16 @@ public class UseTimeProgress extends View {
...
@@ -318,8 +315,16 @@ public class UseTimeProgress extends View {
}
}
public
UseTimeProgress
setProgress
(
float
progress
)
{
public
UseTimeProgress
setProgress
(
float
progress
)
{
return
setProgress
(
progress
,
"NoTag"
);
}
public
UseTimeProgress
setProgress
(
float
progress
,
String
tag
)
{
mWidth
=
this
.
getMeasuredWidth
();
mProgress
=
progress
;
mProgress
=
progress
;
initAnimation
();
// initAnimation();
currentProgress
=
mProgress
*
mWidth
/
100
;
Log
.
e
(
"TAG1"
,
"tag: "
+
tag
+
" mProgress:"
+
mProgress
+
" mWidth:"
+
mWidth
);
invalidate
();
return
this
;
return
this
;
}
}
...
...
lib_common/src/main/java/com/secspace/lib/common/utils/Utils.kt
View file @
616ba36e
...
@@ -13,6 +13,8 @@ import com.skr.activation.utils.DesUtil
...
@@ -13,6 +13,8 @@ import com.skr.activation.utils.DesUtil
import
java.io.ByteArrayOutputStream
import
java.io.ByteArrayOutputStream
import
java.io.File
import
java.io.File
import
java.io.FileWriter
import
java.io.FileWriter
import
java.text.SimpleDateFormat
import
java.util.*
fun
decrypt
(
strMi
:
String
):
String
{
fun
decrypt
(
strMi
:
String
):
String
{
...
@@ -98,3 +100,27 @@ fun write2File(source: String, filePath: String) {
...
@@ -98,3 +100,27 @@ fun write2File(source: String, filePath: String) {
fileWriter
.
write
(
source
)
fileWriter
.
write
(
source
)
}
}
}
}
fun
formatDate2MdHm
(
date
:
Long
):
String
{
val
format
=
SimpleDateFormat
(
"MM-dd HH:mm"
,
Locale
.
US
)
return
format
.
format
(
Date
(
date
))
}
fun
formatDateTime
(
minute
:
Long
):
String
{
var
stringTimes
=
""
val
days
=
minute
/
(
60
*
24
)
val
hours
=
minute
%
(
60
*
24
)
/
60
val
minutes
=
minute
%
60
when
{
days
>
0
->
{
stringTimes
=
days
.
toString
()
+
"天"
+
hours
+
"时"
+
minutes
+
"分"
}
hours
>
0
->
{
stringTimes
=
hours
.
toString
()
+
"时"
+
minutes
+
"分"
}
minutes
>
0
->
{
stringTimes
=
minutes
.
toString
()
+
"分"
}
}
return
stringTimes
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment