Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
2a9fb92c
Commit
2a9fb92c
authored
Jul 31, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shareActivity
parent
fe56a18c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
21 deletions
+81
-21
Classes/gframe/menu_handler.cpp
Classes/gframe/menu_handler.cpp
+1
-2
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+13
-19
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+8
-0
mobile/src/main/AndroidManifest.xml
mobile/src/main/AndroidManifest.xml
+11
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
.../cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
+48
-0
No files found.
Classes/gframe/menu_handler.cpp
View file @
2a9fb92c
...
...
@@ -283,9 +283,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
char
*
fname
=
name
;
myswprintf
(
textBuffer
,
L"%ls"
,
mainGame
->
lstReplayList
->
getListItem
(
sel
));
BufferIO
::
EncodeUTF8
(
textBuffer
,
fname
);
__android_log_print
(
ANDROID_LOG_DEBUG
,
"ygo"
,
"
1
share replay file=%s"
,
fname
);
__android_log_print
(
ANDROID_LOG_DEBUG
,
"ygo"
,
"share replay file=%s"
,
fname
);
android
::
OnShareFile
(
mainGame
->
appMain
,
fname
,
"yrp"
);
__android_log_print
(
ANDROID_LOG_DEBUG
,
"ygo"
,
"2after share replay file:index=%s"
,
fname
);
mainGame
->
gMutex
.
unlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
2a9fb92c
...
...
@@ -6,14 +6,12 @@
*/
package
cn.garymb.ygomobile
;
import
android.app.AlertDialog
;
import
android.app.NativeActivity
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.pm.ActivityInfo
;
import
android.content.res.Resources
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
...
...
@@ -31,7 +29,6 @@ import android.widget.PopupWindow;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
java.io.File
;
import
java.nio.ByteBuffer
;
import
java.util.Arrays
;
...
...
@@ -46,6 +43,7 @@ import cn.garymb.ygomobile.widget.EditWindowCompat;
import
cn.garymb.ygomobile.widget.overlay.OverlayOvalView
;
import
cn.garymb.ygomobile.widget.overlay.OverlayView
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_SHARE_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_START
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_STOP
;
...
...
@@ -531,25 +529,21 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
public
void
shareFile
(
final
String
title
,
final
String
ext
)
{
Log
.
i
(
"看看"
,
title
+
"."
+
ext
);
//TODO 分享文件
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
YGOMobileActivity
.
this
);
builder
.
setTitle
(
title
);
builder
.
setMessage
(
ext
);
builder
.
setNeutralButton
(
android
.
R
.
string
.
ok
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Intent
shareIntent
=
new
Intent
(
Intent
.
ACTION_SEND
);
shareIntent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
Uri
.
fromFile
(
new
File
(
ext
)));
shareIntent
.
setType
(
"*/*"
);
//此处可发送多种文件
startActivity
(
Intent
.
createChooser
(
shareIntent
,
"分享到"
));
dialog
.
dismiss
();
Intent
intent
=
new
Intent
(
ACTION_SHARE_FILE
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_TYPE
,
title
);
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_FILE
,
ext
);
intent
.
setPackage
(
getPackageName
());
try
{
startActivity
(
intent
);
}
catch
(
Throwable
e
)
{
//ignore
Toast
.
makeText
(
YGOMobileActivity
.
this
,
"dev error:not found activity."
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
builder
.
show
();
}
});
}
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
2a9fb92c
...
...
@@ -26,6 +26,14 @@ import static cn.garymb.ygomobile.utils.ByteUtils.byte2uint;
public
final
class
IrrlichtBridge
{
public
static
final
String
ACTION_START
=
"cn.garymb.ygomobile.game.start"
;
public
static
final
String
ACTION_STOP
=
"cn.garymb.ygomobile.game.stop"
;
/**
* @see #EXTRA_SHARE_FILE
* @see #EXTRA_SHARE_TYPE
*/
public
static
final
String
ACTION_SHARE_FILE
=
"cn.garymb.ygomobile.game.shared.file"
;
public
static
final
String
EXTRA_SHARE_FILE
=
Intent
.
EXTRA_STREAM
;
public
static
final
String
EXTRA_SHARE_TYPE
=
Intent
.
EXTRA_TITLE
;
//
public
static
final
String
EXTRA_PID
=
"extras.mypid"
;
public
static
final
String
EXTRA_ARGV
=
"extras.argv"
;
public
static
final
String
EXTRA_ARGV_TIME_OUT
=
"extras.argv_timeout"
;
...
...
mobile/src/main/AndroidManifest.xml
View file @
2a9fb92c
...
...
@@ -112,6 +112,17 @@
<action
android:name=
"android.intent.action.MAIN"
/>
</intent-filter>
</activity>
<activity
android:name=
"cn.garymb.ygomobile.ui.activities.ShareFileActivity"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:launchMode=
"singleTop"
android:theme=
"@style/AppTheme"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
>
<intent-filter>
<action
android:name=
"cn.garymb.ygomobile.game.shared.file"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
<activity
android:name=
"cn.garymb.ygomobile.YGOMobileActivity"
android:theme=
"@style/AppTheme.Game"
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
0 → 100644
View file @
2a9fb92c
package
cn.garymb.ygomobile.ui.activities
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
java.io.File
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.R
;
public
class
ShareFileActivity
extends
BaseActivity
{
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
//TODO setContentView
setContentView
(
R
.
layout
.
combobox_compat_layout
);
doIntent
(
getIntent
());
}
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
super
.
onNewIntent
(
intent
);
}
private
void
doIntent
(
Intent
intent
){
String
title
=
intent
.
getStringExtra
(
IrrlichtBridge
.
EXTRA_SHARE_TYPE
);
String
ext
=
intent
.
getStringExtra
(
IrrlichtBridge
.
EXTRA_SHARE_FILE
);
//TODO
Toast
.
makeText
(
this
,
title
+
"."
+
ext
,
Toast
.
LENGTH_LONG
).
show
();
File
shareFile
=
null
;
if
(
ext
.
equals
(
"yrp"
))
{
shareFile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
()
+
"/"
+
Constants
.
CORE_REPLAY_PATH
+
"/"
+
title
);
}
else
if
(
ext
.
equals
(
"lua"
))
{
shareFile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
()+
"/"
+
Constants
.
CORE_SINGLE_PATH
+
"/"
+
title
);
}
Intent
shareIntent
=
new
Intent
(
Intent
.
ACTION_SEND
);
shareIntent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
Uri
.
fromFile
(
shareFile
));
shareIntent
.
setType
(
"*/*"
);
//此处可发送多种文件
startActivity
(
Intent
.
createChooser
(
shareIntent
,
"分享到"
));
}
}
\ No newline at end of file
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