Skip to content

Commit

Permalink
Merge pull request #145 from the66F95/android-open-editor
Browse files Browse the repository at this point in the history
Android open editor
  • Loading branch information
renpytom authored Nov 27, 2024
2 parents af70b72 + ab8ef9d commit 31a5435
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,22 @@ public void openUrl(String url) {
openURL(url);
}

public void openEditor(String file) {
File f = new File(file);

Uri uri = null;
if (Build.VERSION.SDK_INT >= 24) {
uri = RenPyFileProvider.getUriForFile(this, getPackageName() + ".fileprovider", f);
} else {
uri = Uri.fromFile(f);
}

Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(uri, "text/plain");
i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}

public void vibrate(double s) {
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.renpy.android;

import androidx.core.content.FileProvider;

public class RenPyFileProvider extends FileProvider {
public RenPyFileProvider() {
super(R.xml.file_paths);
}
}
4 changes: 4 additions & 0 deletions rapt/prototype/renpyandroid/src/main/res/xml/file_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="files" path="/" />
</paths>
10 changes: 10 additions & 0 deletions rapt/templates/app-AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@

</activity>

<provider
android:name="org.renpy.android.RenPyFileProvider"
android:authorities="{{ config.package }}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>

{% if (config.store in ("amazon", "all" )) %}
<receiver android:name="com.amazon.device.iap.ResponseReceiver"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY"
Expand Down

0 comments on commit 31a5435

Please sign in to comment.