Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -24,6 +24,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 +64,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 @@ -219,6 +221,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)
}
},
floatingActionButton = {
AnimatedVisibility(visible = canInstall) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ class PatcherViewModel(
}
}

fun getOutputApkUri(): Uri = FileProvider.getUriForFile(app, "${app.packageName}.fileprovider", outputFile)

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

fun prepareLogExport() = viewModelScope.launch {
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