mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-27 17:05:28 +03:00
Use DocumentsProvider
for log sharing
We used a `FileProvider` for log sharing prior, this is no longer necessary since it comes under the `DocumentsProvider` now which can be utilized to share the log document directly.
This commit is contained in:
parent
8efa9298f9
commit
37453ed7fa
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -16,6 +16,7 @@
|
||||
<entry key="app/src/main/res/layout/on_screen_edit_mini_fab.xml" value="0.22335526315789472" />
|
||||
<entry key="app/src/main/res/layout/settings_activity.xml" value="0.22302631578947368" />
|
||||
<entry key="app/src/main/res/menu/toolbar_log.xml" value="0.11019736842105263" />
|
||||
<entry key="app/src/main/res/xml/preferences.xml" value="1.0" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -105,16 +105,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="emu.skyline.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/filepaths" />
|
||||
</provider>
|
||||
|
||||
<provider
|
||||
android:name="emu.skyline.provider.DocumentsProvider"
|
||||
android:authorities="emu.skyline.provider"
|
||||
|
@ -10,17 +10,18 @@ import android.graphics.Color
|
||||
import android.graphics.Rect
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.DocumentsContract
|
||||
import android.view.View
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.content.res.use
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -34,6 +35,7 @@ import emu.skyline.databinding.MainActivityBinding
|
||||
import emu.skyline.loader.AppEntry
|
||||
import emu.skyline.loader.LoaderResult
|
||||
import emu.skyline.loader.RomFormat
|
||||
import emu.skyline.provider.DocumentsProvider
|
||||
import emu.skyline.utils.Settings
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.ceil
|
||||
@ -129,13 +131,12 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
binding.searchBar.apply {
|
||||
binding.logIcon.setOnClickListener {
|
||||
val file = applicationContext.getPublicFilesDir().resolve("logs/emulation.sklog")
|
||||
val file = DocumentFile.fromSingleUri(this@MainActivity, DocumentsContract.buildDocumentUri(DocumentsProvider.AUTHORITY, "${DocumentsProvider.ROOT_ID}/logs/emulation.sklog"))!!
|
||||
if (file.exists() && file.length() != 0L) {
|
||||
val uri = FileProvider.getUriForFile(this@MainActivity, "skyline.emu.fileprovider", file)
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
.setDataAndType(uri, "text/plain")
|
||||
.setDataAndType(file.uri, "text/plain")
|
||||
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
.putExtra(Intent.EXTRA_STREAM, uri)
|
||||
.putExtra(Intent.EXTRA_STREAM, file.uri)
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.log_share_prompt)))
|
||||
} else {
|
||||
Snackbar.make(this@MainActivity.findViewById(android.R.id.content), getString(R.string.logs_not_found), Snackbar.LENGTH_SHORT).show()
|
||||
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths>
|
||||
<files-path path="/" name="Skyline Internal" />
|
||||
<external-files-path path="/" name="Skyline External" />
|
||||
</paths>
|
Loading…
Reference in New Issue
Block a user