Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit ec52b3b

Browse files
committed
[[ Bug 20552 ]] Use content:// urls to transfer file data to/from other apps
This commit replaces the AttachmentProvider class with a generalised FileProvider class, and simplifies the interface to the content provider from other parts of the livecode engine
1 parent 980dc97 commit ec52b3b

File tree

9 files changed

+352
-425
lines changed

9 files changed

+352
-425
lines changed

engine/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
</activity>
4242
<provider
4343
android:name="com.runrev.android.AppProvider"
44-
android:authorities="com.runrev.android.attachmentprovider"
45-
android:exported="true"
44+
android:authorities="com.runrev.android.fileprovider"
45+
android:exported="false"
4646
android:grantUriPermissions="true">
4747
</provider>
4848

engine/engine-sources.gypi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@
900900
[
901901
'src/java/com/runrev/android/AccelerationChangeListener.java',
902902
'src/java/com/runrev/android/Alert.java',
903-
'src/java/com/runrev/android/AttachmentProvider.java',
903+
'src/java/com/runrev/android/AppProvider.java',
904904
'src/java/com/runrev/android/BitmapView.java',
905905
'src/java/com/runrev/android/BusyIndicator.java',
906906
'src/java/com/runrev/android/CalendarEvents.java',
@@ -911,6 +911,7 @@
911911
'src/java/com/runrev/android/Engine.java',
912912
'src/java/com/runrev/android/EngineApi.java',
913913
'src/java/com/runrev/android/EngineReceiver.java',
914+
'src/java/com/runrev/android/FileProvider.java',
914915
'src/java/com/runrev/android/LCBInvocationHandler.java',
915916
'src/java/com/runrev/android/LiveCodeActivity.java',
916917
'src/java/com/runrev/android/LiveCodeService.java',

engine/src/java/AppProvider.java

Lines changed: 5 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2003-2015 LiveCode Ltd.
1+
/* Copyright (C) 2018 LiveCode Ltd.
22
33
This file is part of LiveCode.
44
@@ -14,67 +14,10 @@
1414
You should have received a copy of the GNU General Public License
1515
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1616

17-
package com.runrev.android;
18-
import android.content.*;
19-
import android.net.Uri;
20-
import android.app.*;
21-
import android.database.*;
22-
import java.io.*;
23-
import android.util.Log;
24-
import android.os.ParcelFileDescriptor;
25-
import com.runrev.android.AttachmentProvider;
17+
package com.runrev.revandroid;
2618

27-
public class AppProvider extends ContentProvider
19+
import com.runrev.android.AppProvider;
20+
21+
public class AppProvider extends com.runrev.android.AppProvider
2822
{
29-
public static final String URI = "content://com.runv.android.attachmentprovider";
30-
public static final String AUTHORITY = "com.runv.android.attachmentprovider";
31-
32-
private com.runrev.android.AttachmentProvider m_attachments;
33-
34-
@Override
35-
public boolean onCreate()
36-
{
37-
m_attachments = new AttachmentProvider(getContext());
38-
return true;
39-
}
40-
41-
@Override
42-
public ParcelFileDescriptor openFile(Uri uri, String mode)
43-
throws FileNotFoundException
44-
{
45-
Log.i("revandroid", uri.toString());
46-
return m_attachments.doOpenFile(uri);
47-
}
48-
49-
@Override
50-
public Cursor query (Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
51-
{
52-
Log.i("revandroid", "query: " + uri.toString());
53-
return m_attachments.doQuery(uri, projection, selection, selectionArgs, sortOrder);
54-
}
55-
56-
@Override
57-
public Uri insert (Uri uri, ContentValues p_values)
58-
{
59-
return m_attachments.doInsert(uri, p_values);
60-
}
61-
62-
@Override
63-
public int update (Uri uri, ContentValues values, String selection, String[] selectionArgs)
64-
{
65-
return 0;
66-
}
67-
68-
@Override
69-
public int delete (Uri uri, String selection, String[] selectionArgs)
70-
{
71-
return m_attachments.doDelete(uri, selection, selectionArgs);
72-
}
73-
74-
@Override
75-
public String getType (Uri uri)
76-
{
77-
return m_attachments.doGetType(uri);
78-
}
79-
8023
}

engine/src/java/com/runrev/android/AppProvider.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,16 @@
2222
import java.io.*;
2323
import android.util.Log;
2424
import android.os.ParcelFileDescriptor;
25-
import com.runrev.android.AttachmentProvider;
25+
import com.runrev.android.*;
2626

2727
public class AppProvider extends ContentProvider
2828
{
29-
public static final String URI = "content://com.runv.android.attachmentprovider";
30-
public static final String AUTHORITY = "com.runv.android.attachmentprovider";
31-
32-
private com.runrev.android.AttachmentProvider m_attachments;
29+
private com.runrev.android.FileProvider m_files;
3330

3431
@Override
3532
public boolean onCreate()
3633
{
37-
m_attachments = new AttachmentProvider(getContext());
34+
m_files = FileProvider.getProvider(getContext());
3835
return true;
3936
}
4037

@@ -43,38 +40,38 @@ public ParcelFileDescriptor openFile(Uri uri, String mode)
4340
throws FileNotFoundException
4441
{
4542
Log.i("revandroid", uri.toString());
46-
return m_attachments.doOpenFile(uri);
43+
return m_files.doOpenFile(uri);
4744
}
4845

4946
@Override
5047
public Cursor query (Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
5148
{
5249
Log.i("revandroid", "query: " + uri.toString());
53-
return m_attachments.doQuery(uri, projection, selection, selectionArgs, sortOrder);
50+
return m_files.doQuery(uri, projection, selection, selectionArgs, sortOrder);
5451
}
5552

5653
@Override
5754
public Uri insert (Uri uri, ContentValues p_values)
5855
{
59-
return m_attachments.doInsert(uri, p_values);
56+
return m_files.doInsert(uri, p_values);
6057
}
6158

6259
@Override
6360
public int update (Uri uri, ContentValues values, String selection, String[] selectionArgs)
6461
{
65-
return 0;
62+
return m_files.doUpdate(uri, values, selection, selectionArgs);
6663
}
6764

6865
@Override
6966
public int delete (Uri uri, String selection, String[] selectionArgs)
7067
{
71-
return m_attachments.doDelete(uri, selection, selectionArgs);
68+
return m_files.doDelete(uri, selection, selectionArgs);
7269
}
7370

7471
@Override
7572
public String getType (Uri uri)
7673
{
77-
return m_attachments.doGetType(uri);
74+
return m_files.doGetType(uri);
7875
}
7976

8077
}

0 commit comments

Comments
 (0)