mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
fix share text/data to Forge app
- add additional launcher activity to prevent GLES Context loss (when sharing data via intent) - fix passing data from another app to Forge via share text / share file / share deck
This commit is contained in:
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout"
|
android:isGame="true"
|
||||||
|
android:appCategory="game"
|
||||||
|
android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
@@ -24,8 +26,14 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".Main"
|
android:name=".Main"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout"
|
android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
|
android:theme="@android:style/Theme.Black.NoTitleBar"
|
||||||
|
android:exported="false">
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".Launcher"
|
||||||
|
android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
|
||||||
android:theme="@android:style/Theme.Black.NoTitleBar">
|
android:theme="@android:style/Theme.Black.NoTitleBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@@ -37,7 +45,6 @@
|
|||||||
<data android:mimeType="text/plain" />
|
<data android:mimeType="text/plain" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".Exiter" android:theme="@android:style/Theme.NoDisplay"/>
|
|
||||||
<meta-data android:name="io.sentry.dsn" android:value="https://a0b8dbad9b8a49cfa51bf65d462e8dae:b3f27d7461224cb8836eb5c6050c666c@sentry.cardforge.org/2?buffer.enabled=false" />
|
<meta-data android:name="io.sentry.dsn" android:value="https://a0b8dbad9b8a49cfa51bf65d462e8dae:b3f27d7461224cb8836eb5c6050c666c@sentry.cardforge.org/2?buffer.enabled=false" />
|
||||||
|
|
||||||
<!-- manually added -->
|
<!-- manually added -->
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package forge.app;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
public class Exiter extends Activity {
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
91
forge-gui-android/src/forge/app/Launcher.java
Normal file
91
forge-gui-android/src/forge/app/Launcher.java
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
package forge.app;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import forge.gui.GuiBase;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
public class Launcher extends Activity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
Intent main = new Intent(Launcher.this, Main.class);
|
||||||
|
main.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
startActivity(main);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
String action = intent.getAction();
|
||||||
|
String type = intent.getType();
|
||||||
|
|
||||||
|
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||||
|
final Handler handler = new Handler();
|
||||||
|
handler.postDelayed(() -> {
|
||||||
|
if ("text/plain".equals(type)) {
|
||||||
|
Uri textUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||||
|
if (textUri != null) {
|
||||||
|
try {
|
||||||
|
InputStream in = getContentResolver().openInputStream(textUri);
|
||||||
|
BufferedReader r = new BufferedReader(new InputStreamReader(in));
|
||||||
|
StringBuilder total = new StringBuilder();
|
||||||
|
for (String line; (line = r.readLine()) != null; ) {
|
||||||
|
total.append(line).append('\n');
|
||||||
|
}
|
||||||
|
GuiBase.getInterface().copyToClipboard(total.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
GuiBase.getInterface().copyToClipboard(intent.getStringExtra(Intent.EXTRA_TEXT));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onNewIntent(Intent intent) {
|
||||||
|
super.onNewIntent(intent);
|
||||||
|
setIntent(intent);
|
||||||
|
String action = intent.getAction();
|
||||||
|
String type = intent.getType();
|
||||||
|
|
||||||
|
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||||
|
final Handler handler = new Handler();
|
||||||
|
handler.postDelayed(() -> {
|
||||||
|
if ("text/plain".equals(type)) {
|
||||||
|
Uri textUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||||
|
if (textUri != null) {
|
||||||
|
try {
|
||||||
|
InputStream in = getContentResolver().openInputStream(textUri);
|
||||||
|
BufferedReader r = new BufferedReader(new InputStreamReader(in));
|
||||||
|
StringBuilder total = new StringBuilder();
|
||||||
|
for (String line; (line = r.readLine()) != null; ) {
|
||||||
|
total.append(line).append('\n');
|
||||||
|
}
|
||||||
|
GuiBase.getInterface().copyToClipboard(total.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
GuiBase.getInterface().copyToClipboard(intent.getStringExtra(Intent.EXTRA_TEXT));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,33 +71,12 @@ public class Main extends AndroidApplication {
|
|||||||
androidClipboard = new AndroidClipboard();
|
androidClipboard = new AndroidClipboard();
|
||||||
return androidClipboard;
|
return androidClipboard;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
protected void onNewIntent(Intent intent) {
|
|
||||||
super.onNewIntent(intent);
|
|
||||||
String action = intent.getAction();
|
|
||||||
String type = intent.getType();
|
|
||||||
|
|
||||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
|
||||||
if ("text/plain".equals(type)) {
|
|
||||||
getAndroidClipboard().setContents(intent.getStringExtra(Intent.EXTRA_TEXT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
gamepads = getGameControllers();
|
gamepads = getGameControllers();
|
||||||
|
|
||||||
Intent intent = getIntent();
|
|
||||||
String action = intent.getAction();
|
|
||||||
String type = intent.getType();
|
|
||||||
|
|
||||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
|
||||||
if ("text/plain".equals(type)) {
|
|
||||||
getAndroidClipboard().setContents(intent.getStringExtra(Intent.EXTRA_TEXT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasLaunched)
|
if (hasLaunched)
|
||||||
return;
|
return;
|
||||||
hasLaunched = true;
|
hasLaunched = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user