mirror of
https://github.com/easychen/pushdeer.git
synced 2025-01-10 15:05:27 +08:00
Merge branch 'main' of https://github.com/easychen/pushdeer into main
This commit is contained in:
commit
4db6eeffa0
@ -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 的专用推送通道
|
||||
* 增加修改设备/密钥等名称时"清空文本"按钮
|
||||
* 部分英化汉化
|
||||
|
||||
|
||||
### 感谢
|
||||
|
@ -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 {
|
||||
|
@ -12,7 +12,7 @@
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"versionName": "1.0-dev-2",
|
||||
"outputFile": "app-debug.apk"
|
||||
}
|
||||
],
|
||||
|
Binary file not shown.
11
android/app/proguard-rules.pro
vendored
11
android/app/proguard-rules.pro
vendored
@ -18,4 +18,13 @@
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# 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.**
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -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))
|
||||
|
@ -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 = "")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -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,
|
||||
|
@ -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 = "")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -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() }
|
||||
|
@ -36,9 +36,6 @@ fun MainPage(requestHolder: RequestHolder) {
|
||||
SideEffect {
|
||||
requestHolder.coroutineScope.launch {
|
||||
requestHolder.pushDeerViewModel.userInfo()
|
||||
requestHolder.pushDeerViewModel.keyList()
|
||||
requestHolder.pushDeerViewModel.deviceList()
|
||||
requestHolder.pushDeerViewModel.messageList()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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(
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
@ -26,4 +26,7 @@
|
||||
<string name="main_device_alert_devicename">设备名称</string>
|
||||
<string name="main_key_alert_changekeyname">修改密钥名称</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>
|
@ -25,4 +25,7 @@
|
||||
<string name="main_device_alert_devicename">name</string>
|
||||
<string name="main_key_alert_changekeyname">Change Key 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>
|
||||
|
@ -11,4 +11,5 @@ rootProject.name = "PushDeer"
|
||||
include ':app'
|
||||
include ':common'
|
||||
include ':compose'
|
||||
include ':pushdeerclient'
|
||||
include ':pushdeercommon'
|
||||
|
Loading…
Reference in New Issue
Block a user