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
f723e29c
Commit
f723e29c
authored
Aug 01, 2021
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 分享
parent
fc045ade
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
112 additions
and
29 deletions
+112
-29
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+9
-3
Classes/gframe/game.h
Classes/gframe/game.h
+2
-0
Classes/gframe/gframe.cpp
Classes/gframe/gframe.cpp
+1
-0
Classes/gframe/menu_handler.cpp
Classes/gframe/menu_handler.cpp
+18
-0
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+26
-19
libcore/android/android_tools.h
libcore/android/android_tools.h
+1
-1
mobile/assets/data/conf/strings.conf
mobile/assets/data/conf/strings.conf
+1
-0
mobile/src/main/AndroidManifest.xml
mobile/src/main/AndroidManifest.xml
+10
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/LogoActivity.java
.../java/cn/garymb/ygomobile/ui/activities/LogoActivity.java
+3
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
.../cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
+24
-3
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
...le/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
+8
-0
mobile/src/main/res/values/styles.xml
mobile/src/main/res/values/styles.xml
+0
-1
mobile/src/main/res/xml/file_paths.xml
mobile/src/main/res/xml/file_paths.xml
+9
-0
No files found.
Classes/gframe/game.cpp
View file @
f723e29c
...
...
@@ -1002,12 +1002,18 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
ChangeToIGUIImageButton
(
btnReplayCancel
,
imageManager
.
tButton_S
,
imageManager
.
tButton_S_pressed
);
env
->
addStaticText
(
dataManager
.
GetSysString
(
1349
),
rect
<
s32
>
(
320
*
xScale
,
30
*
yScale
,
550
*
xScale
,
50
*
yScale
),
false
,
true
,
wReplay
);
stReplayInfo
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
320
*
xScale
,
60
*
yScale
,
570
*
xScale
,
315
*
yScale
),
false
,
true
,
wReplay
);
env
->
addStaticText
(
dataManager
.
GetSysString
(
1353
),
rect
<
s32
>
(
320
*
xScale
,
240
*
yScale
,
550
*
xScale
,
260
*
yScale
),
false
,
true
,
wReplay
);
ebRepStartTurn
=
CAndroidGUIEditBox
::
addAndroidEditBox
(
L""
,
true
,
env
,
rect
<
s32
>
(
320
*
xScale
,
260
*
yScale
,
430
*
xScale
,
300
*
yScale
),
wReplay
,
-
1
);
env
->
addStaticText
(
dataManager
.
GetSysString
(
1353
),
rect
<
s32
>
(
320
*
xScale
,
180
*
yScale
,
550
*
xScale
,
200
*
yScale
),
false
,
true
,
wReplay
);
ebRepStartTurn
=
CAndroidGUIEditBox
::
addAndroidEditBox
(
L""
,
true
,
env
,
rect
<
s32
>
(
320
*
xScale
,
210
*
yScale
,
430
*
xScale
,
250
*
yScale
),
wReplay
,
-
1
);
ebRepStartTurn
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
btnExportDeck
=
env
->
addButton
(
rect
<
s32
>
(
440
*
xScale
,
260
*
yScale
,
550
*
xScale
,
300
*
yScale
),
wReplay
,
BUTTON_EXPORT_DECK
,
dataManager
.
GetSysString
(
1282
));
ChangeToIGUIImageButton
(
btnExportDeck
,
imageManager
.
tButton_S
,
imageManager
.
tButton_S_pressed
);
//single play window
btnShareReplay
=
env
->
addButton
(
rect
<
s32
>
(
320
*
xScale
,
260
*
yScale
,
430
*
xScale
,
300
*
yScale
),
wReplay
,
BUTTON_SHARE_REPLAY
,
dataManager
.
GetSysString
(
1368
));
ChangeToIGUIImageButton
(
btnShareReplay
,
imageManager
.
tButton_S
,
imageManager
.
tButton_S_pressed
);
//single play window
wSinglePlay
=
env
->
addWindow
(
rect
<
s32
>
(
220
*
xScale
,
100
*
yScale
,
800
*
xScale
,
520
*
yScale
),
false
,
dataManager
.
GetSysString
(
1201
));
wSinglePlay
->
getCloseButton
()
->
setVisible
(
false
);
wSinglePlay
->
setDrawBackground
(
false
);
...
...
Classes/gframe/game.h
View file @
f723e29c
...
...
@@ -385,6 +385,7 @@ public:
irr
::
gui
::
IGUIButton
*
btnReplayCancel
;
//
irr
::
gui
::
IGUIButton
*
btnExportDeck
;
//
irr
::
gui
::
IGUIEditBox
*
ebRepStartTurn
;
irr
::
gui
::
IGUIButton
*
btnShareReplay
;
//single play
irr
::
gui
::
IGUIWindow
*
wSinglePlay
;
irr
::
gui
::
IGUIImage
*
bgSinglePlay
;
...
...
@@ -732,6 +733,7 @@ private:
#define BUTTON_DELETE_REPLAY 133
#define BUTTON_RENAME_REPLAY 134
#define BUTTON_EXPORT_DECK 135
#define BUTTON_SHARE_REPLAY 136
#define BUTTON_REPLAY_START 140
#define BUTTON_REPLAY_PAUSE 141
#define BUTTON_REPLAY_STEP 142
...
...
Classes/gframe/gframe.cpp
View file @
f723e29c
...
...
@@ -119,6 +119,7 @@ int main(int argc, char* argv[]) {
ygo
::
mainGame
->
lstReplayList
->
setSelected
(
index
);
ClickButton
(
ygo
::
mainGame
->
btnLoadReplay
);
}
break
;
//只播放一个
}
else
if
(
!
strcmp
(
arg
,
"-s"
))
{
// Single
exit_on_return
=
!
keep_on_return
;
...
...
Classes/gframe/menu_handler.cpp
View file @
f723e29c
...
...
@@ -273,6 +273,24 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
prev_sel
=
sel
;
break
;
}
case
BUTTON_SHARE_REPLAY
:
{
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
gMutex
.
lock
();
char
name
[
1024
];
BufferIO
::
EncodeUTF8
(
mainGame
->
lstReplayList
->
getListItem
(
sel
),
name
);
mainGame
->
gMutex
.
unlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
#if defined(_IRR_ANDROID_PLATFORM_)
__android_log_print
(
ANDROID_LOG_DEBUG
,
"ygo"
,
"1share replay file=%s"
,
name
);
android
::
OnShareFile
(
mainGame
->
appMain
,
"yrp"
,
name
);
__android_log_print
(
ANDROID_LOG_DEBUG
,
"ygo"
,
"2after share replay file:index=%d"
,
sel
);
#endif
break
;
}
case
BUTTON_RENAME_REPLAY
:
{
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
...
...
libcore/android/android_tools.cpp
View file @
f723e29c
...
...
@@ -796,7 +796,7 @@ int getLocalAddr(ANDROID_APP app) {
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
addr
;
JNIEnv
*
jni
=
nullptr
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
nullptr
);
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
jmethodID
MethodGetAddr
=
jni
->
GetMethodID
(
ClassNativeActivity
,
...
...
@@ -807,24 +807,6 @@ int getLocalAddr(ANDROID_APP app) {
return
addr
;
}
void
OnShareFile
(
ANDROID_APP
app
,
char
*
title
,
char
*
path
){
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
JNIEnv
*
jni
=
nullptr
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
nullptr
);
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
jmethodID
MethodGetAddr
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"shareFile"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
);
jstring
s_title
=
jni
->
NewStringUTF
(
title
);
jstring
s_path
=
jni
->
NewStringUTF
(
path
);
jni
->
CallVoidMethod
(
lNativeActivity
,
MethodGetAddr
,
s_title
,
s_path
);
jni
->
ReleaseStringUTFChars
(
s_title
,
title
);
jni
->
ReleaseStringUTFChars
(
s_path
,
path
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
}
void
showAndroidComboBoxCompat
(
ANDROID_APP
app
,
bool
pShow
,
char
**
pContents
,
int
count
,
int
mode
)
{
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
...
...
@@ -985,6 +967,31 @@ bool android_deck_delete(const char* deck_name) {
return
status
==
0
;
}
void
OnShareFile
(
ANDROID_APP
app
,
const
char
*
title
,
const
char
*
path
){
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
JNIEnv
*
jni
=
nullptr
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
nullptr
);
if
(
!
jni
)
return
;
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
jmethodID
methodId
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"shareFile"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
);
jstring
s_title
=
jni
->
NewStringUTF
(
title
);
jstring
s_path
=
jni
->
NewStringUTF
(
path
);
jni
->
CallVoidMethod
(
lNativeActivity
,
methodId
,
s_title
,
s_path
);
if
(
s_title
)
{
//不需要用ReleaseStringUTFChars,因为是c变量,函数外面自己释放
jni
->
DeleteLocalRef
(
s_title
);
}
if
(
s_path
)
{
jni
->
DeleteLocalRef
(
s_path
);
}
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
}
void
runWindbot
(
ANDROID_APP
app
,
const
char
*
args
)
{
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
...
...
libcore/android/android_tools.h
View file @
f723e29c
...
...
@@ -98,7 +98,7 @@ extern float getScreenWidth(ANDROID_APP app);
extern
float
getScreenHeight
(
ANDROID_APP
app
);
extern
void
OnShareFile
(
ANDROID_APP
app
,
char
*
title
,
char
*
path
);
extern
void
OnShareFile
(
ANDROID_APP
app
,
const
char
*
title
,
const
char
*
path
);
// Get SDCard path.
extern
irr
::
io
::
path
getExternalStorageDir
(
ANDROID_APP
app
);
...
...
mobile/assets/data/conf/strings.conf
View file @
f723e29c
...
...
@@ -410,6 +410,7 @@
!
system
1365
重命名失败,可能存在同名文件
!
system
1366
自动保存录像
!
system
1367
录像已自动保存为%
ls
.
yrp
!
system
1368
分享录像
!
system
1370
星数↑
!
system
1371
攻击↑
!
system
1372
守备↑
...
...
mobile/src/main/AndroidManifest.xml
View file @
f723e29c
...
...
@@ -107,7 +107,7 @@
android:name=
"cn.garymb.ygomobile.ui.activities.ShareFileActivity"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:launchMode=
"singleTop"
android:theme=
"@style/
App
Theme"
android:theme=
"@style/
Translucent
Theme"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
>
<intent-filter>
<action
android:name=
"cn.garymb.ygomobile.game.shared.file"
/>
...
...
@@ -213,7 +213,15 @@
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/provider_paths"
/>
</provider>
<provider
android:name=
"androidx.core.content.FileProvider"
android:authorities=
"${applicationId}.fileprovider"
android:exported=
"false"
android:grantUriPermissions=
"true"
>
<meta-data
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/file_paths"
/>
</provider>
</application>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/LogoActivity.java
View file @
f723e29c
...
...
@@ -27,6 +27,9 @@ public class LogoActivity extends Activity {
finish
();
return
;
}
else
{
// File file = new File(AppsSettings.get().getDeckDir(), "1.ydk");
// Uri uri = FileUtils.toUri(this, file);
// Log.w("kk-test", file.getAbsolutePath() + "->" + uri);
handler
=
new
Handler
();
runnable
=
new
Runnable
()
{
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
View file @
f723e29c
package
cn.garymb.ygomobile.ui.activities
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
public
class
ShareFileActivity
extends
BaseActivity
{
public
class
ShareFileActivity
extends
Activity
{
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
//TODO setContentView
doIntent
(
getIntent
());
hideBottomUIMenu
();
}
@Override
...
...
@@ -21,9 +25,26 @@ public class ShareFileActivity extends BaseActivity{
super
.
onNewIntent
(
intent
);
}
private
void
doIntent
(
Intent
intent
){
private
void
doIntent
(
Intent
intent
)
{
String
type
=
intent
.
getStringExtra
(
IrrlichtBridge
.
EXTRA_SHARE_TYPE
);
String
path
=
intent
.
getStringExtra
(
IrrlichtBridge
.
EXTRA_SHARE_FILE
);
//TODO
Toast
.
makeText
(
this
,
"type="
+
type
+
",path="
+
path
,
Toast
.
LENGTH_SHORT
).
show
();
finish
();
}
protected
void
hideBottomUIMenu
()
{
//隐藏虚拟按键,并且全屏
if
(
Build
.
VERSION
.
SDK_INT
>
11
&&
Build
.
VERSION
.
SDK_INT
<
19
)
{
// lower api
View
v
=
this
.
getWindow
().
getDecorView
();
v
.
setSystemUiVisibility
(
View
.
GONE
);
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
19
)
{
//for new api versions.
View
decorView
=
getWindow
().
getDecorView
();
int
uiOptions
=
View
.
SYSTEM_UI_FLAG_FULLSCREEN
;
// View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView
.
setSystemUiVisibility
(
uiOptions
);
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
View file @
f723e29c
package
cn.garymb.ygomobile.utils
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.util.Log
;
import
androidx.core.content.FileProvider
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
...
...
@@ -17,6 +21,10 @@ import java.util.List;
public
class
FileUtils
{
public
static
Uri
toUri
(
Context
context
,
File
file
){
return
FileProvider
.
getUriForFile
(
context
,
context
.
getPackageName
()+
".fileprovider"
,
file
);
}
public
static
boolean
deleteFile
(
File
file
)
{
if
(
file
.
isFile
())
{
try
{
...
...
mobile/src/main/res/values/styles.xml
View file @
f723e29c
...
...
@@ -32,7 +32,6 @@
<item
name=
"android:windowIsTranslucent"
>
true
</item>
</style>
<style
name=
"AppTheme.Translucent"
parent=
"AppTheme"
>
<item
name=
"android:windowIsTranslucent"
>
true
</item>
</style>
...
...
mobile/src/main/res/xml/file_paths.xml
0 → 100644
View file @
f723e29c
<?xml version="1.0" encoding="utf-8"?>
<paths
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<root-path
name=
"root"
path=
"."
/>
<files-path
name=
"files"
path=
"."
/>
<cache-path
name=
"cache"
path=
"."
/>
<external-path
name=
"external"
path=
"."
/>
<!--/storage/emulated/0/Android/data/${applicationId}/files/ygocore-->
<external-files-path
name=
"game_path"
path=
"ygocore"
/>
</paths>
\ 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