mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-04 09:45:34 +08:00
Added retry notification function when notification icon rule sync failed in ConfigureActivity, IconRuleManagerTool
This commit is contained in:
@@ -30,11 +30,11 @@ import com.fankes.coloros.notify.bean.IconDataBean
|
|||||||
import com.fankes.coloros.notify.databinding.ActivityConfigBinding
|
import com.fankes.coloros.notify.databinding.ActivityConfigBinding
|
||||||
import com.fankes.coloros.notify.databinding.AdapterConfigBinding
|
import com.fankes.coloros.notify.databinding.AdapterConfigBinding
|
||||||
import com.fankes.coloros.notify.databinding.DiaIconFilterBinding
|
import com.fankes.coloros.notify.databinding.DiaIconFilterBinding
|
||||||
|
import com.fankes.coloros.notify.param.IconPackParams
|
||||||
import com.fankes.coloros.notify.param.factory.isAppNotifyHookAllOf
|
import com.fankes.coloros.notify.param.factory.isAppNotifyHookAllOf
|
||||||
import com.fankes.coloros.notify.param.factory.isAppNotifyHookOf
|
import com.fankes.coloros.notify.param.factory.isAppNotifyHookOf
|
||||||
import com.fankes.coloros.notify.param.factory.putAppNotifyHookAllOf
|
import com.fankes.coloros.notify.param.factory.putAppNotifyHookAllOf
|
||||||
import com.fankes.coloros.notify.param.factory.putAppNotifyHookOf
|
import com.fankes.coloros.notify.param.factory.putAppNotifyHookOf
|
||||||
import com.fankes.coloros.notify.param.IconPackParams
|
|
||||||
import com.fankes.coloros.notify.ui.activity.base.BaseActivity
|
import com.fankes.coloros.notify.ui.activity.base.BaseActivity
|
||||||
import com.fankes.coloros.notify.utils.factory.*
|
import com.fankes.coloros.notify.utils.factory.*
|
||||||
import com.fankes.coloros.notify.utils.tool.IconRuleManagerTool
|
import com.fankes.coloros.notify.utils.tool.IconRuleManagerTool
|
||||||
@@ -196,11 +196,13 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
|||||||
neutralButton(text = "取消")
|
neutralButton(text = "取消")
|
||||||
noCancelable()
|
noCancelable()
|
||||||
}
|
}
|
||||||
|
intent?.getBooleanExtra("isDirectUpdate", false) == true -> onStartRefresh(isByHand = false)
|
||||||
intent?.getBooleanExtra("isShowUpdDialog", true) == true -> onStartRefresh()
|
intent?.getBooleanExtra("isShowUpdDialog", true) == true -> onStartRefresh()
|
||||||
}
|
}
|
||||||
/** 清除数据 */
|
/** 清除数据 */
|
||||||
intent?.apply {
|
intent?.apply {
|
||||||
removeExtra("isNewAppSupport")
|
removeExtra("isNewAppSupport")
|
||||||
|
removeExtra("isDirectUpdate")
|
||||||
removeExtra("isShowUpdDialog")
|
removeExtra("isShowUpdDialog")
|
||||||
}
|
}
|
||||||
/** 设置返回监听事件 */
|
/** 设置返回监听事件 */
|
||||||
@@ -219,12 +221,22 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 开始手动同步 */
|
/**
|
||||||
private fun onStartRefresh() =
|
* 开始同步
|
||||||
IconRuleManagerTool.syncByHand(context = this) {
|
* @param isByHand 是否手动同步 - 默认是
|
||||||
filterText = ""
|
*/
|
||||||
mockLocalData()
|
private fun onStartRefresh(isByHand: Boolean = true) {
|
||||||
}
|
if (isByHand)
|
||||||
|
IconRuleManagerTool.syncByHand(context = this) {
|
||||||
|
filterText = ""
|
||||||
|
mockLocalData()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
IconRuleManagerTool.sync(context = this) {
|
||||||
|
filterText = ""
|
||||||
|
mockLocalData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 装载或刷新本地数据 */
|
/** 装载或刷新本地数据 */
|
||||||
private fun mockLocalData() {
|
private fun mockLocalData() {
|
||||||
|
@@ -310,7 +310,7 @@ object IconRuleManagerTool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else baseCheckingInternetConnect(context) { isDone ->
|
} else baseCheckingInternetConnect(context) { isDone ->
|
||||||
if (isDone) callback() else pushNotify(context, title = "网络不可用", msg = "无法连接到互联网,无法更新通知图标规则")
|
if (isDone) callback() else pushNotify(context, title = "网络不可用", msg = "网络连接失败,无法更新通知图标规则,点击重试", isRetry = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -372,8 +372,9 @@ object IconRuleManagerTool {
|
|||||||
* @param context 实例 - 类型为 [AppCompatActivity] 时将不会推送通知
|
* @param context 实例 - 类型为 [AppCompatActivity] 时将不会推送通知
|
||||||
* @param title 通知标题
|
* @param title 通知标题
|
||||||
* @param msg 通知消息
|
* @param msg 通知消息
|
||||||
|
* @param isRetry 是否发送重试动作 - 默认否
|
||||||
*/
|
*/
|
||||||
private fun pushNotify(context: Context, title: String, msg: String) {
|
private fun pushNotify(context: Context, title: String, msg: String, isRetry: Boolean = false) {
|
||||||
if (context !is AppCompatActivity)
|
if (context !is AppCompatActivity)
|
||||||
context.getSystemService<NotificationManager>()?.apply {
|
context.getSystemService<NotificationManager>()?.apply {
|
||||||
createNotificationChannel(
|
createNotificationChannel(
|
||||||
@@ -393,7 +394,9 @@ object IconRuleManagerTool {
|
|||||||
setContentIntent(
|
setContentIntent(
|
||||||
PendingIntent.getActivity(
|
PendingIntent.getActivity(
|
||||||
context, msg.hashCode(),
|
context, msg.hashCode(),
|
||||||
Intent(context, ConfigureActivity::class.java).apply { putExtra("isShowUpdDialog", false) },
|
Intent(context, ConfigureActivity::class.java).apply {
|
||||||
|
if (isRetry) putExtra("isDirectUpdate", true) else putExtra("isShowUpdDialog", false)
|
||||||
|
},
|
||||||
if (Build.VERSION.SDK_INT < 31) PendingIntent.FLAG_UPDATE_CURRENT else PendingIntent.FLAG_IMMUTABLE
|
if (Build.VERSION.SDK_INT < 31) PendingIntent.FLAG_UPDATE_CURRENT else PendingIntent.FLAG_IMMUTABLE
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user