mirror of
https://github.com/easychen/pushdeer.git
synced 2025-01-10 23:15:30 +08:00
commit
caf646ad22
@ -11,8 +11,8 @@ android {
|
|||||||
applicationId "com.pushdeer.os"
|
applicationId "com.pushdeer.os"
|
||||||
minSdk 22
|
minSdk 22
|
||||||
targetSdk 31
|
targetSdk 31
|
||||||
versionCode 1
|
versionCode 5
|
||||||
versionName "1.0-dev-2"
|
versionName "1.0-dev-5"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
@ -84,6 +84,7 @@ dependencies {
|
|||||||
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
|
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
|
||||||
implementation "com.google.accompanist:accompanist-insets:$accompanist_version"
|
implementation "com.google.accompanist:accompanist-insets:$accompanist_version"
|
||||||
// implementation "com.google.accompanist:accompanist-insets-ui:$accompanist_version"
|
// implementation "com.google.accompanist:accompanist-insets-ui:$accompanist_version"
|
||||||
|
// implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist_version"
|
||||||
|
|
||||||
// room
|
// room
|
||||||
def room_version = "2.4.0"
|
def room_version = "2.4.0"
|
||||||
@ -109,6 +110,6 @@ dependencies {
|
|||||||
implementation "io.coil-kt:coil:1.4.0"
|
implementation "io.coil-kt:coil:1.4.0"
|
||||||
|
|
||||||
implementation 'com.github.vishalkumarsinghvi:sign-in-with-apple-button-android:0.6'
|
implementation 'com.github.vishalkumarsinghvi:sign-in-with-apple-button-android:0.6'
|
||||||
// implementation 'com.github.bumptech.glide:glide:4.12.0'
|
|
||||||
// annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
|
||||||
}
|
}
|
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"artifactType": {
|
|
||||||
"type": "APK",
|
|
||||||
"kind": "Directory"
|
|
||||||
},
|
|
||||||
"applicationId": "com.pushdeer.os",
|
|
||||||
"variantName": "debug",
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"type": "SINGLE",
|
|
||||||
"filters": [],
|
|
||||||
"attributes": [],
|
|
||||||
"versionCode": 1,
|
|
||||||
"versionName": "1.0-dev-2",
|
|
||||||
"outputFile": "app-debug.apk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"elementType": "File"
|
|
||||||
}
|
|
@ -1,11 +1,8 @@
|
|||||||
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
|
||||||
@ -37,6 +34,7 @@ import com.pushdeer.os.ui.compose.page.LoginPage
|
|||||||
import com.pushdeer.os.ui.compose.page.main.MainPage
|
import com.pushdeer.os.ui.compose.page.main.MainPage
|
||||||
import com.pushdeer.os.ui.theme.PushDeerTheme
|
import com.pushdeer.os.ui.theme.PushDeerTheme
|
||||||
import com.pushdeer.os.util.ActivityOpener
|
import com.pushdeer.os.util.ActivityOpener
|
||||||
|
import com.pushdeer.os.util.NotificationUtil
|
||||||
import com.pushdeer.os.util.SystemUtil
|
import com.pushdeer.os.util.SystemUtil
|
||||||
import com.pushdeer.os.viewmodel.LogDogViewModel
|
import com.pushdeer.os.viewmodel.LogDogViewModel
|
||||||
import com.pushdeer.os.viewmodel.MessageViewModel
|
import com.pushdeer.os.viewmodel.MessageViewModel
|
||||||
@ -110,17 +108,7 @@ 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) {
|
NotificationUtil.setupChannel(this)
|
||||||
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)
|
||||||
|
@ -15,7 +15,11 @@ class LogDog {
|
|||||||
var timestamp:Long = System.currentTimeMillis()
|
var timestamp:Long = System.currentTimeMillis()
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "id:$id level:$level entity:$entity\nlog:$log time:${timestamp.toTimestamp()}"
|
return "id:$id\n" +
|
||||||
|
"level:$level\n" +
|
||||||
|
"entity:$entity\n" +
|
||||||
|
"log:$log\n" +
|
||||||
|
"time:${timestamp.toTimestamp()}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Composable
|
// @Composable
|
||||||
|
@ -31,7 +31,7 @@ import kotlinx.coroutines.launch
|
|||||||
@Composable
|
@Composable
|
||||||
fun DeviceListPage(requestHolder: RequestHolder) {
|
fun DeviceListPage(requestHolder: RequestHolder) {
|
||||||
|
|
||||||
SideEffect {
|
LaunchedEffect(Unit) {
|
||||||
requestHolder.coroutineScope.launch {
|
requestHolder.coroutineScope.launch {
|
||||||
requestHolder.pushDeerViewModel.deviceList()
|
requestHolder.pushDeerViewModel.deviceList()
|
||||||
}
|
}
|
||||||
|
@ -9,7 +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.runtime.LaunchedEffect
|
||||||
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
|
||||||
@ -26,7 +26,7 @@ import kotlinx.coroutines.launch
|
|||||||
@Composable
|
@Composable
|
||||||
fun KeyListPage(requestHolder: RequestHolder) {
|
fun KeyListPage(requestHolder: RequestHolder) {
|
||||||
|
|
||||||
SideEffect {
|
LaunchedEffect(Unit) {
|
||||||
requestHolder.coroutineScope.launch {
|
requestHolder.coroutineScope.launch {
|
||||||
requestHolder.pushDeerViewModel.keyList()
|
requestHolder.pushDeerViewModel.keyList()
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,7 @@ import kotlinx.coroutines.launch
|
|||||||
@ExperimentalMaterialApi
|
@ExperimentalMaterialApi
|
||||||
@Composable
|
@Composable
|
||||||
fun MainPage(requestHolder: RequestHolder) {
|
fun MainPage(requestHolder: RequestHolder) {
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
SideEffect {
|
|
||||||
requestHolder.coroutineScope.launch {
|
requestHolder.coroutineScope.launch {
|
||||||
requestHolder.pushDeerViewModel.userInfo()
|
requestHolder.pushDeerViewModel.userInfo()
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import kotlinx.coroutines.launch
|
|||||||
@Composable
|
@Composable
|
||||||
fun MessageListPage(requestHolder: RequestHolder) {
|
fun MessageListPage(requestHolder: RequestHolder) {
|
||||||
|
|
||||||
SideEffect {
|
LaunchedEffect(Unit) {
|
||||||
requestHolder.coroutineScope.launch {
|
requestHolder.coroutineScope.launch {
|
||||||
requestHolder.pushDeerViewModel.messageList()
|
requestHolder.pushDeerViewModel.messageList()
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.pushdeer.os.util
|
||||||
|
|
||||||
|
import android.app.NotificationChannel
|
||||||
|
import android.app.NotificationManager
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
|
||||||
|
object NotificationUtil {
|
||||||
|
|
||||||
|
fun setupChannel(context: Context){
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
val notificationManager =
|
||||||
|
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
notificationManager.createNotificationChannel(
|
||||||
|
NotificationChannel(
|
||||||
|
"high_system",
|
||||||
|
"服务提醒",
|
||||||
|
NotificationManager.IMPORTANCE_HIGH
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -44,12 +44,12 @@ class PushDeerViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("login", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "login: ${e.localizedMessage}")
|
Log.d(TAG, "login: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("login", "", e.toString())
|
logDogRepository.loge("login", "", e.toString())
|
||||||
return@withContext
|
return@withContext
|
||||||
}
|
}
|
||||||
logDogRepository.logi("login", "normally", "nothing happened")
|
|
||||||
} else if (token == "" && idToken == "") {
|
} else if (token == "" && idToken == "") {
|
||||||
return@withContext
|
return@withContext
|
||||||
} else if (token != "") {
|
} else if (token != "") {
|
||||||
@ -71,6 +71,7 @@ class PushDeerViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("userInfo", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "userInfo: ${e.localizedMessage}")
|
Log.d(TAG, "userInfo: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("userInfo", "", e.toString())
|
logDogRepository.loge("userInfo", "", e.toString())
|
||||||
@ -96,6 +97,7 @@ class PushDeerViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("deviceReg", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "deviceReg: ${e.localizedMessage}")
|
Log.d(TAG, "deviceReg: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("deviceReg", "", e.toString())
|
logDogRepository.loge("deviceReg", "", e.toString())
|
||||||
@ -112,6 +114,7 @@ class PushDeerViewModel(
|
|||||||
deviceList.addAll(it.devices.reversed())
|
deviceList.addAll(it.devices.reversed())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("deviceList", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "deviceList: ${e.localizedMessage}")
|
Log.d(TAG, "deviceList: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("deviceList", "", e.toString())
|
logDogRepository.loge("deviceList", "", e.toString())
|
||||||
@ -130,6 +133,7 @@ class PushDeerViewModel(
|
|||||||
deviceList()
|
deviceList()
|
||||||
Log.d(TAG, "deviceRemove: $it")
|
Log.d(TAG, "deviceRemove: $it")
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("deviceRemove", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "deviceRemove: ${e.localizedMessage}")
|
Log.d(TAG, "deviceRemove: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("deviceRemove", "", e.toString())
|
logDogRepository.loge("deviceRemove", "", e.toString())
|
||||||
@ -137,12 +141,13 @@ class PushDeerViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun deviceRename(deviceInfo: DeviceInfo,onReturn: () -> Unit={}){
|
suspend fun deviceRename(deviceInfo: DeviceInfo, onReturn: () -> Unit = {}) {
|
||||||
withContext(Dispatchers.IO){
|
withContext(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
pushDeerService.deviceRename(token,deviceInfo.id,deviceInfo.name)
|
pushDeerService.deviceRename(token, deviceInfo.id, deviceInfo.name)
|
||||||
|
logDogRepository.logi("deviceRename", "normally", "nothing happened")
|
||||||
onReturn()
|
onReturn()
|
||||||
}catch (e:Exception){
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "deviceRename: ${e.localizedMessage}")
|
Log.d(TAG, "deviceRename: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("deviceRename", "", e.toString())
|
logDogRepository.loge("deviceRename", "", e.toString())
|
||||||
}
|
}
|
||||||
@ -158,6 +163,7 @@ class PushDeerViewModel(
|
|||||||
keyList.addAll(it.keys)
|
keyList.addAll(it.keys)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("keyGen", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "keyGen: ${e.localizedMessage}")
|
Log.d(TAG, "keyGen: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("keyGen", "", e.toString())
|
logDogRepository.loge("keyGen", "", e.toString())
|
||||||
@ -176,6 +182,7 @@ class PushDeerViewModel(
|
|||||||
).let {
|
).let {
|
||||||
keyList()
|
keyList()
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("keyRegen", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "keyRegen: ${e.localizedMessage}")
|
Log.d(TAG, "keyRegen: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("keyRegen", "", e.toString())
|
logDogRepository.loge("keyRegen", "", e.toString())
|
||||||
@ -183,16 +190,17 @@ class PushDeerViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun keyRename(key: PushKey,onReturn: () -> Unit={}){
|
suspend fun keyRename(key: PushKey, onReturn: () -> Unit = {}) {
|
||||||
withContext(Dispatchers.IO){
|
withContext(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
pushDeerService.keyRename(
|
pushDeerService.keyRename(
|
||||||
token,
|
token,
|
||||||
key.id,
|
key.id,
|
||||||
key.name
|
key.name
|
||||||
)
|
)
|
||||||
|
logDogRepository.logi("keyRename", "normally", "nothing happened")
|
||||||
onReturn()
|
onReturn()
|
||||||
}catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "keyRename: ${e.localizedMessage}")
|
Log.d(TAG, "keyRename: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("keyRename", "", e.toString())
|
logDogRepository.loge("keyRename", "", e.toString())
|
||||||
}
|
}
|
||||||
@ -208,6 +216,7 @@ class PushDeerViewModel(
|
|||||||
keyList.addAll(it.keys)
|
keyList.addAll(it.keys)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("keyList", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "keyList: ${e.localizedMessage}")
|
Log.d(TAG, "keyList: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("keyList", "", e.toString())
|
logDogRepository.loge("keyList", "", e.toString())
|
||||||
@ -221,6 +230,7 @@ class PushDeerViewModel(
|
|||||||
pushDeerService.keyRemove(mapOf("token" to token, "id" to keyId)).let {
|
pushDeerService.keyRemove(mapOf("token" to token, "id" to keyId)).let {
|
||||||
keyList()
|
keyList()
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("keyRemove", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "keyRemove: ${e.localizedMessage}")
|
Log.d(TAG, "keyRemove: ${e.localizedMessage}")
|
||||||
logDogRepository.loge("keyRemove", "", e.toString())
|
logDogRepository.loge("keyRemove", "", e.toString())
|
||||||
@ -247,6 +257,7 @@ class PushDeerViewModel(
|
|||||||
).let {
|
).let {
|
||||||
messageList()
|
messageList()
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("messagePush", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "messagePush: ${e.localizedMessage}")
|
Log.d(TAG, "messagePush: ${e.localizedMessage}")
|
||||||
}
|
}
|
||||||
@ -261,6 +272,7 @@ class PushDeerViewModel(
|
|||||||
messageRepository.insert(*(it.messages.toTypedArray()))
|
messageRepository.insert(*(it.messages.toTypedArray()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("messageList", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "messageList: ${e.localizedMessage}")
|
Log.d(TAG, "messageList: ${e.localizedMessage}")
|
||||||
}
|
}
|
||||||
@ -273,6 +285,7 @@ class PushDeerViewModel(
|
|||||||
pushDeerService.messageRemove(token, messageId).let {
|
pushDeerService.messageRemove(token, messageId).let {
|
||||||
messageList()
|
messageList()
|
||||||
}
|
}
|
||||||
|
logDogRepository.logi("messageRemove", "normally", "nothing happened")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "keyRemove: ${e.localizedMessage}")
|
Log.d(TAG, "keyRemove: ${e.localizedMessage}")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user