Commit 7a380a6c authored by jyx's avatar jyx

添加应用外弹出开关

parent 0b3c1526
...@@ -28,9 +28,11 @@ import com.mints.flowbox.keepalive.ScreenWatch; ...@@ -28,9 +28,11 @@ import com.mints.flowbox.keepalive.ScreenWatch;
import com.mints.flowbox.keepalive.WifiStateWatch; import com.mints.flowbox.keepalive.WifiStateWatch;
import com.mints.flowbox.manager.CsjGroMoreManager; import com.mints.flowbox.manager.CsjGroMoreManager;
import com.mints.flowbox.manager.MiitHelper; import com.mints.flowbox.manager.MiitHelper;
import com.mints.flowbox.manager.TrackManager;
import com.mints.flowbox.manager.ad.OwManager; import com.mints.flowbox.manager.ad.OwManager;
import com.mints.flowbox.manager.ad.TzManager; import com.mints.flowbox.manager.ad.TzManager;
import com.mints.flowbox.manager.ad.WnManager; import com.mints.flowbox.manager.ad.WnManager;
import com.mints.flowbox.manager.wifi.WifiDataManager;
import com.mints.flowbox.net.LoanService; import com.mints.flowbox.net.LoanService;
import com.mints.flowbox.ui.activitys.keepalive.ApkActivity; import com.mints.flowbox.ui.activitys.keepalive.ApkActivity;
import com.mints.flowbox.ui.activitys.keepalive.BoostActivity; import com.mints.flowbox.ui.activitys.keepalive.BoostActivity;
...@@ -193,30 +195,32 @@ public class MintsApplication extends BaseApp { ...@@ -193,30 +195,32 @@ public class MintsApplication extends BaseApp {
// Toast.makeText(this, "测试:主进程重启成功", Toast.LENGTH_LONG).show(); // Toast.makeText(this, "测试:主进程重启成功", Toast.LENGTH_LONG).show();
// } // }
// 获取应用外开关
TrackManager.getInstance().getOuterAdConfig();
WifiStateWatch.getInstance(this).begin(new WifiStateWatch.WifiStateListener() { WifiStateWatch.getInstance(this).begin(new WifiStateWatch.WifiStateListener() {
@Override @Override
public void onWifiOpen() { public void onWifiOpen() {
// ToastUtils.show("--> 开启wifi <--");
// 应用在前台,则不展示 // 应用在前台,则不展示
if (ForegroundOrBackground.isForeground2()) { if (ForegroundOrBackground.isForeground2()) {
return; return;
} }
// if (WifiDataManager.INSTANCE.getWifiOn()) { if (WifiDataManager.INSTANCE.getWifiOn()) {
showBoost(); // 跳转去wifi加速
// } showTimingActivity(TimingActivity.TIMING_TYPE_WIFI_BOOST);
}
} }
@Override @Override
public void onWifiClose() { public void onWifiClose() {
// ToastUtils.show("--> 关闭wifi <--");
// 应用在前台,则不展示 // 应用在前台,则不展示
if (ForegroundOrBackground.isForeground2()) { if (ForegroundOrBackground.isForeground2()) {
return; return;
} }
// if (WifiDataManager.INSTANCE.getWifiOff()) { if (WifiDataManager.INSTANCE.getWifiOff()) {
// 跳转网络测速
showTimingActivity(TimingActivity.TIMING_TYPE_SPEED_TEST); showTimingActivity(TimingActivity.TIMING_TYPE_SPEED_TEST);
// } }
} }
}); });
...@@ -224,22 +228,12 @@ public class MintsApplication extends BaseApp { ...@@ -224,22 +228,12 @@ public class MintsApplication extends BaseApp {
ScreenWatch.getInstance(this).begin(new ScreenWatch.ScreenStateListener() { ScreenWatch.getInstance(this).begin(new ScreenWatch.ScreenStateListener() {
@Override @Override
public void onScreenOn() { public void onScreenOn() {
// ToastUtils.show("--> 亮屏 <--");
// if (ForegroundOrBackground.isForeground2() & !ScreenLockerUtils.INSTANCE.isOV()) {
// return;
// }
//
// LogUtil.d("亮屏");
//
// showScreen(); // showScreen();
} }
@Override @Override
public void onScreenOff() { public void onScreenOff() {
// ToastUtils.show("--> 息屏 <--"); // 检测应用是否在前台
// 检测是否在前台及是否是oppo或vivo
if (ForegroundOrBackground.isForeground2()) { if (ForegroundOrBackground.isForeground2()) {
return; return;
} }
...@@ -259,26 +253,13 @@ public class MintsApplication extends BaseApp { ...@@ -259,26 +253,13 @@ public class MintsApplication extends BaseApp {
return; return;
} }
if (WifiDataManager.INSTANCE.getLockOn()) {
showScreen(); showScreen();
} }
}
@Override @Override
public void onUserPresent() { public void onUserPresent() {
// ToastUtils.show("--> 解锁屏幕 <--");
if (ForegroundOrBackground.isForeground2() & !ScreenLockerUtils.INSTANCE.isOV()) {
return;
}
if (PhoneBrandUtils.isOppo() & ScreenLockerUtils.INSTANCE.isOppoScreenLockOpen(MintsApplication.getContext())) {
return;
}
if (PhoneBrandUtils.isVivo() & ScreenLockerUtils.INSTANCE.isVivoScreenLockOpen(MintsApplication.getContext())) {
return;
}
showScreen();
} }
}); });
...@@ -286,8 +267,6 @@ public class MintsApplication extends BaseApp { ...@@ -286,8 +267,6 @@ public class MintsApplication extends BaseApp {
// HomeKeyWatch.getInstance(this).begin(new HomeKeyWatch.HomeKeyStateListener() { // HomeKeyWatch.getInstance(this).begin(new HomeKeyWatch.HomeKeyStateListener() {
// @Override // @Override
// public void onHOME_KEY() { // public void onHOME_KEY() {
//// ToastUtils.show("--> 点击HOME键 <--");
//
// if (ForegroundOrBackground.isForeground2()) { // if (ForegroundOrBackground.isForeground2()) {
// return; // return;
// } // }
...@@ -299,8 +278,6 @@ public class MintsApplication extends BaseApp { ...@@ -299,8 +278,6 @@ public class MintsApplication extends BaseApp {
// //
// @Override // @Override
// public void onRECENT_APPS() { // public void onRECENT_APPS() {
//// ToastUtils.show("--> 最近任务列表 <--");
//
// if (ForegroundOrBackground.isForeground2()) { // if (ForegroundOrBackground.isForeground2()) {
// return; // return;
// } // }
...@@ -312,11 +289,10 @@ public class MintsApplication extends BaseApp { ...@@ -312,11 +289,10 @@ public class MintsApplication extends BaseApp {
// }); // });
// 监听电话状态 // 监听电话状态
PhoneWatch.getInstance(this).begin(new PhoneWatch.PhoneStateListener() { PhoneWatch.getInstance(this).begin(new PhoneWatch.PhoneStateListener() {
@Override @Override
public void onIdle() { public void onIdle() {
// ToastUtils.show("--> 电话挂断 <--");
} }
}); });
...@@ -324,26 +300,23 @@ public class MintsApplication extends BaseApp { ...@@ -324,26 +300,23 @@ public class MintsApplication extends BaseApp {
BatteryWatch.getInstance(this).begin(new BatteryWatch.BatteryStateListener() { BatteryWatch.getInstance(this).begin(new BatteryWatch.BatteryStateListener() {
@Override @Override
public void onCharging() { public void onCharging() {
// ToastUtils.show("--> 正在充电 <--");
if (ForegroundOrBackground.isForeground2()) { if (ForegroundOrBackground.isForeground2()) {
return; return;
} }
// if (WifiDataManager.INSTANCE.getBatteryOn()) { if (WifiDataManager.INSTANCE.getBatteryOn()) {
showScreen(); showScreen();
// } }
} }
@Override @Override
public void onUnCharging() { public void onUnCharging() {
// ToastUtils.show("--> 停止充电 <--");
if (ForegroundOrBackground.isForeground2()) { if (ForegroundOrBackground.isForeground2()) {
return; return;
} }
// if (WifiDataManager.INSTANCE.getBatteryOff()) { if (WifiDataManager.INSTANCE.getBatteryOff()) {
showBoost(); // 跳转省电
// } showTimingActivity(TimingActivity.TIMING_TYPE_SAVE_ELE);
}
} }
}); });
...@@ -351,23 +324,32 @@ public class MintsApplication extends BaseApp { ...@@ -351,23 +324,32 @@ public class MintsApplication extends BaseApp {
PackageWatch.getInstance(this).begin(new PackageWatch.InstallStateListener() { PackageWatch.getInstance(this).begin(new PackageWatch.InstallStateListener() {
@Override @Override
public void onAdded(String pkgName) { public void onAdded(String pkgName) {
if (ForegroundOrBackground.isForeground2()) {
return;
}
if (WifiDataManager.INSTANCE.getInstallApk()) {
showApk(0, pkgName); showApk(0, pkgName);
}
// ToastUtils.show("--> APK安装 <--");
} }
@Override @Override
public void onReplaced(String pkgName) { public void onReplaced(String pkgName) {
showApk(1, pkgName); if (ForegroundOrBackground.isForeground2()) {
return;
// ToastUtils.show("--> APK卸载 <--"); }
if (WifiDataManager.INSTANCE.getUpdateApk()) {
showApk(0, pkgName);
}
} }
@Override @Override
public void onRemoved(String pkgName) { public void onRemoved(String pkgName) {
if (ForegroundOrBackground.isForeground2()) {
return;
}
if (WifiDataManager.INSTANCE.getUnInstallApk()) {
showApk(2, pkgName); showApk(2, pkgName);
}
// ToastUtils.show("--> APK移除 <--");
} }
}); });
} }
......
package com.mints.flowbox.keepalive; package com.mints.flowbox.keepalive;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.os.Message; import android.os.Message;
import com.bytedance.msdk.adapter.util.WeakHandler; import com.bytedance.msdk.adapter.util.WeakHandler;
...@@ -9,10 +8,9 @@ import com.mints.flowbox.MintsApplication; ...@@ -9,10 +8,9 @@ import com.mints.flowbox.MintsApplication;
import com.mints.flowbox.ad.express.ExpressManager; import com.mints.flowbox.ad.express.ExpressManager;
import com.mints.flowbox.common.AppConfig; import com.mints.flowbox.common.AppConfig;
import com.mints.flowbox.manager.TrackManager; import com.mints.flowbox.manager.TrackManager;
import com.mints.flowbox.ui.activitys.keepalive.BoostActivity; import com.mints.flowbox.manager.wifi.WifiDataManager;
import com.mints.flowbox.ui.activitys.keepalive.TimingActivity; import com.mints.flowbox.ui.activitys.keepalive.TimingActivity;
import com.mints.flowbox.utils.ForegroundOrBackground; import com.mints.flowbox.utils.ForegroundOrBackground;
import com.mints.flowbox.utils.LogUtil;
import com.mints.flowbox.utils.keepalive.IntentUtils; import com.mints.flowbox.utils.keepalive.IntentUtils;
/** /**
...@@ -24,9 +22,9 @@ public class AlarmManager implements WeakHandler.IHandler { ...@@ -24,9 +22,9 @@ public class AlarmManager implements WeakHandler.IHandler {
private static volatile AlarmManager _inst; private static volatile AlarmManager _inst;
public static final int WIFI_MINTER = 3;//单位-分钟,wifi页重置 private static final int WIFI_MINTER = 3;//单位-分钟,wifi页重置
public static final int USER_ACTIVE_MINTER = 10;//单位-分钟,用户激活接口 private static final int USER_ACTIVE_MINTER = 10;//单位-分钟,用户激活接口
public static final int APP_OUT_CLEAR_MINTER = 1;//单位-分钟,应用外清理 private static int APP_OUT_TIMING_MINTER = 10;//单位-分钟,应用外清理
public static final long ONE_MINTER_Interval = 60 * 1000;//60秒 public static final long ONE_MINTER_Interval = 60 * 1000;//60秒
public static final long TEN_SECOND_Interval = 10 * 1000;//10秒 public static final long TEN_SECOND_Interval = 10 * 1000;//10秒
...@@ -74,8 +72,6 @@ public class AlarmManager implements WeakHandler.IHandler { ...@@ -74,8 +72,6 @@ public class AlarmManager implements WeakHandler.IHandler {
// 防止userTime超出Integer范围 // 防止userTime超出Integer范围
if (userTime < 20) userTime++; if (userTime < 20) userTime++;
LogUtil.d("AAAAAAAAAA");
// 固定时间增长 // 固定时间增长
exeActionForTime(curTime); exeActionForTime(curTime);
// 用户操作按时间增长 // 用户操作按时间增长
...@@ -93,15 +89,18 @@ public class AlarmManager implements WeakHandler.IHandler { ...@@ -93,15 +89,18 @@ public class AlarmManager implements WeakHandler.IHandler {
* @param userTime * @param userTime
*/ */
private void userActionForTime(int userTime) { private void userActionForTime(int userTime) {
if (userTime % APP_OUT_CLEAR_MINTER == 0) { if (userTime % APP_OUT_TIMING_MINTER == 0) {
// 应用在前台时,不弹出应用外广告 // 应用在前台时,不弹出应用外广告
if (ForegroundOrBackground.isForeground2()) { if (ForegroundOrBackground.isForeground2()) {
return; return;
} }
this.resetUserActionTime(); if (WifiDataManager.INSTANCE.getTiming()) {
showTimingActivity(); showTimingActivity();
}
this.resetUserActionTime();
// // 预加载信息流 // // 预加载信息流
// ExpressManager.INSTANCE.loadAppOutExpress(); // ExpressManager.INSTANCE.loadAppOutExpress();
// //用户关闭界面后10分钟调用 // //用户关闭界面后10分钟调用
...@@ -132,6 +131,7 @@ public class AlarmManager implements WeakHandler.IHandler { ...@@ -132,6 +131,7 @@ public class AlarmManager implements WeakHandler.IHandler {
} else if (curTime % USER_ACTIVE_MINTER == 0) { } else if (curTime % USER_ACTIVE_MINTER == 0) {
//每10分钟调用 用户激活接口 //每10分钟调用 用户激活接口
TrackManager.getInstance().setMinsActive(); TrackManager.getInstance().setMinsActive();
TrackManager.getInstance().getOuterAdConfig();
} }
} }
...@@ -139,6 +139,7 @@ public class AlarmManager implements WeakHandler.IHandler { ...@@ -139,6 +139,7 @@ public class AlarmManager implements WeakHandler.IHandler {
* 展示定时页面 * 展示定时页面
*/ */
private void showTimingActivity() { private void showTimingActivity() {
// 预加载信息流 // 预加载信息流
ExpressManager.INSTANCE.loadAppOutExpress(); ExpressManager.INSTANCE.loadAppOutExpress();
...@@ -153,6 +154,11 @@ public class AlarmManager implements WeakHandler.IHandler { ...@@ -153,6 +154,11 @@ public class AlarmManager implements WeakHandler.IHandler {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent); IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent);
} }
public void setAppOutTimingMinter(int timingMinter) {
APP_OUT_TIMING_MINTER = timingMinter;
resetUserActionTime();
}
/** /**
* 重置用户操作时长 * 重置用户操作时长
*/ */
......
...@@ -171,4 +171,10 @@ public class TrackManager { ...@@ -171,4 +171,10 @@ public class TrackManager {
trackPresenter.setMinsActive(vo); trackPresenter.setMinsActive(vo);
} }
} }
public void getOuterAdConfig() {
if (trackPresenter != null) {
trackPresenter.getOuterAdConfig();
}
}
} }
package com.mints.flowbox.manager.wifi package com.mints.flowbox.manager.wifi
import android.text.format.DateUtils import android.text.format.DateUtils
import com.mints.flowbox.keepalive.AlarmManager
import com.mints.flowbox.manager.AppPreferencesManager import com.mints.flowbox.manager.AppPreferencesManager
import com.mints.flowbox.utils.TimeRender import com.mints.flowbox.mvp.model.OutAppConfig
/** /**
* wifi本地数据管理 * wifi本地数据管理
...@@ -12,46 +13,96 @@ import com.mints.flowbox.utils.TimeRender ...@@ -12,46 +13,96 @@ import com.mints.flowbox.utils.TimeRender
object WifiDataManager { object WifiDataManager {
// 新的一天(无需重置状态,自动修改) // 新的一天(无需重置状态,自动修改)
private val NEW_DAY_FLAG = "NEW_DAY_FLAG" private const val NEW_DAY_FLAG = "NEW_DAY_FLAG"
// wifi连接 10次 // wifi连接
private val WIFI_ON = "WIFI_ON" private const val WIFI_ON = "WIFI_ON"
// wifi断开 10次 // wifi断开
private val WIFI_OFF = "WIFI_OFF" private const val WIFI_OFF = "WIFI_OFF"
// 充电 10次 // 充电
private val BATTERY_ON = "BATTERY_ON" private const val BATTERY_ON = "BATTERY_ON"
// 拔电 10次 // 拔电
private val BATTERY_OFF = "BATTERY_OFF" private const val BATTERY_OFF = "BATTERY_OFF"
// 安装apk
private const val INSTALL_APK = "INSTALL_APK"
// 更新apk
private const val UPDATE_APK = "UPDATE_APK"
// 卸载apk
private const val UNINSTALL_APK = "UNINSTALL_APK"
// 安装,卸载 引导 10秒 // 安装,卸载 引导 10秒
private val INSTALLANDUN_SEC = "INSTALLANDUN_SEC" // private val INSTALLANDUN_SEC = "INSTALLANDUN_SEC"
// 点击home键 30分钟 // 点击home键 30分钟
private val HOME_30MIN = "HOME_30MIN" // private val HOME_30MIN = "HOME_30MIN"
// 最近任务列表 30分钟 // 最近任务列表 30分钟
private val APPLIST_30MIN = "APPLIST_30MIN" // private val APPLIST_30MIN = "APPLIST_30MIN"
// 挂断电话 无广告 // 挂断电话
private val TELEPHONE_OFF = "TELEPHONE_OFF" private const val TELEPHONE_OFF = "TELEPHONE_OFF"
// 锁屏 100次 // 锁屏
private val LOCK_ON = "LOCK_ON" private const val LOCK_ON = "LOCK_ON"
// 锁屏
private const val TIMING = "TIMING"
// 锁屏 单位:次数 // 锁屏 单位:次数
var LOCK_TIMES = 100 private var LOCK_TIMES = 120
private var LOCK_OPEN = false
// 充电 次数及开关
private var BATTERY_ON_TIMES = 10
private var BATTERY_ON_OPEN = false
// 拔电 次数及开关
private var BATTERY_OFF_TIMES = 10
private var BATTERY_OFF_OPEN = false
// 断开wifi 次数及开关
private var WIFI_OFF_TIMES = 10
private var WIFI_OFF_OPEN = false
// 开启wifi 次数及开关
private var WIFI_ON_TIMES = 10
private var WIFI_ON_OPEN = false
// 挂断电话 次数及开关
private var PHONE_OFF_TIMES = 20
private var PHONE_OFF_OPEN = false
// 安装apk 次数及开关
private var INSTALL_APK_TIMES = 20
private var INSTALL_APK_OPEN = false
// wifi、拔电 单位:次数 // 更新apk 次数及开关
var WIFI_TIMES = 10 private var UPDATE_APK_TIMES = 20
private var UPDATE_APK_OPEN = false
// 卸载apk 次数及开关
private var UNINSTALL_APK_TIMES = 20
private var UNINSTALL_APK_OPEN = false
// 定时 次数及开关
private var TIMING_TIMES = 20
private var TIMING_OPEN = false
private var TIMING_INTERVAL = 10
// 点击home键、最近任务列表 单位:分钟 // 点击home键、最近任务列表 单位:分钟
var HOME_TIMES = 30 // var HOME_TIMES = 30
// 安装、卸载 单位:秒 // 安装、卸载 单位:秒
var INSTALL_TIMES = 10 // var INSTALL_TIMES = 10
// 应用总开关
var APP_OUT_MAIN_SWITCH = false
val sp by lazy { AppPreferencesManager.get() } val sp by lazy { AppPreferencesManager.get() }
...@@ -59,8 +110,11 @@ object WifiDataManager { ...@@ -59,8 +110,11 @@ object WifiDataManager {
* 是否显示wifi连接广告 * 是否显示wifi连接广告
*/ */
fun getWifiOn(): Boolean { fun getWifiOn(): Boolean {
// 总开关关闭 return
if (!APP_OUT_MAIN_SWITCH || WIFI_ON_OPEN) return false
val wifiOn = sp.getInt(WIFI_ON, 0) val wifiOn = sp.getInt(WIFI_ON, 0)
if (wifiOn < WIFI_TIMES) { if (wifiOn < WIFI_ON_TIMES) {
// 设置wifi次数+1 // 设置wifi次数+1
sp.put(WIFI_ON, wifiOn + 1) sp.put(WIFI_ON, wifiOn + 1)
return true return true
...@@ -72,8 +126,11 @@ object WifiDataManager { ...@@ -72,8 +126,11 @@ object WifiDataManager {
* 是否显示wifi断开广告 * 是否显示wifi断开广告
*/ */
fun getWifiOff(): Boolean { fun getWifiOff(): Boolean {
// 总开关关闭 return
if (!APP_OUT_MAIN_SWITCH || !WIFI_OFF_OPEN) return false
val wifiOff = sp.getInt(WIFI_OFF, 0) val wifiOff = sp.getInt(WIFI_OFF, 0)
if (wifiOff < WIFI_TIMES) { if (wifiOff < WIFI_OFF_TIMES) {
// 设置wifi次数+1 // 设置wifi次数+1
sp.put(WIFI_OFF, wifiOff + 1) sp.put(WIFI_OFF, wifiOff + 1)
return true return true
...@@ -85,8 +142,11 @@ object WifiDataManager { ...@@ -85,8 +142,11 @@ object WifiDataManager {
* 是否显示充电连接广告 * 是否显示充电连接广告
*/ */
fun getBatteryOn(): Boolean { fun getBatteryOn(): Boolean {
// 总开关关闭 return
if (!APP_OUT_MAIN_SWITCH || BATTERY_ON_OPEN) return false
val batteryOn = sp.getInt(BATTERY_ON, 0) val batteryOn = sp.getInt(BATTERY_ON, 0)
if (batteryOn < WIFI_TIMES) { if (batteryOn < BATTERY_ON_TIMES) {
// 设置充电次数+1 // 设置充电次数+1
sp.put(BATTERY_ON, batteryOn + 1) sp.put(BATTERY_ON, batteryOn + 1)
return true return true
...@@ -98,8 +158,11 @@ object WifiDataManager { ...@@ -98,8 +158,11 @@ object WifiDataManager {
* 是否显示断电连接广告 * 是否显示断电连接广告
*/ */
fun getBatteryOff(): Boolean { fun getBatteryOff(): Boolean {
// 总开关关闭 return
if (!APP_OUT_MAIN_SWITCH || BATTERY_OFF_OPEN) return false
val batteryOff = sp.getInt(BATTERY_OFF, 0) val batteryOff = sp.getInt(BATTERY_OFF, 0)
if (batteryOff < WIFI_TIMES) { if (batteryOff < BATTERY_OFF_TIMES) {
// 设置断电次数+1 // 设置断电次数+1
sp.put(BATTERY_OFF, batteryOff + 1) sp.put(BATTERY_OFF, batteryOff + 1)
return true return true
...@@ -111,6 +174,9 @@ object WifiDataManager { ...@@ -111,6 +174,9 @@ object WifiDataManager {
* 是否锁屏 * 是否锁屏
*/ */
fun getLockOn(): Boolean { fun getLockOn(): Boolean {
// 总开关关闭 return
if (!APP_OUT_MAIN_SWITCH || LOCK_OPEN) return false
val lockOn = sp.getInt(LOCK_ON, 0) val lockOn = sp.getInt(LOCK_ON, 0)
if (lockOn < LOCK_TIMES) { if (lockOn < LOCK_TIMES) {
sp.put(LOCK_ON, lockOn + 1) sp.put(LOCK_ON, lockOn + 1)
...@@ -120,70 +186,147 @@ object WifiDataManager { ...@@ -120,70 +186,147 @@ object WifiDataManager {
} }
/** /**
* 是否挂断电 * 是否挂断电
*/ */
fun getTelephoneOff(): Boolean { fun getTelephoneOff(): Boolean {
// 总开关关闭 return
if (!APP_OUT_MAIN_SWITCH || !PHONE_OFF_OPEN) return false
val telephoneOff = sp.getInt(TELEPHONE_OFF, 0) val telephoneOff = sp.getInt(TELEPHONE_OFF, 0)
if (telephoneOff < LOCK_TIMES) { if (telephoneOff < PHONE_OFF_TIMES) {
sp.put(TELEPHONE_OFF, telephoneOff + 1) sp.put(TELEPHONE_OFF, telephoneOff + 1)
return true return true
} }
return false return false
} }
/** /**
* 是否点击home键 满足30分钟后 * 是否安装apk
*/ */
fun getHomeKey(): Boolean { fun getInstallApk(): Boolean {
// 保存的时间戳 // 总开关关闭 return
val preTime = sp.getLong(HOME_30MIN, System.currentTimeMillis()) if (!APP_OUT_MAIN_SWITCH || !INSTALL_APK_OPEN) return false
val currentTime = System.currentTimeMillis()
// 当前时间-保存的时间戳=间隔时间 val install = sp.getInt(INSTALL_APK, 0)
val min = TimeRender.getMinForTimestamp(preTime, currentTime) if (install < INSTALL_APK_TIMES) {
if (min < HOME_TIMES) { sp.put(INSTALL_APK, install + 1)
return false
}
sp.put(HOME_30MIN, currentTime)
return true return true
} }
return false
}
/** /**
* 是否操作最近任务列表 满足30分钟后 * 是否挂断电话
*/ */
fun getApplistKey(): Boolean { fun getUnInstallApk(): Boolean {
// 保存的时间戳 // 总开关关闭 return
val preTime = sp.getLong(APPLIST_30MIN, System.currentTimeMillis()) if (!APP_OUT_MAIN_SWITCH || !UNINSTALL_APK_OPEN) return false
val currentTime = System.currentTimeMillis()
// 当前时间-保存的时间戳=间隔时间 val uninstall = sp.getInt(UNINSTALL_APK, 0)
val min = TimeRender.getMinForTimestamp(preTime, currentTime) if (uninstall < UNINSTALL_APK_TIMES) {
if (min < HOME_TIMES) { sp.put(UNINSTALL_APK, uninstall + 1)
return true
}
return false return false
} }
sp.put(APPLIST_30MIN, currentTime)
/**
* 是否挂断电话
*/
fun getUpdateApk(): Boolean {
// 总开关关闭 return
if (!APP_OUT_MAIN_SWITCH || !UPDATE_APK_OPEN) return false
val update = sp.getInt(UPDATE_APK, 0)
if (update < UPDATE_APK_TIMES) {
sp.put(UPDATE_APK, update + 1)
return true return true
} }
return false
}
/** /**
* 是否操作卸载安装 满足10秒后 * 是否挂断电话
*/ */
fun getInstallAndUnstall(): Boolean { fun getTiming(): Boolean {
// 保存的时间戳 // 总开关关闭 return
val preTime = sp.getLong(INSTALLANDUN_SEC, System.currentTimeMillis()) if (!APP_OUT_MAIN_SWITCH || !TIMING_OPEN) return false
val currentTime = System.currentTimeMillis()
// 当前时间-保存的时间戳=间隔时间 val timing = sp.getInt(TIMING, 0)
val sec = TimeRender.getSecForTimestamp(preTime, currentTime) if (timing < TIMING_TIMES) {
if (sec < INSTALL_TIMES) { sp.put(TIMING, timing + 1)
return true
}
return false return false
} }
sp.put(INSTALLANDUN_SEC, currentTime)
return true fun getTimingInterval(): Int {
// 总开关关闭 return
if (!APP_OUT_MAIN_SWITCH || !TIMING_OPEN) return 0
return TIMING_INTERVAL
} }
/**
* 是否点击home键 满足30分钟后
*/
// fun getHomeKey(): Boolean {
// // 总开关关闭 return
// if (!APP_OUT_MAIN_SWITCH) return false
//
// // 保存的时间戳
// val preTime = sp.getLong(HOME_30MIN, System.currentTimeMillis())
// val currentTime = System.currentTimeMillis()
// // 当前时间-保存的时间戳=间隔时间
// val min = TimeRender.getMinForTimestamp(preTime, currentTime)
// if (min < HOME_TIMES) {
// return false
// }
// sp.put(HOME_30MIN, currentTime)
// return true
// }
/**
* 是否操作最近任务列表 满足30分钟后
*/
// fun getApplistKey(): Boolean {
// // 总开关关闭 return
// if (!APP_OUT_MAIN_SWITCH) return false
//
// // 保存的时间戳
// val preTime = sp.getLong(APPLIST_30MIN, System.currentTimeMillis())
// val currentTime = System.currentTimeMillis()
// // 当前时间-保存的时间戳=间隔时间
// val min = TimeRender.getMinForTimestamp(preTime, currentTime)
// if (min < HOME_TIMES) {
// return false
// }
// sp.put(APPLIST_30MIN, currentTime)
// return true
// }
/**
* 是否操作卸载安装 满足10秒后
*/
// fun getInstallAndUnstall(): Boolean {
// // 总开关关闭 return
// if (!APP_OUT_SWITCH) return false
//
// // 保存的时间戳
// val preTime = sp.getLong(INSTALLANDUN_SEC, System.currentTimeMillis())
// val currentTime = System.currentTimeMillis()
// // 当前时间-保存的时间戳=间隔时间
// val sec = TimeRender.getSecForTimestamp(preTime, currentTime)
// if (sec < INSTALL_TIMES) {
// return false
// }
// sp.put(INSTALLANDUN_SEC, currentTime)
// return true
// }
/** /**
* 是否当天 * 是否当天
*/ */
fun getNewDay(time: Long): Boolean { fun getNewDay(time: Long, data: OutAppConfig): Boolean {
// 上一次服务器的时间,首次为系统时间 // 上一次服务器的时间,首次为系统时间
val preTime = sp.getLong(NEW_DAY_FLAG, System.currentTimeMillis()) val preTime = sp.getLong(NEW_DAY_FLAG, System.currentTimeMillis())
// 判断时间是否是新的一天 // 判断时间是否是新的一天
...@@ -192,26 +335,104 @@ object WifiDataManager { ...@@ -192,26 +335,104 @@ object WifiDataManager {
return true return true
} }
// 第二天,新的一天 // 第二天,新的一天
sp.put(NEW_DAY_FLAG, time) sp.put(NEW_DAY_FLAG, time)
resetData() resetData(data)
return false return false
} }
/** /**
* 重置次数 * 重置次数
*/ */
private fun resetData() { private fun resetData(data: OutAppConfig) {
sp.put(WIFI_ON, 0) if (!data.isOpen) {
sp.put(WIFI_OFF, 0) APP_OUT_MAIN_SWITCH = false
sp.put(BATTERY_ON, 0) return
sp.put(BATTERY_OFF, 0) }
sp.put(LOCK_ON, 0)
sp.put(TELEPHONE_OFF, 0) APP_OUT_MAIN_SWITCH = true
sp.put(HOME_30MIN, System.currentTimeMillis())
sp.put(INSTALLANDUN_SEC, System.currentTimeMillis()) // 充电
sp.put(APPLIST_30MIN, System.currentTimeMillis()) if (data.modules.charge.isOpen) {
BATTERY_ON_OPEN = true
BATTERY_ON_TIMES = data.modules.charge.maxCount
} else {
BATTERY_ON_OPEN = false
}
// 拔电
if (data.modules.charge_stop.isOpen) {
BATTERY_OFF_OPEN = true
BATTERY_OFF_TIMES = data.modules.charge.maxCount
} else {
BATTERY_OFF_OPEN = false
}
// 连接wifi
if (data.modules.wifi_connect.isOpen) {
WIFI_ON_OPEN = true
WIFI_ON_TIMES = data.modules.wifi_connect.maxCount
} else {
WIFI_ON_OPEN = false
}
// 断开wifi
if (data.modules.wifi_disconnect.isOpen) {
WIFI_OFF_OPEN = true
WIFI_OFF_TIMES = data.modules.wifi_disconnect.maxCount
} else {
WIFI_OFF_OPEN = false
}
// 挂断电话
if (data.modules.telephone.isOpen) {
PHONE_OFF_OPEN = true
PHONE_OFF_TIMES = data.modules.wifi_disconnect.maxCount
} else {
PHONE_OFF_OPEN = false
}
// 锁屏
if (data.modules.screen_lock.isOpen) {
LOCK_OPEN = true
LOCK_TIMES = data.modules.telephone.maxCount
} else {
LOCK_OPEN = false
}
// 安装apk
if (data.modules.app_install.isOpen) {
INSTALL_APK_OPEN = true
INSTALL_APK_TIMES = data.modules.app_install.maxCount
} else {
INSTALL_APK_OPEN = false
}
// 更新apk
if (data.modules.app_update.isOpen) {
UPDATE_APK_OPEN = true
UPDATE_APK_TIMES = data.modules.app_update.maxCount
} else {
UPDATE_APK_OPEN = false
}
// 卸载apk
if (data.modules.app_uninstall.isOpen) {
UNINSTALL_APK_OPEN = true
UNINSTALL_APK_TIMES = data.modules.app_uninstall.maxCount
} else {
UNINSTALL_APK_OPEN = false
}
// 定时
if (data.modules.timing.isOpen) {
TIMING_OPEN = true
TIMING_TIMES = data.modules.timing.maxCount
TIMING_INTERVAL = data.modules.timing.intervalMins
AlarmManager.getInstance().setAppOutTimingMinter(TIMING_INTERVAL)
} else {
TIMING_OPEN = false
}
} }
} }
\ No newline at end of file
package com.mints.flowbox.mvp.model;
import java.io.Serializable;
/**
* @author jyx
* @date 2021/7/14
* @des
*/
public class OutAppConfig implements Serializable {
/**
* open : true
* modules : {"screen_open":{"remark":"解锁","intervalMins":10,"maxCount":10,"open":true},"charge":{"remark":"充电","maxCount":10,"open":true},"wifi_disconnect":{"remark":"wifi断开","maxCount":10,"open":true},"screen_lock":{"remark":"锁屏","maxCount":100,"open":true},"timing":{"remark":"定时","intervalMins":10,"maxCount":10,"open":true},"app_uninstall":{"remark":"应用卸载","maxCount":10,"open":true},"wifi_connect":{"remark":"wifi连接","maxCount":10,"open":true},"charge_stop":{"remark":"拔电","maxCount":10,"open":true},"app_install":{"remark":"应用安装","maxCount":10,"open":true},"telephone":{"remark":"电话","maxCount":10,"open":true},"app_update":{"remark":"应用更新","maxCount":10,"open":true}}
*/
private boolean open;
/**
* screen_open : {"remark":"解锁","intervalMins":10,"maxCount":10,"open":true}
* charge : {"remark":"充电","maxCount":10,"open":true}
* wifi_disconnect : {"remark":"wifi断开","maxCount":10,"open":true}
* screen_lock : {"remark":"锁屏","maxCount":100,"open":true}
* timing : {"remark":"定时","intervalMins":10,"maxCount":10,"open":true}
* app_uninstall : {"remark":"应用卸载","maxCount":10,"open":true}
* wifi_connect : {"remark":"wifi连接","maxCount":10,"open":true}
* charge_stop : {"remark":"拔电","maxCount":10,"open":true}
* app_install : {"remark":"应用安装","maxCount":10,"open":true}
* telephone : {"remark":"电话","maxCount":10,"open":true}
* app_update : {"remark":"应用更新","maxCount":10,"open":true}
*/
private ModulesDTO modules;
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
public ModulesDTO getModules() {
return modules;
}
public void setModules(ModulesDTO modules) {
this.modules = modules;
}
public static class ModulesDTO {
/**
* remark : 解锁
* intervalMins : 10
* maxCount : 10
* open : true
*/
private ScreenOpenDTO screen_open;
/**
* remark : 充电
* maxCount : 10
* open : true
*/
private ChargeDTO charge;
/**
* remark : wifi断开
* maxCount : 10
* open : true
*/
private WifiDisconnectDTO wifi_disconnect;
/**
* remark : 锁屏
* maxCount : 100
* open : true
*/
private ScreenLockDTO screen_lock;
/**
* remark : 定时
* intervalMins : 10
* maxCount : 10
* open : true
*/
private TimingDTO timing;
/**
* remark : 应用卸载
* maxCount : 10
* open : true
*/
private AppUninstallDTO app_uninstall;
/**
* remark : wifi连接
* maxCount : 10
* open : true
*/
private WifiConnectDTO wifi_connect;
/**
* remark : 拔电
* maxCount : 10
* open : true
*/
private ChargeStopDTO charge_stop;
/**
* remark : 应用安装
* maxCount : 10
* open : true
*/
private AppInstallDTO app_install;
/**
* remark : 电话
* maxCount : 10
* open : true
*/
private TelephoneDTO telephone;
/**
* remark : 应用更新
* maxCount : 10
* open : true
*/
private AppUpdateDTO app_update;
public ScreenOpenDTO getScreen_open() {
return screen_open;
}
public void setScreen_open(ScreenOpenDTO screen_open) {
this.screen_open = screen_open;
}
public ChargeDTO getCharge() {
return charge;
}
public void setCharge(ChargeDTO charge) {
this.charge = charge;
}
public WifiDisconnectDTO getWifi_disconnect() {
return wifi_disconnect;
}
public void setWifi_disconnect(WifiDisconnectDTO wifi_disconnect) {
this.wifi_disconnect = wifi_disconnect;
}
public ScreenLockDTO getScreen_lock() {
return screen_lock;
}
public void setScreen_lock(ScreenLockDTO screen_lock) {
this.screen_lock = screen_lock;
}
public TimingDTO getTiming() {
return timing;
}
public void setTiming(TimingDTO timing) {
this.timing = timing;
}
public AppUninstallDTO getApp_uninstall() {
return app_uninstall;
}
public void setApp_uninstall(AppUninstallDTO app_uninstall) {
this.app_uninstall = app_uninstall;
}
public WifiConnectDTO getWifi_connect() {
return wifi_connect;
}
public void setWifi_connect(WifiConnectDTO wifi_connect) {
this.wifi_connect = wifi_connect;
}
public ChargeStopDTO getCharge_stop() {
return charge_stop;
}
public void setCharge_stop(ChargeStopDTO charge_stop) {
this.charge_stop = charge_stop;
}
public AppInstallDTO getApp_install() {
return app_install;
}
public void setApp_install(AppInstallDTO app_install) {
this.app_install = app_install;
}
public TelephoneDTO getTelephone() {
return telephone;
}
public void setTelephone(TelephoneDTO telephone) {
this.telephone = telephone;
}
public AppUpdateDTO getApp_update() {
return app_update;
}
public void setApp_update(AppUpdateDTO app_update) {
this.app_update = app_update;
}
public static class ScreenOpenDTO {
private String remark;
private int intervalMins;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getIntervalMins() {
return intervalMins;
}
public void setIntervalMins(int intervalMins) {
this.intervalMins = intervalMins;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class ChargeDTO {
private String remark;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class WifiDisconnectDTO {
private String remark;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class ScreenLockDTO {
private String remark;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class TimingDTO {
private String remark;
private int intervalMins;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getIntervalMins() {
return intervalMins;
}
public void setIntervalMins(int intervalMins) {
this.intervalMins = intervalMins;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class AppUninstallDTO {
private String remark;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class WifiConnectDTO {
private String remark;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class ChargeStopDTO {
private String remark;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class AppInstallDTO {
private String remark;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class TelephoneDTO {
private String remark;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
public static class AppUpdateDTO {
private String remark;
private int maxCount;
private boolean open;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getMaxCount() {
return maxCount;
}
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
}
}
}
...@@ -2,7 +2,9 @@ package com.mints.flowbox.mvp.model ...@@ -2,7 +2,9 @@ package com.mints.flowbox.mvp.model
import java.io.Serializable import java.io.Serializable
data class WifiActiveBean(val ouTofApplicationAdCount: Int = 10, data class WifiActiveBean(
val ouTofApplicationAdCount: Int = 10,
val time: Long = 0, val time: Long = 0,
val ouTofApplicationAdMins: Int = 10 val ouTofApplicationAdMins: Int = 10,
val outerConfigs: OutAppConfig? = null
) : Serializable ) : Serializable
\ No newline at end of file
...@@ -16,6 +16,7 @@ import com.mints.flowbox.manager.UserWeight; ...@@ -16,6 +16,7 @@ import com.mints.flowbox.manager.UserWeight;
import com.mints.flowbox.manager.wifi.WifiDataManager; import com.mints.flowbox.manager.wifi.WifiDataManager;
import com.mints.flowbox.mvp.model.BaseResponse; import com.mints.flowbox.mvp.model.BaseResponse;
import com.mints.flowbox.mvp.model.CommonParamBean; import com.mints.flowbox.mvp.model.CommonParamBean;
import com.mints.flowbox.mvp.model.OutAppConfig;
import com.mints.flowbox.mvp.model.ServerAdBean; import com.mints.flowbox.mvp.model.ServerAdBean;
import com.mints.flowbox.mvp.model.WifiActiveBean; import com.mints.flowbox.mvp.model.WifiActiveBean;
import com.mints.library.net.neterror.BaseSubscriber; import com.mints.library.net.neterror.BaseSubscriber;
...@@ -88,9 +89,9 @@ public class TrackPresenter extends BaseTrackPresenter { ...@@ -88,9 +89,9 @@ public class TrackPresenter extends BaseTrackPresenter {
try { try {
if (baseResponse.getStatus() == 200) { if (baseResponse.getStatus() == 200) {
WifiActiveBean data = baseResponse.getData(); WifiActiveBean data = baseResponse.getData();
if (data != null) { if (data != null && data.getOuterConfigs() != null) {
// 本地标记未赋值时 // 本地标记未赋值时
WifiDataManager.INSTANCE.getNewDay(data.getTime()); WifiDataManager.INSTANCE.getNewDay(data.getTime(), data.getOuterConfigs());
} }
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -525,4 +526,30 @@ public class TrackPresenter extends BaseTrackPresenter { ...@@ -525,4 +526,30 @@ public class TrackPresenter extends BaseTrackPresenter {
}); });
} }
public void getOuterAdConfig() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getOuterAdConfig(),
new BaseSubscriber<BaseResponse<OutAppConfig>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(BaseResponse<OutAppConfig> baseResponse) {
try {
if (baseResponse.getStatus() == 200) {
OutAppConfig data = baseResponse.getData();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
} }
...@@ -20,6 +20,7 @@ import com.mints.flowbox.mvp.model.MainVideoMsgBean; ...@@ -20,6 +20,7 @@ import com.mints.flowbox.mvp.model.MainVideoMsgBean;
import com.mints.flowbox.mvp.model.MealBean; import com.mints.flowbox.mvp.model.MealBean;
import com.mints.flowbox.mvp.model.MorningClockBean; import com.mints.flowbox.mvp.model.MorningClockBean;
import com.mints.flowbox.mvp.model.MyInfo; import com.mints.flowbox.mvp.model.MyInfo;
import com.mints.flowbox.mvp.model.OutAppConfig;
import com.mints.flowbox.mvp.model.ServerAdBean; import com.mints.flowbox.mvp.model.ServerAdBean;
import com.mints.flowbox.mvp.model.SignRedbagsBean; import com.mints.flowbox.mvp.model.SignRedbagsBean;
import com.mints.flowbox.mvp.model.TaskCpdBean; import com.mints.flowbox.mvp.model.TaskCpdBean;
...@@ -467,11 +468,17 @@ public interface LoanService { ...@@ -467,11 +468,17 @@ public interface LoanService {
Observable<BaseResponse<JsonObject>> getRankMsg(); Observable<BaseResponse<JsonObject>> getRankMsg();
/** /**
* 提现排名 * 保活间隔上送后台
*/ */
@POST("na/setMinsActive") @POST("na/setMinsActive")
Observable<BaseResponse<WifiActiveBean>> setMinsActive(@Body Map<String, Object> vo); Observable<BaseResponse<WifiActiveBean>> setMinsActive(@Body Map<String, Object> vo);
/**
* 获取应用外广告配置
*/
@POST("common/getOuterAdConfig")
Observable<BaseResponse<OutAppConfig>> getOuterAdConfig();
/** /**
* 默认http工厂 * 默认http工厂
*/ */
......
...@@ -283,13 +283,13 @@ class CleanActivity : BaseActivity(), View.OnClickListener { ...@@ -283,13 +283,13 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
val bundle = Bundle() val bundle = Bundle()
if (scanMax == 1) { if (scanMax == 1) {
// AppConfig.isCanBoost = false AppConfig.isCanBoost = false
bundle.putString( bundle.putString(
IncreasespeedActivity.INCREASE_TYPE, IncreasespeedActivity.INCREASE_TYPE,
IncreasespeedActivity.INCREASE_BOOST IncreasespeedActivity.INCREASE_BOOST
) )
} else { } else {
// AppConfig.isCanClean = false AppConfig.isCanClean = false
bundle.putString( bundle.putString(
IncreasespeedActivity.INCREASE_TYPE, IncreasespeedActivity.INCREASE_TYPE,
IncreasespeedActivity.INCREASE_CLEAN IncreasespeedActivity.INCREASE_CLEAN
......
...@@ -95,17 +95,17 @@ class IncreasespeedActivity : BaseActivity(), View.OnClickListener { ...@@ -95,17 +95,17 @@ class IncreasespeedActivity : BaseActivity(), View.OnClickListener {
} }
}) })
// if (mIncreaseType == INCREASE_BOOST && AppConfig.isCanBoost) { if (mIncreaseType == INCREASE_BOOST && AppConfig.isCanBoost) {
if (mIncreaseType == INCREASE_BOOST) { // if (mIncreaseType == INCREASE_BOOST) {
startTimer()
// } else if (mIncreaseType == INCREASE_SAVE_ELECTRICITY && AppConfig.isCanSaveBattery) {
} else if (mIncreaseType == INCREASE_SAVE_ELECTRICITY) {
startTimer() startTimer()
} else if (mIncreaseType == INCREASE_SAVE_ELECTRICITY && AppConfig.isCanSaveBattery) {
// } else if (mIncreaseType == INCREASE_SAVE_ELECTRICITY) {
mTimerMax = 11 mTimerMax = 11
// } else if (mIncreaseType == INCREASE_CLEAN && AppConfig.isCanClean) {
} else if (mIncreaseType == INCREASE_CLEAN) {
startTimer() startTimer()
} else if (mIncreaseType == INCREASE_CLEAN && AppConfig.isCanClean) {
// } else if (mIncreaseType == INCREASE_CLEAN) {
mTimerMax = 14 mTimerMax = 14
startTimer()
} else { } else {
initView() initView()
......
package com.mints.flowbox.ui.activitys.base package com.mints.flowbox.ui.activitys.base
import android.app.KeyguardManager
import android.content.Context
import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.AttributeSet
import android.view.View
import android.view.WindowManager import android.view.WindowManager
import com.mints.flowbox.R
import com.mints.flowbox.utils.keepalive.ScreenLockerUtils import com.mints.flowbox.utils.keepalive.ScreenLockerUtils
import com.mints.library.base.BaseSwipeBackCompatActivity import com.mints.library.base.BaseSwipeBackCompatActivity
import com.mints.library.net.netstatus.NetUtils import com.mints.library.net.netstatus.NetUtils
...@@ -24,17 +18,18 @@ abstract class OutAppActivity : BaseSwipeBackCompatActivity() { ...@@ -24,17 +18,18 @@ abstract class OutAppActivity : BaseSwipeBackCompatActivity() {
setShowWhenLocked(true) setShowWhenLocked(true)
// 强制亮屏 // 强制亮屏
// setTurnScreenOn(true) // setTurnScreenOn(true)
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager // val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
keyguardManager.requestDismissKeyguard(this, null) // keyguardManager.requestDismissKeyguard(this, null)
} } else {
ScreenLockerUtils.updateWindowFlags(this.window.decorView)
this.window.addFlags( this.window.addFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
) )
}
// 设置锁屏页全屏 // 设置锁屏页全屏
ScreenLockerUtils.makeLockWindowFullScreen(this, this.window.attributes, true) ScreenLockerUtils.updateWindowFlags(this.window.decorView)
ScreenLockerUtils.makeLockWindowFullScreen(this, this.window.attributes, false)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
} }
......
...@@ -20,7 +20,6 @@ import kotlinx.android.synthetic.main.activity_apk.btnClean ...@@ -20,7 +20,6 @@ import kotlinx.android.synthetic.main.activity_apk.btnClean
import kotlinx.android.synthetic.main.activity_apk.fl_ad import kotlinx.android.synthetic.main.activity_apk.fl_ad
import kotlinx.android.synthetic.main.activity_apk.tvInfo import kotlinx.android.synthetic.main.activity_apk.tvInfo
import kotlinx.android.synthetic.main.activity_boost.iv_close import kotlinx.android.synthetic.main.activity_boost.iv_close
import kotlinx.android.synthetic.main.activity_timing.*
import kotlin.random.Random import kotlin.random.Random
/** /**
...@@ -113,7 +112,7 @@ class ApkActivity : BaseActivity() { ...@@ -113,7 +112,7 @@ class ApkActivity : BaseActivity() {
initExpress() initExpress()
btnClean.postDelayed({ btnClean.postDelayed({
rope = YoYo.with(Techniques.Pulse).duration(1000).repeat(6).playOn(btnClean) rope = YoYo.with(Techniques.Pulse).duration(1000).repeat(10).playOn(btnClean)
}, 200) }, 200)
} }
......
...@@ -3,7 +3,9 @@ package com.mints.flowbox.ui.activitys.keepalive ...@@ -3,7 +3,9 @@ package com.mints.flowbox.ui.activitys.keepalive
import android.app.WallpaperManager import android.app.WallpaperManager
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.* import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View import android.view.View
import com.mints.flowbox.R import com.mints.flowbox.R
import com.mints.flowbox.ad.express.ExpressManager import com.mints.flowbox.ad.express.ExpressManager
...@@ -11,10 +13,12 @@ import com.mints.flowbox.common.Constant ...@@ -11,10 +13,12 @@ import com.mints.flowbox.common.Constant
import com.mints.flowbox.ui.activitys.CleanActivity import com.mints.flowbox.ui.activitys.CleanActivity
import com.mints.flowbox.ui.activitys.IncreasespeedActivity import com.mints.flowbox.ui.activitys.IncreasespeedActivity
import com.mints.flowbox.ui.activitys.base.OutAppActivity import com.mints.flowbox.ui.activitys.base.OutAppActivity
import com.mints.flowbox.utils.TimeThread import com.mints.flowbox.utils.TimeRender
import com.mints.flowbox.utils.ToolUtil import com.mints.flowbox.utils.ToolUtil
import com.mints.flowbox.utils.keepalive.ScreenLockerUtils
import com.mints.library.utils.nodoubleclick.AntiShake import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_screen.* import kotlinx.android.synthetic.main.activity_screen.*
import java.util.*
class ScreenActivity : OutAppActivity(), View.OnClickListener { class ScreenActivity : OutAppActivity(), View.OnClickListener {
...@@ -38,8 +42,8 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener { ...@@ -38,8 +42,8 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
) )
}, 500) }, 500)
val thread = TimeThread(tvDate, tvTime) // val thread = TimeThread(tvDate, tvTime)
thread.start() // thread.start()
tvBoost.setOnClickListener(this) tvBoost.setOnClickListener(this)
tvClean.setOnClickListener(this) tvClean.setOnClickListener(this)
...@@ -48,9 +52,20 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener { ...@@ -48,9 +52,20 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
resetTime()
initExpress() initExpress()
} }
private fun resetTime() {
val date = Date()
val monthDay = TimeRender.formatDate(date, TimeRender.DEFAULT_FORMAT_MONTH_DAY)
val time = TimeRender.formatDate(date, TimeRender.DEFAULT_FORMAT_MINTER)
tvDate.text = TimeRender.getWeek() + " " + monthDay
tvTime.text = time
}
override fun onClick(v: View?) { override fun onClick(v: View?) {
if (AntiShake.check(v?.id)) return if (AntiShake.check(v?.id)) return
......
...@@ -78,9 +78,7 @@ class TimingActivity : BaseActivity() { ...@@ -78,9 +78,7 @@ class TimingActivity : BaseActivity() {
btnClean.text = "立即清理" btnClean.text = "立即清理"
} }
TIMING_TYPE_SAVE_ELE -> { // 省电 TIMING_TYPE_SAVE_ELE -> { // 省电
if (AppConfig.fakeSaveBatteryCount == 0) {
AppConfig.fakeSaveBatteryCount = 1 + Random.nextInt(8) AppConfig.fakeSaveBatteryCount = 1 + Random.nextInt(8)
}
tvInfo.text = SpanUtils() tvInfo.text = SpanUtils()
.append("检测到") .append("检测到")
...@@ -173,7 +171,7 @@ class TimingActivity : BaseActivity() { ...@@ -173,7 +171,7 @@ class TimingActivity : BaseActivity() {
initExpress() initExpress()
btnClean.postDelayed({ btnClean.postDelayed({
rope = YoYo.with(Techniques.Pulse).duration(1000).repeat(6).playOn(btnClean) rope = YoYo.with(Techniques.Pulse).duration(1000).repeat(10).playOn(btnClean)
}, 200) }, 200)
} }
......
...@@ -30,6 +30,7 @@ import com.mints.flowbox.ui.activitys.* ...@@ -30,6 +30,7 @@ import com.mints.flowbox.ui.activitys.*
import com.mints.flowbox.ui.adapter.MainWifiAdapter import com.mints.flowbox.ui.adapter.MainWifiAdapter
import com.mints.flowbox.ui.adapter.listener.OnItemClickListener import com.mints.flowbox.ui.adapter.listener.OnItemClickListener
import com.mints.flowbox.ui.fragment.base.BaseFragment import com.mints.flowbox.ui.fragment.base.BaseFragment
import com.mints.flowbox.ui.widgets.RecyItemDecoration
import com.mints.flowbox.ui.widgets.dialog.DialogListener import com.mints.flowbox.ui.widgets.dialog.DialogListener
import com.mints.flowbox.ui.widgets.dialog.DialogUtils import com.mints.flowbox.ui.widgets.dialog.DialogUtils
import com.mints.flowbox.ui.widgets.dialog.WifiConnectDialog import com.mints.flowbox.ui.widgets.dialog.WifiConnectDialog
...@@ -239,12 +240,11 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -239,12 +240,11 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
.setForegroundColor(ContextCompat.getColor(mContext, R.color.color_4BB93F)) .setForegroundColor(ContextCompat.getColor(mContext, R.color.color_4BB93F))
.setFontSize(BubbleUtils.sp2px(10)) .setFontSize(BubbleUtils.sp2px(10))
.create() .create()
AppConfig.isCanBoost = true
} }
if (AppConfig.isCanSaveBattery) { if (AppConfig.isCanSaveBattery) {
if (AppConfig.fakeSaveBatteryCount == 0) {
AppConfig.fakeSaveBatteryCount = 1 + Random.nextInt(8) AppConfig.fakeSaveBatteryCount = 1 + Random.nextInt(8)
}
tv_save_battery.text = SpanUtils() tv_save_battery.text = SpanUtils()
.append("超强省电\n") .append("超强省电\n")
.append("${AppConfig.fakeSaveBatteryCount}个") .append("${AppConfig.fakeSaveBatteryCount}个")
...@@ -264,6 +264,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -264,6 +264,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
.setForegroundColor(ContextCompat.getColor(mContext, R.color.color_4BB93F)) .setForegroundColor(ContextCompat.getColor(mContext, R.color.color_4BB93F))
.setFontSize(BubbleUtils.sp2px(10)) .setFontSize(BubbleUtils.sp2px(10))
.create() .create()
AppConfig.isCanSaveBattery = true
} }
if (AppConfig.isCanClean) { if (AppConfig.isCanClean) {
...@@ -286,6 +287,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -286,6 +287,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
.setForegroundColor(ContextCompat.getColor(mContext, R.color.color_4BB93F)) .setForegroundColor(ContextCompat.getColor(mContext, R.color.color_4BB93F))
.setFontSize(BubbleUtils.sp2px(10)) .setFontSize(BubbleUtils.sp2px(10))
.create() .create()
AppConfig.isCanSaveBattery = true
} }
} }
...@@ -296,7 +298,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -296,7 +298,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
} }
private fun initRecy() { private fun initRecy() {
recy_wifi.addItemDecoration(DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL)) recy_wifi.addItemDecoration(RecyItemDecoration(mContext, DividerItemDecoration.VERTICAL))
mMainWifiAdapter = MainWifiAdapter(mContext, mWifiList) mMainWifiAdapter = MainWifiAdapter(mContext, mWifiList)
recy_wifi.adapter = mMainWifiAdapter recy_wifi.adapter = mMainWifiAdapter
mMainWifiAdapter?.setOnItemClickListener(this) mMainWifiAdapter?.setOnItemClickListener(this)
......
package com.mints.flowbox.ui.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
public class RecyItemDecoration extends RecyclerView.ItemDecoration {
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
private static final String TAG = "DividerItem";
private static final int[] ATTRS = new int[]{16843284};
private Drawable mDivider;
private int mOrientation;
private final Rect mBounds = new Rect();
public RecyItemDecoration(Context context, int orientation) {
TypedArray a = context.obtainStyledAttributes(ATTRS);
this.mDivider = a.getDrawable(0);
if (this.mDivider == null) {
Log.w("DividerItem", "@android:attr/listDivider was not set in the theme used for this DividerItemDecoration. Please set that attribute all call setDrawable()");
}
a.recycle();
this.setOrientation(orientation);
}
public void setOrientation(int orientation) {
if (orientation != 0 && orientation != 1) {
throw new IllegalArgumentException("Invalid orientation. It should be either HORIZONTAL or VERTICAL");
} else {
this.mOrientation = orientation;
}
}
public void setDrawable(Drawable drawable) {
if (drawable == null) {
throw new IllegalArgumentException("Drawable cannot be null.");
} else {
this.mDivider = drawable;
}
}
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
if (parent.getLayoutManager() != null && this.mDivider != null) {
if (this.mOrientation == 1) {
this.drawVertical(c, parent);
} else {
this.drawHorizontal(c, parent);
}
}
}
private void drawVertical(Canvas canvas, RecyclerView parent) {
canvas.save();
int left;
int right;
if (parent.getClipToPadding()) {
left = parent.getPaddingLeft();
right = parent.getWidth() - parent.getPaddingRight();
canvas.clipRect(left, parent.getPaddingTop(), right, parent.getHeight() - parent.getPaddingBottom());
} else {
left = 0;
right = parent.getWidth();
}
int childCount = parent.getChildCount();
//当最后一个子项的时候去除下划线
for (int i = 0; i < childCount - 1; ++i) {
View child = parent.getChildAt(i);
parent.getDecoratedBoundsWithMargins(child, this.mBounds);
int bottom = this.mBounds.bottom + Math.round(child.getTranslationY());
int top = bottom - this.mDivider.getIntrinsicHeight();
this.mDivider.setBounds(left, top, right, bottom);
this.mDivider.draw(canvas);
}
canvas.restore();
}
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
canvas.save();
int top;
int bottom;
if (parent.getClipToPadding()) {
top = parent.getPaddingTop();
bottom = parent.getHeight() - parent.getPaddingBottom();
canvas.clipRect(parent.getPaddingLeft(), top, parent.getWidth() - parent.getPaddingRight(), bottom);
} else {
top = 0;
bottom = parent.getHeight();
}
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; ++i) {
View child = parent.getChildAt(i);
parent.getLayoutManager().getDecoratedBoundsWithMargins(child, this.mBounds);
int right = this.mBounds.right + Math.round(child.getTranslationX());
int left = right - this.mDivider.getIntrinsicWidth();
this.mDivider.setBounds(left, top, right, bottom);
this.mDivider.draw(canvas);
}
canvas.restore();
}
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
if (this.mDivider == null) {
outRect.set(0, 0, 0, 0);
} else {
if (this.mOrientation == 1) {
outRect.set(0, 0, 0, this.mDivider.getIntrinsicHeight());
} else {
outRect.set(0, 0, this.mDivider.getIntrinsicWidth(), 0);
}
}
}
}
...@@ -23,6 +23,7 @@ public class TimeRender { ...@@ -23,6 +23,7 @@ public class TimeRender {
public static String DEFAULT_FORMAT_MONTH_DAY = "MM月dd日"; public static String DEFAULT_FORMAT_MONTH_DAY = "MM月dd日";
public static String DEFAULT_FORMAT_LINE = "yyyy/MM/dd"; public static String DEFAULT_FORMAT_LINE = "yyyy/MM/dd";
public static String DEFAULT_FORMAT_TIME = "HH:mm:ss"; public static String DEFAULT_FORMAT_TIME = "HH:mm:ss";
public static String DEFAULT_FORMAT_MINTER = "HH:mm";
/** /**
* 年月日时分秒加横杠 * 年月日时分秒加横杠
......
...@@ -20,6 +20,7 @@ private const val TAG = "screenlocker.utils" ...@@ -20,6 +20,7 @@ private const val TAG = "screenlocker.utils"
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
object ScreenLockerUtils { object ScreenLockerUtils {
fun canShowScreenLocker(context: Context): Boolean { fun canShowScreenLocker(context: Context): Boolean {
try { try {
val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager
......
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