Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
6d606ea1
Commit
6d606ea1
authored
Mar 29, 2019
by
Colin Yang
Committed by
Jeffrey Schiller
Mar 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unified file provider source (#1563)
* Unified file provider source
parent
653ecab0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
22 deletions
+7
-22
appinventor/components/src/com/google/appinventor/components/runtime/ActivityStarter.java
...oogle/appinventor/components/runtime/ActivityStarter.java
+2
-5
appinventor/components/src/com/google/appinventor/components/runtime/Camera.java
...src/com/google/appinventor/components/runtime/Camera.java
+2
-3
appinventor/components/src/com/google/appinventor/components/runtime/Sharing.java
...rc/com/google/appinventor/components/runtime/Sharing.java
+2
-7
appinventor/components/src/com/google/appinventor/components/runtime/util/AssetFetcher.java
...gle/appinventor/components/runtime/util/AssetFetcher.java
+1
-4
appinventor/components/src/com/google/appinventor/components/runtime/util/PackageInstaller.java
...appinventor/components/runtime/util/PackageInstaller.java
+0
-3
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/ActivityStarter.java
View file @
6d606ea1
...
...
@@ -16,8 +16,6 @@ import android.content.pm.ResolveInfo;
import
android.net.Uri
;
import
android.support.v4.content.FileProvider
;
import
android.text.TextUtils
;
import
android.util.Log
;
...
...
@@ -38,6 +36,7 @@ import com.google.appinventor.components.runtime.errors.YailRuntimeError;
import
com.google.appinventor.components.runtime.util.AnimationUtil
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
com.google.appinventor.components.runtime.util.NougatUtil
;
import
com.google.appinventor.components.runtime.util.YailList
;
import
java.io.File
;
...
...
@@ -475,9 +474,7 @@ public class ActivityStarter extends AndroidNonvisibleComponent
File
file
=
new
File
(
uri
.
getPath
());
if
(
file
.
isFile
())
{
Log
.
d
(
LOG_TAG
,
"It's a file"
);
String
packageName
=
form
.
$context
().
getPackageName
();
uri
=
FileProvider
.
getUriForFile
(
form
.
$context
(),
packageName
+
".provider"
,
file
);
uri
=
NougatUtil
.
getPackageUri
(
form
,
file
);
intent
=
new
Intent
(
action
);
intent
.
setFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
Log
.
d
(
LOG_TAG
,
"added permissions"
);
// adb log shows this gets printed
...
...
appinventor/components/src/com/google/appinventor/components/runtime/Camera.java
View file @
6d606ea1
...
...
@@ -6,7 +6,6 @@
package
com.google.appinventor.components.runtime
;
import
com.google.appinventor.components.annotations.DesignerProperty
;
import
com.google.appinventor.components.annotations.DesignerComponent
;
import
com.google.appinventor.components.annotations.PropertyCategory
;
import
com.google.appinventor.components.annotations.SimpleEvent
;
...
...
@@ -15,9 +14,9 @@ import com.google.appinventor.components.annotations.SimpleObject;
import
com.google.appinventor.components.annotations.SimpleProperty
;
import
com.google.appinventor.components.annotations.UsesPermissions
;
import
com.google.appinventor.components.common.ComponentCategory
;
import
com.google.appinventor.components.common.PropertyTypeConstants
;
import
com.google.appinventor.components.common.YaVersion
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
com.google.appinventor.components.runtime.util.NougatUtil
;
import
android.app.Activity
;
import
android.content.ContentValues
;
...
...
@@ -213,7 +212,7 @@ public class Camera extends AndroidNonvisibleComponent
*/
private
void
scanFileToAdd
(
File
image
)
{
Intent
mediaScanIntent
=
new
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
);
Uri
contentUri
=
Uri
.
fromFile
(
image
);
Uri
contentUri
=
NougatUtil
.
getPackageUri
(
form
,
image
);
mediaScanIntent
.
setData
(
contentUri
);
container
.
$context
().
getApplicationContext
().
sendBroadcast
(
mediaScanIntent
);
}
...
...
appinventor/components/src/com/google/appinventor/components/runtime/Sharing.java
View file @
6d606ea1
...
...
@@ -10,8 +10,6 @@ import android.content.Intent;
import
android.net.Uri
;
import
android.support.v4.content.FileProvider
;
import
android.webkit.MimeTypeMap
;
import
com.google.appinventor.components.annotations.DesignerComponent
;
...
...
@@ -23,6 +21,7 @@ import com.google.appinventor.components.common.ComponentCategory;
import
com.google.appinventor.components.common.YaVersion
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
com.google.appinventor.components.runtime.util.NougatUtil
;
import
java.io.File
;
...
...
@@ -90,9 +89,6 @@ public class Sharing extends AndroidNonvisibleComponent {
+
"installed on the phone by displaying a list of available apps and allowing the user to "
+
" choose one from the list. The selected app will open with the file and message inserted on it."
)
public
void
ShareFileWithMessage
(
String
file
,
String
message
)
{
String
packageName
=
form
.
$context
().
getPackageName
();
if
(!
file
.
startsWith
(
"file://"
))
file
=
"file://"
+
file
;
...
...
@@ -103,8 +99,7 @@ public class Sharing extends AndroidNonvisibleComponent {
MimeTypeMap
mime
=
MimeTypeMap
.
getSingleton
();
String
type
=
mime
.
getMimeTypeFromExtension
(
fileExtension
);
Uri
shareableUri
=
FileProvider
.
getUriForFile
(
form
.
$context
(),
packageName
+
".provider"
,
imageFile
);
Uri
shareableUri
=
NougatUtil
.
getPackageUri
(
form
,
imageFile
);
Intent
shareIntent
=
new
Intent
(
Intent
.
ACTION_SEND
);
shareIntent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
shareableUri
);
shareIntent
.
setFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
...
...
appinventor/components/src/com/google/appinventor/components/runtime/util/AssetFetcher.java
View file @
6d606ea1
...
...
@@ -10,8 +10,6 @@ import android.net.Uri;
import
android.os.Environment
;
import
android.support.v4.content.FileProvider
;
import
android.util.Log
;
import
com.google.appinventor.components.runtime.Form
;
...
...
@@ -96,8 +94,7 @@ public class AssetFetcher {
try
{
Form
form
=
Form
.
getActiveForm
();
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
String
packageName
=
form
.
$context
().
getPackageName
();
Uri
packageuri
=
FileProvider
.
getUriForFile
(
form
.
$context
(),
packageName
+
".provider"
,
assetFile
);
Uri
packageuri
=
NougatUtil
.
getPackageUri
(
form
,
assetFile
);
intent
.
setDataAndType
(
packageuri
,
"application/vnd.android.package-archive"
);
intent
.
setFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
form
.
startActivity
(
intent
);
...
...
appinventor/components/src/com/google/appinventor/components/runtime/util/PackageInstaller.java
View file @
6d606ea1
...
...
@@ -11,11 +11,8 @@ import android.content.Intent;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.support.v4.content.FileProvider
;
import
android.util.Log
;
import
com.google.appinventor.components.runtime.Form
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment