Commit 742053e9 by 郑鹏

修复bug

parent 4e12ceca
...@@ -4,10 +4,8 @@ ...@@ -4,10 +4,8 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="delegatedBuild" value="false" /> <option name="delegatedBuild" value="false" />
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules"> <option name="modules">
...@@ -18,7 +16,6 @@ ...@@ -18,7 +16,6 @@
</set> </set>
</option> </option>
<option name="resolveModulePerSourceSet" value="false" /> <option name="resolveModulePerSourceSet" value="false" />
<option name="testRunner" value="PLATFORM" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>
......
<?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
...@@ -103,7 +103,7 @@ ext { ...@@ -103,7 +103,7 @@ ext {
GITHUB_REPO_PATH = "../../androidlibrary" GITHUB_REPO_PATH = "../../androidlibrary"
PUBLISH_GROUP_ID = 'cn.dankal.android' PUBLISH_GROUP_ID = 'cn.dankal.android'
PUBLISH_ARTIFACT_ID = 'launcher' PUBLISH_ARTIFACT_ID = 'launcher'
PUBLISH_VERSION = '1.4.4.8' PUBLISH_VERSION = '1.4.5.7'
} }
uploadArchives { uploadArchives {
......
...@@ -33,6 +33,7 @@ import android.graphics.PorterDuffColorFilter; ...@@ -33,6 +33,7 @@ import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.Property; import android.util.Property;
import android.util.SparseArray; import android.util.SparseArray;
...@@ -168,11 +169,13 @@ public class FastBitmapDrawable extends Drawable { ...@@ -168,11 +169,13 @@ public class FastBitmapDrawable extends Drawable {
// //
canvas.drawBitmap(mBitmap, null, bounds, mPaint); 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()); ManagementInfo managementInfo = LauncherManager.getInstance().getManageAppInfo(info.getIntent().getComponent().getPackageName());
if (managementInfo != null) { if (managementInfo != null) {
Log.i(TAG, "drawInternal___packageName=" + managementInfo.getPackageName() + " type=" + managementInfo.getUseType());
if (managementInfo.getLock() == ColumnDef.LockApp.LOCKED) { if (managementInfo.getLock() == ColumnDef.LockApp.LOCKED) {
......
...@@ -36,6 +36,7 @@ import android.animation.ObjectAnimator; ...@@ -36,6 +36,7 @@ import android.animation.ObjectAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager;
...@@ -99,6 +100,7 @@ import android.view.Menu; ...@@ -99,6 +100,7 @@ import android.view.Menu;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent;
import android.view.animation.OvershootInterpolator; import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout; import android.widget.FrameLayout;
...@@ -473,7 +475,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, ...@@ -473,7 +475,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
PermissionUtil.putAutoStartUp(this); PermissionUtil.putAutoStartUp(this);
} }
UIExecutor.postRunableDelay(new Runnable() { /* UIExecutor.postRunableDelay(new Runnable() {
@Override @Override
public void run() { public void run() {
if (LauncherManager.mCustomDialog != null) { if (LauncherManager.mCustomDialog != null) {
...@@ -482,7 +484,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, ...@@ -482,7 +484,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
Log.i("launch_debug_show", "关闭了进度条=" + Thread.currentThread()); Log.i("launch_debug_show", "关闭了进度条=" + Thread.currentThread());
} }
} }
}, 2000); }, 2000);*/
} }
private long mLastTime; private long mLastTime;
...@@ -1003,6 +1005,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, ...@@ -1003,6 +1005,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
mStateManager.getState().containerType, -1); mStateManager.getState().containerType, -1);
getUserEventDispatcher().startSession(); getUserEventDispatcher().startSession();
Log.i("launch_debug_show", "logOnDelayedResume"); 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() { UIExecutor.postRunableDelay(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -1012,7 +1021,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, ...@@ -1012,7 +1021,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
Log.i("launch_debug_show", "关闭了进度条=" + Thread.currentThread()); Log.i("launch_debug_show", "关闭了进度条=" + Thread.currentThread());
} }
} }
}, 2000); }, 6000);
//LauncherManager.getInstance().changeExitState(false);//开启管制 //LauncherManager.getInstance().changeExitState(false);//开启管制
if (SystemUtils.isOPPO()) { if (SystemUtils.isOPPO()) {
...@@ -1080,6 +1089,19 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, ...@@ -1080,6 +1089,19 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
@Override @Override
public void onWindowFocusChanged(boolean hasFocus) { public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(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(); mStateManager.onWindowFocusChanged();
} }
......
...@@ -287,6 +287,11 @@ public class ListenerAppService extends Service { ...@@ -287,6 +287,11 @@ public class ListenerAppService extends Service {
} }
} }
} else {//没有管制,直接显示默认桌面app } else {//没有管制,直接显示默认桌面app
if (LauncherManager.mCustomDialog != null) {
LauncherManager.mCustomDialog.dismiss();
LauncherManager.mCustomDialog = null;
Log.i("launch_debug_show", "关闭了进度条=" + Thread.currentThread());
}
PermissionUtil.initLauncherIconIsShow(context, true); PermissionUtil.initLauncherIconIsShow(context, true);
} }
} else if (Intent.ACTION_SCREEN_OFF.equals(action)) { } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
...@@ -311,10 +316,10 @@ public class ListenerAppService extends Service { ...@@ -311,10 +316,10 @@ public class ListenerAppService extends Service {
} }
private void showProgress(Context context) { private void showProgress(Context context) {
if (SystemUtils.isMEIZU()) {
return;
}
try { try {
if (SystemUtils.isMEIZU()) {
return;
}
if (LauncherManager.mCustomDialog == null) { if (LauncherManager.mCustomDialog == null) {
LauncherManager.mCustomDialog = new CustomDialog(context.getApplicationContext(), R.layout.activity_clock_alarm); LauncherManager.mCustomDialog = new CustomDialog(context.getApplicationContext(), R.layout.activity_clock_alarm);
LauncherManager.mCustomDialog.show(); LauncherManager.mCustomDialog.show();
...@@ -332,6 +337,7 @@ public class ListenerAppService extends Service { ...@@ -332,6 +337,7 @@ public class ListenerAppService extends Service {
private UsageStatsManager usageStatsManager; private UsageStatsManager usageStatsManager;
private PackageManager mPackageManager; private PackageManager mPackageManager;
private volatile String mLastPackage = "";
public CheckAppAsyncTask(WeakHandler handler, Context context) { public CheckAppAsyncTask(WeakHandler handler, Context context) {
...@@ -374,6 +380,19 @@ public class ListenerAppService extends Service { ...@@ -374,6 +380,19 @@ public class ListenerAppService extends Service {
// 过滤重复的 // 过滤重复的
if (stats.get(j).getLastTimeUsed() < lastUseAppControlTimeStamp && lastUseAppControlTimeStamp > 0) { 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; return -1;
} }
topActivity = stats.get(j).getPackageName(); topActivity = stats.get(j).getPackageName();
...@@ -405,6 +424,9 @@ public class ListenerAppService extends Service { ...@@ -405,6 +424,9 @@ public class ListenerAppService extends Service {
if (!LauncherManager.getInstance().isSafePackageName(topActivity) && !LauncherManager.getInstance().isSystemPackageName(topActivity)) { if (!LauncherManager.getInstance().isSafePackageName(topActivity) && !LauncherManager.getInstance().isSystemPackageName(topActivity)) {
if (appinfo != null) { if (appinfo != null) {
if (!mLastPackage.equals(topActivity)) {
mLastPackage = topActivity;
}
if (appinfo.getLock() == ColumnDef.LockApp.LOCKED) { if (appinfo.getLock() == ColumnDef.LockApp.LOCKED) {
return APP_LOCKED; return APP_LOCKED;
} else if (appinfo.getUseType() == ColumnDef.AppUseType.UNCLASS_TYPE) { } else if (appinfo.getUseType() == ColumnDef.AppUseType.UNCLASS_TYPE) {
......
...@@ -197,34 +197,38 @@ public class PermissionOpenAccessiblityService extends AccessibilityService { ...@@ -197,34 +197,38 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
} }
public void recycle(AccessibilityEvent event, AccessibilityNodeInfo info) { public void recycle(AccessibilityEvent event, AccessibilityNodeInfo info) {
if (info.getChildCount() == 0) { try {
Log.i(TAG_TOW, "child widget----------------------------" + info.getClassName()); if (info.getChildCount() == 0) {
Log.i(TAG_TOW, "showDialog:" + info.canOpenPopup()); Log.i(TAG_TOW, "child widget----------------------------" + info.getClassName());
Log.i(TAG_TOW, "Text:" + info.getText()); Log.i(TAG_TOW, "showDialog:" + info.canOpenPopup());
Log.i(TAG_TOW, "windowId:" + info.getWindowId()); Log.i(TAG_TOW, "Text:" + info.getText());
Log.i(TAG_TOW, "id:" + info.getViewIdResourceName()); Log.i(TAG_TOW, "windowId:" + info.getWindowId());
} else { Log.i(TAG_TOW, "id:" + info.getViewIdResourceName());
for (int i = 0; i < info.getChildCount(); i++) { } else {
if (info.getChild(i) != null) { for (int i = 0; i < info.getChildCount(); i++) {
recycle(event, info.getChild(i)); if (info.getChild(i) != null) {
recycle(event, info.getChild(i));
}
} }
} }
}
try { try {
Log.i("reqeustAutoStartUp", "当前界面包名:" + event.getPackageName() + "\n当前应用的包名:" + getApplicationContext().getPackageName()); Log.i("reqeustAutoStartUp", "当前界面包名:" + event.getPackageName() + "\n当前应用的包名:" + getApplicationContext().getPackageName());
Log.i("reqeustAutoStartUp", "当前界面类名:" + event.getClassName() + "\n当前应用类:" + "android.widget.LinearLayout"); Log.i("reqeustAutoStartUp", "当前界面类名:" + event.getClassName() + "\n当前应用类:" + "android.widget.LinearLayout");
//判断当前界面 //判断当前界面
if (event.getPackageName().equals("android")) { if (event.getPackageName().equals("android")) {
PermissionUtil.isSystemUI = true; PermissionUtil.isSystemUI = true;
} else { } else {
PermissionUtil.isSystemUI = false;
}
} catch (Exception e) {
e.printStackTrace();
PermissionUtil.isSystemUI = false; PermissionUtil.isSystemUI = false;
} }
} catch (Exception e) { }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
PermissionUtil.isSystemUI = false;
} }
} }
......
...@@ -7,11 +7,14 @@ import android.os.Build; ...@@ -7,11 +7,14 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import com.android.launcher3.R; import com.android.launcher3.R;
import androidx.annotation.NonNull;
/** /**
* Author: roczheng * Author: roczheng
* Date: 2019/11/28 * Date: 2019/11/28
...@@ -24,7 +27,7 @@ public class CustomDialog extends AlertDialog { ...@@ -24,7 +27,7 @@ public class CustomDialog extends AlertDialog {
private View mDialogView; private View mDialogView;
public CustomDialog(Context context, int resource) { 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.mContext = context;
this.mResource = resource; this.mResource = resource;
} }
...@@ -33,24 +36,35 @@ public class CustomDialog extends AlertDialog { ...@@ -33,24 +36,35 @@ public class CustomDialog extends AlertDialog {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {//6.0 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); getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
}else { } else {
getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE); getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
} }
} else { } else {
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); 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_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); WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
if (mDialogView != null) { if (mDialogView != null) {
setContentView(mDialogView); setContentView(mDialogView);
} else if (mResource != 0) { } else if (mResource != 0) {
mDialogView = LayoutInflater.from(mContext).inflate(mResource, null); mDialogView = LayoutInflater.from(mContext).inflate(mResource, null);
mDialogView.setLayoutParams(layoutParams);
setContentView(mDialogView, layoutParams); setContentView(mDialogView, layoutParams);
} }
mDialogView.setFocusable(false);
mDialogView.setFocusableInTouchMode(false);
setCanceledOnTouchOutside(false); setCanceledOnTouchOutside(false);
}
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
return false;
} }
@Override @Override
......
...@@ -937,7 +937,7 @@ public class LauncherManager { ...@@ -937,7 +937,7 @@ public class LauncherManager {
intent.setComponent(cn); intent.setComponent(cn);
Uri uri = Uri.parse("cn.dankal.bzshchild.ui.SplashActivity"); Uri uri = Uri.parse("cn.dankal.bzshchild.ui.SplashActivity");
/* ComponentName cn = new ComponentName("com.dankal.dankal_launcher", "com.dankal.dankal_launcher.PackageManageActivity"); /* ComponentName cn = new ComponentName("com.dankal.dankal_launcher", "com.dankal.dankal_launcher.PackageManageActivity");
intent.setComponent(cn); intent.setComponent(cn);
Uri uri = Uri.parse("com.dankal.dankal_launcher.PackageManageActivity");*/ Uri uri = Uri.parse("com.dankal.dankal_launcher.PackageManageActivity");*/
......
...@@ -36,6 +36,8 @@ import androidx.collection.ArraySet; ...@@ -36,6 +36,8 @@ import androidx.collection.ArraySet;
public class TimeModeManager { public class TimeModeManager {
public static volatile int mEndTime = 1;
private static final String TAG = "TimeModeManager"; private static final String TAG = "TimeModeManager";
private UsageStatsManager usageStatsManager; private UsageStatsManager usageStatsManager;
private static TimeModeManager mInstance; private static TimeModeManager mInstance;
...@@ -189,6 +191,12 @@ public class TimeModeManager { ...@@ -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)); Logger.e(TAG, String.format("this app had use time %d can use time %d \t", hadUseTime, canUseTime));
return -2; return -2;
} }
//判断今日剩余可玩时间
if (mEndTime <= 0) {
return -3;
}
} else { } else {
Logger.e(TAG, "not includeTimeRegion"); Logger.e(TAG, "not includeTimeRegion");
} }
...@@ -200,6 +208,7 @@ public class TimeModeManager { ...@@ -200,6 +208,7 @@ public class TimeModeManager {
/** /**
* 获取各个分类的所有app下当天已使用的时长 * 获取各个分类的所有app下当天已使用的时长
*
* @return * @return
*/ */
public HashMap<Integer, Long> getAppUseTimeStamp() { public HashMap<Integer, Long> getAppUseTimeStamp() {
......
...@@ -38,6 +38,7 @@ import com.android.launcher3.shortcuts.ShortcutKey; ...@@ -38,6 +38,7 @@ import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.LongArrayMap; import com.android.launcher3.util.LongArrayMap;
import com.android.launcher3.util.MultiHashMap; import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.SystemUtils;
import com.google.protobuf.nano.MessageNano; import com.google.protobuf.nano.MessageNano;
import java.io.FileDescriptor; import java.io.FileDescriptor;
...@@ -124,7 +125,7 @@ public class BgDataModel { ...@@ -124,7 +125,7 @@ public class BgDataModel {
} }
public synchronized void dump(String prefix, FileDescriptor fd, PrintWriter writer, public synchronized void dump(String prefix, FileDescriptor fd, PrintWriter writer,
String[] args) { String[] args) {
if (Arrays.asList(args).contains("--proto")) { if (Arrays.asList(args).contains("--proto")) {
dumpProto(prefix, fd, writer, args); dumpProto(prefix, fd, writer, args);
return; return;
...@@ -144,11 +145,11 @@ public class BgDataModel { ...@@ -144,11 +145,11 @@ public class BgDataModel {
writer.println(prefix + '\t' + appWidgets.get(i).toString()); writer.println(prefix + '\t' + appWidgets.get(i).toString());
} }
writer.println(prefix + " ---- folder items "); 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 + '\t' + folders.valueAt(i).toString());
} }
writer.println(prefix + " ---- items id map "); 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()); writer.println(prefix + '\t' + itemsIdMap.valueAt(i).toString());
} }
...@@ -165,7 +166,7 @@ public class BgDataModel { ...@@ -165,7 +166,7 @@ public class BgDataModel {
} }
private synchronized void dumpProto(String prefix, FileDescriptor fd, PrintWriter writer, private synchronized void dumpProto(String prefix, FileDescriptor fd, PrintWriter writer,
String[] args) { String[] args) {
// Add top parent nodes. (L1) // Add top parent nodes. (L1)
DumpTargetWrapper hotseat = new DumpTargetWrapper(ContainerType.HOTSEAT, 0); DumpTargetWrapper hotseat = new DumpTargetWrapper(ContainerType.HOTSEAT, 0);
...@@ -180,7 +181,7 @@ public class BgDataModel { ...@@ -180,7 +181,7 @@ public class BgDataModel {
FolderInfo fInfo = folders.valueAt(i); FolderInfo fInfo = folders.valueAt(i);
dtw = new DumpTargetWrapper(ContainerType.FOLDER, folders.size()); dtw = new DumpTargetWrapper(ContainerType.FOLDER, folders.size());
dtw.writeToDumpTarget(fInfo); dtw.writeToDumpTarget(fInfo);
for(ShortcutInfo sInfo: fInfo.contents) { for (ShortcutInfo sInfo : fInfo.contents) {
DumpTargetWrapper child = new DumpTargetWrapper(sInfo); DumpTargetWrapper child = new DumpTargetWrapper(sInfo);
child.writeToDumpTarget(sInfo); child.writeToDumpTarget(sInfo);
dtw.add(child); dtw.add(child);
...@@ -274,7 +275,7 @@ public class BgDataModel { ...@@ -274,7 +275,7 @@ public class BgDataModel {
MutableInt count = pinnedShortcutCounts.get(pinnedShortcut); MutableInt count = pinnedShortcutCounts.get(pinnedShortcut);
if ((count == null || --count.value == 0) if ((count == null || --count.value == 0)
&& !InstallShortcutReceiver.getPendingShortcuts(context) && !InstallShortcutReceiver.getPendingShortcuts(context)
.contains(pinnedShortcut)) { .contains(pinnedShortcut)) {
DeepShortcutManager.getInstance(context).unpinShortcut(pinnedShortcut); DeepShortcutManager.getInstance(context).unpinShortcut(pinnedShortcut);
} }
// Fall through. // Fall through.
......
...@@ -94,6 +94,9 @@ public class NotificationItemView { ...@@ -94,6 +94,9 @@ public class NotificationItemView {
} }
public void inverseGutterMargin() { public void inverseGutterMargin() {
if (mGutter == null) {
return;
}
MarginLayoutParams lp = (MarginLayoutParams) mGutter.getLayoutParams(); MarginLayoutParams lp = (MarginLayoutParams) mGutter.getLayoutParams();
int top = lp.topMargin; int top = lp.topMargin;
lp.topMargin = lp.bottomMargin; lp.topMargin = lp.bottomMargin;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/cl_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
...@@ -12,6 +13,8 @@ ...@@ -12,6 +13,8 @@
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:focusable="false"
android:focusableInTouchMode="false"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
/> />
......
...@@ -198,4 +198,11 @@ ...@@ -198,4 +198,11 @@
<style name="LockScreenStyle" parent="AppTheme"> <style name="LockScreenStyle" parent="AppTheme">
<item name="android:windowFullscreen">true</item> <item name="android:windowFullscreen">true</item>
</style> </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> </resources>
...@@ -47,5 +47,6 @@ dependencies { ...@@ -47,5 +47,6 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(':Launcher3') implementation project(':Launcher3')
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation "com.alibaba:fastjson:1.1.54.android"
// api 'cn.dankal.android:launcher:1.0.4' // api 'cn.dankal.android:launcher:1.0.4'
} }
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
...@@ -21,6 +21,7 @@ import android.view.accessibility.AccessibilityEvent; ...@@ -21,6 +21,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.alibaba.fastjson.JSONObject;
import com.android.launcher3.accessibility.DeviceReceiver; import com.android.launcher3.accessibility.DeviceReceiver;
import com.android.launcher3.accessibility.StopRunReceiver; import com.android.launcher3.accessibility.StopRunReceiver;
import com.android.launcher3.manager.ColumnDef; import com.android.launcher3.manager.ColumnDef;
...@@ -326,16 +327,59 @@ public class PackageManageActivity extends Activity { ...@@ -326,16 +327,59 @@ public class PackageManageActivity extends Activity {
// int week = calendar.get(Calendar.DAY_OF_WEEK); // int week = calendar.get(Calendar.DAY_OF_WEEK);
// //
// Logger.e(TAG, week + "\t" + (calendar.getFirstDayOfWeek() == Calendar.SUNDAY)); // Logger.e(TAG, week + "\t" + (calendar.getFirstDayOfWeek() == Calendar.SUNDAY));
List<Long> regions = new ArrayList<>(); /* List<Long> regions = new ArrayList<>();
regions.add(Long.valueOf(0));
regions.add(Long.valueOf(3600));
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(0 * 3600)); regions.add(Long.valueOf(64800 ));
regions.add(Long.valueOf(12 * 3600)); regions.add(Long.valueOf(68400 ));
regions.add(Long.valueOf(14 * 3600)); regions.add(Long.valueOf( 68400));
regions.add(Long.valueOf(15 * 3600 + (12 * 60))); 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) TimeConfig config = new TimeConfig.Builder(ColumnDef.TimeManager.WORK_DAY)
.lockScreenMode(ColumnDef.LockScreen.MODE_REST) .lockScreenMode(ColumnDef.LockScreen.MODE_REST)
...@@ -344,7 +388,9 @@ public class PackageManageActivity extends Activity { ...@@ -344,7 +388,9 @@ public class PackageManageActivity extends Activity {
.build(); .build();
// //
LauncherManager.getInstance().addWorkMode(config); LauncherManager.getInstance().addWorkMode(config);
LauncherManager.getInstance().setCurrentWorkMode(ColumnDef.TimeManager.WORK_DAY); LauncherManager.getInstance().setCurrentWorkMode(ColumnDef.TimeManager.WORK_DAY);*/
initTime();
// handler.sendEmptyMessageDelayed(0, 15000); // handler.sendEmptyMessageDelayed(0, 15000);
...@@ -374,6 +420,38 @@ public class PackageManageActivity extends Activity { ...@@ -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() { private void toggleNotificationListenerService() {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
pm.setComponentEnabledSetting(new ComponentName(this, NotificationListener2.class), pm.setComponentEnabledSetting(new ComponentName(this, NotificationListener2.class),
......
<resources> <resources>
<string name="app_name">倍知守护孩子端</string> <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> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment