Commit 80bdeaf4 authored by jyx's avatar jyx

适配android10连接wifi,界面优化

parent 6737bb78
...@@ -180,6 +180,7 @@ dependencies { ...@@ -180,6 +180,7 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.11.0' implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.documentfile:documentfile:1.0.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
// 65536 // 65536
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
......
...@@ -277,7 +277,8 @@ ...@@ -277,7 +277,8 @@
# 避免影响升级功能,需要keep住support包的类 # 避免影响升级功能,需要keep住support包的类
-keep class android.support.**{*;} -keep class android.support.**{*;}
# 避免清理aidl
-keep class android.content.pm.** { *; }
# ===================== shareSDK START ================ # ===================== shareSDK START ================
-dontwarn com.mob.** -dontwarn com.mob.**
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> <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.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" /> <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
......
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; ...@@ -28,6 +28,7 @@ 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;
...@@ -186,6 +187,8 @@ public class MintsApplication extends BaseApp { ...@@ -186,6 +187,8 @@ 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() {
......
...@@ -216,7 +216,10 @@ public class FullGroManager { ...@@ -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) { if (BuildConfig.DEBUG) {
LogUtil.d(TAG, "showFullAd isLoadSuccess=" + isLoadSuccess + " isReady=" + mTTFullVideoAd.isReady()); LogUtil.d(TAG, "showFullAd isLoadSuccess=" + isLoadSuccess + " isReady=" + mTTFullVideoAd.isReady());
} }
...@@ -240,7 +243,7 @@ public class FullGroManager { ...@@ -240,7 +243,7 @@ public class FullGroManager {
/** /**
* 激励视频交互回调 * 激励视频交互回调
*/ */
private TTFullVideoAdListener mTTFullVideoAdListener = new TTFullVideoAdListener() { private final TTFullVideoAdListener mTTFullVideoAdListener = new TTFullVideoAdListener() {
@Override @Override
public void onFullVideoAdShow() { public void onFullVideoAdShow() {
......
...@@ -106,6 +106,7 @@ class WifiAdManager private constructor() { ...@@ -106,6 +106,7 @@ class WifiAdManager private constructor() {
//// interstitialGroManager?.showInteractionAd() //// interstitialGroManager?.showInteractionAd()
//// } //// }
// Constant.GROMORE_FULL_AD -> { // Constant.GROMORE_FULL_AD -> {
fullGroManager?.setWifiAdStatusListener(wifiAdStatusListener)
fullGroManager?.showFullAd() fullGroManager?.showFullAd()
// } // }
// } // }
...@@ -133,7 +134,7 @@ class WifiAdManager private constructor() { ...@@ -133,7 +134,7 @@ class WifiAdManager private constructor() {
// interstitialGroManager?.showInteractionAd(_activity) // interstitialGroManager?.showInteractionAd(_activity)
// } // }
// Constant.GROMORE_FULL_AD -> { // Constant.GROMORE_FULL_AD -> {
fullGroManager?.showFullAd(_activity) fullGroManager?.showFullAd(_activity,wifiAdStatusListener)
// } // }
// } // }
} }
......
...@@ -118,7 +118,7 @@ public class CleanUtils { ...@@ -118,7 +118,7 @@ public class CleanUtils {
} else { } else {
uuid = UUID.fromString(uuidStr); uuid = UUID.fromString(uuidStr);
} }
int uid = getUid(context, "com.mints.cleaner"); int uid = getUid(context, "com.mints.camera");
//通过包名获取uid //通过包名获取uid
StorageStats storageStats = null; StorageStats storageStats = null;
try { try {
......
...@@ -136,8 +136,8 @@ public class AlarmManager implements WeakHandler.IHandler { ...@@ -136,8 +136,8 @@ public class AlarmManager implements WeakHandler.IHandler {
} }
Intent intent = new Intent(MintsApplication.getContext(), TransparentActivity.class); 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.putExtra(TransparentActivity.TIMING_TYPE, currentType++);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (PhoneBrandUtils.isLockScreenProtected()) { if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent); IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent);
} else { } else {
......
...@@ -62,6 +62,12 @@ object OutAppRouter { ...@@ -62,6 +62,12 @@ object OutAppRouter {
intent.flags = Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT intent.flags = Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
} }
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
if (PhoneBrandUtils.isHuaweiHonor()) {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
return
}
if (PhoneBrandUtils.isLockScreenProtected()) { if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent) IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
} else { } else {
......
package com.mints.flowbox.ui.activitys package com.mints.flowbox.ui.activitys
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.ActivityManager
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
import android.view.animation.Animation import android.view.animation.Animation
...@@ -21,6 +24,7 @@ import com.mints.flowbox.ui.adapter.clean.CleanExpandAdapter ...@@ -21,6 +24,7 @@ import com.mints.flowbox.ui.adapter.clean.CleanExpandAdapter
import com.mints.flowbox.ui.adapter.clean.ExpandInfo import com.mints.flowbox.ui.adapter.clean.ExpandInfo
import com.mints.flowbox.ui.adapter.clean.ExpandInfo.ChildInfo import com.mints.flowbox.ui.adapter.clean.ExpandInfo.ChildInfo
import com.mints.flowbox.ui.widgets.seekbar.BubbleUtils import com.mints.flowbox.ui.widgets.seekbar.BubbleUtils
import com.mints.flowbox.utils.CleanRDataUtil
import com.mints.flowbox.utils.FileUtils import com.mints.flowbox.utils.FileUtils
import com.mints.flowbox.utils.SpanUtils import com.mints.flowbox.utils.SpanUtils
import kotlinx.android.synthetic.main.activity_clean.* import kotlinx.android.synthetic.main.activity_clean.*
...@@ -139,6 +143,7 @@ class CleanActivity : BaseActivity(), View.OnClickListener { ...@@ -139,6 +143,7 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
childInfo.headId = cacheListItem.applicationIcon childInfo.headId = cacheListItem.applicationIcon
childInfo.fileSize = cacheListItem.cacheSize childInfo.fileSize = cacheListItem.cacheSize
childInfo.filePath = cacheListItem.filePath childInfo.filePath = cacheListItem.filePath
childInfo.pkgName = cacheListItem.packageName
childInfo.tint = "建议清理" childInfo.tint = "建议清理"
childInfo.isChecked = true childInfo.isChecked = true
mCleanList[taskType].childList.add(childInfo) mCleanList[taskType].childList.add(childInfo)
...@@ -208,7 +213,6 @@ class CleanActivity : BaseActivity(), View.OnClickListener { ...@@ -208,7 +213,6 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
mCleanTimer = Timer() mCleanTimer = Timer()
mCleanTimer?.schedule(object : TimerTask() { mCleanTimer?.schedule(object : TimerTask() {
override fun run() { override fun run() {
runOnUiThread { runOnUiThread {
// 单项清理清理完成或没有继续清理的 // 单项清理清理完成或没有继续清理的
if (!isItemCleanOk) { if (!isItemCleanOk) {
...@@ -240,21 +244,15 @@ class CleanActivity : BaseActivity(), View.OnClickListener { ...@@ -240,21 +244,15 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
var removeIndex = -1 var removeIndex = -1
var removeChildInfo: ChildInfo? = null var removeChildInfo: ChildInfo? = null
// 清理动画 if (taskType == 0) {
for (i in 0 until mCleanList[taskType].childList.size) { cleaningOperation(mContext, mCleanList[taskType].childList)
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) { if (taskType == 1) {
// cleaningOperation(mContext) if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
// TODO 清理缓存
// CleanRDataUtil.getAndroidDataCacheUri()
}
} }
if (taskType == 4) { if (taskType == 4) {
...@@ -265,6 +263,19 @@ class CleanActivity : BaseActivity(), View.OnClickListener { ...@@ -265,6 +263,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++ taskType++
...@@ -479,41 +490,13 @@ class CleanActivity : BaseActivity(), View.OnClickListener { ...@@ -479,41 +490,13 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
} }
/** 清理内存 */ /** 清理内存 */
private fun cleaningOperation(ctx: Context) { private fun cleaningOperation(ctx: Context, list: List<ChildInfo>) {
// val infoList = am.runningAppProcesses val am = ctx.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
// val serviceInfos = am.getRunningServices(100) for (childInfo in list) {
// var count = 0 if (childInfo.getName() != Constant.MINTS_PKG_NAME) {
// if (infoList != null) { am.killBackgroundProcesses(childInfo.pkgName)
// 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")
//// }
//// }
// }
// }
} }
} }
...@@ -58,7 +58,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener { ...@@ -58,7 +58,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
// 奖励页预加载 信息流广告 // 奖励页预加载 信息流广告
ExpressManager.loadExpress(true) ExpressManager.loadExpress(true)
PreLoadExpressManager.loadADFrameLayout()
mainPresenter.attachView(this) mainPresenter.attachView(this)
......
...@@ -9,14 +9,17 @@ import android.os.Bundle ...@@ -9,14 +9,17 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.view.View 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.R
import com.mints.flowbox.ad.express.ExpressManager import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.ad.wifi.WifiAdManager 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.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.*
import kotlinx.android.synthetic.main.activity_boost_fast.iv_close import kotlinx.android.synthetic.main.activity_boost_fast.iv_close
import net.phone.PhoneBrandUtils
import java.util.*
import kotlin.random.Random import kotlin.random.Random
/** /**
...@@ -79,15 +82,37 @@ class BoostFastActivity : BaseActivity() { ...@@ -79,15 +82,37 @@ class BoostFastActivity : BaseActivity() {
Handler(Looper.getMainLooper()).postDelayed( Handler(Looper.getMainLooper()).postDelayed(
{ {
YoYo.with(Techniques.FadeOut).duration(500).playOn(container) WifiAdManager.instance.setWifiAdStatusListener(object : WifiAdStatusListener {
YoYo.with(Techniques.FadeOut).duration(500).playOn(ccav_speed) override fun adSuccess() {
}
override fun adFail() {
}
override fun adClose() {
}
})
WifiAdManager.instance.showInterstitial(this@BoostFastActivity) WifiAdManager.instance.showInterstitial(this@BoostFastActivity)
}, },
2500 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.stopAnimation()
ccav_speed.visibility = View.GONE ccav_speed.visibility = View.GONE
container.visibility = View.GONE container.visibility = View.GONE
...@@ -107,19 +132,6 @@ class BoostFastActivity : BaseActivity() { ...@@ -107,19 +132,6 @@ class BoostFastActivity : BaseActivity() {
TransparentActivity.TIMING_TYPE_SAFE -> tvContent.text = "当前网络环境良好" TransparentActivity.TIMING_TYPE_SAFE -> tvContent.text = "当前网络环境良好"
TransparentActivity.TIMING_TYPE_PRICARY -> 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() { private fun initView() {
...@@ -129,6 +141,11 @@ class BoostFastActivity : BaseActivity() { ...@@ -129,6 +141,11 @@ class BoostFastActivity : BaseActivity() {
} }
} }
override fun onDestroy() {
WifiAdManager.instance.onDestroy()
super.onDestroy()
}
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
initExpress() initExpress()
......
...@@ -54,6 +54,7 @@ class TransparentActivity : BaseActivity() { ...@@ -54,6 +54,7 @@ class TransparentActivity : BaseActivity() {
ExpressManager.loadAppOutExpress() ExpressManager.loadAppOutExpress()
val intent = Intent(MintsApplication.getContext(), BoostFastActivity::class.java) 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) intent.putExtra(TIMING_TYPE, mType)
startActivity(intent) startActivity(intent)
finish() finish()
......
...@@ -4,6 +4,7 @@ import android.content.Context ...@@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.provider.Settings import android.provider.Settings
import android.text.TextUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
...@@ -81,6 +82,18 @@ class MainWifiAdapter(val context: Context, val taskData: MutableList<WifiListBe ...@@ -81,6 +82,18 @@ class MainWifiAdapter(val context: Context, val taskData: MutableList<WifiListBe
wifiHolder.btnConnect.setBackgroundResource(R.drawable.shape_tv_gold_gury) 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 { wifiHolder.btnConnect.setOnClickListener {
mOnItemClickListener?.onItemClick(it, position) mOnItemClickListener?.onItemClick(it, position)
} }
......
...@@ -47,6 +47,15 @@ public class ExpandInfo { ...@@ -47,6 +47,15 @@ public class ExpandInfo {
public String tint; // 提示 public String tint; // 提示
public String filePath; // 路径 public String filePath; // 路径
public boolean isChecked; // 是否选中 public boolean isChecked; // 是否选中
public String pkgName; // 包名
public String isPkgName() {
return pkgName;
}
public void setPkgName(String pkgName) {
this.pkgName = pkgName;
}
public Object getHeadId() { public Object getHeadId() {
return headId; return headId;
......
...@@ -92,6 +92,12 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -92,6 +92,12 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
openGpsSettings() openGpsSettings()
} }
updateUiState()
btn_signal.postDelayed({
rope = YoYo.with(Techniques.Pulse).duration(500).repeat(-1).playOn(btn_signal)
}, 200)
// 防止banner刷新太快 // 防止banner刷新太快
// if (AntiShake.check(fl_wifi_banner?.id)) return // if (AntiShake.check(fl_wifi_banner?.id)) return
// BannerManager.instance.getTtBanner(TtCsjAdManager.TT_AD_BANNER_MY, fl_wifi_banner) // BannerManager.instance.getTtBanner(TtCsjAdManager.TT_AD_BANNER_MY, fl_wifi_banner)
...@@ -120,14 +126,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -120,14 +126,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
/** 重置wifi数据 */ /** 重置wifi数据 */
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
private fun loadWifiData() { private fun loadWifiData() {
btn_signal.postDelayed({
rope = YoYo.with(Techniques.Pulse).duration(500).repeat(-1).playOn(btn_signal)
}, 200)
if (wifiUtils.isWifiEnable) {
mWifiList.clear() mWifiList.clear()
updateUiState()
if (wifiUtils.isWifiEnable) {
val connectionWifiInfo = wifiUtils.connectionWifiInfo val connectionWifiInfo = wifiUtils.connectionWifiInfo
// 校验是否有定位权限 // 校验是否有定位权限
...@@ -148,7 +149,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -148,7 +149,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
btn_signal.text = "打开设置" btn_signal.text = "打开设置"
imageView2.setImageResource(R.mipmap.ic_main_wifi_none) imageView2.setImageResource(R.mipmap.ic_main_wifi_none)
} }
Handler(Looper.getMainLooper()).postDelayed({
swipeRefreshLayout.isRefreshing = false swipeRefreshLayout.isRefreshing = false
}, 1000)
return return
} }
...@@ -157,28 +160,49 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -157,28 +160,49 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
tv_wifi_ssid.text = connectionWifiInfo.ssid.replace("\"", "") tv_wifi_ssid.text = connectionWifiInfo.ssid.replace("\"", "")
tv_wifi_info.text = "连接成功,安全保护中" tv_wifi_info.text = "连接成功,安全保护中"
btn_signal.text = "信号增强" btn_signal.text = "信号增强"
if (connectionWifiInfo.rssi > -70) {
imageView2.setImageResource(R.mipmap.ic_main_wifi) imageView2.setImageResource(R.mipmap.ic_main_wifi)
} else {
imageView2.setImageResource(R.mipmap.ic_main_wifi_low)
}
generateWifiListData(connectionWifiInfo, true)
} else { } else {
tv_wifi_ssid.text = "WIFI未连接" tv_wifi_ssid.text = "WIFI未连接"
tv_wifi_info.text = "请连接无线网络" tv_wifi_info.text = "请连接无线网络"
btn_signal.text = "打开设置" btn_signal.text = "打开设置"
imageView2.setImageResource(R.mipmap.ic_main_wifi_none) imageView2.setImageResource(R.mipmap.ic_main_wifi_none)
generateWifiListData(null, false)
} }
generateWifiListData(connectionWifiInfo)
} else { } else {
tv_wifi_ssid.text = "WIFI未开启" tv_wifi_ssid.text = "WIFI未开启"
tv_wifi_info.text = "请先开启无线网络" tv_wifi_info.text = "请先开启无线网络"
btn_signal.text = "开启WIFI" btn_signal.text = "开启WIFI"
imageView2.setImageResource(R.mipmap.ic_main_wifi_none) imageView2.setImageResource(R.mipmap.ic_main_wifi_none)
swipeRefreshLayout.isRefreshing = false generateWifiListData(null, false)
} }
} }
/** 生成wifi列表数据 */ /** 生成wifi列表数据 */
private fun generateWifiListData(connectionWifiInfo: WifiInfo) { private fun generateWifiListData(connectionWifiInfo: WifiInfo?, isConnected: Boolean) {
val ssid = connectionWifiInfo.ssid.replace("\"", "") 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) { for (scanResult in wifiUtils.wifiList) {
if (TextUtils.isEmpty(scanResult.SSID)) continue if (TextUtils.isEmpty(scanResult.SSID)) continue
if (TextUtils.equals(scanResult.SSID, ssid)) { if (TextUtils.equals(scanResult.SSID, ssid)) {
...@@ -225,7 +249,10 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -225,7 +249,10 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
Collections.swap(mWifiList, 0, connectIndex) Collections.swap(mWifiList, 0, connectIndex)
} }
Handler(Looper.getMainLooper()).postDelayed({
swipeRefreshLayout.isRefreshing = false swipeRefreshLayout.isRefreshing = false
}, 1000)
mMainWifiAdapter?.notifyDataSetChanged() mMainWifiAdapter?.notifyDataSetChanged()
} }
...@@ -257,7 +284,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -257,7 +284,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
} }
if (AppConfig.isCanSaveBattery) { if (AppConfig.isCanSaveBattery) {
if (AppConfig.fakeBoostCount != 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}个")
...@@ -311,7 +340,12 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -311,7 +340,12 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
} }
private fun initRecy() { private fun initRecy() {
recy_wifi.addItemDecoration(RecyItemDecoration(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)
...@@ -559,6 +593,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -559,6 +593,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
object : WifiUtils.CallBack { object : WifiUtils.CallBack {
override fun onSuccess() { override fun onSuccess() {
ToastUtils.show("连接成功...") ToastUtils.show("连接成功...")
requireActivity().runOnUiThread {
loadWifiData()
}
} }
override fun onFail() { override fun onFail() {
......
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();
}
}
}
...@@ -90,7 +90,7 @@ public class WifiUtils { ...@@ -90,7 +90,7 @@ public class WifiUtils {
ConnectivityManager connectivityManager = (ConnectivityManager) context ConnectivityManager connectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE); .getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
return activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI; return activeNetInfo != null && activeNetInfo.isConnected();
} }
/** /**
......
...@@ -2,17 +2,16 @@ package com.mints.flowbox.utils.keepalive; ...@@ -2,17 +2,16 @@ package com.mints.flowbox.utils.keepalive;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.provider.Settings; import android.provider.Settings;
import com.activityutil.ActivityManagerProxy; import com.activityutil.ActivityManagerProxy;
import com.activityutil.BringToFrontListener; import com.activityutil.BringToFrontListener;
import com.activityutil.ContextLike; import com.activityutil.ContextLike;
import com.mints.flowbox.MintsApplication; import com.mints.flowbox.utils.ForegroundOrBackground;
import com.mints.flowbox.keepalive.NotificationUtil;
import net.phone.PhoneBrandUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
...@@ -28,6 +27,10 @@ public class IntentUtils { ...@@ -28,6 +27,10 @@ public class IntentUtils {
public static final String TAG = "IntentUtils"; public static final String TAG = "IntentUtils";
public static void startActivity2(Intent intent) { public static void startActivity2(Intent intent) {
if (PhoneBrandUtils.isHuaweiHonor()){
startActivity(ForegroundOrBackground.getMain_activity(),intent);
return;
}
try { try {
ActivityManagerProxy.INSTANCE.bringToFront(new BringToFrontListener() { ActivityManagerProxy.INSTANCE.bringToFront(new BringToFrontListener() {
@Override @Override
...@@ -46,17 +49,9 @@ public class IntentUtils { ...@@ -46,17 +49,9 @@ public class IntentUtils {
public static void startActivity(Activity activity, Intent intent) { public static void startActivity(Activity activity, Intent intent) {
try { try {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
moveToFront(activity); moveToFront(activity);
activity.startActivity(intent); activity.startActivity(intent);
activity.moveTaskToBack(true); activity.moveTaskToBack(true);
// PendingIntent pendingIntent =
// PendingIntent.getActivity(activity, 0, intent, 0);
// pendingIntent.send();
} else {
NotificationUtils.INSTANCE.sendNotificationFullScreen(MintsApplication.getContext(), "", "", intent);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
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