Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
launcher
Overview
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
lihuaikun
launcher
Commits
742053e9
Commit
742053e9
authored
Sep 27, 2020
by
郑鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug
parent
4e12ceca
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
247 additions
and
24 deletions
+247
-24
gradle.xml
.idea/gradle.xml
+1
-4
jarRepositories.xml
.idea/jarRepositories.xml
+36
-0
build.gradle
Launcher3/build.gradle
+1
-1
FastBitmapDrawable.java
...c/main/java/com/android/launcher3/FastBitmapDrawable.java
+4
-1
Launcher.java
Launcher3/src/main/java/com/android/launcher3/Launcher.java
+25
-3
ListenerAppService.java
...m/android/launcher3/accessibility/ListenerAppService.java
+23
-1
PermissionOpenAccessiblityService.java
...her3/accessibility/PermissionOpenAccessiblityService.java
+4
-0
CustomDialog.java
...c/main/java/com/android/launcher3/debug/CustomDialog.java
+17
-3
LauncherManager.java
...n/java/com/android/launcher3/manager/LauncherManager.java
+0
-0
TimeModeManager.java
...n/java/com/android/launcher3/manager/TimeModeManager.java
+9
-0
BgDataModel.java
...rc/main/java/com/android/launcher3/model/BgDataModel.java
+4
-3
NotificationItemView.java
.../android/launcher3/notification/NotificationItemView.java
+3
-0
activity_clock_alarm.xml
Launcher3/src/main/res/layout/activity_clock_alarm.xml
+3
-0
styles.xml
Launcher3/src/main/res/values/styles.xml
+7
-0
build.gradle
app/build.gradle
+1
-0
AppTimeBean.kt
app/src/main/java/com/dankal/dankal_launcher/AppTimeBean.kt
+21
-0
PackageManageActivity.java
...ava/com/dankal/dankal_launcher/PackageManageActivity.java
+86
-8
strings.xml
app/src/main/res/values/strings.xml
+2
-0
No files found.
.idea/gradle.xml
View file @
742053e9
...
...
@@ -4,10 +4,8 @@
<component
name=
"GradleSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild
compositeDefinitionSource=
"SCRIPT"
/>
</compositeConfiguration>
<option
name=
"delegatedBuild"
value=
"false"
/>
<option
name=
"testRunner"
value=
"PLATFORM"
/>
<option
name=
"distributionType"
value=
"DEFAULT_WRAPPED"
/>
<option
name=
"externalProjectPath"
value=
"$PROJECT_DIR$"
/>
<option
name=
"modules"
>
...
...
@@ -18,7 +16,6 @@
</set>
</option>
<option
name=
"resolveModulePerSourceSet"
value=
"false"
/>
<option
name=
"testRunner"
value=
"PLATFORM"
/>
</GradleProjectSettings>
</option>
</component>
...
...
.idea/jarRepositories.xml
0 → 100644
View file @
742053e9
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"RemoteRepositoriesConfiguration"
>
<remote-repository>
<option
name=
"id"
value=
"central"
/>
<option
name=
"name"
value=
"Maven Central repository"
/>
<option
name=
"url"
value=
"https://repo1.maven.org/maven2"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"jboss.community"
/>
<option
name=
"name"
value=
"JBoss Community repository"
/>
<option
name=
"url"
value=
"https://repository.jboss.org/nexus/content/repositories/public/"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"MavenRepo"
/>
<option
name=
"name"
value=
"MavenRepo"
/>
<option
name=
"url"
value=
"https://repo.maven.apache.org/maven2/"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"maven"
/>
<option
name=
"name"
value=
"maven"
/>
<option
name=
"url"
value=
"https://git.dankal.cn/lihuaikun/androidlibrary/raw/master"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"BintrayJCenter"
/>
<option
name=
"name"
value=
"BintrayJCenter"
/>
<option
name=
"url"
value=
"https://jcenter.bintray.com/"
/>
</remote-repository>
<remote-repository>
<option
name=
"id"
value=
"Google"
/>
<option
name=
"name"
value=
"Google"
/>
<option
name=
"url"
value=
"https://dl.google.com/dl/android/maven2/"
/>
</remote-repository>
</component>
</project>
\ No newline at end of file
Launcher3/build.gradle
View file @
742053e9
...
...
@@ -103,7 +103,7 @@ ext {
GITHUB_REPO_PATH
=
"../../androidlibrary"
PUBLISH_GROUP_ID
=
'cn.dankal.android'
PUBLISH_ARTIFACT_ID
=
'launcher'
PUBLISH_VERSION
=
'1.4.
4.8
'
PUBLISH_VERSION
=
'1.4.
5.7
'
}
uploadArchives
{
...
...
Launcher3/src/main/java/com/android/launcher3/FastBitmapDrawable.java
View file @
742053e9
...
...
@@ -33,6 +33,7 @@ import android.graphics.PorterDuffColorFilter;
import
android.graphics.Rect
;
import
android.graphics.RectF
;
import
android.graphics.drawable.Drawable
;
import
android.util.Log
;
import
android.util.Property
;
import
android.util.SparseArray
;
...
...
@@ -168,11 +169,13 @@ public class FastBitmapDrawable extends Drawable {
//
canvas
.
drawBitmap
(
mBitmap
,
null
,
bounds
,
mPaint
);
Log
.
i
(
TAG
,
"drawInternal___total="
+
LauncherManager
.
getInstance
().
getAppInfo
().
size
());
if
(
info
!=
null
&&
info
.
getIntent
()
!=
null
)
{
if
(
info
!=
null
&&
info
.
getIntent
()
!=
null
)
{
ManagementInfo
managementInfo
=
LauncherManager
.
getInstance
().
getManageAppInfo
(
info
.
getIntent
().
getComponent
().
getPackageName
());
if
(
managementInfo
!=
null
)
{
Log
.
i
(
TAG
,
"drawInternal___packageName="
+
managementInfo
.
getPackageName
()
+
" type="
+
managementInfo
.
getUseType
());
if
(
managementInfo
.
getLock
()
==
ColumnDef
.
LockApp
.
LOCKED
)
{
...
...
Launcher3/src/main/java/com/android/launcher3/Launcher.java
View file @
742053e9
...
...
@@ -36,6 +36,7 @@ import android.animation.ObjectAnimator;
import
android.animation.ValueAnimator
;
import
android.annotation.SuppressLint
;
import
android.annotation.TargetApi
;
import
android.app.Activity
;
import
android.app.ActivityOptions
;
import
android.appwidget.AppWidgetHostView
;
import
android.appwidget.AppWidgetManager
;
...
...
@@ -99,6 +100,7 @@ import android.view.Menu;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewTreeObserver
;
import
android.view.WindowManager
;
import
android.view.accessibility.AccessibilityEvent
;
import
android.view.animation.OvershootInterpolator
;
import
android.widget.FrameLayout
;
...
...
@@ -473,7 +475,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
PermissionUtil
.
putAutoStartUp
(
this
);
}
UIExecutor
.
postRunableDelay
(
new
Runnable
()
{
/*
UIExecutor.postRunableDelay(new Runnable() {
@Override
public void run() {
if (LauncherManager.mCustomDialog != null) {
...
...
@@ -482,7 +484,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
Log.i("launch_debug_show", "关闭了进度条=" + Thread.currentThread());
}
}
},
2000
);
}, 2000);
*/
}
private
long
mLastTime
;
...
...
@@ -1003,6 +1005,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
mStateManager
.
getState
().
containerType
,
-
1
);
getUserEventDispatcher
().
startSession
();
Log
.
i
(
"launch_debug_show"
,
"logOnDelayedResume"
);
Activity
currentActivity
=
this
;
if
(!
currentActivity
.
hasWindowFocus
())
{
View
view
=
currentActivity
.
getWindow
().
getDecorView
();
view
.
setFocusable
(
true
);
view
.
setFocusableInTouchMode
(
true
);
view
.
requestFocus
();
}
UIExecutor
.
postRunableDelay
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -1012,7 +1021,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
Log
.
i
(
"launch_debug_show"
,
"关闭了进度条="
+
Thread
.
currentThread
());
}
}
},
2
000
);
},
6
000
);
//LauncherManager.getInstance().changeExitState(false);//开启管制
if
(
SystemUtils
.
isOPPO
())
{
...
...
@@ -1080,6 +1089,19 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
@Override
public
void
onWindowFocusChanged
(
boolean
hasFocus
)
{
super
.
onWindowFocusChanged
(
hasFocus
);
if
(
hasFocus
)
{
Log
.
i
(
"onWindowFocusChanged"
,
"------------------------------绘制完毕"
);
UIExecutor
.
postRunableDelay
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
LauncherManager
.
mCustomDialog
!=
null
)
{
LauncherManager
.
mCustomDialog
.
dismiss
();
LauncherManager
.
mCustomDialog
=
null
;
Log
.
i
(
"launch_debug_show"
,
"关闭了进度条="
+
Thread
.
currentThread
());
}
}
},
1000
);
}
mStateManager
.
onWindowFocusChanged
();
}
...
...
Launcher3/src/main/java/com/android/launcher3/accessibility/ListenerAppService.java
View file @
742053e9
...
...
@@ -287,6 +287,11 @@ public class ListenerAppService extends Service {
}
}
}
else
{
//没有管制,直接显示默认桌面app
if
(
LauncherManager
.
mCustomDialog
!=
null
)
{
LauncherManager
.
mCustomDialog
.
dismiss
();
LauncherManager
.
mCustomDialog
=
null
;
Log
.
i
(
"launch_debug_show"
,
"关闭了进度条="
+
Thread
.
currentThread
());
}
PermissionUtil
.
initLauncherIconIsShow
(
context
,
true
);
}
}
else
if
(
Intent
.
ACTION_SCREEN_OFF
.
equals
(
action
))
{
...
...
@@ -311,10 +316,10 @@ public class ListenerAppService extends Service {
}
private
void
showProgress
(
Context
context
)
{
try
{
if
(
SystemUtils
.
isMEIZU
())
{
return
;
}
try
{
if
(
LauncherManager
.
mCustomDialog
==
null
)
{
LauncherManager
.
mCustomDialog
=
new
CustomDialog
(
context
.
getApplicationContext
(),
R
.
layout
.
activity_clock_alarm
);
LauncherManager
.
mCustomDialog
.
show
();
...
...
@@ -332,6 +337,7 @@ public class ListenerAppService extends Service {
private
UsageStatsManager
usageStatsManager
;
private
PackageManager
mPackageManager
;
private
volatile
String
mLastPackage
=
""
;
public
CheckAppAsyncTask
(
WeakHandler
handler
,
Context
context
)
{
...
...
@@ -374,6 +380,19 @@ public class ListenerAppService extends Service {
// 过滤重复的
if
(
stats
.
get
(
j
).
getLastTimeUsed
()
<
lastUseAppControlTimeStamp
&&
lastUseAppControlTimeStamp
>
0
)
{
topActivity
=
stats
.
get
(
j
).
getPackageName
();
ManagementInfo
appinfo
=
LauncherManager
.
getInstance
().
getManageAppInfo
(
topActivity
);
if
(
appinfo
!=
null
)
{
if
(
appinfo
.
getLock
()
!=
ColumnDef
.
LockApp
.
UNLOCKED
)
{
if
(!
mLastPackage
.
equals
(
topActivity
))
lastUseAppControlTimeStamp
=
0
;
}
int
type
=
LauncherManager
.
getInstance
().
canUse
(
topActivity
);
if
(
type
<
0
)
{
if
(!
mLastPackage
.
equals
(
topActivity
))
lastUseAppControlTimeStamp
=
0
;
}
}
return
-
1
;
}
topActivity
=
stats
.
get
(
j
).
getPackageName
();
...
...
@@ -405,6 +424,9 @@ public class ListenerAppService extends Service {
if
(!
LauncherManager
.
getInstance
().
isSafePackageName
(
topActivity
)
&&
!
LauncherManager
.
getInstance
().
isSystemPackageName
(
topActivity
))
{
if
(
appinfo
!=
null
)
{
if
(!
mLastPackage
.
equals
(
topActivity
))
{
mLastPackage
=
topActivity
;
}
if
(
appinfo
.
getLock
()
==
ColumnDef
.
LockApp
.
LOCKED
)
{
return
APP_LOCKED
;
}
else
if
(
appinfo
.
getUseType
()
==
ColumnDef
.
AppUseType
.
UNCLASS_TYPE
)
{
...
...
Launcher3/src/main/java/com/android/launcher3/accessibility/PermissionOpenAccessiblityService.java
View file @
742053e9
...
...
@@ -197,6 +197,7 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
}
public
void
recycle
(
AccessibilityEvent
event
,
AccessibilityNodeInfo
info
)
{
try
{
if
(
info
.
getChildCount
()
==
0
)
{
Log
.
i
(
TAG_TOW
,
"child widget----------------------------"
+
info
.
getClassName
());
Log
.
i
(
TAG_TOW
,
"showDialog:"
+
info
.
canOpenPopup
());
...
...
@@ -226,6 +227,9 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
e
.
printStackTrace
();
PermissionUtil
.
isSystemUI
=
false
;
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
}
Launcher3/src/main/java/com/android/launcher3/debug/CustomDialog.java
View file @
742053e9
...
...
@@ -7,11 +7,14 @@ import android.os.Build;
import
android.os.Bundle
;
import
android.view.KeyEvent
;
import
android.view.LayoutInflater
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.WindowManager
;
import
com.android.launcher3.R
;
import
androidx.annotation.NonNull
;
/**
* Author: roczheng
* Date: 2019/11/28
...
...
@@ -24,7 +27,7 @@ public class CustomDialog extends AlertDialog {
private
View
mDialogView
;
public
CustomDialog
(
Context
context
,
int
resource
)
{
super
(
context
,
R
.
style
.
Theme_AppCompat_Dialog
);
//加载dialog的样式
super
(
context
,
R
.
style
.
Dialog_Fullscreen
);
//加载dialog的样式
this
.
mContext
=
context
;
this
.
mResource
=
resource
;
}
...
...
@@ -33,24 +36,35 @@ public class CustomDialog extends AlertDialog {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
//6.0
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
getWindow
().
setType
(
WindowManager
.
LayoutParams
.
TYPE_APPLICATION_OVERLAY
);
}
else
{
}
else
{
getWindow
().
setType
(
WindowManager
.
LayoutParams
.
TYPE_PHONE
);
}
}
else
{
getWindow
().
setType
(
WindowManager
.
LayoutParams
.
TYPE_SYSTEM_ALERT
);
}
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_NOT_TOUCH_MODAL
,
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
);
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
,
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
);
WindowManager
.
LayoutParams
layoutParams
=
new
WindowManager
.
LayoutParams
(
WindowManager
.
LayoutParams
.
MATCH_PARENT
,
WindowManager
.
LayoutParams
.
MATCH_PARENT
);
if
(
mDialogView
!=
null
)
{
setContentView
(
mDialogView
);
}
else
if
(
mResource
!=
0
)
{
mDialogView
=
LayoutInflater
.
from
(
mContext
).
inflate
(
mResource
,
null
);
mDialogView
.
setLayoutParams
(
layoutParams
);
setContentView
(
mDialogView
,
layoutParams
);
}
mDialogView
.
setFocusable
(
false
);
mDialogView
.
setFocusableInTouchMode
(
false
);
setCanceledOnTouchOutside
(
false
);
}
@Override
public
boolean
onTouchEvent
(
@NonNull
MotionEvent
event
)
{
return
false
;
}
@Override
...
...
Launcher3/src/main/java/com/android/launcher3/manager/LauncherManager.java
View file @
742053e9
Launcher3/src/main/java/com/android/launcher3/manager/TimeModeManager.java
View file @
742053e9
...
...
@@ -36,6 +36,8 @@ import androidx.collection.ArraySet;
public
class
TimeModeManager
{
public
static
volatile
int
mEndTime
=
1
;
private
static
final
String
TAG
=
"TimeModeManager"
;
private
UsageStatsManager
usageStatsManager
;
private
static
TimeModeManager
mInstance
;
...
...
@@ -189,6 +191,12 @@ public class TimeModeManager {
Logger
.
e
(
TAG
,
String
.
format
(
"this app had use time %d can use time %d \t"
,
hadUseTime
,
canUseTime
));
return
-
2
;
}
//判断今日剩余可玩时间
if
(
mEndTime
<=
0
)
{
return
-
3
;
}
}
else
{
Logger
.
e
(
TAG
,
"not includeTimeRegion"
);
}
...
...
@@ -200,6 +208,7 @@ public class TimeModeManager {
/**
* 获取各个分类的所有app下当天已使用的时长
*
* @return
*/
public
HashMap
<
Integer
,
Long
>
getAppUseTimeStamp
()
{
...
...
Launcher3/src/main/java/com/android/launcher3/model/BgDataModel.java
View file @
742053e9
...
...
@@ -38,6 +38,7 @@ import com.android.launcher3.shortcuts.ShortcutKey;
import
com.android.launcher3.util.ComponentKey
;
import
com.android.launcher3.util.LongArrayMap
;
import
com.android.launcher3.util.MultiHashMap
;
import
com.android.launcher3.util.SystemUtils
;
import
com.google.protobuf.nano.MessageNano
;
import
java.io.FileDescriptor
;
...
...
@@ -144,11 +145,11 @@ public class BgDataModel {
writer
.
println
(
prefix
+
'\t'
+
appWidgets
.
get
(
i
).
toString
());
}
writer
.
println
(
prefix
+
" ---- folder items "
);
for
(
int
i
=
0
;
i
<
folders
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
folders
.
size
();
i
++)
{
writer
.
println
(
prefix
+
'\t'
+
folders
.
valueAt
(
i
).
toString
());
}
writer
.
println
(
prefix
+
" ---- items id map "
);
for
(
int
i
=
0
;
i
<
itemsIdMap
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
itemsIdMap
.
size
();
i
++)
{
writer
.
println
(
prefix
+
'\t'
+
itemsIdMap
.
valueAt
(
i
).
toString
());
}
...
...
@@ -180,7 +181,7 @@ public class BgDataModel {
FolderInfo
fInfo
=
folders
.
valueAt
(
i
);
dtw
=
new
DumpTargetWrapper
(
ContainerType
.
FOLDER
,
folders
.
size
());
dtw
.
writeToDumpTarget
(
fInfo
);
for
(
ShortcutInfo
sInfo
:
fInfo
.
contents
)
{
for
(
ShortcutInfo
sInfo
:
fInfo
.
contents
)
{
DumpTargetWrapper
child
=
new
DumpTargetWrapper
(
sInfo
);
child
.
writeToDumpTarget
(
sInfo
);
dtw
.
add
(
child
);
...
...
Launcher3/src/main/java/com/android/launcher3/notification/NotificationItemView.java
View file @
742053e9
...
...
@@ -94,6 +94,9 @@ public class NotificationItemView {
}
public
void
inverseGutterMargin
()
{
if
(
mGutter
==
null
)
{
return
;
}
MarginLayoutParams
lp
=
(
MarginLayoutParams
)
mGutter
.
getLayoutParams
();
int
top
=
lp
.
topMargin
;
lp
.
topMargin
=
lp
.
bottomMargin
;
...
...
Launcher3/src/main/res/layout/activity_clock_alarm.xml
View file @
742053e9
...
...
@@ -2,6 +2,7 @@
<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:id=
"@+id/cl_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
...
...
@@ -12,6 +13,8 @@
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
android:focusable=
"false"
android:focusableInTouchMode=
"false"
app:layout_constraintBottom_toBottomOf=
"parent"
/>
...
...
Launcher3/src/main/res/values/styles.xml
View file @
742053e9
...
...
@@ -198,4 +198,11 @@
<style
name=
"LockScreenStyle"
parent=
"AppTheme"
>
<item
name=
"android:windowFullscreen"
>
true
</item>
</style>
<style
name=
"Dialog_Fullscreen"
>
<item
name=
"android:windowFullscreen"
>
true
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
<item
name=
"android:windowCloseOnTouchOutside"
>
true
</item>
<item
name=
"android:windowBackground"
>
@android:color/transparent
</item>
</style>
</resources>
app/build.gradle
View file @
742053e9
...
...
@@ -47,5 +47,6 @@ dependencies {
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
implementation
project
(
':Launcher3'
)
implementation
'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation
"com.alibaba:fastjson:1.1.54.android"
// api 'cn.dankal.android:launcher:1.0.4'
}
app/src/main/java/com/dankal/dankal_launcher/AppTimeBean.kt
0 → 100644
View file @
742053e9
package
com.dankal.dankal_launcher
/**
* Author: roczheng
* Date: 2020/9/8
* Time: 15:38
* Description:
*/
class
AppTimeBean
{
var
list
:
AppTimeBeanList
?
=
null
class
AppTimeBeanList
{
var
game_time
:
Long
?
=
0
var
rest_time
:
Int
?
=
0
var
uuid
:
String
?
=
""
var
type
:
String
?
=
""
var
list
:
List
<
String
>?
=
null
}
}
\ No newline at end of file
app/src/main/java/com/dankal/dankal_launcher/PackageManageActivity.java
View file @
742053e9
...
...
@@ -21,6 +21,7 @@ import android.view.accessibility.AccessibilityEvent;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.alibaba.fastjson.JSONObject
;
import
com.android.launcher3.accessibility.DeviceReceiver
;
import
com.android.launcher3.accessibility.StopRunReceiver
;
import
com.android.launcher3.manager.ColumnDef
;
...
...
@@ -326,16 +327,59 @@ public class PackageManageActivity extends Activity {
// int week = calendar.get(Calendar.DAY_OF_WEEK);
//
// Logger.e(TAG, week + "\t" + (calendar.getFirstDayOfWeek() == Calendar.SUNDAY));
List
<
Long
>
regions
=
new
ArrayList
<>();
/*
List<Long> regions = new ArrayList<>();
regions
.
add
(
Long
.
valueOf
(
0
*
3600
));
regions
.
add
(
Long
.
valueOf
(
12
*
3600
));
regions.add(Long.valueOf(0));
regions.add(Long.valueOf(3600));
regions
.
add
(
Long
.
valueOf
(
14
*
3600
));
regions
.
add
(
Long
.
valueOf
(
15
*
3600
+
(
12
*
60
)));
regions.add(Long.valueOf(3600));
regions.add(Long.valueOf(7200));
regions.add(Long.valueOf(28800));
regions.add(Long.valueOf(32400));
regions.add(Long.valueOf(32400));
regions.add(Long.valueOf(36000));
regions.add(Long.valueOf(36000 ));
regions.add(Long.valueOf(39600 ));
regions.add(Long.valueOf( 39600));
regions.add(Long.valueOf(43200));
regions.add(Long.valueOf(43200 ));
regions.add(Long.valueOf(46800 ));
regions.add(Long.valueOf( 46800));
regions.add(Long.valueOf( 50400));
regions.add(Long.valueOf(50400 ));
regions.add(Long.valueOf(54000 ));
regions.add(Long.valueOf( 54000));
regions.add(Long.valueOf( 57600));
regions.add(Long.valueOf(57600 ));
regions.add(Long.valueOf(61200 ));
regions.add(Long.valueOf( 61200));
regions.add(Long.valueOf(64800));
regions.add(Long.valueOf(64800 ));
regions.add(Long.valueOf(68400 ));
regions.add(Long.valueOf( 68400));
regions.add(Long.valueOf( 72000));
regions.add(Long.valueOf(72000 ));
regions.add(Long.valueOf(75600 ));
regions.add(Long.valueOf(75600));
regions.add(Long.valueOf( 79200));
regions.add(Long.valueOf(79200 ));
regions.add(Long.valueOf(82800));
regions
.
add
(
Long
.
valueOf
(
16
*
3600
));
regions
.
add
(
Long
.
valueOf
(
19
*
3600
));
TimeConfig config = new TimeConfig.Builder(ColumnDef.TimeManager.WORK_DAY)
.lockScreenMode(ColumnDef.LockScreen.MODE_REST)
...
...
@@ -344,7 +388,9 @@ public class PackageManageActivity extends Activity {
.build();
//
LauncherManager.getInstance().addWorkMode(config);
LauncherManager
.
getInstance
().
setCurrentWorkMode
(
ColumnDef
.
TimeManager
.
WORK_DAY
);
LauncherManager.getInstance().setCurrentWorkMode(ColumnDef.TimeManager.WORK_DAY);*/
initTime
();
// handler.sendEmptyMessageDelayed(0, 15000);
...
...
@@ -374,6 +420,38 @@ public class PackageManageActivity extends Activity {
});
}
private
void
initTime
()
{
AppTimeBean
appTimeBean
=
(
AppTimeBean
)
JSONObject
.
parse
(
getString
(
R
.
string
.
abc
));
List
<
Long
>
regions
=
new
ArrayList
<>();
if
(
appTimeBean
.
getList
()
!=
null
&&
appTimeBean
.
getList
().
getList
()
!=
null
)
{
for
(
int
i
=
0
;
i
<
appTimeBean
.
getList
().
getList
().
size
();
i
++)
{
if
(
appTimeBean
.
getList
().
getList
().
get
(
i
).
equals
(
"1"
))
{
regions
.
add
((
long
)
(
i
*
3600
));
//起始时间 9*3600=当天的早上九点
regions
.
add
((
long
)
((
i
+
1
)
*
3600
));
//结束时间
}
}
}
int
mode
;
mode
=
ColumnDef
.
TimeManager
.
WORK_DAY
;
//设置管控配置
TimeConfig
config
=
new
TimeConfig
.
Builder
(
mode
)
//管控类型 WORK_DAY=工作日 WEEK_RESET=周末 HOLIDAY_MODE=假日
.
lockScreenMode
(
ColumnDef
.
LockScreen
.
MODE_REST
)
//指定不包含regions的时间段中的锁屏模式
.
addUseRegion
(
regions
)
//用户可使用的时间段
.
addAppTypeConfig
(
ColumnDef
.
AppUseType
.
GAME_LOCK_TYPE
,
46800
)
//指定某一类别的app每天可使用的最大时长
.
build
();
//添加管控配置
LauncherManager
.
getInstance
().
addWorkMode
(
config
);
//设置当前的工作模式(主要是针对假日模式,其他两个模式会根据当前时间自动变换,
//在假日模式过期之后需要主动调用此方法设置为其他模式)
LauncherManager
.
getInstance
().
setCurrentWorkMode
(
mode
);
}
private
void
toggleNotificationListenerService
()
{
PackageManager
pm
=
getPackageManager
();
pm
.
setComponentEnabledSetting
(
new
ComponentName
(
this
,
NotificationListener2
.
class
),
...
...
app/src/main/res/values/strings.xml
View file @
742053e9
<resources>
<string
name=
"app_name"
>
倍知守护孩子端
</string>
<string
name=
"abc"
>
{"list":{"game_time":150,"list":["1","1","0","0","0","0","0","0","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","0"],"rest_time":0,"type":"work","uuid":"531c28693ff26688803f9174666f21c0"}}
</string>
</resources>
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