Skip to content

Commit

Permalink
Enhance screen mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
ismartcoding committed May 2, 2024
1 parent d0990e3 commit 1e81487
Show file tree
Hide file tree
Showing 140 changed files with 2,555 additions and 2,431 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ android {
else -> 0
}

val vCode = 280
val vCode = 283
versionCode = vCode - singleAbiNum
versionName = "1.2.49"
versionName = "1.2.50"

ndk {
//noinspection ChromeOsAbiSupport
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- <uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />-->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<!-- <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />-->
<!-- <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />-->
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/ismartcoding/plain/TempData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.ismartcoding.plain

import com.ismartcoding.plain.data.DNotification
import com.ismartcoding.plain.enums.MediaPlayMode
import com.ismartcoding.plain.enums.ScreenMirrorQualityType

object TempData {
var webEnabled = false
Expand All @@ -19,7 +18,6 @@ object TempData {
var chatItemsMigrated = false
val notifications = mutableListOf<DNotification>()
var audioPlayMode = MediaPlayMode.REPEAT
var screenMirrorQualityType = ScreenMirrorQualityType.HIGH

var audioSleepTimerFutureTime = 0L
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.ismartcoding.plain.data

import kotlinx.serialization.Serializable

@Serializable
data class DScreenMirrorQuality(
val quality: Int = 50,
val resolution: Int = 720 // 480p, 720p,1080p,4k
)

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ object PackageHelper {
}

fun getCerts(packageInfo: PackageInfo): List<DCertificate> {
var certs = appCertsCache[packageInfo.packageName]
if (certs == null) {
certs = mutableListOf<DCertificate>()
val certs = appCertsCache[packageInfo.packageName]?.toMutableList() ?: mutableListOf()
if (certs.isEmpty()) {
val signatures = signatures(packageInfo)
for (signature in signatures) {
val cert = X509Certificate.getInstance(signature.toByteArray())
Expand All @@ -129,8 +128,6 @@ object PackageHelper {
)
}
appCertsCache[packageInfo.packageName] = certs
} else {
certs = mutableListOf()
}

return certs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data class DFile(
var name: String,
var path: String,
val permission: String,
val createdAt: Instant?,
val updatedAt: Instant,
val size: Long,
val isDir: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ object FileMediaStoreHelper : BaseContentHelper() {
MediaStore.Files.FileColumns.DISPLAY_NAME,
MediaStore.Files.FileColumns.DATA,
MediaStore.Files.FileColumns.SIZE,
MediaStore.Files.FileColumns.DATE_ADDED,
MediaStore.Files.FileColumns.DATE_MODIFIED,
MediaStore.Files.FileColumns.MIME_TYPE,
MediaStore.Files.FileColumns.MEDIA_TYPE,
Expand Down Expand Up @@ -86,13 +87,15 @@ object FileMediaStoreHelper : BaseContentHelper() {
val title = cursor.getStringValue(MediaStore.Files.FileColumns.DISPLAY_NAME, cache)
val size = cursor.getLongValue(MediaStore.Files.FileColumns.SIZE, cache)
val path = cursor.getStringValue(MediaStore.Files.FileColumns.DATA, cache)
val createdAt = cursor.getTimeValue(MediaStore.Files.FileColumns.DATE_ADDED, cache)
val updatedAt = cursor.getTimeValue(MediaStore.Files.FileColumns.DATE_MODIFIED, cache)
val mediaType = cursor.getIntValue(MediaStore.Files.FileColumns.MEDIA_TYPE, cache)
result.add(
DFile(
title,
path,
"",
createdAt,
updatedAt,
size,
mediaType == MediaStore.Files.FileColumns.MEDIA_TYPE_NONE,
Expand All @@ -112,13 +115,17 @@ object FileMediaStoreHelper : BaseContentHelper() {
val title = cursor.getStringValue(MediaStore.Files.FileColumns.DISPLAY_NAME, indexCache)
val size = cursor.getLongValue(MediaStore.Files.FileColumns.SIZE, indexCache)
val path = cursor.getStringValue(MediaStore.Files.FileColumns.DATA, indexCache)
val createdAt = Instant.fromEpochMilliseconds(
cursor.getLongValue(MediaStore.Files.FileColumns.DATE_ADDED, indexCache) * 1000L,
)
val updatedAt = Instant.fromEpochMilliseconds(
cursor.getLongValue(MediaStore.Files.FileColumns.DATE_MODIFIED, indexCache) * 1000L,
)
file = DFile(
title,
path,
"",
createdAt,
updatedAt,
size,
false,
Expand Down Expand Up @@ -157,38 +164,41 @@ object FileMediaStoreHelper : BaseContentHelper() {
}

val path = cursor.getStringValue(MediaStore.Files.FileColumns.DATA, cache)
val createdAt = Instant.fromEpochMilliseconds(
cursor.getLongValue(MediaStore.Files.FileColumns.DATE_ADDED, cache) * 1000L,
)
val updatedAt = Instant.fromEpochMilliseconds(
cursor.getLongValue(MediaStore.Files.FileColumns.DATE_MODIFIED, cache) * 1000L,
)
val mimetype = fullMimetype.substringBefore("/")
when (fileType) {
FileType.IMAGE -> {
if (mimetype == "image") {
items.add(DFile(name, path, "", updatedAt, size, false, 0, id))
items.add(DFile(name, path, "", createdAt, updatedAt, size, false, 0, id))
}
}

FileType.VIDEO -> {
if (mimetype == "video") {
items.add(DFile(name, path, "", updatedAt, size, false, 0, id))
items.add(DFile(name, path, "", createdAt, updatedAt, size, false, 0, id))
}
}

FileType.AUDIO -> {
if (mimetype == "audio" || extraAudioMimeTypes.contains(fullMimetype)) {
items.add(DFile(name, path, "", updatedAt, size, false, 0, id))
items.add(DFile(name, path, "", createdAt, updatedAt, size, false, 0, id))
}
}

FileType.DOCUMENT -> {
if (mimetype == "text" || extraDocumentMimeTypes.contains(fullMimetype)) {
items.add(DFile(name, path, "", updatedAt, size, false, 0, id))
items.add(DFile(name, path, "", createdAt, updatedAt, size, false, 0, id))
}
}

FileType.ARCHIVE -> {
if (archiveMimeTypes.contains(fullMimetype)) {
items.add(DFile(name, path, "", updatedAt, size, false, 0, id))
items.add(DFile(name, path, "", createdAt, updatedAt, size, false, 0, id))
}
}

Expand All @@ -197,7 +207,7 @@ object FileMediaStoreHelper : BaseContentHelper() {
!extraAudioMimeTypes.contains(fullMimetype) && !extraDocumentMimeTypes.contains(fullMimetype) &&
!archiveMimeTypes.contains(fullMimetype)
) {
items.add(DFile(name, path, "", updatedAt, size, false, 0, id))
items.add(DFile(name, path, "", createdAt, updatedAt, size, false, 0, id))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ object FileSystemHelper {
file.name,
file.path,
"",
null,
Instant.fromEpochMilliseconds(file.lastModified()),
size,
isDir,
Expand Down Expand Up @@ -275,6 +276,7 @@ object FileSystemHelper {
arrayOf(
MediaStore.Files.FileColumns.DATA,
MediaStore.Files.FileColumns.DISPLAY_NAME,
MediaStore.Files.FileColumns.DATE_ADDED,
MediaStore.Files.FileColumns.DATE_MODIFIED,
MediaStore.Files.FileColumns.SIZE,
)
Expand All @@ -296,11 +298,14 @@ object FileSystemHelper {

val name = cursor.getStringValue(MediaStore.Files.FileColumns.DISPLAY_NAME, cache)
val size = cursor.getLongValue(MediaStore.Files.FileColumns.SIZE, cache)
val createdAt = Instant.fromEpochMilliseconds(
cursor.getLongValue(MediaStore.Files.FileColumns.DATE_ADDED, cache) * 1000L,
)
val updatedAt =
Instant.fromEpochMilliseconds(
cursor.getLongValue(MediaStore.Files.FileColumns.DATE_MODIFIED, cache) * 1000L,
)
items.add(DFile(name, path, "", updatedAt, size, false, 0))
items.add(DFile(name, path, "", createdAt, updatedAt, size, false, 0))
} while (cursor.moveToNext())
}
}
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/ismartcoding/plain/preference/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.ismartcoding.plain.enums.MediaPlayMode
import com.ismartcoding.plain.features.device.DeviceSortBy
import com.ismartcoding.plain.features.file.FileSortBy
import com.ismartcoding.plain.data.DVideo
import com.ismartcoding.plain.data.DScreenMirrorQuality
import java.util.Locale

object PasswordPreference : BasePreference<String>() {
Expand Down Expand Up @@ -296,6 +297,26 @@ object ExchangeRatePreference : BasePreference<String>() {
}
}

object ScreenMirrorQualityPreference : BasePreference<String>() {
override val default = ""
override val key = stringPreferencesKey("screen_mirror_quality")

suspend fun getValueAsync(context: Context): DScreenMirrorQuality {
val str = getAsync(context)
if (str.isEmpty()) {
return DScreenMirrorQuality()
}
return jsonDecode(str)
}

suspend fun putAsync(
context: Context,
value: DScreenMirrorQuality,
) {
putAsync(context, jsonEncode(value))
}
}

object ClientIdPreference : BasePreference<String>() {
override val default = ""
override val key = stringPreferencesKey("client_id")
Expand Down

0 comments on commit 1e81487

Please sign in to comment.