Commit 742053e9 by 郑鹏

修复bug

parent 4e12ceca
......@@ -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>
......
<?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 {
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 {
......
......@@ -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) {
......
......@@ -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());
}
}
}, 2000);
}, 6000);
//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();
}
......
......@@ -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) {
......
......@@ -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();
}
}
}
......@@ -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
......
......@@ -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() {
......
......@@ -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);
......
......@@ -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;
......
......@@ -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"
/>
......
......@@ -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>
......@@ -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'
}
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;
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),
......
<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>
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