Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
Expand All @@ -24,6 +25,7 @@ import androidx.compose.material.icons.outlined.Cancel
import androidx.compose.material.icons.outlined.FileDownload
import androidx.compose.material.icons.outlined.PostAdd
import androidx.compose.material.icons.outlined.Save
import androidx.compose.material.icons.outlined.Share
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.ButtonDefaults
Expand Down Expand Up @@ -63,6 +65,7 @@ import app.revanced.manager.ui.model.StepCategory
import app.revanced.manager.ui.viewmodel.PatcherViewModel
import app.revanced.manager.util.APK_MIMETYPE
import app.revanced.manager.util.EventEffect
import app.revanced.manager.util.shareApk
import app.revanced.manager.util.toast

@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
Expand Down Expand Up @@ -203,7 +206,7 @@ fun PatcherScreen(
BottomAppBar(
actions = {
TooltipIconButton(
onClick = { exportApkLauncher.launch("${viewModel.packageName}_${viewModel.version}_revanced_patched.apk") },
onClick = { exportApkLauncher.launch(viewModel.patchedApkFileName) },
tooltip = stringResource(id = R.string.save_apk),
enabled = patcherSucceeded == true,
) { contentDescription ->
Expand All @@ -219,6 +222,13 @@ fun PatcherScreen(
) { contentDescription ->
Icon(Icons.Outlined.PostAdd, contentDescription)
}
TooltipIconButton(
onClick = { context.shareApk(viewModel.getOutputApkUri()) },
tooltip = stringResource(id = R.string.share_apk),
enabled = patcherSucceeded == true,
) { contentDescription ->
Icon(Icons.Outlined.Share, contentDescription, Modifier.size(21.dp))
}
},
floatingActionButton = {
AnimatedVisibility(visible = canInstall) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ class PatcherViewModel(
private var installerPkgName: String by savedStateHandle.saveableVar { "" }
private var installerSessionId: ParcelUuid? by savedStateHandle.saveableVar()

val patchedApkFileName = "${packageName}${version?.let { "_$it" } ?: ""}_revanced_patched.apk"
private var inputFile: File? by savedStateHandle.saveableVar()
private val outputFile = tempDir.resolve("output.apk")
private val outputFile = tempDir.resolve(patchedApkFileName)
var preparedLogUri by mutableStateOf<Uri?>(null)
private set

Expand Down Expand Up @@ -361,7 +362,9 @@ class PatcherViewModel(
}
}

fun logFileName() = "revanced_patcher_${packageName}_${version}_${System.currentTimeMillis()}.txt"
fun getOutputApkUri(): Uri = FileProvider.getUriForFile(app, "${app.packageName}.fileprovider", outputFile)

fun logFileName() = "revanced_patcher_${packageName}${version?.let { "_$it" } ?: ""}_${System.currentTimeMillis()}.txt"

fun prepareLogExport() = viewModelScope.launch {
val logSnapshot = logs.toList()
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/app/revanced/manager/util/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.content.Context
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.graphics.Bitmap
import android.net.Uri
import android.os.Handler
import android.os.Looper
import android.renderscript.Allocation
Expand Down Expand Up @@ -76,6 +77,17 @@ fun Context.openUrl(url: String) {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
})
}
fun Context.shareApk(apkUri: Uri) {
startActivity(
Intent.createChooser(Intent(Intent.ACTION_SEND).apply {
type = APK_MIMETYPE
putExtra(Intent.EXTRA_STREAM, apkUri)
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
}, null).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
)
}
Comment thread
validcube marked this conversation as resolved.
Resolved

fun Context.toast(string: String, duration: Int = Toast.LENGTH_SHORT) {
Toast.makeText(this, string, duration).show()
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ It’s only compatible with these versions: %2$s</string>
<string name="sign_fail">Failed to sign APK: %s</string>
<string name="save_logs">Save logs</string>
<string name="save_as_file">Save to files</string>
<string name="share_apk">Share APK</string>
<string name="export_patcher_logs">Export patcher logs</string>
<string name="save_logs_success">Logs saved</string>
<string name="downloader_activity_dialog_body">You need to interact with this downloader in order to continue</string>
Expand Down
Loading