diff --git a/android/Readme.md b/android/Readme.md
index 8e9e348..fe2c39a 100644
--- a/android/Readme.md
+++ b/android/Readme.md
@@ -5,7 +5,8 @@
* MiPush(状态:已调通、已接入)
* miui √
* Mokee √
- * HuaWei √
+ * WaWei √
+ * 坚果pro3-8.0.1 √ 坚果pro2s-7.2.0.2 x(暂无法成功注册)
* 部分原生、类原生 可成功注册,无法收到推送,可能和地区识别有关,待解决
### TODO
@@ -25,7 +26,7 @@
* ~~增加对PushKey重命名的逻辑~~
* ~~增加对设备重命名的逻辑~~
* ~~增加长按复制消息内容的逻辑~~
-* 增加点击设置界面用户名修改用户名逻辑
+* 增加点击设置界面用户名修改用户名逻辑(暂无路由)
* ~~适配image类型的消息显示~~
* ~~修改app图标~~
@@ -113,6 +114,9 @@
* 增加点击 Message 列表项目复制文本功能
* 增加适配Image类型Message的显示
* 完善登陆注销逻辑
+ * 适配 PushDeer 的专用推送通道
+ * 增加修改设备/密钥等名称时"清空文本"按钮
+ * 部分英化汉化
### 感谢
diff --git a/android/app/build.gradle b/android/app/build.gradle
index b00d603..7b19126 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -12,7 +12,7 @@ android {
minSdk 22
targetSdk 31
versionCode 1
- versionName "1.0"
+ versionName "1.0-dev-2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
diff --git a/android/app/debug/output-metadata.json b/android/app/debug/output-metadata.json
index 3258f2e..c0fa5ae 100644
--- a/android/app/debug/output-metadata.json
+++ b/android/app/debug/output-metadata.json
@@ -12,7 +12,7 @@
"filters": [],
"attributes": [],
"versionCode": 1,
- "versionName": "1.0",
+ "versionName": "1.0-dev-2",
"outputFile": "app-debug.apk"
}
],
diff --git a/android/app/debug/pushdeer-for-android-v1.0.apk b/android/app/debug/pushdeer-for-android-v1.0.apk
deleted file mode 100644
index e603594..0000000
Binary files a/android/app/debug/pushdeer-for-android-v1.0.apk and /dev/null differ
diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro
index 481bb43..a7dd0e8 100644
--- a/android/app/proguard-rules.pro
+++ b/android/app/proguard-rules.pro
@@ -18,4 +18,13 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
-#-renamesourcefileattribute SourceFile
\ No newline at end of file
+#-renamesourcefileattribute SourceFile
+
+#这里com.xiaomi.mipushdemo.DemoMessageRreceiver改成app中定义的完整类名
+#-keep class com.xiaomi.mipush.sdk.DemoMessageReceiver {*;}
+
+
+# MiPush
+-keep class com.pushdeer.os.receiver.MessageReceiver {*;}
+#可以防止一个误报的 warning 导致无法成功编译,如果编译使用的 Android 版本是 23。
+-dontwarn com.xiaomi.push.**
\ No newline at end of file
diff --git a/android/app/src/main/java/com/pushdeer/os/App.kt b/android/app/src/main/java/com/pushdeer/os/App.kt
index 06227e1..a33f564 100644
--- a/android/app/src/main/java/com/pushdeer/os/App.kt
+++ b/android/app/src/main/java/com/pushdeer/os/App.kt
@@ -22,7 +22,7 @@ class App : Application() {
val storeKeeper by lazy { StoreKeeper(this) }
val database by lazy { AppDatabase.getDatabase(this) }
val repositoryKeeper by lazy { RepositoryKeeper(database) }
- val pushDeerService by lazy {
+ private val pushDeerService: PushDeerApi by lazy {
Retrofit.Builder()
.baseUrl(PushDeerApi.baseUrl)
.addConverterFactory(ScalarsConverterFactory.create())
@@ -76,4 +76,4 @@ class App : Application() {
companion object {
const val TAG = "TAG"
}
-}
+}
\ No newline at end of file
diff --git a/android/app/src/main/java/com/pushdeer/os/MainActivity.kt b/android/app/src/main/java/com/pushdeer/os/MainActivity.kt
index c840559..7db26c0 100644
--- a/android/app/src/main/java/com/pushdeer/os/MainActivity.kt
+++ b/android/app/src/main/java/com/pushdeer/os/MainActivity.kt
@@ -1,8 +1,11 @@
package com.pushdeer.os
+import android.app.NotificationChannel
+import android.app.NotificationManager
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
+import android.os.Build
import android.os.Bundle
import android.text.util.Linkify
import androidx.activity.compose.setContent
@@ -93,7 +96,7 @@ class MainActivity : AppCompatActivity(), RequestHolder {
Markwon.builder(this)
.usePlugin(CoilImagesPlugin.create(this, coilImageLoader))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
- .build();
+ .build()
}
override lateinit var globalNavController: NavHostController
@@ -107,6 +110,18 @@ class MainActivity : AppCompatActivity(), RequestHolder {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
+ notificationManager.createNotificationChannel(
+ NotificationChannel(
+ "high_system",
+ "服务提醒",
+ NotificationManager.IMPORTANCE_HIGH
+ )
+ )
+ }
+
+
myActivity = this
qrScanActivityOpener = ActivityOpener.forResult(this)
requestPermissionOpener = ActivityOpener.forPermission(this)
diff --git a/android/app/src/main/java/com/pushdeer/os/holder/RequestHolder.kt b/android/app/src/main/java/com/pushdeer/os/holder/RequestHolder.kt
index 5fc747e..6f53489 100644
--- a/android/app/src/main/java/com/pushdeer/os/holder/RequestHolder.kt
+++ b/android/app/src/main/java/com/pushdeer/os/holder/RequestHolder.kt
@@ -62,12 +62,16 @@ interface RequestHolder {
fun clearLogDog() {
alert.alert(R.string.global_alert_title_confirm,"Clear?",onOk = {
- coroutineScope.launch {
logDogViewModel.clear()
- }
})
}
+ fun userRename(newName:String){
+
+ }
+
+// abstract class LogDogRequest(private val )
+
abstract class ClipRequest(private val clipboardManager: ClipboardManager) {
fun copyMessagePlainText(str: String) {
clipboardManager.setPrimaryClip(ClipData.newPlainText("pushdeer-copy-plain-text", str))
diff --git a/android/app/src/main/java/com/pushdeer/os/ui/compose/componment/KeyItem.kt b/android/app/src/main/java/com/pushdeer/os/ui/compose/componment/KeyItem.kt
index 517c78c..d40b555 100644
--- a/android/app/src/main/java/com/pushdeer/os/ui/compose/componment/KeyItem.kt
+++ b/android/app/src/main/java/com/pushdeer/os/ui/compose/componment/KeyItem.kt
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Clear
import androidx.compose.material.icons.filled.DateRange
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@@ -34,6 +35,7 @@ fun KeyItem(key: PushKey, requestHolder: RequestHolder) {
mutableStateOf(key.name)
}
CardItemWithContent(onClick = {
+ name = key.name
requestHolder.alert.alert(
title = R.string.main_key_alert_changekeyname,
content = {
@@ -50,7 +52,12 @@ fun KeyItem(key: PushKey, requestHolder: RequestHolder) {
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent,
errorIndicatorColor = Color.Transparent,
- )
+ ),
+ trailingIcon = {
+ if (name != "") IconButton(onClick = { name = "" }) {
+ Icon(imageVector = Icons.Default.Clear, contentDescription = "")
+ }
+ }
)
}
},
diff --git a/android/app/src/main/java/com/pushdeer/os/ui/compose/componment/SettingItem.kt b/android/app/src/main/java/com/pushdeer/os/ui/compose/componment/SettingItem.kt
index 05a8498..3535f9f 100644
--- a/android/app/src/main/java/com/pushdeer/os/ui/compose/componment/SettingItem.kt
+++ b/android/app/src/main/java/com/pushdeer/os/ui/compose/componment/SettingItem.kt
@@ -14,13 +14,13 @@ import com.pushdeer.os.ui.theme.MBlue
@ExperimentalMaterialApi
@Composable
-fun SettingItem(text: String, buttonString: String, onClick: () -> Unit) {
+fun SettingItem(text: String, buttonString: String, onItemClick:()->Unit={},onButtonClick: () -> Unit) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp)
) {
- CardItemWithContent() {
+ CardItemWithContent(onClick = onItemClick) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -36,7 +36,7 @@ fun SettingItem(text: String, buttonString: String, onClick: () -> Unit) {
maxLines = 1,
)
Button(
- onClick = onClick,
+ onClick = onButtonClick,
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = MaterialTheme.colors.MBlue,
diff --git a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/DeviceListPage.kt b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/DeviceListPage.kt
index 1b320ad..2f60cd7 100644
--- a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/DeviceListPage.kt
+++ b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/DeviceListPage.kt
@@ -7,10 +7,9 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.ExperimentalMaterialApi
-import androidx.compose.material.Text
-import androidx.compose.material.TextField
-import androidx.compose.material.TextFieldDefaults
+import androidx.compose.material.*
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Clear
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -25,11 +24,19 @@ import com.pushdeer.os.ui.compose.componment.ListBottomBlankItem
import com.pushdeer.os.ui.compose.componment.SwipeToDismissItem
import com.pushdeer.os.ui.navigation.Page
import com.pushdeer.os.util.SystemUtil
+import kotlinx.coroutines.launch
@ExperimentalMaterialApi
@Composable
fun DeviceListPage(requestHolder: RequestHolder) {
+
+ SideEffect {
+ requestHolder.coroutineScope.launch {
+ requestHolder.pushDeerViewModel.deviceList()
+ }
+ }
+
MainPageFrame(
titleStringId = Page.Devices.labelStringId,
onSideIconClick = {
@@ -75,11 +82,11 @@ fun DeviceListPage(requestHolder: RequestHolder) {
) {
CardItemSingleLineWithIcon(
onClick = {
+ name = deviceInfo.name
requestHolder.alert.alert(
title = R.string.main_device_alert_changedevicename,
content = {
Column {
-// Text(text = "type:${deviceInfo.type}")
TextField(
value = name,
onValueChange = { name = it },
@@ -92,7 +99,12 @@ fun DeviceListPage(requestHolder: RequestHolder) {
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent,
errorIndicatorColor = Color.Transparent,
- )
+ ),
+ trailingIcon = {
+ if (name != "") IconButton(onClick = { name = "" }) {
+ Icon(imageVector = Icons.Default.Clear, contentDescription = "")
+ }
+ }
)
}
},
diff --git a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/KeyListPage.kt b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/KeyListPage.kt
index d531aca..878037f 100644
--- a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/KeyListPage.kt
+++ b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/KeyListPage.kt
@@ -9,6 +9,7 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.SideEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
@@ -19,10 +20,18 @@ import com.pushdeer.os.ui.compose.componment.KeyItem
import com.pushdeer.os.ui.compose.componment.ListBottomBlankItem
import com.pushdeer.os.ui.compose.componment.SwipeToDismissItem
import com.pushdeer.os.ui.navigation.Page
+import kotlinx.coroutines.launch
@ExperimentalMaterialApi
@Composable
fun KeyListPage(requestHolder: RequestHolder) {
+
+ SideEffect {
+ requestHolder.coroutineScope.launch {
+ requestHolder.pushDeerViewModel.keyList()
+ }
+ }
+
MainPageFrame(
titleStringId = Page.Keys.labelStringId,
onSideIconClick = { requestHolder.key.gen() }
diff --git a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/MainPage.kt b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/MainPage.kt
index 287fdfa..eb42f8f 100644
--- a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/MainPage.kt
+++ b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/MainPage.kt
@@ -36,9 +36,6 @@ fun MainPage(requestHolder: RequestHolder) {
SideEffect {
requestHolder.coroutineScope.launch {
requestHolder.pushDeerViewModel.userInfo()
- requestHolder.pushDeerViewModel.keyList()
- requestHolder.pushDeerViewModel.deviceList()
- requestHolder.pushDeerViewModel.messageList()
}
}
diff --git a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/MessageListPage.kt b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/MessageListPage.kt
index 6c22481..5efa569 100644
--- a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/MessageListPage.kt
+++ b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/MessageListPage.kt
@@ -23,12 +23,20 @@ import com.pushdeer.os.ui.compose.componment.*
import com.pushdeer.os.ui.navigation.Page
import com.pushdeer.os.ui.theme.MBlue
import com.pushdeer.os.values.ConstValues
+import kotlinx.coroutines.launch
@ExperimentalAnimationApi
@ExperimentalMaterialApi
@Composable
fun MessageListPage(requestHolder: RequestHolder) {
+
+ SideEffect {
+ requestHolder.coroutineScope.launch {
+ requestHolder.pushDeerViewModel.messageList()
+ }
+ }
+
MainPageFrame(
titleStringId = Page.Messages.labelStringId,
sideIcon = if (requestHolder.uiViewModel.showMessageSender) Icons.Default.KeyboardArrowUp else Icons.Default.KeyboardArrowDown,
diff --git a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/SettingPage.kt b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/SettingPage.kt
index 881cefb..4aba2bc 100644
--- a/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/SettingPage.kt
+++ b/android/app/src/main/java/com/pushdeer/os/ui/compose/page/main/SettingPage.kt
@@ -1,5 +1,8 @@
package com.pushdeer.os.ui.compose.page.main
+import android.content.Intent
+import android.net.Uri
+import android.util.Log
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.ExperimentalMaterialApi
@@ -22,20 +25,45 @@ fun SettingPage(requestHolder: RequestHolder) {
modifier = Modifier.fillMaxSize()
) {
item {
+// var newName by remember {
+// mutableStateOf(requestHolder.pushDeerViewModel.userInfo.name)
+// }
SettingItem(
text = "${stringResource(id = R.string.main_setting_user_hi)} ${requestHolder.pushDeerViewModel.userInfo.name} !",
- buttonString = stringResource(id = R.string.main_setting_user_logout)
- ) {
- requestHolder.pushDeerViewModel.deviceList.filter { it.device_id == requestHolder.settingStore.thisDeviceId }.forEach {
- requestHolder.device.deviceRemove(it)
+ buttonString = stringResource(id = R.string.main_setting_user_logout),
+ onItemClick = {
+
+// requestHolder.alert.alert(
+// title = "修改用户名",
+// content = {
+// TextField(
+// value = newName,
+// onValueChange = { newName = it },
+// colors = TextFieldDefaults.textFieldColors(
+// focusedIndicatorColor = Color.Transparent,
+// unfocusedIndicatorColor = Color.Transparent,
+// disabledIndicatorColor = Color.Transparent,
+// errorIndicatorColor = Color.Transparent,
+// )
+// )
+// },
+// onOk = {
+//
+// }
+// )
}
+ ) {
+ requestHolder.pushDeerViewModel.deviceList.filter { it.device_id == requestHolder.settingStore.thisDeviceId }
+ .forEach {
+ requestHolder.device.deviceRemove(it)
+ }
requestHolder.settingStore.userToken = ""
requestHolder.globalNavController.navigate("login") {
requestHolder.globalNavController.popBackStack()
}
requestHolder.alert.alert(
- "提示",
- "由于厂商推送设备服务限制,暂时不支持更换为自建 PushDeer 服务器,但仅更换登陆账号并不会影响您的使用",
+ R.string.global_alert_title_alert,
+ R.string.main_setting_alert_logout,
{}
)
}
@@ -48,13 +76,24 @@ fun SettingPage(requestHolder: RequestHolder) {
// requestHolder.startQrScanActivity()
// }
// }
-// item {
-// SettingItem(
-// text = "Do you like PushDeer ?",
-// buttonString = "Like"
-// ) {
-// }
-// }
+ item {
+ SettingItem(
+ text = stringResource(id = R.string.main_setting_douyoulike),
+ buttonString = stringResource(id = R.string.main_setting_btn_like)
+ ) {
+ val uri = Uri.parse("market://details?id=" + "com.pushdeer.os")
+ Intent(Intent.ACTION_VIEW, uri).apply {
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ }.let {
+ try {
+ requestHolder.myActivity.startActivity(it)
+ } catch (e: Exception) {
+ Log.d("WH_", "SettingPage: ${e.localizedMessage}")
+// requestHolder.logDogViewModel
+ }
+ }
+ }
+ }
item {
SettingItem(
diff --git a/android/app/src/main/java/com/pushdeer/os/viewmodel/LogDogViewModel.kt b/android/app/src/main/java/com/pushdeer/os/viewmodel/LogDogViewModel.kt
index c373db0..642888c 100644
--- a/android/app/src/main/java/com/pushdeer/os/viewmodel/LogDogViewModel.kt
+++ b/android/app/src/main/java/com/pushdeer/os/viewmodel/LogDogViewModel.kt
@@ -1,12 +1,20 @@
package com.pushdeer.os.viewmodel
import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
import com.pushdeer.os.data.repository.LogDogRepository
+import kotlinx.coroutines.launch
class LogDogViewModel(private val logDogRepository: LogDogRepository): ViewModel() {
val all = logDogRepository.all
- suspend fun clear(){
- logDogRepository.clear()
+// suspend fun clear(){
+// logDogRepository.clear()
+// }
+
+ fun clear(){
+ viewModelScope.launch {
+ logDogRepository.clear()
+ }
}
}
\ No newline at end of file
diff --git a/android/app/src/main/res/values-zh/strings.xml b/android/app/src/main/res/values-zh/strings.xml
index a394120..5990b6a 100644
--- a/android/app/src/main/res/values-zh/strings.xml
+++ b/android/app/src/main/res/values-zh/strings.xml
@@ -26,4 +26,7 @@
设备名称
修改密钥名称
密钥名称
+ 喜欢 PushDeer 吗?
+ 喜欢
+ 由于厂商推送设备服务限制,暂时不支持更换为自建 PushDeer 服务器,但仅更换登陆账号并不会影响您的使用。
\ No newline at end of file
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index d4cba6d..06d7b27 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -25,4 +25,7 @@
name
Change Key Name
name
+ Do you line PushDeer?
+ Like
+ Due to the limitations of the vendor\'s push device service, it is not supported to change to the self-built PushDeer server for the time being, but only changing the login account will not affect your use.
diff --git a/android/settings.gradle b/android/settings.gradle
index 1bfaa3c..bd740a3 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -11,4 +11,5 @@ rootProject.name = "PushDeer"
include ':app'
include ':common'
include ':compose'
+include ':pushdeerclient'
include ':pushdeercommon'