Comments (8)
@CyberShadow So, I did search about what would be the best way to programmatically add and remove intent filters...
The most interesting option I found was to use activity aliases and use the enabling/disabling of components based on a setting.
Unfortunately I'm currently running on issue trying to get this working, but I believe I made some progress.
from share2storage.
This does it:
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 48e55b4..323fb7c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -25,6 +25,7 @@
<intent-filter>
<action android:name="android.intent.action.SEND" />
+ <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/DetailsActivity.kt b/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/DetailsActivity.kt
index 4e4daf6..ebb8a94 100644
--- a/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/DetailsActivity.kt
+++ b/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/DetailsActivity.kt
@@ -81,13 +81,16 @@ class DetailsActivity : ComponentActivity() {
}
private fun handleIntent() {
- if (intent.action == Intent.ACTION_SEND) {
- val fileUri: Uri? =
+ if (intent.action == Intent.ACTION_SEND || intent.action == Intent.ACTION_VIEW) {
+ var fileUri: Uri? =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) intent.getParcelableExtra(
Intent.EXTRA_STREAM,
Uri::class.java
)
else @Suppress("DEPRECATION") intent.getParcelableExtra(Intent.EXTRA_STREAM)
+ if (fileUri == null) {
+ fileUri = intent.data;
+ }
Log.d("fileUri", fileUri.toString())
uriData = getUriData(contentResolver, fileUri)
Probably should be optional, which means that the intent-filter
needs to be set programmatically, so maybe a bit more code than that.
Or maybe there's no reason why it should be optional.
from share2storage.
@CyberShadow Hey, thanks for the feature request!
Well, since it's just a bit outside of the main use case but adjacent to it, I believe I could do it but it would have to be gated behind a preference.
So, yeah, I will have to figure out how to dynamically add (or at least enable) new intent filters.
Thanks for the code excerpt, I will take a look into this in the near future.
from share2storage.
Thanks for considering it.
For the record, the use case is that for some reason, my bank app does not allow saving/sharing/exporting receipts - only viewing them.
The above patch allowed me to actually save the receipt and attach it to a customs declaration.
from share2storage.
@CyberShadow I managed to implement this and it will make it into the next version!
The next version is planned for either the end of this month or start of next month, in the mean time you can compile the current dev branch yourself.
from share2storage.
Excellent!
Does it need testing?
I'm surprised that your diff almost doesn't touch DetailsActivity
like mine did.
from share2storage.
I'm surprised that your diff almost doesn't touch
DetailsActivity
like mine did.
Actually, I got so distracted focusing on the manifest (the activity alias) and on the setting that I might have forgot completely to edit the DetailsActivity code that actually grabs the intent.
I will fix that in a bit.
from share2storage.
Actually, I got so distracted focusing on the manifest (the activity alias) and on the setting that I might have forgot completely to edit the DetailsActivity code that actually grabs the intent.
Should be fixed now.
Does it need testing?
Sure, feel free to test it!
from share2storage.
Related Issues (13)
- Add to F-Droid HOT 1
- [Feature] Preview image HOT 2
- Monochrome icon HOT 1
- F-Droid can't build HOT 22
- Improve takePersistableUriPermission usage
- [BUG] Doesn't seem to work with Android 14 HOT 2
- App crach HOT 4
- Add support for multiple files HOT 1
- Allow for file rename HOT 2
- Allow to save in a default/last folder HOT 4
- Share Nearby enhancement HOT 1
- [Feature] Change file name HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from share2storage.