Added share buttons to android
This commit is contained in:
parent
e2a62e852c
commit
7f94f65bea
16 changed files with 146 additions and 19 deletions
|
|
@ -96,4 +96,5 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation "androidx.core:core:1.18.0"
|
||||
}
|
||||
|
|
|
|||
2
android-project/app/proguard-rules.pro
vendored
2
android-project/app/proguard-rules.pro
vendored
|
|
@ -22,6 +22,8 @@
|
|||
void updateTextboxAndCursorPos(java.lang.String, int, int);
|
||||
void startNetworkService();
|
||||
void stopNetworkService();
|
||||
void shareText(java.lang.String);
|
||||
void shareInternalFile(java.lang.String, java.lang.String);
|
||||
}
|
||||
|
||||
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLActivity {
|
||||
|
|
|
|||
|
|
@ -89,6 +89,16 @@
|
|||
android:value="When connected to a server/hosting a server, keep the connection alive even when the application is in the background."/>
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name="com.erroratline0.infinipaint.InfiniPaintFileProvider"
|
||||
android:authorities="com.erroratline0.infinipaint.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<activity android:name="com.erroratline0.infinipaint.InfiniPaint"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="adjustNothing"
|
||||
|
|
|
|||
|
|
@ -18,8 +18,11 @@
|
|||
|
||||
package com.erroratline0.infinipaint;
|
||||
|
||||
import static androidx.core.content.FileProvider.getUriForFile;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
|
@ -35,6 +38,8 @@ import org.libsdl.app.SDLActivity;
|
|||
import org.libsdl.app.SDLDummyEdit;
|
||||
import org.libsdl.app.SDLSurface;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class InfiniPaint extends SDLActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -148,4 +153,33 @@ public class InfiniPaint extends SDLActivity {
|
|||
static public void stopNetworkService() {
|
||||
mSingleton.stopService(new Intent(mSingleton, InfiniPaintNetworkService.class));
|
||||
}
|
||||
|
||||
static public void shareInternalFile(String filePath, String mimeType) {
|
||||
File newFile = new File(getContext().getFilesDir(), filePath);
|
||||
Uri contentUri;
|
||||
|
||||
try {
|
||||
contentUri = getUriForFile(getContext(), "com.erroratline0.infinipaint.fileprovider", newFile);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.v("INFO", "[shareInternalFile] Exception " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
|
||||
sendIntent.setType(mimeType);
|
||||
Intent shareIntent = Intent.createChooser(sendIntent, null);
|
||||
getContext().startActivity(shareIntent);
|
||||
}
|
||||
|
||||
static public void shareText(String textToSend) {
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, textToSend);
|
||||
sendIntent.setType("text/plain");
|
||||
Intent shareIntent = Intent.createChooser(sendIntent, null);
|
||||
getContext().startActivity(shareIntent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.erroratline0.infinipaint;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
public class InfiniPaintFileProvider extends FileProvider {
|
||||
public InfiniPaintFileProvider() {
|
||||
super(R.xml.file_paths);
|
||||
}
|
||||
}
|
||||
5
android-project/app/src/main/res/xml/file_paths.xml
Normal file
5
android-project/app/src/main/res/xml/file_paths.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<files-path name="infinipaint_saves" path="saves/" />
|
||||
</paths>
|
||||
|
|
@ -6,7 +6,7 @@ buildscript {
|
|||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.7.3'
|
||||
classpath 'com.android.tools.build:gradle:8.13.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
android.useAndroidX=true
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#Thu Nov 11 18:20:34 PST 2021
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue