Commit 5f7318cb authored by wanglei's avatar wanglei

...

parent 33848093
......@@ -224,14 +224,25 @@
android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
<activity
android:theme="@style/MaterialComponentsTheme"
android:name=".ui.activity.search.SearchActivity"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/MaterialComponentsTheme"
android:windowSoftInputMode="adjustResize|stateHidden"
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
<receiver
android:name=".fcm.PackageBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.base.browserwhite.provider"
......
......@@ -6,6 +6,9 @@ import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import com.base.browserwhite.fcm.FCMManager
import com.base.browserwhite.fcm.NotificationPushUtil.sendNotificationWhere
import com.base.browserwhite.fcm.PackageBroadcastReceiver
import com.base.browserwhite.fcm.PackageBroadcastReceiver.Companion.registerPackageBroadcastReceiver
import com.base.browserwhite.fcm.ScreenStatusReceiver
import com.base.browserwhite.help.BlackHelper
import com.base.browserwhite.help.ConfigHelper
......@@ -52,6 +55,7 @@ class MyApplication : Application() {
}
}
private var packageBroadcastReceiver: PackageBroadcastReceiver? = null
fun initApp() {
FacebookSdk.sdkInitialize(applicationContext)
......@@ -60,6 +64,7 @@ class MyApplication : Application() {
FCMManager.initFirebase(this)
FCMManager.subscribeToTopic(topic)
ScreenStatusReceiver.setupScreenStatusListener(this)
registerPackageBroadcastReceiver()
InstallHelps.init()
BlackHelper.requestBlack()
initLifeListener()
......
......@@ -11,6 +11,8 @@ object ConstObject {
const val YANDEX = "Yandex"
const val BAIDU = "Baidu"
const val ID_INSTALL_APP = 20000
const val ID_UNINSTALL_APP = 20001
const val ID_JUNK_CLEANER = 12001
const val ID_CLEAN_JUNK_MEMORY = 12009
const val ID_NEWS = 12002
......
......@@ -178,7 +178,7 @@ object NotificationPushUtil {
//天气
fun canPushWeather(where: String): Boolean {
private fun canPushWeather(where: String): Boolean {
val lastPushTime = AppPreferences.getInstance().getLong("last_notification_time", 0)
if (where == PUSH_WHERE_TIMBER || where == PUSH_WHERE_UNLOCK) {
......
......@@ -18,8 +18,10 @@ import com.base.browserwhite.MyApplication
import com.base.browserwhite.R
import com.base.browserwhite.bean.ConstObject.ID_APP_PROCESS
import com.base.browserwhite.bean.ConstObject.ID_CLEAN_JUNK_MEMORY
import com.base.browserwhite.bean.ConstObject.ID_INSTALL_APP
import com.base.browserwhite.bean.ConstObject.ID_JUNK_CLEANER
import com.base.browserwhite.bean.ConstObject.ID_NEWS
import com.base.browserwhite.bean.ConstObject.ID_UNINSTALL_APP
import com.base.browserwhite.bean.ConstObject.ID_WEATHER
import com.base.browserwhite.bean.NewsBean
import com.base.browserwhite.bean.WeatherBean
......@@ -49,7 +51,7 @@ object NotificationUiUtil {
@SuppressLint("RemoteViewLayout")
fun sendNotification(context: Context, actionId: Int) {
when (actionId) {
ID_JUNK_CLEANER -> {//清理
ID_JUNK_CLEANER, ID_INSTALL_APP, ID_UNINSTALL_APP -> {//清理
var size = fastGetJunkSize(context)
if (size == 0L) {
size = Random.nextLong(1024 * 5, 1024 * 10)
......
package com.base.browserwhite.fcm
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import com.applovin.impl.br
import com.base.browserwhite.bean.ConstObject.ID_INSTALL_APP
import com.base.browserwhite.bean.ConstObject.ID_UNINSTALL_APP
import com.base.browserwhite.fcm.NotificationPushUtil.PUSH_WHERE_UN_INSTALL_BROADCAST
import com.base.browserwhite.fcm.NotificationPushUtil.sendNotificationWhere
import com.base.browserwhite.utils.LogEx
class PackageBroadcastReceiver : BroadcastReceiver() {
private val TAG = "PackageBroadcastReceiver"
override fun onReceive(context: Context?, intent: Intent?) {
LogEx.logDebug(TAG, "onReceive")
if (intent == null) return
when (intent.action) {
Intent.ACTION_PACKAGE_ADDED -> {
// 获取安装的应用包名
val packageName = intent.dataString
// 处理应用安装事件
LogEx.logDebug(TAG, "PACKAGE_ADDED")
context?.sendNotificationWhere(ID_INSTALL_APP, PUSH_WHERE_UN_INSTALL_BROADCAST)
}
Intent.ACTION_PACKAGE_REMOVED -> {
// 获取卸载的应用包名
val packageName = intent.data?.schemeSpecificPart
// 处理应用卸载事件
LogEx.logDebug(TAG, "PACKAGE_REMOVED")
context?.sendNotificationWhere(ID_UNINSTALL_APP, PUSH_WHERE_UN_INSTALL_BROADCAST)
}
}
}
companion object {
fun Context.registerPackageBroadcastReceiver(): PackageBroadcastReceiver {
val packageBroadcastReceiver = PackageBroadcastReceiver()
val intentFilter = IntentFilter()
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED)
intentFilter.addAction(Intent.ACTION_PACKAGE_INSTALL)
intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED)
intentFilter.addDataScheme("package")
registerReceiver(packageBroadcastReceiver, intentFilter)
return packageBroadcastReceiver
}
}
}
package com.base.browserwhite.fcm;
import static com.base.browserwhite.fcm.NotificationPushUtil.PUSH_WHERE_UNLOCK;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import com.base.browserwhite.utils.AppPreferences;
import java.util.Objects;
......@@ -44,7 +48,7 @@ public class ScreenStatusReceiver extends BroadcastReceiver {
if (isDeviceInteractive() && !isSecureLockActive()) {
int secureSetting = Integer.parseInt(AppPreferences.getInstance().getString("lockS", "1"));
if (secureSetting == 1) {
// NotificationUtil.INSTANCE.sendNotification(MyApplication.context, "ScreenStatusReceiver");
NotificationPushUtil.INSTANCE.sendNotificationWhere(context, null, PUSH_WHERE_UNLOCK);
}
}
break;
......
......@@ -14,7 +14,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.base.browserwhite.R
import com.base.browserwhite.ads.admob.AdmobNativeUtils
import com.base.browserwhite.bean.BookmarkBean
import com.base.browserwhite.bean.ConstObject
import com.base.browserwhite.bean.ConstObject.APP_PROCESS
import com.base.browserwhite.bean.ConstObject.BAIDU
import com.base.browserwhite.bean.ConstObject.BING
......@@ -30,7 +29,7 @@ import com.base.browserwhite.bean.WebSiteBean
import com.base.browserwhite.bean.defaultValue
import com.base.browserwhite.bean.webSiteGroupBeanList
import com.base.browserwhite.databinding.FragmentHomeBinding
import com.base.browserwhite.fcm.NotificationUiUtil
import com.base.browserwhite.fcm.PackageBroadcastReceiver.Companion.registerPackageBroadcastReceiver
import com.base.browserwhite.help.Constants
import com.base.browserwhite.help.NewsUtils.requestNews
import com.base.browserwhite.help.RxBus
......@@ -361,7 +360,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
// i++
// lastClickTime = System.currentTimeMillis()
NotificationUiUtil.sendNotification(requireContext(), ConstObject.ID_WEATHER, "test")
}
binding.ivUp.setOnClickListener {
binding.rv.scrollToPosition(0)
......
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