mirror of
https://github.com/easychen/pushdeer.git
synced 2025-01-08 22:15:57 +08:00
Merge pull request #25 from alone-wolf/main
主要更改:增加key/device重命名逻辑,增加多国语言适配
This commit is contained in:
commit
3f5bf6a292
@ -13,6 +13,7 @@
|
||||
<entry key="../../../../layout/compose-model-1641659551303.xml" value="2.0" />
|
||||
<entry key="../../../../layout/compose-model-1641659962289.xml" value="2.0" />
|
||||
<entry key="../../../../layout/compose-model-1641694023752.xml" value="0.1" />
|
||||
<entry key="../../../../layout/compose-model-1642733328920.xml" value="2.0" />
|
||||
<entry key="app/src/main/res/drawable/fragment_qr_scan.xml" value="0.12314814814814815" />
|
||||
<entry key="app/src/main/res/drawable/ic_markdown.xml" value="0.12962962962962962" />
|
||||
</map>
|
||||
|
@ -101,6 +101,11 @@
|
||||
* 将自动注册设备修改为手动点击加号注册设备
|
||||
* 当前app几乎处于可以使用的状态
|
||||
|
||||
* 2022-01-21
|
||||
* 修改登陆界面ui
|
||||
* 增加key/device的重命名逻辑
|
||||
* 适配英语和中文
|
||||
|
||||
|
||||
### 感谢
|
||||
|
||||
|
20
android/app/debug/output-metadata.json
Normal file
20
android/app/debug/output-metadata.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.pushdeer.os",
|
||||
"variantName": "debug",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"outputFile": "app-debug.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
BIN
android/app/debug/pushdeer-for-android-v1.0.apk
Normal file
BIN
android/app/debug/pushdeer-for-android-v1.0.apk
Normal file
Binary file not shown.
@ -62,6 +62,7 @@ class MainActivity : AppCompatActivity(), RequestHolder {
|
||||
override val messageViewModel: MessageViewModel by viewModels { viewModelFactory }
|
||||
override val settingStore: SettingStore by lazy { (application as App).storeKeeper.settingStore }
|
||||
override val fragmentManager: FragmentManager by lazy { this.supportFragmentManager }
|
||||
// override val resource: Resources by lazy { this.resource }
|
||||
|
||||
override val coilImageLoader: ImageLoader by lazy {
|
||||
ImageLoader.Builder(this)
|
||||
@ -72,7 +73,7 @@ class MainActivity : AppCompatActivity(), RequestHolder {
|
||||
}
|
||||
.build()
|
||||
}
|
||||
override val alert: RequestHolder.AlertRequest = object : RequestHolder.AlertRequest() {}
|
||||
override val alert: RequestHolder.AlertRequest by lazy { object : RequestHolder.AlertRequest(resources) {} }
|
||||
|
||||
override val markdown: Markwon by lazy {
|
||||
Markwon.builder(this)
|
||||
|
@ -1,7 +1,10 @@
|
||||
package com.pushdeer.os.data.api
|
||||
|
||||
import com.pushdeer.os.data.api.data.response.*
|
||||
import retrofit2.http.*
|
||||
import retrofit2.http.Field
|
||||
import retrofit2.http.FieldMap
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.POST
|
||||
|
||||
interface PushDeerApi {
|
||||
companion object {
|
||||
@ -12,8 +15,8 @@ interface PushDeerApi {
|
||||
@POST("/login/idtoken")
|
||||
suspend fun loginIdToken(@Field("idToken") idToken: String): ReturnData<TokenOnly>
|
||||
|
||||
@GET("/login/fake")
|
||||
suspend fun fakeLogin(): ReturnData<TokenOnly>
|
||||
// @GET("/login/fake")
|
||||
// suspend fun fakeLogin(): ReturnData<TokenOnly>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("/user/info")
|
||||
@ -31,6 +34,14 @@ interface PushDeerApi {
|
||||
@POST("/device/remove")
|
||||
suspend fun deviceRemove(@Field("token") token: String, @Field("id") id: Int): String
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("/device/rename")
|
||||
suspend fun deviceRename(
|
||||
@Field("token") token: String,
|
||||
@Field("id") id: Int,
|
||||
@Field("name") newName: String
|
||||
): String
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("/key/gen")
|
||||
suspend fun keyGen(@Field("token") token: String): ReturnData<PushKeyList>
|
||||
@ -47,6 +58,14 @@ interface PushDeerApi {
|
||||
@POST("/key/remove")
|
||||
suspend fun keyRemove(@FieldMap data: Map<String, String>): String
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("/key/rename")
|
||||
suspend fun keyRename(
|
||||
@Field("token") token: String,
|
||||
@Field("id") id: String,
|
||||
@Field("name") newName: String
|
||||
): String
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("/message/push")
|
||||
suspend fun messagePush(@FieldMap data: Map<String, String>): String
|
||||
|
@ -1,13 +0,0 @@
|
||||
package com.pushdeer.os.data.api.data.response
|
||||
|
||||
class DeviceRemove {
|
||||
var token: String = ""
|
||||
var id = ""
|
||||
|
||||
fun toMap():Map<String,String> {
|
||||
return mapOf(
|
||||
"token" to token,
|
||||
"id" to id
|
||||
)
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.pushdeer.os.holder
|
||||
|
||||
interface DataHolder {
|
||||
}
|
@ -3,9 +3,10 @@ package com.pushdeer.os.holder
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.content.res.Resources
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
@ -13,6 +14,7 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.navigation.NavHostController
|
||||
import coil.ImageLoader
|
||||
import com.pushdeer.os.R
|
||||
import com.pushdeer.os.activity.QrScanActivity
|
||||
import com.pushdeer.os.data.api.data.request.DeviceInfo
|
||||
import com.pushdeer.os.data.api.data.response.Message
|
||||
@ -40,7 +42,9 @@ interface RequestHolder {
|
||||
val activityOpener: ActivityResultLauncher<Intent>
|
||||
val coilImageLoader: ImageLoader
|
||||
|
||||
val fragmentManager:FragmentManager
|
||||
// val resource:Resources
|
||||
|
||||
val fragmentManager: FragmentManager
|
||||
|
||||
val alert: AlertRequest
|
||||
|
||||
@ -73,6 +77,16 @@ interface RequestHolder {
|
||||
}
|
||||
}
|
||||
|
||||
fun keyRename(pushKey: PushKey){
|
||||
coroutineScope.launch {
|
||||
pushDeerViewModel.keyRename(pushKey){
|
||||
coroutineScope.launch {
|
||||
pushDeerViewModel.keyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deviceReg(deviceInfo: DeviceInfo) {
|
||||
coroutineScope.launch {
|
||||
pushDeerViewModel.deviceReg(deviceInfo)
|
||||
@ -86,6 +100,16 @@ interface RequestHolder {
|
||||
}
|
||||
}
|
||||
|
||||
fun deviceRename(deviceInfo: DeviceInfo) {
|
||||
coroutineScope.launch {
|
||||
pushDeerViewModel.deviceRename(deviceInfo) {
|
||||
coroutineScope.launch {
|
||||
pushDeerViewModel.deviceList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun messagePush(text: String, desp: String, type: String, pushkey: String) {
|
||||
coroutineScope.launch {
|
||||
pushDeerViewModel.messagePush(text, desp, type, pushkey)
|
||||
@ -100,8 +124,10 @@ interface RequestHolder {
|
||||
pushDeerViewModel.messageList()
|
||||
}
|
||||
} else {
|
||||
alert.alert("Alert", "You Should Add One PushKey", onOk = {})
|
||||
Log.d("WH_", "messagePushTest: keylist is empty")
|
||||
alert.alert(
|
||||
R.string.global_alert_title_alert,
|
||||
R.string.main_message_send_alert,
|
||||
onOk = {})
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,13 +150,14 @@ interface RequestHolder {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AlertRequest {
|
||||
abstract class AlertRequest(private val resources: Resources) {
|
||||
val show: MutableState<Boolean> = mutableStateOf(false)
|
||||
var title: String = ""
|
||||
|
||||
var content: @Composable () -> Unit = {}
|
||||
var onOKAction: () -> Unit = {}
|
||||
var onCancelAction: () -> Unit = {}
|
||||
|
||||
|
||||
fun alert(
|
||||
title: String,
|
||||
content: @Composable () -> Unit,
|
||||
@ -145,11 +172,25 @@ interface RequestHolder {
|
||||
}
|
||||
|
||||
fun alert(title: String, content: String, onOk: () -> Unit, onCancel: () -> Unit = {}) {
|
||||
this.title = title
|
||||
this.content = { Text(text = content) }
|
||||
this.onOKAction = onOk
|
||||
this.onCancelAction = onCancel
|
||||
this.show.value = true
|
||||
alert(title, { Text(text = content) }, onOk, onCancel)
|
||||
}
|
||||
|
||||
fun alert(
|
||||
@StringRes title: Int,
|
||||
@StringRes content: Int,
|
||||
onOk: () -> Unit,
|
||||
onCancel: () -> Unit = {}
|
||||
) {
|
||||
alert(resources.getString(title), resources.getString(content), onOk, onCancel)
|
||||
}
|
||||
|
||||
fun alert(
|
||||
@StringRes title: Int,
|
||||
content: @Composable () -> Unit,
|
||||
onOk: () -> Unit,
|
||||
onCancel: () -> Unit={}
|
||||
) {
|
||||
alert(resources.getString(title), content, onOk, onCancel)
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ class MessageReceiver : PushMessageReceiver() {
|
||||
|
||||
override fun onReceivePassThroughMessage(context: Context, message: MiPushMessage) {
|
||||
init(context)
|
||||
// Log.d("WH_", "onReceivePassThroughMessage: $message")
|
||||
mMessage = message.content
|
||||
if (!TextUtils.isEmpty(message.topic)) {
|
||||
mTopic = message.topic
|
||||
@ -46,7 +45,6 @@ class MessageReceiver : PushMessageReceiver() {
|
||||
|
||||
override fun onNotificationMessageClicked(context: Context, message: MiPushMessage) {
|
||||
init(context)
|
||||
// Log.d("WH_", "onNotificationMessageClicked: $message")
|
||||
mMessage = message.content
|
||||
if (!TextUtils.isEmpty(message.topic)) {
|
||||
mTopic = message.topic
|
||||
@ -59,7 +57,6 @@ class MessageReceiver : PushMessageReceiver() {
|
||||
|
||||
override fun onNotificationMessageArrived(context: Context, message: MiPushMessage) {
|
||||
init(context)
|
||||
// Log.d("WH_", "onNotificationMessageArrived: $message")
|
||||
mMessage = message.content
|
||||
if (!TextUtils.isEmpty(message.topic)) {
|
||||
mTopic = message.topic
|
||||
@ -72,7 +69,6 @@ class MessageReceiver : PushMessageReceiver() {
|
||||
|
||||
override fun onCommandResult(context: Context, message: MiPushCommandMessage) {
|
||||
init(context)
|
||||
// Log.d("WH_", "onCommandResult: $message")
|
||||
val command = message.command
|
||||
val arguments = message.commandArguments
|
||||
val cmdArg1 = if (arguments != null && arguments.size > 0) arguments[0] else null
|
||||
@ -108,7 +104,6 @@ class MessageReceiver : PushMessageReceiver() {
|
||||
|
||||
override fun onReceiveRegisterResult(context: Context, message: MiPushCommandMessage) {
|
||||
init(context)
|
||||
// Log.d("WH_", "onReceiveRegisterResult: $message")
|
||||
val command = message.command
|
||||
val arguments = message.commandArguments
|
||||
val cmdArg1 = if (arguments != null && arguments.size > 0) arguments[0] else null
|
||||
|
@ -1,19 +0,0 @@
|
||||
//package com.pushdeer.os.sss
|
||||
//
|
||||
//import android.content.Context
|
||||
//import android.content.Intent
|
||||
//import androidx.activity.result.contract.ActivityResultContract
|
||||
//import com.pushdeer.os.activity.QrScanActivity
|
||||
//
|
||||
//class MyActivityResultContract : ActivityResultContract<String, String>() {
|
||||
// override fun createIntent(context: Context, input: String): Intent {
|
||||
// return QrScanActivity.forScanResultIntent(context)
|
||||
// }
|
||||
//
|
||||
// override fun parseResult(resultCode: Int, intent: Intent?): String {
|
||||
// intent?.let {
|
||||
// return it.getStringExtra(QrScanActivity.DataKey).toString()
|
||||
// }
|
||||
// return ""
|
||||
// }
|
||||
//}
|
@ -7,13 +7,13 @@ class SettingStore(context:Context) {
|
||||
val store = Store.create(context,"setting")
|
||||
|
||||
var userToken by store.string("user-token","")
|
||||
var deviceName by store.string("device-name","My Dear Deer")
|
||||
var useRecv by store.boolean("use-recv",false) // 启用接收
|
||||
var useSend by store.boolean("use-send",false)
|
||||
var useSendNotification by store.boolean("use-send-notification",false)
|
||||
var notificationPackages by store.stringSet("notification-packages", emptySet())
|
||||
var useSendMissedCall by store.boolean("use-send=missed-call",false)
|
||||
var useSendSMS by store.boolean("use-send-sms",false)
|
||||
// var deviceName by store.string("device-name","My Dear Deer")
|
||||
// var useRecv by store.boolean("use-recv",false) // 启用接收
|
||||
// var useSend by store.boolean("use-send",false)
|
||||
// var useSendNotification by store.boolean("use-send-notification",false)
|
||||
// var notificationPackages by store.stringSet("notification-packages", emptySet())
|
||||
// var useSendMissedCall by store.boolean("use-send=missed-call",false)
|
||||
// var useSendSMS by store.boolean("use-send-sms",false)
|
||||
|
||||
var showMessageSender by store.boolean("show-message-sender",true)
|
||||
var thisPushSdk by store.string("this-push-sdk","mi-push")
|
||||
|
@ -1,8 +0,0 @@
|
||||
package com.pushdeer.os.typeExt
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -8,11 +8,12 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.DateRange
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
@ -24,8 +25,37 @@ import com.wh.common.util.TimeUtils
|
||||
|
||||
@ExperimentalMaterialApi
|
||||
@Composable
|
||||
fun KeyItem(key: PushKey, requestHolder: RequestHolder) {
|
||||
CardItemWithContent {
|
||||
fun KeyItem(key: PushKey,requestHolder: RequestHolder) {
|
||||
var name by remember {
|
||||
mutableStateOf(key.name)
|
||||
}
|
||||
CardItemWithContent(onClick = {
|
||||
requestHolder.alert.alert(
|
||||
title = R.string.main_key_alert_changekeyname,
|
||||
content = {
|
||||
Column {
|
||||
TextField(
|
||||
value = name,
|
||||
onValueChange = { name = it },
|
||||
shape = RoundedCornerShape(6.dp),
|
||||
singleLine = true,
|
||||
maxLines = 1,
|
||||
label = { Text(text = stringResource(id = R.string.main_key_alert_keyname)) },
|
||||
colors = TextFieldDefaults.textFieldColors(
|
||||
focusedIndicatorColor = Color.Transparent,
|
||||
unfocusedIndicatorColor = Color.Transparent,
|
||||
disabledIndicatorColor = Color.Transparent,
|
||||
errorIndicatorColor = Color.Transparent,
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
onOk = {
|
||||
key.name = name
|
||||
requestHolder.keyRename(key)
|
||||
}
|
||||
)
|
||||
}) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@ -113,7 +143,7 @@ fun KeyItem(key: PushKey, requestHolder: RequestHolder) {
|
||||
border = BorderStroke(1.dp, MaterialTheme.colors.MBlue),
|
||||
shape = RoundedCornerShape(6.dp)
|
||||
) {
|
||||
Text(text = "Reset")
|
||||
Text(text = stringResource(id = R.string.main_key_reset))
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
@ -125,7 +155,7 @@ fun KeyItem(key: PushKey, requestHolder: RequestHolder) {
|
||||
),
|
||||
shape = RoundedCornerShape(6.dp)
|
||||
) {
|
||||
Text(text = "Copy")
|
||||
Text(text = stringResource(id = R.string.main_key_copy))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import androidx.compose.material.AlertDialog
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.pushdeer.os.R
|
||||
import com.pushdeer.os.holder.RequestHolder
|
||||
|
||||
@Composable
|
||||
@ -16,7 +18,7 @@ fun MyAlertDialog(alertRequest: RequestHolder.AlertRequest) {
|
||||
alertRequest.onOKAction.invoke()
|
||||
alertRequest.show.value = false
|
||||
}) {
|
||||
Text(text = "Ok")
|
||||
Text(text = stringResource(id = R.string.global_alert_ok))
|
||||
}
|
||||
|
||||
},
|
||||
@ -25,7 +27,7 @@ fun MyAlertDialog(alertRequest: RequestHolder.AlertRequest) {
|
||||
alertRequest.onCancelAction.invoke()
|
||||
alertRequest.show.value = false
|
||||
}) {
|
||||
Text(text = "Cancel")
|
||||
Text(text = stringResource(id = R.string.global_alert_cancel))
|
||||
}
|
||||
|
||||
},
|
||||
|
@ -2,27 +2,19 @@ package com.pushdeer.os.ui.compose.page
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import com.pushdeer.os.R
|
||||
import com.pushdeer.os.holder.RequestHolder
|
||||
import com.pushdeer.os.ui.theme.MainBlue
|
||||
import com.pushdeer.os.ui.theme.MainGreen
|
||||
import com.willowtreeapps.signinwithapplebutton.SignInWithAppleConfiguration
|
||||
import com.willowtreeapps.signinwithapplebutton.SignInWithAppleResult
|
||||
import com.willowtreeapps.signinwithapplebutton.view.SignInWithAppleButton
|
||||
@ -31,12 +23,7 @@ import kotlinx.coroutines.launch
|
||||
@ExperimentalMaterialApi
|
||||
@Composable
|
||||
fun LoginPage(requestHolder: RequestHolder) {
|
||||
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
|
||||
val configuration = SignInWithAppleConfiguration.Builder()
|
||||
.clientId("com.pushdeer.site")
|
||||
@ -48,9 +35,10 @@ fun LoginPage(requestHolder: RequestHolder) {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.logo_com_x2),
|
||||
contentDescription = "big push deer logo",
|
||||
modifier = Modifier.clickable {
|
||||
requestHolder.globalNavController.navigate("logdog")
|
||||
}
|
||||
modifier = Modifier
|
||||
.clickable { requestHolder.globalNavController.navigate("logdog") }
|
||||
.align(Alignment.TopCenter)
|
||||
.padding(top = 50.dp)
|
||||
)
|
||||
AndroidView(
|
||||
factory = {
|
||||
@ -87,54 +75,8 @@ fun LoginPage(requestHolder: RequestHolder) {
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.padding(bottom = 16.dp)
|
||||
.border(
|
||||
width = 1.dp,
|
||||
color = MainBlue,
|
||||
shape = RoundedCornerShape(4.dp)
|
||||
)
|
||||
.align(alignment = Alignment.BottomCenter)
|
||||
.padding(bottom = 100.dp)
|
||||
)
|
||||
Card(
|
||||
onClick = {
|
||||
|
||||
},
|
||||
shape = RoundedCornerShape(4.dp),
|
||||
modifier = Modifier
|
||||
.padding(bottom = 16.dp)
|
||||
.border(
|
||||
width = 1.dp,
|
||||
color = MainBlue,
|
||||
shape = RoundedCornerShape(4.dp)
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = "Sign in with Apple",
|
||||
color = MainBlue,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.padding(vertical = 16.dp)
|
||||
.fillMaxWidth(0.6F)
|
||||
|
||||
)
|
||||
}
|
||||
Card(
|
||||
onClick = {},
|
||||
shape = RoundedCornerShape(4.dp),
|
||||
modifier = Modifier.border(
|
||||
width = 1.dp,
|
||||
color = MainGreen,
|
||||
shape = RoundedCornerShape(4.dp)
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = "Sign in with WeChat",
|
||||
color = MainGreen,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.padding(vertical = 16.dp)
|
||||
.fillMaxWidth(0.6F)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,16 +1,23 @@
|
||||
package com.pushdeer.os.ui.compose.page.main
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
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.runtime.Composable
|
||||
import androidx.compose.material.TextField
|
||||
import androidx.compose.material.TextFieldDefaults
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pushdeer.os.R
|
||||
import com.pushdeer.os.data.api.data.request.DeviceInfo
|
||||
import com.pushdeer.os.holder.RequestHolder
|
||||
@ -29,8 +36,8 @@ fun DeviceListPage(requestHolder: RequestHolder) {
|
||||
onSideIconClick = {
|
||||
if (requestHolder.settingStore.thisDeviceId == "") {
|
||||
requestHolder.alert.alert(
|
||||
title = "Confirm",
|
||||
content = "This Device Registered Failed in PushSDK",
|
||||
title = R.string.global_alert_title_confirm,
|
||||
content = R.string.alert_device_register_failed_push_sdk,
|
||||
onOk = {})
|
||||
// device regid got failed
|
||||
} else {
|
||||
@ -52,7 +59,7 @@ fun DeviceListPage(requestHolder: RequestHolder) {
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(
|
||||
text = "It's Empty, Click '+' to Add New Device"
|
||||
text = stringResource(id = R.string.main_device_list_placeholder)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@ -61,14 +68,49 @@ fun DeviceListPage(requestHolder: RequestHolder) {
|
||||
items(
|
||||
items = requestHolder.pushDeerViewModel.deviceList,
|
||||
key = { item: DeviceInfo -> item.id }) { deviceInfo: DeviceInfo ->
|
||||
var name by remember {
|
||||
mutableStateOf(deviceInfo.name)
|
||||
}
|
||||
SwipeToDismissItem(
|
||||
onAction = { requestHolder.deviceRemove(deviceInfo) }
|
||||
) {
|
||||
CardItemSingleLineWithIcon(
|
||||
onClick = {},
|
||||
onClick = {
|
||||
requestHolder.alert.alert(
|
||||
title = R.string.main_device_alert_changedevicename,
|
||||
content = {
|
||||
Column {
|
||||
// Text(text = "type:${deviceInfo.type}")
|
||||
TextField(
|
||||
value = name,
|
||||
onValueChange = { name = it },
|
||||
shape = RoundedCornerShape(6.dp),
|
||||
singleLine = true,
|
||||
maxLines = 1,
|
||||
label = { Text(text = stringResource(id = R.string.main_device_alert_devicename)) },
|
||||
colors = TextFieldDefaults.textFieldColors(
|
||||
focusedIndicatorColor = Color.Transparent,
|
||||
unfocusedIndicatorColor = Color.Transparent,
|
||||
disabledIndicatorColor = Color.Transparent,
|
||||
errorIndicatorColor = Color.Transparent,
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
onOk = {
|
||||
deviceInfo.name = name
|
||||
requestHolder.deviceRename(deviceInfo)
|
||||
}
|
||||
)
|
||||
},
|
||||
resId = R.drawable.ipad_landscape2x,
|
||||
text = if (deviceInfo.device_id == requestHolder.settingStore.thisDeviceId) "${deviceInfo.name} (this device) " else deviceInfo.name
|
||||
text = if (deviceInfo.device_id == requestHolder.settingStore.thisDeviceId) "${deviceInfo.name} (${
|
||||
stringResource(
|
||||
id = R.string.main_device_this_device
|
||||
)
|
||||
}) " else deviceInfo.name
|
||||
)
|
||||
Log.d("WH_", "DeviceListPage: $deviceInfo")
|
||||
}
|
||||
}
|
||||
item {
|
||||
|
@ -11,6 +11,8 @@ import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.pushdeer.os.R
|
||||
import com.pushdeer.os.data.api.data.response.PushKey
|
||||
import com.pushdeer.os.holder.RequestHolder
|
||||
import com.pushdeer.os.ui.compose.componment.KeyItem
|
||||
@ -32,7 +34,7 @@ fun KeyListPage(requestHolder: RequestHolder) {
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(
|
||||
text = "It's Empty, Click '+' to Add New Key"
|
||||
text = stringResource(id = R.string.main_key_list_placeholder)
|
||||
)
|
||||
}
|
||||
}else{
|
||||
|
@ -14,7 +14,9 @@ import androidx.compose.material.icons.filled.KeyboardArrowUp
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pushdeer.os.R
|
||||
import com.pushdeer.os.data.database.entity.MessageEntity
|
||||
import com.pushdeer.os.holder.RequestHolder
|
||||
import com.pushdeer.os.ui.compose.componment.*
|
||||
@ -78,7 +80,7 @@ fun MessageListPage(requestHolder: RequestHolder) {
|
||||
contentColor = Color.White
|
||||
),
|
||||
) {
|
||||
Text(text = "Send")
|
||||
Text(text = stringResource(id = R.string.main_message_send))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.pushdeer.os.ui.compose.page.main
|
||||
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.pushdeer.os.R
|
||||
import com.pushdeer.os.holder.RequestHolder
|
||||
import com.pushdeer.os.ui.compose.componment.SettingItem
|
||||
import com.pushdeer.os.ui.navigation.Page
|
||||
@ -24,8 +23,8 @@ fun SettingPage(requestHolder: RequestHolder) {
|
||||
) {
|
||||
item {
|
||||
SettingItem(
|
||||
text = "Hi ${requestHolder.pushDeerViewModel.userInfo.name} !",
|
||||
buttonString = "Logout"
|
||||
text = "${stringResource(id = R.string.main_setting_user_hi)} ${requestHolder.pushDeerViewModel.userInfo.name} !",
|
||||
buttonString = stringResource(id = R.string.main_setting_user_logout)
|
||||
) {
|
||||
requestHolder.settingStore.userToken = ""
|
||||
// logout 操作:
|
||||
@ -33,26 +32,26 @@ fun SettingPage(requestHolder: RequestHolder) {
|
||||
// 删除保存的 token
|
||||
}
|
||||
}
|
||||
item {
|
||||
SettingItem(
|
||||
text = "Customize Server",
|
||||
buttonString = "Scan QR"
|
||||
) {
|
||||
requestHolder.startQrScanActivity()
|
||||
}
|
||||
}
|
||||
item {
|
||||
SettingItem(
|
||||
text = "Do you like PushDeer ?",
|
||||
buttonString = "Like"
|
||||
) {
|
||||
}
|
||||
}
|
||||
// item {
|
||||
// SettingItem(
|
||||
// text = "Customize Server",
|
||||
// buttonString = "Scan QR"
|
||||
// ) {
|
||||
// requestHolder.startQrScanActivity()
|
||||
// }
|
||||
// }
|
||||
// item {
|
||||
// SettingItem(
|
||||
// text = "Do you like PushDeer ?",
|
||||
// buttonString = "Like"
|
||||
// ) {
|
||||
// }
|
||||
// }
|
||||
|
||||
item {
|
||||
SettingItem(
|
||||
text = "LogDog",
|
||||
buttonString = "Open"
|
||||
text = stringResource(id = R.string.main_setting_logdog),
|
||||
buttonString = stringResource(id = R.string.main_setting_logdog_open)
|
||||
) {
|
||||
requestHolder.globalNavController.navigate("logdog")
|
||||
}
|
||||
@ -61,12 +60,12 @@ fun SettingPage(requestHolder: RequestHolder) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun TogglePreferenceItem(label: String) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
Text(text = label)
|
||||
}
|
||||
}
|
||||
//@Composable
|
||||
//fun TogglePreferenceItem(label: String) {
|
||||
// Row(
|
||||
// verticalAlignment = Alignment.CenterVertically,
|
||||
// modifier = Modifier.fillMaxSize()
|
||||
// ) {
|
||||
// Text(text = label)
|
||||
// }
|
||||
//}
|
@ -109,11 +109,12 @@ class PushDeerViewModel(
|
||||
pushDeerService.deviceList(token).let {
|
||||
it.content?.let {
|
||||
deviceList.clear()
|
||||
deviceList.addAll(it.devices)
|
||||
deviceList.addAll(it.devices.reversed())
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "deviceList: ${e.localizedMessage}")
|
||||
logDogRepository.loge("deviceList", "", e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,6 +132,19 @@ class PushDeerViewModel(
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "deviceRemove: ${e.localizedMessage}")
|
||||
logDogRepository.loge("deviceRemove", "", e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deviceRename(deviceInfo: DeviceInfo,onReturn: () -> Unit={}){
|
||||
withContext(Dispatchers.IO){
|
||||
try {
|
||||
pushDeerService.deviceRename(token,deviceInfo.id,deviceInfo.name)
|
||||
onReturn()
|
||||
}catch (e:Exception){
|
||||
Log.d(TAG, "deviceRename: ${e.localizedMessage}")
|
||||
logDogRepository.loge("deviceRename", "", e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,6 +160,7 @@ class PushDeerViewModel(
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyGen: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyGen", "", e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,6 +178,23 @@ class PushDeerViewModel(
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyRegen: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyRegen", "", e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun keyRename(key: PushKey,onReturn: () -> Unit={}){
|
||||
withContext(Dispatchers.IO){
|
||||
try {
|
||||
pushDeerService.keyRename(
|
||||
token,
|
||||
key.id,
|
||||
key.name
|
||||
)
|
||||
onReturn()
|
||||
}catch (e: Exception) {
|
||||
Log.d(TAG, "keyRename: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyRename", "", e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,6 +210,7 @@ class PushDeerViewModel(
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyList: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyList", "", e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -190,6 +223,7 @@ class PushDeerViewModel(
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyRemove: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyRemove", "", e.toString())
|
||||
}
|
||||
}
|
||||
|
||||
|
4
android/app/src/main/res/values-zh-rCN/strings.xml
Normal file
4
android/app/src/main/res/values-zh-rCN/strings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">PushDeer</string>
|
||||
</resources>
|
29
android/app/src/main/res/values-zh/strings.xml
Normal file
29
android/app/src/main/res/values-zh/strings.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">PushDeer</string>
|
||||
<string name="main_device">设备</string>
|
||||
<string name="main_key">密钥</string>
|
||||
<string name="main_message">消息</string>
|
||||
<string name="main_setting">设置</string>
|
||||
<string name="global_logdog">LogDog-罗格狗</string>
|
||||
<string name="main_key_reset">重置</string>
|
||||
<string name="main_key_copy">复制</string>
|
||||
<string name="main_setting_logdog_open">打开</string>
|
||||
<string name="main_setting_user_hi">你好</string>
|
||||
<string name="main_setting_user_logout">注销</string>
|
||||
<string name="main_setting_logdog">LogDog-罗格狗</string>
|
||||
<string name="main_device_list_placeholder">点击\"+\"创建新设备</string>
|
||||
<string name="main_device_this_device">本设备</string>
|
||||
<string name="global_alert_title_confirm">确认</string>
|
||||
<string name="alert_device_register_failed_push_sdk">本设备在厂商推送服务注册失败</string>
|
||||
<string name="main_message_send">发送</string>
|
||||
<string name="global_alert_title_alert">警告</string>
|
||||
<string name="main_message_send_alert">发送消息前请创建新的密钥</string>
|
||||
<string name="global_alert_ok">确认</string>
|
||||
<string name="global_alert_cancel">取消</string>
|
||||
<string name="main_key_list_placeholder">点击\"+\"创建新密钥</string>
|
||||
<string name="main_device_alert_changedevicename">修改设备名称</string>
|
||||
<string name="main_device_alert_devicename">设备名称</string>
|
||||
<string name="main_key_alert_changekeyname">修改密钥名称</string>
|
||||
<string name="main_key_alert_keyname">密钥名称</string>
|
||||
</resources>
|
@ -5,4 +5,24 @@
|
||||
<string name="main_message">Message</string>
|
||||
<string name="main_setting">Setting</string>
|
||||
<string name="global_logdog">LogDog</string>
|
||||
<string name="main_key_reset">Reset</string>
|
||||
<string name="main_key_copy">Copy</string>
|
||||
<string name="main_setting_logdog_open">Open</string>
|
||||
<string name="main_setting_user_hi">Hi</string>
|
||||
<string name="main_setting_user_logout">Logout</string>
|
||||
<string name="main_setting_logdog">LogDog</string>
|
||||
<string name="main_device_list_placeholder">It\'s Empty, Click \'+\' to Add New Device.</string>
|
||||
<string name="main_device_this_device">this device</string>
|
||||
<string name="global_alert_title_confirm">Confirm</string>
|
||||
<string name="alert_device_register_failed_push_sdk">This Device Registered Failed in PushSDK</string>
|
||||
<string name="main_message_send">Send</string>
|
||||
<string name="global_alert_title_alert">Alert</string>
|
||||
<string name="main_message_send_alert">You Should Add One PushKey</string>
|
||||
<string name="global_alert_ok">OK</string>
|
||||
<string name="global_alert_cancel">Cancel</string>
|
||||
<string name="main_key_list_placeholder">It\'s Empty, Click \'+\' to Add New Key.</string>
|
||||
<string name="main_device_alert_changedevicename">Change Device 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_keyname">name</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user