Commit 60aa978b authored by mengcuiguang2's avatar mengcuiguang2
parents 0d89b226 6824b0f8
......@@ -159,6 +159,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.1'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
// 网络请求
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
......@@ -179,6 +180,7 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.documentfile:documentfile:1.0.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
// 65536
implementation 'androidx.multidex:multidex:2.0.1'
......
......@@ -277,7 +277,8 @@
# 避免影响升级功能,需要keep住support包的类
-keep class android.support.**{*;}
# 避免清理aidl
-keep class android.content.pm.** { *; }
# ===================== shareSDK START ================
-dontwarn com.mob.**
......
......@@ -5,7 +5,9 @@
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.CALL_PHONE" />
......@@ -23,8 +25,6 @@
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<permission android:name="com.mints.flowbox.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
......@@ -199,10 +199,18 @@
<activity
android:name=".ui.activitys.keepalive.TransparentActivity"
android:excludeFromRecents="true"
android:exported="false"
android:finishOnTaskLaunch="false"
android:launchMode="singleInstance"
android:theme="@style/CustomerTransparentTheme" />
<activity
android:name=".ui.activitys.keepalive.BoostFastActivity"
android:excludeFromRecents="true"
android:exported="false"
android:finishOnTaskLaunch="false"
android:launchMode="singleInstance"
android:theme="@style/CustomerTransparentTheme" />
<service
......
package android.content.pm;
/**
* API for package data change related callbacks from the Package Manager.
* Some usage scenarios include deletion of cache directory, generate
* statistics related to code, data, cache usage(TODO)
* {@hide}
*/
oneway interface IPackageDataObserver {
void onRemoveCompleted(in String packageName, boolean succeeded);
}
\ No newline at end of file
package android.content.pm;
import android.content.pm.PackageStats;
/**
* API for package data change related callbacks from the Package Manager.
* Some usage scenarios include deletion of cache directory, generate
* statistics related to code, data, cache usage(TODO)
* {@hide}
*/
oneway interface IPackageStatsObserver {
void onGetStatsCompleted(in PackageStats pStats, boolean succeeded);
}
\ No newline at end of file
package android.content.pm;
parcelable PackageStats;
\ No newline at end of file
......@@ -28,6 +28,7 @@ import com.mints.flowbox.keepalive.ScreenWatch;
import com.mints.flowbox.keepalive.WifiStateWatch;
import com.mints.flowbox.manager.CsjGroMoreManager;
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.TzManager;
import com.mints.flowbox.manager.ad.WnManager;
......@@ -35,6 +36,7 @@ import com.mints.flowbox.manager.wifi.WifiDataManager;
import com.mints.flowbox.net.LoanService;
import com.mints.flowbox.ui.activitys.keepalive.TriggerActivity;
import com.mints.flowbox.utils.ForegroundOrBackground;
import com.mints.flowbox.utils.LogUtil;
import com.mints.flowbox.utils.SystemUtils;
import com.mints.flowbox.utils.keepalive.ScreenLockerUtils;
import com.module.legacy.oreo.RegisterJobUtils;
......@@ -186,13 +188,11 @@ public class MintsApplication extends BaseApp {
// Toast.makeText(this, "测试:主进程重启成功", Toast.LENGTH_LONG).show();
// }
TrackManager.getInstance().getOuterAdConfig();
WifiStateWatch.getInstance(this).begin(new WifiStateWatch.WifiStateListener() {
@Override
public void onWifiOpen() {
// 应用在前台,则不展示
if (ForegroundOrBackground.isForeground2()) {
return;
}
if (WifiDataManager.INSTANCE.getWifiOn()) {
// 跳转去wifi加速
OutAppRouter.INSTANCE.showTriggerActivity(TriggerActivity.TRIGGER_TYPE_WIFI_BOOST);
......@@ -201,10 +201,6 @@ public class MintsApplication extends BaseApp {
@Override
public void onWifiClose() {
// 应用在前台,则不展示
if (ForegroundOrBackground.isForeground2()) {
return;
}
if (WifiDataManager.INSTANCE.getWifiOff()) {
// 跳转网络测速
OutAppRouter.INSTANCE.showTriggerActivity(TriggerActivity.TRIGGER_TYPE_WIFI_DISCONNECT_TEST);
......@@ -220,13 +216,7 @@ public class MintsApplication extends BaseApp {
@Override
public void onScreenOff() {
// 检测应用是否在前台
if (ForegroundOrBackground.isForeground2()) {
return;
}
// 检测屏幕是否亮起
if (!ScreenLockerUtils.INSTANCE.canShowScreenLocker(MintsApplication.getContext())) {
if (!ScreenLockerUtils.INSTANCE.canShowScreenLocker(mContext)) {
return;
}
......@@ -269,7 +259,6 @@ public class MintsApplication extends BaseApp {
// });
// 监听电话状态
PhoneWatch.getInstance(this).begin(new PhoneWatch.PhoneStateListener() {
@Override
public void onIdle(String phoneNum, int time) {
......@@ -283,7 +272,7 @@ public class MintsApplication extends BaseApp {
BatteryWatch.getInstance(this).begin(new BatteryWatch.BatteryStateListener() {
@Override
public void onCharging() {
if (ForegroundOrBackground.isForeground2()) {
if (ScreenLockerUtils.INSTANCE.canShowScreenLocker(mContext)) {
return;
}
if (WifiDataManager.INSTANCE.getBatteryOn()) {
......@@ -293,9 +282,6 @@ public class MintsApplication extends BaseApp {
@Override
public void onUnCharging() {
if (ForegroundOrBackground.isForeground2()) {
return;
}
if (WifiDataManager.INSTANCE.getBatteryOff()) {
// 跳转省电
OutAppRouter.INSTANCE.showTriggerActivity(TriggerActivity.TRIGGER_TYPE_SAVE_ELE);
......@@ -307,9 +293,6 @@ public class MintsApplication extends BaseApp {
PackageWatch.getInstance(this).begin(new PackageWatch.InstallStateListener() {
@Override
public void onAdded(String pkgName) {
if (ForegroundOrBackground.isForeground2()) {
return;
}
if (WifiDataManager.INSTANCE.getInstallApk()) {
OutAppRouter.INSTANCE.showApkActivity(0, pkgName);
}
......@@ -317,9 +300,6 @@ public class MintsApplication extends BaseApp {
@Override
public void onReplaced(String pkgName) {
if (ForegroundOrBackground.isForeground2()) {
return;
}
if (WifiDataManager.INSTANCE.getUpdateApk()) {
OutAppRouter.INSTANCE.showApkActivity(1, pkgName);
}
......@@ -327,9 +307,6 @@ public class MintsApplication extends BaseApp {
@Override
public void onRemoved(String pkgName) {
if (ForegroundOrBackground.isForeground2()) {
return;
}
if (WifiDataManager.INSTANCE.getUnInstallApk()) {
OutAppRouter.INSTANCE.showApkActivity(2, pkgName);
}
......
......@@ -125,8 +125,6 @@ class AppOutGroMoreCarrierExpressManager : TTSettingConfigCallback {
mTTAdNative?.loadAd(adSlot, object : TTNativeAdLoadCallback {
override fun onAdLoadedFial(adError: AdError?) {
LogUtil.e(TAG, "load feed ad error : " + adError?.code + ", " + adError?.message)
AppConfig.isPreExpressAwardActivity = false
}
override fun onAdLoaded(ads: MutableList<TTNativeAd>?) {
......
......@@ -45,17 +45,19 @@ object KsPreLoadExpressManager {
KsAdSDK.getLoadManager().loadNativeAd(scene, object : KsLoadManager.NativeAdListener {
override fun onError(p0: Int, p1: String?) {
LogUtil.d("$p0 -> $p1")
AppConfig.isPreExpressAwardActivity=false
AppConfig.isPreExpressAwardActivity = false
}
override fun onNativeAdLoad(p0: MutableList<KsNativeAd>?) {
AppConfig.isPreExpressAwardActivity = true
ksNativeAd = p0?.get(0)
mADLoadSuccessListener?.onKSAdLoadSuc(returnAdView(parent, ksNativeAd!!))
}
})
} catch (e: Exception) {
AppConfig.isPreExpressAwardActivity=false
AppConfig.isPreExpressAwardActivity = false
e.printStackTrace()
}
}
......@@ -88,7 +90,8 @@ object KsPreLoadExpressManager {
* 使用SDK渲染的播放控件
*/
private fun getVideoItemView(parent: ViewGroup, ksNativeAd: KsNativeAd): View? {
val convertView: View = LayoutInflater.from(mContext).inflate(R.layout.native_item_video, parent, false)
val convertView: View =
LayoutInflater.from(mContext).inflate(R.layout.native_item_video, parent, false)
val videoViewHolder = AdVideoViewHolder(convertView)
// 设置广告数据
......@@ -123,7 +126,8 @@ object KsPreLoadExpressManager {
* 自定义的单图广告
*/
private fun getSingleImageItemView(parent: ViewGroup, ksNativeAd: KsNativeAd): View? {
val convertView: View = LayoutInflater.from(mContext).inflate(R.layout.native_item_single_image, parent, false)
val convertView: View =
LayoutInflater.from(mContext).inflate(R.layout.native_item_single_image, parent, false)
val viewHolder = AdSingleImageViewHolder(convertView)
bindCommonData(convertView as ViewGroup, viewHolder, ksNativeAd)
......@@ -141,7 +145,8 @@ object KsPreLoadExpressManager {
* 自定义的组图广告
*/
private fun getGroupImageItemView(parent: ViewGroup, ksNativeAd: KsNativeAd): View? {
val convertView: View = LayoutInflater.from(mContext).inflate(R.layout.native_item_group_image, parent, false)
val convertView: View =
LayoutInflater.from(mContext).inflate(R.layout.native_item_group_image, parent, false)
val viewHolder = AdGroupImageViewHolder(convertView)
bindCommonData(convertView as ViewGroup, viewHolder, ksNativeAd)
......@@ -170,14 +175,17 @@ object KsPreLoadExpressManager {
@SuppressLint("DefaultLocale")
private fun getNormalItemView(parent: ViewGroup): View? {
val convertView: View = LayoutInflater.from(mContext).inflate(R.layout.native_item_normal, parent, false)
val convertView: View =
LayoutInflater.from(mContext).inflate(R.layout.native_item_normal, parent, false)
val normalViewHolder = NormalViewHolder(convertView)
normalViewHolder.textView.text = "没有广告"
return convertView
}
private fun bindCommonData(convertView: ViewGroup, adBaseViewHolder: AdBaseViewHolder,
ad: KsNativeAd) {
private fun bindCommonData(
convertView: ViewGroup, adBaseViewHolder: AdBaseViewHolder,
ad: KsNativeAd
) {
// 点击转换view的集合,传入的view点击时会触发转换操作:app下载, 打开h5页面
val clickViewList: MutableList<View> = ArrayList()
clickViewList.add(convertView) // 点击整个view都可触发转换
......@@ -235,7 +243,8 @@ object KsPreLoadExpressManager {
adBaseViewHolder.mAppIcon.visibility = View.GONE
} else {
adBaseViewHolder.mAppIcon.visibility = View.VISIBLE
Glide.with(MintsApplication.getContext()).load(ad.appIconUrl).into(adBaseViewHolder.mAppIcon)
Glide.with(MintsApplication.getContext()).load(ad.appIconUrl)
.into(adBaseViewHolder.mAppIcon)
}
// app名称
if (!TextUtils.isEmpty(ad.appName)) {
......
......@@ -27,9 +27,13 @@ object YlhPreLoadExpressManager {
fun loadYlhFrameLayout() {
try {
nativeExpressAD = NativeExpressAD(MintsApplication.getContext(), ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), YlhAdManager.YLH_AD_NATIVEEXPRESS_AWARD, object : NativeExpressAD.NativeExpressADListener {
nativeExpressAD = NativeExpressAD(
MintsApplication.getContext(),
ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT),
YlhAdManager.YLH_AD_NATIVEEXPRESS_AWARD,
object : NativeExpressAD.NativeExpressADListener {
override fun onNoAD(p0: AdError?) {
AppConfig.isPreExpressAwardActivity=false
AppConfig.isPreExpressAwardActivity = false
}
override fun onADClicked(p0: NativeExpressADView?) {
......@@ -48,6 +52,8 @@ object YlhPreLoadExpressManager {
}
override fun onADLoaded(p0: MutableList<NativeExpressADView>?) {
AppConfig.isPreExpressAwardActivity = true
// 释放前一个展示的NativeExpressADView的资源
nativeExpressADView?.destroy()
......@@ -63,7 +69,7 @@ object YlhPreLoadExpressManager {
}
override fun onRenderFail(p0: NativeExpressADView?) {
AppConfig.isPreExpressAwardActivity=false
AppConfig.isPreExpressAwardActivity = false
}
override fun onRenderSuccess(p0: NativeExpressADView?) {
......@@ -74,7 +80,7 @@ object YlhPreLoadExpressManager {
} catch (e: Exception) {
e.printStackTrace()
AppConfig.isPreExpressAwardActivity=false
AppConfig.isPreExpressAwardActivity = false
}
}
......
......@@ -216,7 +216,10 @@ public class FullGroManager {
}
}
public void showFullAd(Activity _activity) {
public void showFullAd(Activity _activity, WifiAdStatusListener wifiAdStatusListener) {
if (wifiAdStatusListener != null) {
this.wifiAdStatusListener = wifiAdStatusListener;
}
if (BuildConfig.DEBUG) {
LogUtil.d(TAG, "showFullAd isLoadSuccess=" + isLoadSuccess + " isReady=" + mTTFullVideoAd.isReady());
}
......@@ -240,7 +243,7 @@ public class FullGroManager {
/**
* 激励视频交互回调
*/
private TTFullVideoAdListener mTTFullVideoAdListener = new TTFullVideoAdListener() {
private final TTFullVideoAdListener mTTFullVideoAdListener = new TTFullVideoAdListener() {
@Override
public void onFullVideoAdShow() {
......
......@@ -106,6 +106,7 @@ class WifiAdManager private constructor() {
//// interstitialGroManager?.showInteractionAd()
//// }
// Constant.GROMORE_FULL_AD -> {
fullGroManager?.setWifiAdStatusListener(wifiAdStatusListener)
fullGroManager?.showFullAd()
// }
// }
......@@ -133,7 +134,7 @@ class WifiAdManager private constructor() {
// interstitialGroManager?.showInteractionAd(_activity)
// }
// Constant.GROMORE_FULL_AD -> {
fullGroManager?.showFullAd(_activity)
fullGroManager?.showFullAd(_activity,wifiAdStatusListener)
// }
// }
}
......
......@@ -118,7 +118,7 @@ public class CleanUtils {
} else {
uuid = UUID.fromString(uuidStr);
}
int uid = getUid(context, "com.mints.cleaner");
int uid = getUid(context, "com.mints.camera");
//通过包名获取uid
StorageStats storageStats = null;
try {
......
......@@ -11,6 +11,9 @@ import com.mints.flowbox.manager.wifi.WifiDataManager;
import com.mints.flowbox.ui.activitys.keepalive.TransparentActivity;
import com.mints.flowbox.utils.ForegroundOrBackground;
import com.mints.flowbox.utils.keepalive.IntentUtils;
import com.mints.flowbox.utils.keepalive.ScreenLockerUtils;
import net.phone.PhoneBrandUtils;
/**
* 描述:应用外广告定时器
......@@ -91,7 +94,7 @@ public class AlarmManager implements WeakHandler.IHandler {
if (userTime % APP_OUT_TIMING_MINTER == 0) {
// 应用在前台时,不弹出应用外广告
if (ForegroundOrBackground.isForeground2()) {
if (ForegroundOrBackground.isForeground2() || ScreenLockerUtils.INSTANCE.canShowScreenLocker(MintsApplication.getContext())) {
return;
}
......@@ -128,14 +131,22 @@ public class AlarmManager implements WeakHandler.IHandler {
* 展示定时页面
*/
private void showTimingActivity() {
if (ForegroundOrBackground.isForeground2() || ScreenLockerUtils.INSTANCE.canShowScreenLocker(MintsApplication.getContext())) {
return;
}
if (currentType > 5) {
currentType = 0;
}
Intent intent = new Intent(MintsApplication.getContext(), TransparentActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.putExtra(TransparentActivity.TIMING_TYPE, currentType++);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent);
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(intent);
} else {
IntentUtils.startActivity2(intent);
}
}
public void setAppOutTimingMinter(int timingMinter) {
......
package com.mints.flowbox.keepalive
import android.R.attr.phoneNumber
import android.app.Activity
import android.content.Intent
import android.net.Uri
import com.mints.flowbox.MintsApplication
import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.ui.activitys.keepalive.ApkActivity
import com.mints.flowbox.ui.activitys.keepalive.BoostActivity
import com.mints.flowbox.ui.activitys.keepalive.ScreenActivity
import com.mints.flowbox.ui.activitys.keepalive.TriggerActivity
import com.mints.flowbox.utils.ForegroundOrBackground
import com.mints.flowbox.utils.keepalive.IntentUtils
import com.mints.flowbox.utils.keepalive.ScreenLockerUtils.canShowScreenLocker
import net.phone.PhoneBrandUtils
/**
*
* @author jyx
......@@ -30,6 +28,10 @@ object OutAppRouter {
* @param pkgName 包名
*/
fun showApkActivity(state: Int, pkgName: String) {
if (ForegroundOrBackground.isForeground2() || canShowScreenLocker(MintsApplication.getContext())) {
return
}
// 预加载信息流
ExpressManager.loadAppOutExpress()
......@@ -41,7 +43,11 @@ object OutAppRouter {
intent.putExtra(ApkActivity.APK_STATE, state)
intent.putExtra(ApkActivity.APK_PKG_NAME, pkgName)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(intent)
} else {
IntentUtils.startActivity2(intent)
}
}
/**
......@@ -50,12 +56,23 @@ object OutAppRouter {
fun showScreenActivity() {
// 预加载信息流
ExpressManager.loadAppOutExpress()
val intent = Intent(MintsApplication.getContext(), ScreenActivity::class.java)
if (!PhoneBrandUtils.isOppo()) {
intent.flags = Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
}
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
if (PhoneBrandUtils.isHuaweiHonor()) {
IntentUtils.startActivity(intent)
return
}
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(intent)
} else {
IntentUtils.startActivity2(intent)
}
}
/**
......@@ -64,7 +81,7 @@ object OutAppRouter {
fun goToCall(activity: Activity, phone: String?) {
val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:${phone}"))
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
ForegroundOrBackground.getMain_activity().startActivity(intent);
activity.startActivity(intent);
}
/**
......@@ -73,24 +90,29 @@ object OutAppRouter {
fun goToSms(activity: Activity, phone: String?) {
val uri = Uri.parse("smsto:${phone}")
val intent = Intent(Intent.ACTION_SENDTO, uri)
ForegroundOrBackground.getMain_activity().startActivity(intent);
activity.startActivity(intent);
}
/**
* 展示加速页面
*/
fun showBoostActivity() {
// 预加载信息流
ExpressManager.loadAppOutExpress()
val intent = Intent(MintsApplication.getContext(), BoostActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
}
// fun showBoostActivity() {
// // 预加载信息流
// ExpressManager.loadAppOutExpress()
// val intent = Intent(MintsApplication.getContext(), BoostActivity::class.java)
// intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
// IntentUtils.startActivity2(intent)
// }
/**
* 展示弹出页面
*/
fun showTriggerActivity(currentType: Int, phone: String, time: Int) {
// 应用在前台,则不展示
if (ForegroundOrBackground.isForeground2() || canShowScreenLocker(MintsApplication.getContext())) {
return
}
// 预加载信息流
ExpressManager.loadAppOutExpress()
......@@ -98,14 +120,23 @@ object OutAppRouter {
intent.putExtra(TriggerActivity.TRIGGER_TYPE, currentType)
intent.putExtra(TriggerActivity.CALL_PHONE_TIME, time)
intent.putExtra(TriggerActivity.CALL_PHONE_NUM, phone)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(intent)
} else {
IntentUtils.startActivity2(intent)
}
}
/**
* 展示弹出页面
*/
fun showTriggerActivity(currentType: Int) {
// 应用在前台,则不展示
if (ForegroundOrBackground.isForeground2() || canShowScreenLocker(MintsApplication.getContext())) {
return
}
// 预加载信息流
ExpressManager.loadAppOutExpress()
......@@ -123,8 +154,12 @@ object OutAppRouter {
val intent = Intent(MintsApplication.getContext(), TriggerActivity::class.java)
intent.putExtra(TriggerActivity.TRIGGER_TYPE, realType)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(intent)
} else {
IntentUtils.startActivity2(intent)
}
}
private var mWifiConnectType = TriggerActivity.TRIGGER_TYPE_WIFI_BOOST - 1
......
package com.mints.flowbox.ui.activitys
import android.annotation.SuppressLint
import android.app.ActivityManager
import android.content.Context
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.WindowManager
......@@ -26,6 +28,7 @@ import com.mints.flowbox.utils.SpanUtils
import kotlinx.android.synthetic.main.activity_clean.*
import kotlinx.android.synthetic.main.header_layout.*
import kotlinx.android.synthetic.main.view_title.*
import java.lang.Exception
import java.util.*
/**
......@@ -139,6 +142,7 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
childInfo.headId = cacheListItem.applicationIcon
childInfo.fileSize = cacheListItem.cacheSize
childInfo.filePath = cacheListItem.filePath
childInfo.pkgName = cacheListItem.packageName
childInfo.tint = "建议清理"
childInfo.isChecked = true
mCleanList[taskType].childList.add(childInfo)
......@@ -208,7 +212,6 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
mCleanTimer = Timer()
mCleanTimer?.schedule(object : TimerTask() {
override fun run() {
runOnUiThread {
// 单项清理清理完成或没有继续清理的
if (!isItemCleanOk) {
......@@ -240,21 +243,15 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
var removeIndex = -1
var removeChildInfo: ChildInfo? = null
// 清理动画
for (i in 0 until mCleanList[taskType].childList.size) {
if (mCleanList[taskType].childList[i].isChecked) {
removeChildInfo = mCleanList[taskType].childList[i]
removeIndex = i
break
}
}
if (removeIndex >= 0) {
isItemCleanOk = false
remove(taskType, removeIndex, removeChildInfo)
if (taskType == 0) {
cleaningOperation(mContext, mCleanList[taskType].childList)
}
if (taskType == 0) {
// cleaningOperation(mContext)
if (taskType == 1) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
// TODO 清理缓存
// CleanRDataUtil.getAndroidDataCacheUri()
}
}
if (taskType == 4) {
......@@ -265,6 +262,19 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
}
}
}
// 清理动画
for (i in 0 until mCleanList[taskType].childList.size) {
if (mCleanList[taskType].childList[i].isChecked) {
removeChildInfo = mCleanList[taskType].childList[i]
removeIndex = i
break
}
}
if (removeIndex >= 0) {
isItemCleanOk = false
remove(taskType, removeIndex, removeChildInfo)
}
}
taskType++
......@@ -479,41 +489,17 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
}
/** 清理内存 */
private fun cleaningOperation(ctx: Context) {
// val infoList = am.runningAppProcesses
// val serviceInfos = am.getRunningServices(100)
// var count = 0
// if (infoList != null) {
// for (i in infoList.indices) {
// val appProcessInfo = infoList[i]
// Log.e("TAGDD1", "process name : ----------" + appProcessInfo.processName)
// //importance 该进程的重要程度 分为几个级别,数值越低就越重要。
// Log.e("TAGDD2", "importance : -----------" + appProcessInfo.importance)
// // 一般数值大于RunningAppProcessInfo.IMPORTANCE_SERVICE的进程都长时间没用或者空进程了
// // 一般数值大于RunningAppProcessInfo.IMPORTANCE_VISIBLE的进程都是非可见进程,也就是在后台运行着
// if (appProcessInfo.importance > ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE) {
// val pkgList = appProcessInfo.pkgList
// for (j in pkgList.indices) {//pkgList 得到该进程下运行的包名
// Log.e("TAGDD4", "It will be killed, package name : " + pkgList[j])
// if (pkgList[j] != Constant.MINTS_PKG_NAME) {
// am.killBackgroundProcesses(pkgList[j])
// count++
// Log.e("TAGDD4", "count : ----------$count")
// }
// }
// }
// //只要不是com.example.hasee.a1011ceshi这个包名的进程,其余进程全部禁止
//// if (appProcessInfo.processName != Constant.MINTS_PKG_NAME) {
//// val pkgList = appProcessInfo.pkgList
//// for (j in pkgList.indices) { //pkgList 得到该进程下运行的包名
//// Log.e("TAGDD3", "It will be killed, package name : ----------" + pkgList[j])
//// am.killBackgroundProcesses(pkgList[j])
//// count++
//// Log.e("TAGDD4", "count : ----------$count")
//// }
//// }
// }
// }
private fun cleaningOperation(ctx: Context, list: List<ChildInfo>) {
try {
val am = ctx.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
for (childInfo in list) {
if (childInfo.pkgName != Constant.MINTS_PKG_NAME) {
am.killBackgroundProcesses(childInfo.pkgName)
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
......@@ -58,7 +58,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
override fun initViewsAndEvents() {
// 奖励页预加载 信息流广告
ExpressManager.loadExpress(true)
PreLoadExpressManager.loadADFrameLayout()
mainPresenter.attachView(this)
......
......@@ -24,6 +24,7 @@ import com.mints.flowbox.ui.activitys.base.BaseActivity
import com.mints.flowbox.ui.widgets.dialog.DialogListener
import com.mints.flowbox.ui.widgets.dialog.DialogUtils
import com.mints.flowbox.utils.DecodeCodeTools
import com.mints.flowbox.utils.LogUtil
import com.mints.flowbox.utils.WifiUtils
import kotlinx.android.synthetic.main.activity_scan.*
import java.nio.ByteBuffer
......@@ -188,6 +189,8 @@ class ScanActivity : BaseActivity(), View.OnClickListener {
*
*/
private fun autoConnectWifi(wifiStr: String?) {
LogUtil.d(wifiStr)
if (TextUtils.isEmpty(wifiStr)) {
ToastUtils.show("无效的WIFI二维码!")
return
......@@ -196,7 +199,7 @@ class ScanActivity : BaseActivity(), View.OnClickListener {
var ssid = ""
var psw = ""
wifiStr?.let {
if (!it.contains("WIFI") or !it.contains("wifi")) {
if (!it.contains("WIFI")) {
ToastUtils.show("无效的WIFI二维码!")
return
}
......@@ -219,23 +222,21 @@ class ScanActivity : BaseActivity(), View.OnClickListener {
override fun onClick(dialog: Dialog?, v: View?) {
super.onClick(dialog, v)
Handler(Looper.getMainLooper()).postDelayed({
if (TextUtils.equals(
ssid,
WifiUtils.getInstance(this@ScanActivity).connectionWifiInfo.ssid
)
) {
ToastUtils.show("正在连接中...")
WifiUtils.getInstance(this@ScanActivity)
.connectWifiPws(ssid, psw, object : WifiUtils.CallBack {
override fun onSuccess() {
ToastUtils.show("连接成功...")
finish()
} else {
}
override fun onFail() {
ToastUtils.show("连接失败...")
startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
}
}, 3000)
ToastUtils.show("正在连接中...")
WifiUtils.getInstance(this@ScanActivity).connectWifiPws(ssid, psw)
})
dialog?.dismiss()
}
})
......
......@@ -123,7 +123,7 @@ public class SplashGroMoreActivity extends BaseActivity {
// mTTSplashAd.loadAd(adSlot, new TTSplashAdLoadCallback() {
@Override
public void onSplashAdLoadFail(AdError adError) {
mProgressBar.setComplete();
mProgressBar.post(() -> mProgressBar.setComplete());
mMainHandler.postDelayed(() -> {
LogUtil.d(TAG, adError.message);
......@@ -140,7 +140,7 @@ public class SplashGroMoreActivity extends BaseActivity {
@Override
public void onSplashAdLoadSuccess() {
mProgressBar.setComplete();
mProgressBar.post(() -> mProgressBar.setComplete());
mMainHandler.postDelayed(() -> {
......@@ -165,7 +165,7 @@ public class SplashGroMoreActivity extends BaseActivity {
@Override
public void onAdLoadTimeout() {
mProgressBar.setComplete();
mProgressBar.post(() -> mProgressBar.setComplete());
mMainHandler.postDelayed(() -> {
mHasLoaded = true;
......
......@@ -41,16 +41,10 @@ abstract class OutAppActivity : BaseSwipeBackCompatActivity() {
resetWindowTransparentBackground()
// 设置锁屏页全屏
val isUsingShowWhenLockedFlag = !ScreenLockerUtils.isLockScreenProtected(this)
if (isUsingShowWhenLockedFlag) {
ScreenLockerUtils.updateWindowFlags(window.decorView)
} else {
ScreenLockerUtils.makeLockWindowFullScreen(
this,
this.window.attributes,
isUsingShowWhenLockedFlag
)
}
// val isUsingShowWhenLockedFlag = !ScreenLockerUtils.isLockScreenProtected(this)
// if (isUsingShowWhenLockedFlag) {
// ScreenLockerUtils.updateWindowFlags(window.decorView)
// }
}
private fun resetWindowTransparentBackground() {
......@@ -61,7 +55,7 @@ abstract class OutAppActivity : BaseSwipeBackCompatActivity() {
Manifest.permission.WRITE_EXTERNAL_STORAGE
) != 0
) {
window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
window.setBackgroundDrawable(ColorDrawable(Color.BLACK))
} else {
val wallpaperManager = WallpaperManager.getInstance(this)
val wallpaperDrawable: Drawable = wallpaperManager.drawable
......
......@@ -9,14 +9,17 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.mints.flowbox.R
import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.ad.wifi.WifiAdManager
import com.mints.flowbox.ad.wifi.WifiAdStatusListener
import com.mints.flowbox.ui.activitys.base.BaseActivity
import com.mints.flowbox.utils.ForegroundOrBackground
import com.mints.flowbox.utils.LogUtil
import kotlinx.android.synthetic.main.activity_boost_fast.*
import kotlinx.android.synthetic.main.activity_boost_fast.iv_close
import net.phone.PhoneBrandUtils
import java.util.*
import kotlin.random.Random
/**
......@@ -79,15 +82,37 @@ class BoostFastActivity : BaseActivity() {
Handler(Looper.getMainLooper()).postDelayed(
{
YoYo.with(Techniques.FadeOut).duration(500).playOn(container)
YoYo.with(Techniques.FadeOut).duration(500).playOn(ccav_speed)
WifiAdManager.instance.showInterstitial(this)
WifiAdManager.instance.setWifiAdStatusListener(object : WifiAdStatusListener {
override fun adSuccess() {
}
override fun adFail() {
}
override fun adClose() {
}
})
WifiAdManager.instance.showInterstitial(this@BoostFastActivity)
},
2500
)
Handler(Looper.getMainLooper()).postDelayed(
{
Handler(Looper.getMainLooper()).postDelayed({ updataUi() }, 3000)
colorAnim.addListener(object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator?) {}
override fun onAnimationEnd(animation: Animator?) {
}
override fun onAnimationCancel(animation: Animator?) {}
override fun onAnimationRepeat(animation: Animator?) {}
})
}
private fun updataUi() {
ccav_speed.stopAnimation()
ccav_speed.visibility = View.GONE
container.visibility = View.GONE
......@@ -107,19 +132,6 @@ class BoostFastActivity : BaseActivity() {
TransparentActivity.TIMING_TYPE_SAFE -> tvContent.text = "当前网络环境良好"
TransparentActivity.TIMING_TYPE_PRICARY -> tvContent.text = "当前使用环境安全"
}
}, 3000
)
colorAnim.addListener(object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator?) {}
override fun onAnimationEnd(animation: Animator?) {
}
override fun onAnimationCancel(animation: Animator?) {}
override fun onAnimationRepeat(animation: Animator?) {}
})
}
private fun initView() {
......@@ -129,6 +141,11 @@ class BoostFastActivity : BaseActivity() {
}
}
override fun onDestroy() {
WifiAdManager.instance.onDestroy()
super.onDestroy()
}
override fun onResume() {
super.onResume()
initExpress()
......
......@@ -54,6 +54,7 @@ class TransparentActivity : BaseActivity() {
ExpressManager.loadAppOutExpress()
val intent = Intent(MintsApplication.getContext(), BoostFastActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
intent.putExtra(TIMING_TYPE, mType)
startActivity(intent)
finish()
......
......@@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.provider.Settings
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -29,8 +30,6 @@ class MainWifiAdapter(val context: Context, val taskData: MutableList<WifiListBe
mOnItemClickListener = onItemClickListener
}
// fun set
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
if (viewType == FriendsInvitedAdapter.HOLDER_TYPE_EMPTY) {
val emptyView =
......@@ -83,6 +82,18 @@ class MainWifiAdapter(val context: Context, val taskData: MutableList<WifiListBe
wifiHolder.btnConnect.setBackgroundResource(R.drawable.shape_tv_gold_gury)
}
when {
TextUtils.equals(taskData[position].wifiSignal, "很强") -> {
wifiHolder.ivWifiSignal.setImageResource(R.mipmap.ic_main_wifi_signal_level_1)
}
TextUtils.equals(taskData[position].wifiSignal, "较强") -> {
wifiHolder.ivWifiSignal.setImageResource(R.mipmap.ic_main_wifi_signal_level_2)
}
else -> {
wifiHolder.ivWifiSignal.setImageResource(R.mipmap.ic_main_wifi_signal_level_3)
}
}
wifiHolder.btnConnect.setOnClickListener {
mOnItemClickListener?.onItemClick(it, position)
}
......
......@@ -47,6 +47,15 @@ public class ExpandInfo {
public String tint; // 提示
public String filePath; // 路径
public boolean isChecked; // 是否选中
public String pkgName; // 包名
public String isPkgName() {
return pkgName;
}
public void setPkgName(String pkgName) {
this.pkgName = pkgName;
}
public Object getHeadId() {
return headId;
......
......@@ -11,7 +11,9 @@ import android.os.Bundle
import android.text.TextUtils
import android.view.Gravity
import android.view.View
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.mints.flowbox.BuildConfig
import com.mints.flowbox.MintsApplication
import com.mints.library.net.netstatus.NetUtils
......@@ -39,6 +41,7 @@ import com.mints.flowbox.ui.widgets.dialog.ShareDialog
import com.mints.flowbox.ui.widgets.seekbar.BubbleUtils
import com.mints.flowbox.utils.AppUtil
import com.mints.flowbox.utils.SpanUtils
import com.mints.flowbox.utils.ToolUtil
import com.mints.library.utils.CommonUtils
import com.mints.library.utils.GlideUtils
import kotlinx.android.synthetic.main.fragment_main_my.*
......@@ -59,7 +62,7 @@ private val TAG = MyFragment::class.java.simpleName
class MyFragment : BaseFragment(),
MyView,
OnItemChildClickListener,
View.OnClickListener {
View.OnClickListener, SwipeRefreshLayout.OnRefreshListener {
private val myPresenter by lazy { MyPresenter() }
private val userManager by lazy { UserManager.getInstance() }
......@@ -162,6 +165,8 @@ class MyFragment : BaseFragment(),
}
override fun getUserTaskMsgSuc(data: MyInfo?) {
swipeRefreshLayout.isRefreshing = false
if (data == null) {
userConfig = null
return
......@@ -731,6 +736,13 @@ class MyFragment : BaseFragment(),
iv_right_icon.visibility = View.VISIBLE
iv_right_icon.setImageResource(R.mipmap.ic_settings)
line.visibility = View.GONE
swipeRefreshLayout.setProgressViewEndTarget(true, ToolUtil.dp2px(mContext, 100))
swipeRefreshLayout.setColorSchemeColors(
ContextCompat.getColor(
mContext,
R.color.color_main
)
)
tv_left_subtitle.setOnClickListener(this)
item_title_id.setOnClickListener(this)
......@@ -739,6 +751,7 @@ class MyFragment : BaseFragment(),
btn_coinRecord.setOnClickListener(this)
item_title_friends.setOnClickListener(this)
ll_my_login.setOnClickListener(this)
swipeRefreshLayout.setOnRefreshListener(this)
}
/** 初始化任务列表 */
......@@ -908,4 +921,8 @@ class MyFragment : BaseFragment(),
mReceiverBroadcastReceiver = null
}
}
override fun onRefresh() {
onResume()
}
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import android.view.View
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.hjq.toast.ToastUtils
......@@ -44,6 +45,7 @@ import com.mints.library.net.netstatus.NetUtils
import com.mints.library.utils.nodoubleclick.AntiShake
import com.tbruyelle.rxpermissions.RxPermissions
import kotlinx.android.synthetic.main.fragment_wifi.*
import kotlinx.android.synthetic.main.fragment_wifi.swipeRefreshLayout
import rx.Observable
import java.util.*
import kotlin.random.Random
......@@ -57,7 +59,7 @@ private val TAG = WifiFragment::class.java.simpleName
* @des 福利页
*/
class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
WifiStateManager.WifiStateCallback {
WifiStateManager.WifiStateCallback, SwipeRefreshLayout.OnRefreshListener {
private var mMainWifiAdapter: MainWifiAdapter? = null
private val mWifiList: MutableList<WifiListBean> = mutableListOf()
......@@ -90,6 +92,12 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
openGpsSettings()
}
updateUiState()
btn_signal.postDelayed({
rope = YoYo.with(Techniques.Pulse).duration(500).repeat(-1).playOn(btn_signal)
}, 200)
// 防止banner刷新太快
// if (AntiShake.check(fl_wifi_banner?.id)) return
// BannerManager.instance.getTtBanner(TtCsjAdManager.TT_AD_BANNER_MY, fl_wifi_banner)
......@@ -118,14 +126,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
/** 重置wifi数据 */
@SuppressLint("SetTextI18n")
private fun loadWifiData() {
btn_signal.postDelayed({
rope = YoYo.with(Techniques.Pulse).duration(500).repeat(-1).playOn(btn_signal)
}, 200)
if (wifiUtils.isWifiEnable) {
mWifiList.clear()
updateUiState()
if (wifiUtils.isWifiEnable) {
val connectionWifiInfo = wifiUtils.connectionWifiInfo
// 校验是否有定位权限
......@@ -146,6 +149,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
btn_signal.text = "打开设置"
imageView2.setImageResource(R.mipmap.ic_main_wifi_none)
}
Handler(Looper.getMainLooper()).postDelayed({
swipeRefreshLayout.isRefreshing = false
}, 1000)
return
}
......@@ -154,26 +160,49 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
tv_wifi_ssid.text = connectionWifiInfo.ssid.replace("\"", "")
tv_wifi_info.text = "连接成功,安全保护中"
btn_signal.text = "信号增强"
if (connectionWifiInfo.rssi > -70) {
imageView2.setImageResource(R.mipmap.ic_main_wifi)
} else {
imageView2.setImageResource(R.mipmap.ic_main_wifi_low)
}
generateWifiListData(connectionWifiInfo, true)
} else {
tv_wifi_ssid.text = "WIFI未连接"
tv_wifi_info.text = "请连接无线网络"
btn_signal.text = "打开设置"
imageView2.setImageResource(R.mipmap.ic_main_wifi_none)
generateWifiListData(null, false)
}
generateWifiListData(connectionWifiInfo)
} else {
tv_wifi_ssid.text = "WIFI未开启"
tv_wifi_info.text = "请先开启无线网络"
btn_signal.text = "开启WIFI"
imageView2.setImageResource(R.mipmap.ic_main_wifi_none)
generateWifiListData(null, false)
}
}
/** 生成wifi列表数据 */
private fun generateWifiListData(connectionWifiInfo: WifiInfo) {
val ssid = connectionWifiInfo.ssid.replace("\"", "")
private fun generateWifiListData(connectionWifiInfo: WifiInfo?, isConnected: Boolean) {
Handler(Looper.getMainLooper()).postDelayed({
swipeRefreshLayout.isRefreshing = false
}, 1000)
if (!isConnected) {
Handler(Looper.getMainLooper()).postDelayed({
swipeRefreshLayout.isRefreshing = false
}, 1000)
mMainWifiAdapter?.notifyDataSetChanged()
return
}
mWifiList.clear()
val ssid = connectionWifiInfo!!.ssid.replace("\"", "")
for (scanResult in wifiUtils.wifiList) {
if (TextUtils.isEmpty(scanResult.SSID)) continue
if (TextUtils.equals(scanResult.SSID, ssid)) {
......@@ -220,6 +249,10 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
Collections.swap(mWifiList, 0, connectIndex)
}
Handler(Looper.getMainLooper()).postDelayed({
swipeRefreshLayout.isRefreshing = false
}, 1000)
mMainWifiAdapter?.notifyDataSetChanged()
}
......@@ -251,7 +284,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
if (AppConfig.isCanSaveBattery) {
if (AppConfig.fakeBoostCount != 0) {
AppConfig.fakeSaveBatteryCount = 1 + Random.nextInt(8)
}
tv_save_battery.text = SpanUtils()
.append("超强省电\n")
.append("${AppConfig.fakeSaveBatteryCount}个")
......@@ -305,7 +340,12 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
private fun initRecy() {
recy_wifi.addItemDecoration(RecyItemDecoration(mContext, DividerItemDecoration.VERTICAL))
recy_wifi.addItemDecoration(
RecyItemDecoration(
mContext,
DividerItemDecoration.VERTICAL
)
)
mMainWifiAdapter = MainWifiAdapter(mContext, mWifiList)
recy_wifi.adapter = mMainWifiAdapter
mMainWifiAdapter?.setOnItemClickListener(this)
......@@ -320,9 +360,17 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
tv_save_battery.setOnClickListener(this)
btn_signal.setOnClickListener(this)
ivImg.setOnClickListener(this)
swipeRefreshLayout.setOnRefreshListener(this)
}
private fun initView() {
swipeRefreshLayout.setProgressViewEndTarget(true, ToolUtil.dp2px(mContext, 100))
swipeRefreshLayout.setColorSchemeColors(
ContextCompat.getColor(
mContext,
R.color.color_main
)
)
WifiStateManager.instance.setWifiStateCallback(this)
}
......@@ -465,7 +513,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
/** 滚动到底部 */
private fun scrollToBottom() {
Handler(Looper.getMainLooper()).postDelayed({
container.scrollTo(0, container.height)
container.smoothScrollTo(0, container.height)
}, 100)
}
......@@ -537,14 +585,31 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
return
}
wifiUtils.connectWifiPws(wifiListBean.wifiName, wifiDialog!!.getInputStr())
ToastUtils.show("正在连接中...")
wifiUtils.connectWifiPws(
wifiListBean.wifiName,
wifiDialog!!.getInputStr(),
object : WifiUtils.CallBack {
override fun onSuccess() {
ToastUtils.show("连接成功...")
requireActivity().runOnUiThread {
loadWifiData()
}
}
override fun onFail() {
ToastUtils.show("连接失败...")
startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
}
})
wifiDialog?.dismiss()
}
})
wifiDialog?.let {
it.clearInput()
it.setWifiName(wifiListBean.wifiName)
it.setWifiSignal(wifiListBean.wifiSignal)
it.setWifiEncodeType(wifiListBean.cipherType)
......@@ -566,4 +631,8 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
// fl_wifi_banner?.removeAllViews()
super.onDestroy()
}
override fun onRefresh() {
loadWifiData()
}
}
\ No newline at end of file
......@@ -113,6 +113,11 @@ public class CycleProgress extends View {
}
public void setComplete() {
if (mAnimator != null) {
mAnimator.cancel();
mAnimator = null;
}
mProgressWidth = mViewWidth;
invalidate();
}
......
......@@ -51,6 +51,10 @@ class WifiConnectDialog(context: Context, private val listener: DialogListener)
tvCancel.setOnClickListener { dismiss() }
}
fun clearInput() {
etPsw.text.clear()
}
fun setWifiName(str: String) {
tvName.text = str
}
......
This diff is collapsed.
package com.mints.flowbox.utils;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.IPackageStatsObserver;
import android.content.pm.PackageStats;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* @author jyx
* @date 2021/7/17
* @des
*/
public class CleanUtils {
public static void cleanCache(Context context) {
PackageManager pm = context.getPackageManager();
try {
Method getPackageSizeInfoMethod = pm.getClass().getMethod("getPackageSizeInfo", String.class, IPackageStatsObserver.class);
Method myUserId = UserHandle.class.getDeclaredMethod("myUserId");
getPackageSizeInfoMethod.invoke(pm, "com.mints.camera", new IPackageStatsObserver() {
@Override
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
if (succeeded) {
LogUtil.d("AAA" + pStats.cacheSize);
}
}
@Override
public IBinder asBinder() {
return null;
}
});
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
}
......@@ -64,10 +64,15 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
}
public static Activity getMain_activity() {
try {
if (main_activity.get() == null) {
return app_activity.get();
}
return main_activity.get();
} catch (NullPointerException e) {
e.printStackTrace();
return null;
}
}
@Override
......
......@@ -3,13 +3,24 @@ package com.mints.flowbox.utils;
import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiNetworkSpecifier;
import android.os.Build;
import android.os.PatternMatcher;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.mints.flowbox.MintsApplication;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
......@@ -79,7 +90,7 @@ public class WifiUtils {
ConnectivityManager connectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
return activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI;
return activeNetInfo != null && activeNetInfo.isConnected();
}
/**
......@@ -172,10 +183,54 @@ public class WifiUtils {
* @param ssid
* @param pws
*/
public void connectWifiPws(String ssid, String pws) {
public void connectWifiPws(String ssid, String pws, CallBack callBack) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
connectWifiPswQ(ssid, pws, callBack);
return;
}
wifiManager.disableNetwork(wifiManager.getConnectionInfo().getNetworkId());
int netId = wifiManager.addNetwork(getWifiConfig(ssid, pws, true));
wifiManager.enableNetwork(netId, true);
if (wifiManager.enableNetwork(netId, true)) {
callBack.onSuccess();
} else {
callBack.onFail();
}
}
@RequiresApi(api = Build.VERSION_CODES.Q)
private void connectWifiPswQ(String ssid, String pws, CallBack callBack) {
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier.Builder()
.setSsidPattern(new PatternMatcher(ssid, PatternMatcher.PATTERN_PREFIX))
.setWpa2Passphrase(pws)
.build();
NetworkRequest networkRequest = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.setNetworkSpecifier(wifiNetworkSpecifier)
.build();
ConnectivityManager connectivityManager = MintsApplication.getContext().getSystemService(ConnectivityManager.class);
connectivityManager.requestNetwork(networkRequest,
new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(@NonNull Network network) {
super.onAvailable(network);
connectivityManager.bindProcessToNetwork(network);
callBack.onSuccess();
}
@Override
public void onUnavailable() {
super.onUnavailable();
callBack.onFail();
}
});
}
public interface CallBack {
void onSuccess();
void onFail();
}
/**
......
......@@ -11,8 +11,8 @@ import androidx.core.app.NotificationCompat
import com.mints.flowbox.R
object NotificationUtils {
private const val ID = "channel_1"
private const val NAME = "notification"
private const val ID = "channel_flowbox"
private const val NAME = "默认通知"
private var manager: NotificationManager? = null
......@@ -56,7 +56,7 @@ object NotificationUtils {
PendingIntent.FLAG_UPDATE_CURRENT
)
val notificationBuilder = NotificationCompat.Builder(context, ID)
.setSmallIcon(R.drawable.ic_launcher_main)
.setSmallIcon(R.mipmap.ic_wifi_notice)
.setContentTitle(title)
.setContentText(content)
.setSound(null)
......
......@@ -4,13 +4,17 @@ import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import com.mints.flowbox.MintsApplication;
import com.activityutil.ActivityManagerProxy;
import com.activityutil.BringToFrontListener;
import com.activityutil.ContextLike;
import com.mints.flowbox.utils.ForegroundOrBackground;
import net.phone.PhoneBrandUtils;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
......@@ -22,22 +26,38 @@ public class IntentUtils {
public static final String TAG = "IntentUtils";
public static void startActivity(Activity activity, Intent intent) {
if (PhoneBrandUtils.isXiaomi() | PhoneBrandUtils.isVivo() | PhoneBrandUtils.isOppo()) {
// if (!isRunningForeground(activity)) {
// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
public static void startActivity2(Intent intent) {
if (PhoneBrandUtils.isHuaweiHonor()) {
if (ForegroundOrBackground.getMain_activity() != null) {
startActivity(intent);
return;
}
}
try {
ActivityManagerProxy.INSTANCE.bringToFront(new BringToFrontListener() {
@Override
public void onCall(@NotNull ContextLike contextLike) {
contextLike.startActivity(intent);
}
@Override
public void onResult(boolean b) {
}
}, null);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void startActivity(Intent intent) {
if (ForegroundOrBackground.getMain_activity() != null) {
Activity activity = ForegroundOrBackground.getMain_activity();
moveToFront(activity);
MintsApplication.getContext().startActivity(intent);
activity.startActivity(intent);
activity.moveTaskToBack(true);
// } else {
// NotificationUtils.INSTANCE.sendNotificationFullScreen(activity, "", "", intent);
// }
// } else {
// MintsApplication.getContext().startActivity(intent);
// }
} else {
MintsApplication.getContext().startActivity(intent);
return;
}
startActivity2(intent);
}
public static Boolean isRunningForeground(Activity activity) {
......@@ -54,7 +74,7 @@ public class IntentUtils {
public static void moveToFront(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> taskInfoList = activityManager.getRunningTasks(1);
List<ActivityManager.RunningTaskInfo> taskInfoList = activityManager.getRunningTasks(20);
for (ActivityManager.RunningTaskInfo taskInfo : taskInfoList) {
//遍历找到本应用的 task,并将它切换到前台
......
......@@ -15,7 +15,7 @@
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginStart="15dp"
android:layout_marginTop="180dp"
android:layout_marginTop="150dp"
android:layout_marginEnd="15dp"
android:background="@mipmap/ic_app_out_background">
......@@ -34,7 +34,7 @@
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginEnd="5dp"
android:drawableStart="@mipmap/ic_ok"
android:drawableStart="@mipmap/ic_right"
android:drawablePadding="6dp"
android:text="-"
android:textColor="@color/white"
......
......@@ -44,9 +44,9 @@
android:layout_height="wrap_content"
android:layout_above="@id/app_logo"
android:layout_alignParentBottom="true"
android:layout_marginStart="20dp"
android:layout_marginStart="30dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="50dp" />
</RelativeLayout>
......
......@@ -4,16 +4,18 @@
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="@drawable/shape_bg_write"
android:padding="10dp">
android:paddingStart="20dp"
android:paddingTop="10dp"
android:paddingEnd="20dp"
android:paddingBottom="10dp">
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="15dp"
android:text="WIFI名称"
android:textColor="@color/black"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -21,10 +23,9 @@
android:id="@+id/tv_wifi_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="15dp"
android:text="-"
android:textColor="@color/black"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -32,7 +33,7 @@
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:layout_marginTop="15dp"
android:background="@color/color_E6E6E6"
app:layout_constraintTop_toBottomOf="@id/textView8" />
......@@ -40,10 +41,9 @@
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="15dp"
android:text="信号强度"
android:textColor="@color/black"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line1" />
......@@ -51,10 +51,9 @@
android:id="@+id/tv_wifi_signal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="15dp"
android:text="-"
android:textColor="@color/black"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/line1" />
......@@ -62,7 +61,7 @@
android:id="@+id/line2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:layout_marginTop="15dp"
android:background="@color/color_E6E6E6"
app:layout_constraintTop_toBottomOf="@id/textView9" />
......@@ -70,10 +69,9 @@
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="15dp"
android:text="加密方式"
android:textColor="@color/black"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line2" />
......@@ -81,7 +79,7 @@
android:id="@+id/tv_wifi_encode_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="15dp"
android:text="-"
android:textColor="@color/black"
android:textSize="12sp"
......@@ -92,7 +90,7 @@
android:id="@+id/line3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:layout_marginTop="15dp"
android:background="@color/color_E6E6E6"
app:layout_constraintTop_toBottomOf="@id/textView10" />
......@@ -103,7 +101,7 @@
android:layout_marginTop="20dp"
android:text="输入WiFi密码"
android:textColor="@color/black"
android:textSize="16sp"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......@@ -118,7 +116,7 @@
android:hint="输入密码"
android:inputType="textPassword"
android:padding="10dp"
android:textSize="12sp"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@id/textView11" />
<Button
......@@ -129,7 +127,7 @@
android:background="@drawable/shape_btn_clean"
android:text="连接"
android:textColor="@color/white"
android:textSize="18sp"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="@id/et_psw" />
<TextView
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollviewMy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:overScrollMode="never">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<View
android:layout_width="match_parent"
......@@ -69,4 +74,5 @@
</FrameLayout>
</androidx.core.widget.NestedScrollView>
\ No newline at end of file
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -233,4 +238,5 @@
</FrameLayout>
</androidx.core.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
\ No newline at end of file
......@@ -10,7 +10,7 @@
android:id="@+id/iv_left_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="10dp"
android:padding="14dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
......@@ -18,6 +18,6 @@
android:layout_height="20dp"
android:layout_alignTop="@id/tv1"
android:layout_alignParentEnd="true"
android:src="@mipmap/bg_right" />
android:src="@mipmap/ic_right_green" />
</RelativeLayout>
\ No newline at end of file
......@@ -10,7 +10,7 @@
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:padding="10dp"
android:padding="14dp"
android:src="@mipmap/ic_arrow_back" />
<ImageView
......@@ -19,7 +19,7 @@
android:layout_height="50dp"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/tv_activity_back"
android:padding="12dp"
android:padding="15dp"
android:src="@mipmap/ic_close" />
<TextView
......
app/src/main/res/mipmap-xhdpi/ic_close.png

420 Bytes | W: | H:

app/src/main/res/mipmap-xhdpi/ic_close.png

655 Bytes | W: | H:

app/src/main/res/mipmap-xhdpi/ic_close.png
app/src/main/res/mipmap-xhdpi/ic_close.png
app/src/main/res/mipmap-xhdpi/ic_close.png
app/src/main/res/mipmap-xhdpi/ic_close.png
  • 2-up
  • Swipe
  • Onion skin
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