Merge branch 'main' of https://github.com/easychen/pushdeer into main

This commit is contained in:
EasyChen 2022-01-23 11:14:07 +08:00
commit 4db6eeffa0
19 changed files with 157 additions and 38 deletions

View File

@ -5,7 +5,8 @@
* MiPush状态已调通、已接入 * MiPush状态已调通、已接入
* miui √ * miui √
* Mokee √ * Mokee √
* HuaWei √ * WaWei √
* 坚果pro3-8.0.1 √ 坚果pro2s-7.2.0.2 x暂无法成功注册
* 部分原生、类原生 可成功注册,无法收到推送,可能和地区识别有关,待解决 * 部分原生、类原生 可成功注册,无法收到推送,可能和地区识别有关,待解决
### TODO ### TODO
@ -25,7 +26,7 @@
* ~~增加对PushKey重命名的逻辑~~ * ~~增加对PushKey重命名的逻辑~~
* ~~增加对设备重命名的逻辑~~ * ~~增加对设备重命名的逻辑~~
* ~~增加长按复制消息内容的逻辑~~ * ~~增加长按复制消息内容的逻辑~~
* 增加点击设置界面用户名修改用户名逻辑 * 增加点击设置界面用户名修改用户名逻辑(暂无路由)
* ~~适配image类型的消息显示~~ * ~~适配image类型的消息显示~~
* ~~修改app图标~~ * ~~修改app图标~~
@ -113,6 +114,9 @@
* 增加点击 Message 列表项目复制文本功能 * 增加点击 Message 列表项目复制文本功能
* 增加适配Image类型Message的显示 * 增加适配Image类型Message的显示
* 完善登陆注销逻辑 * 完善登陆注销逻辑
* 适配 PushDeer 的专用推送通道
* 增加修改设备/密钥等名称时"清空文本"按钮
* 部分英化汉化
### 感谢 ### 感谢

View File

@ -12,7 +12,7 @@ android {
minSdk 22 minSdk 22
targetSdk 31 targetSdk 31
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0-dev-2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables { vectorDrawables {

View File

@ -12,7 +12,7 @@
"filters": [], "filters": [],
"attributes": [], "attributes": [],
"versionCode": 1, "versionCode": 1,
"versionName": "1.0", "versionName": "1.0-dev-2",
"outputFile": "app-debug.apk" "outputFile": "app-debug.apk"
} }
], ],

View File

@ -19,3 +19,12 @@
# If you keep the line number information, uncomment this to # If you keep the line number information, uncomment this to
# hide the original source file name. # hide the original source file name.
#-renamesourcefileattribute SourceFile #-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.**

View File

@ -22,7 +22,7 @@ class App : Application() {
val storeKeeper by lazy { StoreKeeper(this) } val storeKeeper by lazy { StoreKeeper(this) }
val database by lazy { AppDatabase.getDatabase(this) } val database by lazy { AppDatabase.getDatabase(this) }
val repositoryKeeper by lazy { RepositoryKeeper(database) } val repositoryKeeper by lazy { RepositoryKeeper(database) }
val pushDeerService by lazy { private val pushDeerService: PushDeerApi by lazy {
Retrofit.Builder() Retrofit.Builder()
.baseUrl(PushDeerApi.baseUrl) .baseUrl(PushDeerApi.baseUrl)
.addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(ScalarsConverterFactory.create())

View File

@ -1,8 +1,11 @@
package com.pushdeer.os package com.pushdeer.os
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.ClipboardManager import android.content.ClipboardManager
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.util.Linkify import android.text.util.Linkify
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
@ -93,7 +96,7 @@ class MainActivity : AppCompatActivity(), RequestHolder {
Markwon.builder(this) Markwon.builder(this)
.usePlugin(CoilImagesPlugin.create(this, coilImageLoader)) .usePlugin(CoilImagesPlugin.create(this, coilImageLoader))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS)) .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.build(); .build()
} }
override lateinit var globalNavController: NavHostController override lateinit var globalNavController: NavHostController
@ -107,6 +110,18 @@ class MainActivity : AppCompatActivity(), RequestHolder {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) 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 myActivity = this
qrScanActivityOpener = ActivityOpener.forResult(this) qrScanActivityOpener = ActivityOpener.forResult(this)
requestPermissionOpener = ActivityOpener.forPermission(this) requestPermissionOpener = ActivityOpener.forPermission(this)

View File

@ -62,12 +62,16 @@ interface RequestHolder {
fun clearLogDog() { fun clearLogDog() {
alert.alert(R.string.global_alert_title_confirm,"Clear?",onOk = { alert.alert(R.string.global_alert_title_confirm,"Clear?",onOk = {
coroutineScope.launch {
logDogViewModel.clear() logDogViewModel.clear()
}
}) })
} }
fun userRename(newName:String){
}
// abstract class LogDogRequest(private val )
abstract class ClipRequest(private val clipboardManager: ClipboardManager) { abstract class ClipRequest(private val clipboardManager: ClipboardManager) {
fun copyMessagePlainText(str: String) { fun copyMessagePlainText(str: String) {
clipboardManager.setPrimaryClip(ClipData.newPlainText("pushdeer-copy-plain-text", str)) clipboardManager.setPrimaryClip(ClipData.newPlainText("pushdeer-copy-plain-text", str))

View File

@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.* import androidx.compose.material.*
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material.icons.filled.DateRange import androidx.compose.material.icons.filled.DateRange
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@ -34,6 +35,7 @@ fun KeyItem(key: PushKey, requestHolder: RequestHolder) {
mutableStateOf(key.name) mutableStateOf(key.name)
} }
CardItemWithContent(onClick = { CardItemWithContent(onClick = {
name = key.name
requestHolder.alert.alert( requestHolder.alert.alert(
title = R.string.main_key_alert_changekeyname, title = R.string.main_key_alert_changekeyname,
content = { content = {
@ -50,7 +52,12 @@ fun KeyItem(key: PushKey, requestHolder: RequestHolder) {
unfocusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent, disabledIndicatorColor = Color.Transparent,
errorIndicatorColor = Color.Transparent, errorIndicatorColor = Color.Transparent,
) ),
trailingIcon = {
if (name != "") IconButton(onClick = { name = "" }) {
Icon(imageVector = Icons.Default.Clear, contentDescription = "")
}
}
) )
} }
}, },

View File

@ -14,13 +14,13 @@ import com.pushdeer.os.ui.theme.MBlue
@ExperimentalMaterialApi @ExperimentalMaterialApi
@Composable @Composable
fun SettingItem(text: String, buttonString: String, onClick: () -> Unit) { fun SettingItem(text: String, buttonString: String, onItemClick:()->Unit={},onButtonClick: () -> Unit) {
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(bottom = 16.dp) .padding(bottom = 16.dp)
) { ) {
CardItemWithContent() { CardItemWithContent(onClick = onItemClick) {
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
@ -36,7 +36,7 @@ fun SettingItem(text: String, buttonString: String, onClick: () -> Unit) {
maxLines = 1, maxLines = 1,
) )
Button( Button(
onClick = onClick, onClick = onButtonClick,
shape = RoundedCornerShape(8.dp), shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = MaterialTheme.colors.MBlue, backgroundColor = MaterialTheme.colors.MBlue,

View File

@ -7,10 +7,9 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.*
import androidx.compose.material.Text import androidx.compose.material.icons.Icons
import androidx.compose.material.TextField import androidx.compose.material.icons.filled.Clear
import androidx.compose.material.TextFieldDefaults
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier 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.compose.componment.SwipeToDismissItem
import com.pushdeer.os.ui.navigation.Page import com.pushdeer.os.ui.navigation.Page
import com.pushdeer.os.util.SystemUtil import com.pushdeer.os.util.SystemUtil
import kotlinx.coroutines.launch
@ExperimentalMaterialApi @ExperimentalMaterialApi
@Composable @Composable
fun DeviceListPage(requestHolder: RequestHolder) { fun DeviceListPage(requestHolder: RequestHolder) {
SideEffect {
requestHolder.coroutineScope.launch {
requestHolder.pushDeerViewModel.deviceList()
}
}
MainPageFrame( MainPageFrame(
titleStringId = Page.Devices.labelStringId, titleStringId = Page.Devices.labelStringId,
onSideIconClick = { onSideIconClick = {
@ -75,11 +82,11 @@ fun DeviceListPage(requestHolder: RequestHolder) {
) { ) {
CardItemSingleLineWithIcon( CardItemSingleLineWithIcon(
onClick = { onClick = {
name = deviceInfo.name
requestHolder.alert.alert( requestHolder.alert.alert(
title = R.string.main_device_alert_changedevicename, title = R.string.main_device_alert_changedevicename,
content = { content = {
Column { Column {
// Text(text = "type:${deviceInfo.type}")
TextField( TextField(
value = name, value = name,
onValueChange = { name = it }, onValueChange = { name = it },
@ -92,7 +99,12 @@ fun DeviceListPage(requestHolder: RequestHolder) {
unfocusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent, disabledIndicatorColor = Color.Transparent,
errorIndicatorColor = Color.Transparent, errorIndicatorColor = Color.Transparent,
) ),
trailingIcon = {
if (name != "") IconButton(onClick = { name = "" }) {
Icon(imageVector = Icons.Default.Clear, contentDescription = "")
}
}
) )
} }
}, },

View File

@ -9,6 +9,7 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource 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.ListBottomBlankItem
import com.pushdeer.os.ui.compose.componment.SwipeToDismissItem import com.pushdeer.os.ui.compose.componment.SwipeToDismissItem
import com.pushdeer.os.ui.navigation.Page import com.pushdeer.os.ui.navigation.Page
import kotlinx.coroutines.launch
@ExperimentalMaterialApi @ExperimentalMaterialApi
@Composable @Composable
fun KeyListPage(requestHolder: RequestHolder) { fun KeyListPage(requestHolder: RequestHolder) {
SideEffect {
requestHolder.coroutineScope.launch {
requestHolder.pushDeerViewModel.keyList()
}
}
MainPageFrame( MainPageFrame(
titleStringId = Page.Keys.labelStringId, titleStringId = Page.Keys.labelStringId,
onSideIconClick = { requestHolder.key.gen() } onSideIconClick = { requestHolder.key.gen() }

View File

@ -36,9 +36,6 @@ fun MainPage(requestHolder: RequestHolder) {
SideEffect { SideEffect {
requestHolder.coroutineScope.launch { requestHolder.coroutineScope.launch {
requestHolder.pushDeerViewModel.userInfo() requestHolder.pushDeerViewModel.userInfo()
requestHolder.pushDeerViewModel.keyList()
requestHolder.pushDeerViewModel.deviceList()
requestHolder.pushDeerViewModel.messageList()
} }
} }

View File

@ -23,12 +23,20 @@ import com.pushdeer.os.ui.compose.componment.*
import com.pushdeer.os.ui.navigation.Page import com.pushdeer.os.ui.navigation.Page
import com.pushdeer.os.ui.theme.MBlue import com.pushdeer.os.ui.theme.MBlue
import com.pushdeer.os.values.ConstValues import com.pushdeer.os.values.ConstValues
import kotlinx.coroutines.launch
@ExperimentalAnimationApi @ExperimentalAnimationApi
@ExperimentalMaterialApi @ExperimentalMaterialApi
@Composable @Composable
fun MessageListPage(requestHolder: RequestHolder) { fun MessageListPage(requestHolder: RequestHolder) {
SideEffect {
requestHolder.coroutineScope.launch {
requestHolder.pushDeerViewModel.messageList()
}
}
MainPageFrame( MainPageFrame(
titleStringId = Page.Messages.labelStringId, titleStringId = Page.Messages.labelStringId,
sideIcon = if (requestHolder.uiViewModel.showMessageSender) Icons.Default.KeyboardArrowUp else Icons.Default.KeyboardArrowDown, sideIcon = if (requestHolder.uiViewModel.showMessageSender) Icons.Default.KeyboardArrowUp else Icons.Default.KeyboardArrowDown,

View File

@ -1,5 +1,8 @@
package com.pushdeer.os.ui.compose.page.main 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.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ExperimentalMaterialApi
@ -22,11 +25,36 @@ fun SettingPage(requestHolder: RequestHolder) {
modifier = Modifier.fillMaxSize() modifier = Modifier.fillMaxSize()
) { ) {
item { item {
// var newName by remember {
// mutableStateOf(requestHolder.pushDeerViewModel.userInfo.name)
// }
SettingItem( SettingItem(
text = "${stringResource(id = R.string.main_setting_user_hi)} ${requestHolder.pushDeerViewModel.userInfo.name} !", text = "${stringResource(id = R.string.main_setting_user_hi)} ${requestHolder.pushDeerViewModel.userInfo.name} !",
buttonString = stringResource(id = R.string.main_setting_user_logout) 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.pushDeerViewModel.deviceList.filter { it.device_id == requestHolder.settingStore.thisDeviceId }
.forEach {
requestHolder.device.deviceRemove(it) requestHolder.device.deviceRemove(it)
} }
requestHolder.settingStore.userToken = "" requestHolder.settingStore.userToken = ""
@ -34,8 +62,8 @@ fun SettingPage(requestHolder: RequestHolder) {
requestHolder.globalNavController.popBackStack() requestHolder.globalNavController.popBackStack()
} }
requestHolder.alert.alert( requestHolder.alert.alert(
"提示", R.string.global_alert_title_alert,
"由于厂商推送设备服务限制,暂时不支持更换为自建 PushDeer 服务器,但仅更换登陆账号并不会影响您的使用", R.string.main_setting_alert_logout,
{} {}
) )
} }
@ -48,13 +76,24 @@ fun SettingPage(requestHolder: RequestHolder) {
// requestHolder.startQrScanActivity() // requestHolder.startQrScanActivity()
// } // }
// } // }
// item { item {
// SettingItem( SettingItem(
// text = "Do you like PushDeer ?", text = stringResource(id = R.string.main_setting_douyoulike),
// buttonString = "Like" 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 { item {
SettingItem( SettingItem(

View File

@ -1,12 +1,20 @@
package com.pushdeer.os.viewmodel package com.pushdeer.os.viewmodel
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.pushdeer.os.data.repository.LogDogRepository import com.pushdeer.os.data.repository.LogDogRepository
import kotlinx.coroutines.launch
class LogDogViewModel(private val logDogRepository: LogDogRepository): ViewModel() { class LogDogViewModel(private val logDogRepository: LogDogRepository): ViewModel() {
val all = logDogRepository.all val all = logDogRepository.all
suspend fun clear(){ // suspend fun clear(){
// logDogRepository.clear()
// }
fun clear(){
viewModelScope.launch {
logDogRepository.clear() logDogRepository.clear()
} }
} }
}

View File

@ -26,4 +26,7 @@
<string name="main_device_alert_devicename">设备名称</string> <string name="main_device_alert_devicename">设备名称</string>
<string name="main_key_alert_changekeyname">修改密钥名称</string> <string name="main_key_alert_changekeyname">修改密钥名称</string>
<string name="main_key_alert_keyname">密钥名称</string> <string name="main_key_alert_keyname">密钥名称</string>
<string name="main_setting_douyoulike">喜欢 PushDeer 吗?</string>
<string name="main_setting_btn_like">喜欢</string>
<string name="main_setting_alert_logout">由于厂商推送设备服务限制,暂时不支持更换为自建 PushDeer 服务器,但仅更换登陆账号并不会影响您的使用。</string>
</resources> </resources>

View File

@ -25,4 +25,7 @@
<string name="main_device_alert_devicename">name</string> <string name="main_device_alert_devicename">name</string>
<string name="main_key_alert_changekeyname">Change Key Name</string> <string name="main_key_alert_changekeyname">Change Key Name</string>
<string name="main_key_alert_keyname">name</string> <string name="main_key_alert_keyname">name</string>
<string name="main_setting_douyoulike">Do you line PushDeer?</string>
<string name="main_setting_btn_like">Like</string>
<string name="main_setting_alert_logout">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.</string>
</resources> </resources>

View File

@ -11,4 +11,5 @@ rootProject.name = "PushDeer"
include ':app' include ':app'
include ':common' include ':common'
include ':compose' include ':compose'
include ':pushdeerclient'
include ':pushdeercommon' include ':pushdeercommon'