Skip to content

Commit

Permalink
Merge branch 'rhunk:dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
RevealedSoulEven authored Jan 14, 2024
2 parents 6968c03 + e9184f5 commit 3ffd29b
Show file tree
Hide file tree
Showing 184 changed files with 12,415 additions and 4,248 deletions.
13 changes: 10 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Bug report"
description: "Report an issue to help the project improve."
title: "bug: TITLE"
title: "TITLE"
labels:
- "bug"
body:
Expand Down Expand Up @@ -40,13 +40,20 @@ body:
placeholder: "ex. 12.35.0.45"
validations:
required: true
- type: input
id: snapenhance-version
attributes:
label: "SnapEnhance Version"
description: "On which SnapEnhance version is this happening?"
placeholder: "ex. 1.2.5"
validations:
required: true
- type: checkboxes
id: terms
attributes:
label: "Agreement"
description: "By creating this issue, I agree to the following terms:"
description: "**By creating this issue, I agree to the following terms:**"
options:
- label: "I am using the latest stable SnapEnhance version."
- label: "This is not a bug regarding Snapchat+."
- label: "I have provided a detailed description of the issue."
- label: "I have attached a log if deemed neccessary."
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<img src="https://raw.githubusercontent.com/rhunk/SnapEnhance/main/app/src/main/res/mipmap-xxxhdpi/launcher_icon_foreground.png" height="250" />

[![Build](https://img.shields.io/github/actions/workflow/status/rhunk/SnapEnhance/beta.yml?branch=dev&logo=github&label=Build)](https://github.com/rhunk/SnapEnhance/actions/workflows/android.yml?query=branch%3Amain+event%3Apush+is%3Acompleted) [![Total](https://shields.io/github/downloads/rhunk/SnapEnhance/total?logo=Bookmeter&label=Downloads&logoColor=Green&color=Green)](https://github.com/rhunk/snapenhance/releases) [![Crowdin](https://badges.crowdin.net/snapenhance/localized.svg)](https://crowdin.com/project/snapenhance)
[![Build](https://img.shields.io/github/actions/workflow/status/rhunk/SnapEnhance/beta.yml?branch=dev&logo=github&label=Build)](https://github.com/rhunk/SnapEnhance/actions/workflows/android.yml?query=branch%3Amain+event%3Apush+is%3Acompleted) [![Total](https://shields.io/github/downloads/rhunk/SnapEnhance/total?logo=Bookmeter&label=Downloads&logoColor=Green&color=Green)](https://github.com/rhunk/snapenhance/releases) [![Translation status](https://hosted.weblate.org/widget/snapenhance/app/svg-badge.svg)](https://hosted.weblate.org/engage/snapenhance/)

# SnapEnhance
SnapEnhance is an Xposed mod that enhances your Snapchat experience.<br/><br/>
Expand Down Expand Up @@ -137,6 +137,12 @@ We no longer offer official LSPatch binaries for obvious reasons. However, you'r
- No, this will cause some severe issues, and the mod will not be able to inject.
</details>

<details>
<summary>How can I translate SnapEnhance into my language?</summary>

- We have a [Weblate](https://hosted.weblate.org/projects/snapenhance/app/) hosted repo, feel free to submit your translations there.
</details>

## Privacy
We do not collect any user information or data. However, please be aware that third-party libraries may collect data as described in their respective privacy policies.
<details>
Expand Down Expand Up @@ -171,7 +177,6 @@ Thanks to everyone involved including the [third-party libraries](https://github
- [TheVisual](https://github.com/TheVisual)
- [CanerKaraca23](https://github.com/CanerKaraca23)


## Donate
- LTC: LbBnT9GxgnFhwy891EdDKqGmpn7XtduBdE
- BCH: qpu57a05kqljjadvpgjc6t894apprvth9slvlj4vpj
Expand Down
29 changes: 24 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.gradle.configurationcache.extensions.capitalized
import java.io.ByteArrayOutputStream

plugins {
alias(libs.plugins.androidApplication)
Expand Down Expand Up @@ -153,12 +157,27 @@ dependencies {
afterEvaluate {
properties["debug_flavor"]?.toString()?.let { tasks.findByName("install${it.capitalized()}Debug") }?.doLast {
runCatching {
exec {
commandLine("adb", "shell", "am", "force-stop", properties["debug_package_name"])
val devices = ByteArrayOutputStream().also {
exec {
commandLine("adb", "devices")
standardOutput = it
}
}.toString().lines().drop(1).mapNotNull {
line -> line.split("\t").firstOrNull()?.takeIf { it.isNotEmpty() }
}
Thread.sleep(1000L)
exec {
commandLine("adb", "shell", "am", "start", properties["debug_package_name"])

runBlocking {
devices.forEach { device ->
launch {
exec {
commandLine("adb", "-s", device, "shell", "am", "force-stop", properties["debug_package_name"])
}
delay(500)
exec {
commandLine("adb", "-s", device, "shell", "am", "start", properties["debug_package_name"])
}
}
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

-keep enum * { *; }

-keep class org.jf.dexlib2.** { *; }
-keep class com.android.tools.smali.dexlib2.** { *; }
-keep class org.mozilla.javascript.** { *; }
-keep class androidx.compose.material.icons.** { *; }
-keep class androidx.compose.material3.R$* { *; }
-keep class androidx.navigation.** { *; }
-keep class me.rhunk.snapenhance.** { *; }
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
Expand Down
23 changes: 14 additions & 9 deletions app/src/main/kotlin/me/rhunk/snapenhance/LogManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,26 @@ class LogReader(

fun incrementLineCount() {
randomAccessFile.seek(randomAccessFile.length())
startLineIndexes.add(randomAccessFile.filePointer)
startLineIndexes.add(randomAccessFile.filePointer + 1)
lineCount++
}

private fun queryLineCount(): Int {
randomAccessFile.seek(0)
var lines = 0
var lastIndex: Long
while (true) {
lastIndex = randomAccessFile.filePointer
readLogLine() ?: break
startLineIndexes.add(lastIndex)
lines++
var lineCount = 0
var lastPointer: Long
var line: String?

while (randomAccessFile.also {
lastPointer = it.filePointer
}.readLine().also { line = it } != null) {
if (line?.startsWith('|') == true) {
lineCount++
startLineIndexes.add(lastPointer + 1)
}
}
return lines

return lineCount
}

private fun getLine(index: Int): String? {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/me/rhunk/snapenhance/RemoteSideContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class RemoteSideContext(
}

scriptManager.runtime.eachModule {
callFunction("module.onManagerLoad", androidContext)
callFunction("module.onSnapEnhanceLoad", androidContext)
}
}

Expand Down Expand Up @@ -195,7 +195,7 @@ class RemoteSideContext(
}
}

if (mappings.isMappingsOutdated() || !mappings.isMappingsLoaded()) {
if (mappings.isMappingsOutdated() || !mappings.isMappingsLoaded) {
requirements = requirements or Requirements.MAPPINGS
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,15 @@ class DownloadProcessor (
fallbackToast(it)
}

private fun newFFMpegProcessor(pendingTask: PendingTask) = FFMpegProcessor(
logManager = remoteSideContext.log,
ffmpegOptions = remoteSideContext.config.root.downloader.ffmpegOptions,
onStatistics = {
pendingTask.updateProgress("Processing (frames=${it.videoFrameNumber}, fps=${it.videoFps}, time=${it.time}, bitrate=${it.bitrate}, speed=${it.speed})")
}
)
private fun newFFMpegProcessor(pendingTask: PendingTask) = FFMpegProcessor.newFFMpegProcessor(remoteSideContext, pendingTask)

@SuppressLint("UnspecifiedRegisterReceiverFlag")
private suspend fun saveMediaToGallery(pendingTask: PendingTask, inputFile: File, metadata: DownloadMetadata) {
suspend fun saveMediaToGallery(pendingTask: PendingTask, inputFile: File, metadata: DownloadMetadata) {
if (coroutineContext.job.isCancelled) return

runCatching {
var fileType = FileType.fromFile(inputFile)

if (fileType == FileType.UNKNOWN) {
callbackOnFailure(translation.format("failed_gallery_toast", "error" to "Unknown media type"), null)
pendingTask.fail("Unknown media type")
return
}

if (fileType.isImage) {
remoteSideContext.config.root.downloader.forceImageFormat.getNullable()?.let { format ->
val bitmap = BitmapFactory.decodeFile(inputFile.absolutePath) ?: throw Exception("Failed to decode bitmap")
Expand Down Expand Up @@ -154,9 +142,9 @@ class DownloadProcessor (
pendingTask.success()

runCatching {
val mediaScanIntent = Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE")
mediaScanIntent.setData(outputFile.uri)
remoteSideContext.androidContext.sendBroadcast(mediaScanIntent)
remoteSideContext.androidContext.sendBroadcast(Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE").apply {
data = outputFile.uri
})
}.onFailure {
remoteSideContext.log.error("Failed to scan media file", it)
callbackOnFailure(translation.format("failed_gallery_toast", "error" to it.toString()), it.message)
Expand Down Expand Up @@ -266,7 +254,7 @@ class DownloadProcessor (
val outputFile = File.createTempFile("voice_note", ".$format")
newFFMpegProcessor(pendingTask).execute(FFMpegProcessor.Request(
action = FFMpegProcessor.Action.AUDIO_CONVERSION,
input = media.file,
inputs = listOf(media.file),
output = outputFile
))
media.file.delete()
Expand Down Expand Up @@ -303,7 +291,7 @@ class DownloadProcessor (
runCatching {
newFFMpegProcessor(pendingTask).execute(FFMpegProcessor.Request(
action = FFMpegProcessor.Action.DOWNLOAD_DASH,
input = dashPlaylistFile,
inputs = listOf(dashPlaylistFile),
output = outputFile,
startTime = dashOptions.offsetTime,
duration = dashOptions.duration
Expand Down Expand Up @@ -356,7 +344,8 @@ class DownloadProcessor (
val pendingTask = remoteSideContext.taskManager.createPendingTask(
Task(
type = TaskType.DOWNLOAD,
title = downloadMetadata.downloadSource + " (" + downloadMetadata.mediaAuthor + ")",
title = downloadMetadata.downloadSource,
author = downloadMetadata.mediaAuthor,
hash = downloadMetadata.mediaIdentifier
)
).apply {
Expand Down Expand Up @@ -406,7 +395,6 @@ class DownloadProcessor (

if (shouldMergeOverlay) {
assert(downloadedMedias.size == 2)
//TODO: convert "mp4 images" into real images
val media = downloadedMedias.entries.first { !it.key.isOverlay }.value
val overlayMedia = downloadedMedias.entries.first { it.key.isOverlay }.value

Expand All @@ -418,7 +406,7 @@ class DownloadProcessor (

newFFMpegProcessor(pendingTask).execute(FFMpegProcessor.Request(
action = FFMpegProcessor.Action.MERGE_OVERLAY,
input = renamedMedia,
inputs = listOf(renamedMedia),
output = mergedOverlay,
overlay = renamedOverlayMedia
))
Expand Down
Loading

0 comments on commit 3ffd29b

Please sign in to comment.