Skip to content

Commit 4baada0

Browse files
committed
remove support for QQ Lite and QQ HD
1 parent 7112548 commit 4baada0

File tree

13 files changed

+116
-45
lines changed

13 files changed

+116
-45
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
## 主要功能
1010

11-
⚠️最低系统要求 Android 8.0 (O)。
12-
13-
支持原版 QQ / Tim / 轻聊版。
11+
支持 QQ 标准版 与 TIM。
1412

1513
![](https://i.loli.net/2020/07/22/g4yIqwZADcozR7K.png)
1614

@@ -25,5 +23,4 @@
2523

2624
- [QQ-Notfiy-Improve](https://github.com/Jinhaihan/QQ-Notfiy-Improve)(已获授权)
2725
- [QQNotfAndShare](https://github.com/ekibun/QQNotfAndShare)(原始项目)
28-
2926
- [QQNotifyPlus](https://github.com/ekibun/QQNotifyPlus)(QQ 与 QZone 图标)

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
<meta-data
6565
android:name="packages"
66-
android:value="com.tencent.mobileqq|com.tencent.tim|com.tencent.qqlite|com.tencent.minihd.qq" />
66+
android:value="com.tencent.mobileqq|com.tencent.tim" />
6767
<meta-data
6868
android:name="settings.activity"
6969
android:value="cc.chenhe.qqnotifyevo.preference.PreferenceAty" />

app/src/main/java/cc/chenhe/qqnotifyevo/core/DelegateNotificationResolver.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class DelegateNotificationResolver : NotificationResolver {
1818
return when (tag) {
1919
Tag.UNKNOWN -> null
2020
Tag.QQ -> qqResolver
21-
Tag.QQ_HD -> qqResolver
22-
Tag.QQ_LITE -> qqResolver
2321
Tag.TIM -> timResolver
2422
}?.run { resolveNotification(tag, title, content, ticker) }
2523
}

app/src/main/java/cc/chenhe/qqnotifyevo/core/InnerNotificationProcessor.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class InnerNotificationProcessor(
3939

4040
// 储存所有通知的 id 以便清除
4141
private val qqNotifyIds: MutableSet<Int> = HashSet()
42-
private val qqLiteNotifyIds: MutableSet<Int> = HashSet()
43-
private val qqHdNotifyIds: MutableSet<Int> = HashSet()
4442
private val timNotifyIds: MutableSet<Int> = HashSet()
4543

4644
/**
@@ -50,9 +48,7 @@ class InnerNotificationProcessor(
5048
clearHistory(tag)
5149
val ids = when (tag) {
5250
Tag.QQ -> qqNotifyIds
53-
Tag.QQ_LITE -> qqLiteNotifyIds
5451
Tag.TIM -> timNotifyIds
55-
Tag.QQ_HD -> qqHdNotifyIds
5652
Tag.UNKNOWN -> null
5753
}
5854
Timber.tag(TAG).v("Clear all evolutionary notifications.")
@@ -127,8 +123,6 @@ class InnerNotificationProcessor(
127123
private fun addNotifyId(tag: Tag, ids: Int) {
128124
when (tag) {
129125
Tag.QQ -> qqNotifyIds.add(ids)
130-
Tag.QQ_HD -> qqHdNotifyIds.add(ids)
131-
Tag.QQ_LITE -> qqLiteNotifyIds.add(ids)
132126
Tag.TIM -> timNotifyIds.add(ids)
133127
Tag.UNKNOWN -> {
134128
}

app/src/main/java/cc/chenhe/qqnotifyevo/core/NotificationProcessor.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ abstract class NotificationProcessor(context: Context, scope: CoroutineScope) {
4545
return when (packageName) {
4646
"com.tencent.mobileqq" -> Tag.QQ
4747
"com.tencent.tim" -> Tag.TIM
48-
"com.tencent.qqlite" -> Tag.QQ_LITE
49-
"com.tencent.minihd.qq" -> Tag.QQ_HD
5048
else -> Tag.UNKNOWN
5149
}
5250
}
@@ -62,8 +60,6 @@ abstract class NotificationProcessor(context: Context, scope: CoroutineScope) {
6260
private val qzoneSpecialTitle = context.getString(R.string.notify_qzone_special_title)
6361

6462
private val qqHistory = ArrayList<Conversation>()
65-
private val qqLiteHistory = ArrayList<Conversation>()
66-
private val qqHdHistory = ArrayList<Conversation>()
6763
private val timHistory = ArrayList<Conversation>()
6864

6965
private val avatarManager =
@@ -529,7 +525,7 @@ abstract class NotificationProcessor(context: Context, scope: CoroutineScope) {
529525
}
530526
when (iconStyle) {
531527
IconStyle.Auto -> when (tag) {
532-
Tag.QQ, Tag.QQ_HD, Tag.QQ_LITE -> R.drawable.ic_notify_qq
528+
Tag.QQ -> R.drawable.ic_notify_qq
533529
Tag.TIM -> R.drawable.ic_notify_tim
534530
else -> R.drawable.ic_notify_qq
535531
}
@@ -546,9 +542,7 @@ abstract class NotificationProcessor(context: Context, scope: CoroutineScope) {
546542
protected fun getHistoryMessage(tag: Tag): ArrayList<Conversation> {
547543
return when (tag) {
548544
Tag.TIM -> timHistory
549-
Tag.QQ_LITE -> qqLiteHistory
550545
Tag.QQ -> qqHistory
551-
Tag.QQ_HD -> qqHdHistory
552546
else -> throw RuntimeException("Unknown tag: $tag.")
553547
}
554548
}

app/src/main/java/cc/chenhe/qqnotifyevo/ui/common/ErrorCard.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidx.compose.material3.TextButton
1818
import androidx.compose.runtime.Composable
1919
import androidx.compose.ui.Alignment
2020
import androidx.compose.ui.Modifier
21+
import androidx.compose.ui.graphics.Color
2122
import androidx.compose.ui.graphics.vector.ImageVector
2223
import androidx.compose.ui.tooling.preview.Preview
2324
import androidx.compose.ui.unit.dp
@@ -46,9 +47,10 @@ internal fun ErrorCard(
4647
icon: ImageVector = Icons.Rounded.ErrorOutline,
4748
description: String? = null,
4849
button: (@Composable () -> Unit)? = null,
50+
containerColor: Color = MaterialTheme.colorScheme.errorContainer,
4951
) {
5052
Card(
51-
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer),
53+
colors = CardDefaults.cardColors(containerColor = containerColor),
5254
modifier = modifier
5355
) {
5456
Column(

app/src/main/java/cc/chenhe/qqnotifyevo/ui/main/MainPreferenceScreen.kt

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import androidx.compose.material3.Text
3333
import androidx.compose.material3.TextButton
3434
import androidx.compose.material3.TopAppBar
3535
import androidx.compose.runtime.Composable
36+
import androidx.compose.runtime.LaunchedEffect
3637
import androidx.compose.runtime.getValue
3738
import androidx.compose.runtime.mutableIntStateOf
3839
import androidx.compose.runtime.mutableStateOf
@@ -41,10 +42,14 @@ import androidx.compose.runtime.setValue
4142
import androidx.compose.ui.Modifier
4243
import androidx.compose.ui.draw.clip
4344
import androidx.compose.ui.platform.LocalContext
45+
import androidx.compose.ui.platform.LocalLifecycleOwner
4446
import androidx.compose.ui.res.stringResource
4547
import androidx.compose.ui.tooling.preview.Preview
4648
import androidx.compose.ui.unit.dp
49+
import androidx.lifecycle.Lifecycle
50+
import androidx.lifecycle.LifecycleOwner
4751
import androidx.lifecycle.compose.collectAsStateWithLifecycle
52+
import androidx.lifecycle.repeatOnLifecycle
4853
import androidx.lifecycle.viewmodel.compose.viewModel
4954
import cc.chenhe.qqnotifyevo.R
5055
import cc.chenhe.qqnotifyevo.ui.common.ErrorCard
@@ -70,8 +75,14 @@ fun MainPreferenceScreen(
7075
navigateToPermissionScreen: () -> Unit,
7176
navigateToAdvancedOptionsScreen: () -> Unit,
7277
model: MainPreferenceViewModel = viewModel(),
78+
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current
7379
) {
7480
val uiState by model.uiState.collectAsStateWithLifecycle()
81+
LaunchedEffect(key1 = lifecycleOwner) {
82+
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
83+
model.checkUnsupportedApp()
84+
}
85+
}
7586
MainPreference(
7687
uiState = uiState,
7788
onIntent = { model.sendIntent(it) },
@@ -125,6 +136,7 @@ private fun MainPreference(
125136
}
126137

127138
WarningCards(
139+
uiState.showUnsupportedAppWarning,
128140
isServiceRunning = uiState.isServiceRunning,
129141
mode = uiState.mode,
130142
onIntent = onIntent,
@@ -142,36 +154,34 @@ private fun MainPreference(
142154

143155
@Composable
144156
private fun WarningCards(
157+
unsupportedAppDetected: Boolean,
145158
isServiceRunning: Boolean,
146159
mode: Mode,
147160
onIntent: (MainPreferenceIntent) -> Unit,
148161
navigateToPermissionScreen: () -> Unit,
149162
) {
150163
val ctx = LocalContext.current
164+
val space = PaddingValues(bottom = 12.dp)
165+
166+
// 不支持的 QQ 版本
167+
AnimatedVisibility(visible = unsupportedAppDetected) {
168+
UnsupportedAppWarningCard(modifier = Modifier.padding(space), onIntent = onIntent)
169+
}
170+
151171
// 通知权限
152172
val notificationPermission = rememberNotificationPermissionState(onAlwaysDenied = {
153173
openNotificationSettings(ctx)
154174
})
155-
val space = PaddingValues(bottom = 12.dp)
156175
AnimatedVisibility(visible = !notificationPermission.isGranted) {
157-
ErrorCard(
176+
NotificationPermissionWarningCard(
158177
modifier = Modifier.padding(space),
159-
title = stringResource(id = R.string.permission_notification_card_title),
160-
description = stringResource(id = R.string.permission_notification_card_text),
161-
button = {
162-
TextButton(
163-
onClick = {
164-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
165-
notificationPermission.launchPermissionRequest()
166-
} else {
167-
openNotificationSettings(ctx)
168-
}
169-
},
170-
colors = ButtonDefaults.textButtonColors(contentColor = MaterialTheme.colorScheme.onErrorContainer)
171-
) {
172-
Text(text = stringResource(id = R.string.permission_notification_card_allow))
178+
requestPermission = {
179+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
180+
notificationPermission.launchPermissionRequest()
181+
} else {
182+
openNotificationSettings(ctx)
173183
}
174-
},
184+
}
175185
)
176186
}
177187

@@ -198,6 +208,46 @@ private fun openNotificationSettings(context: Context) {
198208
}
199209
}
200210

211+
@Composable
212+
@Preview
213+
private fun UnsupportedAppWarningCard(
214+
modifier: Modifier = Modifier,
215+
onIntent: (MainPreferenceIntent) -> Unit = {},
216+
) {
217+
ErrorCard(
218+
containerColor = MaterialTheme.colorScheme.primaryContainer,
219+
title = stringResource(id = R.string.unsupported_app_card_title),
220+
description = stringResource(id = R.string.unsupported_app_card_text),
221+
button = {
222+
TextButton(onClick = { onIntent(MainPreferenceIntent.DismissUnsupportedAppWarning) }) {
223+
Text(text = stringResource(id = R.string.unsupported_app_card_button))
224+
}
225+
},
226+
modifier = modifier,
227+
)
228+
}
229+
230+
@Composable
231+
@Preview
232+
private fun NotificationPermissionWarningCard(
233+
modifier: Modifier = Modifier,
234+
requestPermission: () -> Unit = {},
235+
) {
236+
ErrorCard(
237+
modifier = modifier,
238+
title = stringResource(id = R.string.permission_notification_card_title),
239+
description = stringResource(id = R.string.permission_notification_card_text),
240+
button = {
241+
TextButton(
242+
onClick = requestPermission,
243+
colors = ButtonDefaults.textButtonColors(contentColor = MaterialTheme.colorScheme.onErrorContainer)
244+
) {
245+
Text(text = stringResource(id = R.string.permission_notification_card_allow))
246+
}
247+
},
248+
)
249+
}
250+
201251
@Composable
202252
@Preview
203253
private fun NevoServiceWarningCard(

app/src/main/java/cc/chenhe/qqnotifyevo/ui/main/MainPreferenceViewModel.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cc.chenhe.qqnotifyevo.ui.main
22

3+
import android.annotation.SuppressLint
34
import android.app.Application
5+
import android.content.Context
46
import androidx.datastore.preferences.core.edit
57
import androidx.lifecycle.viewModelScope
68
import cc.chenhe.qqnotifyevo.service.NevoDecorator
@@ -12,23 +14,29 @@ import cc.chenhe.qqnotifyevo.utils.Mode.Legacy
1214
import cc.chenhe.qqnotifyevo.utils.Mode.Nevo
1315
import cc.chenhe.qqnotifyevo.utils.PREFERENCE_ICON
1416
import cc.chenhe.qqnotifyevo.utils.PREFERENCE_MODE
17+
import cc.chenhe.qqnotifyevo.utils.USAGE_SHOW_UNSUPPORTED_APP_WARNING
18+
import cc.chenhe.qqnotifyevo.utils.USAGE_SHOW_UNSUPPORTED_APP_WARNING_DEFAULT
1519
import cc.chenhe.qqnotifyevo.utils.dataStore
1620
import kotlinx.coroutines.delay
1721
import kotlinx.coroutines.flow.collectLatest
22+
import kotlinx.coroutines.flow.first
1823
import kotlinx.coroutines.flow.getAndUpdate
24+
import kotlinx.coroutines.flow.map
1925
import kotlinx.coroutines.launch
2026

2127
data class MainPreferenceUiState(
2228
val mode: Mode = Legacy,
2329
val iconStyle: IconStyle = IconStyle.Auto,
2430
val isServiceRunning: Boolean = true,
2531
val showNevoNotInstalledDialog: Boolean = false,
32+
val showUnsupportedAppWarning: Boolean = false,
2633
)
2734

2835
sealed interface MainPreferenceIntent {
2936
data class SetMode(val newMode: Mode) : MainPreferenceIntent
3037
data class SetIconStyle(val newIcon: IconStyle) : MainPreferenceIntent
3138
data class ShowNevoNotInstalledDialog(val show: Boolean) : MainPreferenceIntent
39+
data object DismissUnsupportedAppWarning : MainPreferenceIntent
3240
}
3341

3442
class MainPreferenceViewModel(application: Application) :
@@ -41,6 +49,10 @@ class MainPreferenceViewModel(application: Application) :
4149
}
4250

4351
init {
52+
viewModelScope.launch {
53+
checkUnsupportedApp()
54+
}
55+
4456
viewModelScope.launch {
4557
application.dataStore.data.collectLatest { pref ->
4658
val newMode = Mode.fromValue(pref[PREFERENCE_MODE])
@@ -62,6 +74,20 @@ class MainPreferenceViewModel(application: Application) :
6274
}
6375
}
6476

77+
@SuppressLint("QueryPermissionsNeeded")
78+
internal suspend fun checkUnsupportedApp() {
79+
val ctx: Context = getApplication()
80+
val shouldShowWarning =
81+
ctx.dataStore.data.map {
82+
it[USAGE_SHOW_UNSUPPORTED_APP_WARNING]
83+
}.first() ?: USAGE_SHOW_UNSUPPORTED_APP_WARNING_DEFAULT
84+
&& getApplication<Application>().packageManager.getInstalledApplications(0)
85+
.find {
86+
it.packageName == "com.tencent.qqlite" || it.packageName == "com.tencent.minihd.qq"
87+
} != null
88+
_uiState.getAndUpdate { it.copy(showUnsupportedAppWarning = shouldShowWarning) }
89+
}
90+
6591
private fun updateServiceState(running: Boolean) {
6692
_uiState.getAndUpdate { old ->
6793
if (old.isServiceRunning == running) old else old.copy(isServiceRunning = running)
@@ -85,6 +111,13 @@ class MainPreferenceViewModel(application: Application) :
85111
is MainPreferenceIntent.ShowNevoNotInstalledDialog -> {
86112
_uiState.getAndUpdate { it.copy(showNevoNotInstalledDialog = intent.show) }
87113
}
114+
115+
MainPreferenceIntent.DismissUnsupportedAppWarning -> {
116+
getApplication<Application>().dataStore.edit {
117+
it[USAGE_SHOW_UNSUPPORTED_APP_WARNING] = false
118+
}
119+
_uiState.getAndUpdate { it.copy(showUnsupportedAppWarning = false) }
120+
}
88121
}
89122
}
90123

app/src/main/java/cc/chenhe/qqnotifyevo/utils/PreferencesUtils.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,16 @@ val PREFERENCE_NICKNAME_FORMAT = stringPreferencesKey("format_nickname_format")
9797
const val PREFERENCE_NICKNAME_FORMAT_DEFAULT = "[\$n]"
9898
val PREFERENCE_AVATAR_CACHE_AGE = longPreferencesKey("avatar_cache_age")
9999
val PREFERENCE_AVATAR_CACHE_AGE_DEFAULT = AvatarCacheAge.OneDay
100-
val USAGE_TIP_NEVO_MULTI_MESSAGE = booleanPreferencesKey("show_nevo_multi_message_tip")
101-
const val USAGE_TIP_NEVO_MULTI_MESSAGE_DEFAULT = true
102100
val PREFERENCE_SHOW_IN_RECENT_APPS = booleanPreferencesKey("show_in_recent_apps")
103101
const val PREFERENCE_SHOW_IN_RECENT_APPS_DEFAULT = true
104102
val PREFERENCE_ENABLE_LOG = booleanPreferencesKey("enable_log")
105103
const val PREFERENCE_ENABLE_LOG_DEFAULT = false
106104

105+
val USAGE_TIP_NEVO_MULTI_MESSAGE = booleanPreferencesKey("show_nevo_multi_message_tip")
106+
const val USAGE_TIP_NEVO_MULTI_MESSAGE_DEFAULT = true
107+
val USAGE_SHOW_UNSUPPORTED_APP_WARNING = booleanPreferencesKey("show_unsupported_app_warning")
108+
const val USAGE_SHOW_UNSUPPORTED_APP_WARNING_DEFAULT = true
109+
107110

108111
fun getAvatarCachePeriod(context: Context): Long {
109112
val s = sp(context).getString("avatar_cache_period", "0") ?: "0"

app/src/main/java/cc/chenhe/qqnotifyevo/utils/Tag.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ package cc.chenhe.qqnotifyevo.utils
66
enum class Tag(val pkg: String) {
77
UNKNOWN(""),
88
QQ("com.tencent.mobileqq"),
9-
QQ_HD("com.tencent.minihd.qq"),
10-
QQ_LITE("com.tencent.qqlite"),
119
TIM("com.tencent.tim");
1210
}

0 commit comments

Comments
 (0)