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
db226e7a
Commit
db226e7a
authored
Aug 01, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
经由file provider分享
parent
4406eb1c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
53 deletions
+96
-53
Classes/gframe/menu_handler.cpp
Classes/gframe/menu_handler.cpp
+6
-6
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+26
-20
libcore/android/android_tools.h
libcore/android/android_tools.h
+1
-1
mobile/src/main/AndroidManifest.xml
mobile/src/main/AndroidManifest.xml
+12
-13
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
.../cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
+34
-13
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/xml/file_paths.xml
mobile/src/main/res/xml/file_paths.xml
+9
-0
No files found.
Classes/gframe/menu_handler.cpp
View file @
db226e7a
...
@@ -278,16 +278,16 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -278,16 +278,16 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if
(
sel
==
-
1
)
if
(
sel
==
-
1
)
break
;
break
;
mainGame
->
gMutex
.
lock
();
mainGame
->
gMutex
.
lock
();
wchar_t
textBuffer
[
256
];
char
name
[
1024
];
char
name
[
1024
];
char
*
fname
=
name
;
BufferIO
::
EncodeUTF8
(
mainGame
->
lstReplayList
->
getListItem
(
sel
),
name
);
myswprintf
(
textBuffer
,
L"%ls"
,
mainGame
->
lstReplayList
->
getListItem
(
sel
));
BufferIO
::
EncodeUTF8
(
textBuffer
,
fname
);
__android_log_print
(
ANDROID_LOG_DEBUG
,
"ygo"
,
"share replay file=%s"
,
fname
);
android
::
OnShareFile
(
mainGame
->
appMain
,
fname
,
"yrp"
);
mainGame
->
gMutex
.
unlock
();
mainGame
->
gMutex
.
unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
prev_sel
=
sel
;
prev_sel
=
sel
;
#ifdef _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
;
break
;
}
}
case
BUTTON_RENAME_REPLAY
:
{
case
BUTTON_RENAME_REPLAY
:
{
...
...
libcore/android/android_tools.cpp
View file @
db226e7a
...
@@ -23,17 +23,17 @@ InitOptions::InitOptions(void*data) :
...
@@ -23,17 +23,17 @@ InitOptions::InitOptions(void*data) :
char
*
rawdata
=
(
char
*
)
data
;
char
*
rawdata
=
(
char
*
)
data
;
int
tmplength
=
0
;
int
tmplength
=
0
;
m_opengles_version
=
BufferIO
::
ReadInt32
(
rawdata
);
m_opengles_version
=
BufferIO
::
ReadInt32
(
rawdata
);
m_card_quality
=
BufferIO
::
ReadInt32
(
rawdata
);
m_card_quality
=
BufferIO
::
ReadInt32
(
rawdata
);
m_font_aa_enabled
=
BufferIO
::
ReadInt32
(
rawdata
)
>
0
;
m_font_aa_enabled
=
BufferIO
::
ReadInt32
(
rawdata
)
>
0
;
m_ps_enabled
=
BufferIO
::
ReadInt32
(
rawdata
)
>
0
;
m_ps_enabled
=
BufferIO
::
ReadInt32
(
rawdata
)
>
0
;
//cache dir
//cache dir
ReadString
(
m_work_dir
,
rawdata
);
ReadString
(
m_work_dir
,
rawdata
);
//cdbs
//cdbs
cdb_count
=
BufferIO
::
ReadInt32
(
rawdata
);
cdb_count
=
BufferIO
::
ReadInt32
(
rawdata
);
m_db_files
=
new
io
::
path
[
cdb_count
];
m_db_files
=
new
io
::
path
[
cdb_count
];
for
(
int
i
=
0
;
i
<
cdb_count
;
i
++
){
for
(
int
i
=
0
;
i
<
cdb_count
;
i
++
){
io
::
path
tmp_path
;
io
::
path
tmp_path
;
ReadString
(
tmp_path
,
rawdata
);
ReadString
(
tmp_path
,
rawdata
);
...
@@ -64,7 +64,7 @@ irr::io::path getExternalStorageDir(ANDROID_APP app) {
...
@@ -64,7 +64,7 @@ irr::io::path getExternalStorageDir(ANDROID_APP app) {
return
ret
;
return
ret
;
JNIEnv
*
jni
=
nullptr
;
JNIEnv
*
jni
=
nullptr
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
nullptr
);
if
(
!
jni
)
if
(
!
jni
)
return
ret
;
return
ret
;
jclass
classEnvironment
=
jni
->
FindClass
(
"android/os/Environment"
);
jclass
classEnvironment
=
jni
->
FindClass
(
"android/os/Environment"
);
...
@@ -807,22 +807,28 @@ int getLocalAddr(ANDROID_APP app) {
...
@@ -807,22 +807,28 @@ int getLocalAddr(ANDROID_APP app) {
return
addr
;
return
addr
;
}
}
void
OnShareFile
(
ANDROID_APP
app
,
char
*
title
,
char
*
ext
){
void
OnShareFile
(
ANDROID_APP
app
,
const
char
*
title
,
const
char
*
ext
){
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
return
;
JNIEnv
*
jni
=
nullptr
;
JNIEnv
*
jni
=
nullptr
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
nullptr
);
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
nullptr
);
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
if
(
!
jni
)
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
return
;
jmethodID
MethodGetAddr
=
jni
->
GetMethodID
(
ClassNativeActivity
,
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
"shareFile"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
);
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
jstring
s_title
=
jni
->
NewStringUTF
(
title
);
jmethodID
methodId
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"shareFile"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
);
jstring
s_ext
=
jni
->
NewStringUTF
(
ext
);
jstring
s_title
=
jni
->
NewStringUTF
(
title
);
jni
->
CallVoidMethod
(
lNativeActivity
,
MethodGetAddr
,
s_title
,
s_ext
);
jstring
s_ext
=
jni
->
NewStringUTF
(
ext
);
jni
->
ReleaseStringUTFChars
(
s_title
,
title
);
jni
->
CallVoidMethod
(
lNativeActivity
,
methodId
,
s_title
,
s_ext
);
jni
->
ReleaseStringUTFChars
(
s_ext
,
ext
);
if
(
s_title
)
{
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
//不需要用ReleaseStringUTFChars,因为是c变量,函数外面自己释放
app
->
activity
->
vm
->
DetachCurrentThread
();
jni
->
DeleteLocalRef
(
s_title
);
}
if
(
s_ext
)
{
jni
->
DeleteLocalRef
(
s_ext
);
}
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
}
}
void
showAndroidComboBoxCompat
(
ANDROID_APP
app
,
bool
pShow
,
char
**
pContents
,
void
showAndroidComboBoxCompat
(
ANDROID_APP
app
,
bool
pShow
,
char
**
pContents
,
...
...
libcore/android/android_tools.h
View file @
db226e7a
...
@@ -98,7 +98,7 @@ extern float getScreenWidth(ANDROID_APP app);
...
@@ -98,7 +98,7 @@ extern float getScreenWidth(ANDROID_APP app);
extern
float
getScreenHeight
(
ANDROID_APP
app
);
extern
float
getScreenHeight
(
ANDROID_APP
app
);
extern
void
OnShareFile
(
ANDROID_APP
app
,
c
har
*
title
,
char
*
ext
);
extern
void
OnShareFile
(
ANDROID_APP
app
,
c
onst
char
*
title
,
const
char
*
ext
);
// Get SDCard path.
// Get SDCard path.
extern
irr
::
io
::
path
getExternalStorageDir
(
ANDROID_APP
app
);
extern
irr
::
io
::
path
getExternalStorageDir
(
ANDROID_APP
app
);
...
...
mobile/src/main/AndroidManifest.xml
View file @
db226e7a
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
android:supportsRtl=
"false"
android:supportsRtl=
"false"
android:theme=
"@style/AppTheme"
android:theme=
"@style/AppTheme"
android:usesCleartextTraffic=
"true"
android:usesCleartextTraffic=
"true"
android:extractNativeLibs=
"true"
android:requestLegacyExternalStorage=
"true"
android:requestLegacyExternalStorage=
"true"
tools:replace=
"android:allowBackup,android:supportsRtl"
tools:replace=
"android:allowBackup,android:supportsRtl"
tools:targetApi=
"m"
>
tools:targetApi=
"m"
>
<activity
<activity
...
@@ -97,15 +97,6 @@
...
@@ -97,15 +97,6 @@
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\..*\.yrp"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\..*\.yrp"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\..*\..*\.yrp"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\..*\..*\.yrp"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\..*\..*\..*\.yrp"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\..*\..*\..*\.yrp"
/>
<data
android:pathPattern=
".*\.lua"
/>
<data
android:pathPattern=
".*\..*\.lua"
/>
<data
android:pathPattern=
".*\..*\..*\.lua"
/>
<data
android:pathPattern=
".*\..*\..*\..*\.lua"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\.lua"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\.lua"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\..*\.lua"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\..*\..*\.lua"
/>
<data
android:pathPattern=
".*\..*\..*\..*\..*\..*\..*\..*\..*\.lua"
/>
</intent-filter>
</intent-filter>
<intent-filter>
<intent-filter>
...
@@ -116,7 +107,7 @@
...
@@ -116,7 +107,7 @@
android:name=
"cn.garymb.ygomobile.ui.activities.ShareFileActivity"
android:name=
"cn.garymb.ygomobile.ui.activities.ShareFileActivity"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:launchMode=
"singleTop"
android:launchMode=
"singleTop"
android:theme=
"@style/
App
Theme"
android:theme=
"@style/
Translucent
Theme"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
>
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
>
<intent-filter>
<intent-filter>
<action
android:name=
"cn.garymb.ygomobile.game.shared.file"
/>
<action
android:name=
"cn.garymb.ygomobile.game.shared.file"
/>
...
@@ -192,7 +183,7 @@
...
@@ -192,7 +183,7 @@
android:windowSoftInputMode=
"stateHidden|adjustResize"
/>
android:windowSoftInputMode=
"stateHidden|adjustResize"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.mycard.mcchat.SplashActivity"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.mycard.mcchat.SplashActivity"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.activities.FileLogActivity"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.activities.FileLogActivity"
/>
<activity
<activity
android:name=
"cn.garymb.ygomobile.ui.activities.PermissionsActivity"
android:name=
"cn.garymb.ygomobile.ui.activities.PermissionsActivity"
android:theme=
"@style/TranslucentTheme"
/>
android:theme=
"@style/TranslucentTheme"
/>
<activity
<activity
...
@@ -222,7 +213,15 @@
...
@@ -222,7 +213,15 @@
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/provider_paths"
/>
android:resource=
"@xml/provider_paths"
/>
</provider>
</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>
</application>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
View file @
db226e7a
package
cn.garymb.ygomobile.ui.activities
;
package
cn.garymb.ygomobile.ui.activities
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
...
@@ -16,14 +18,15 @@ import cn.garymb.ygomobile.Constants;
...
@@ -16,14 +18,15 @@ import cn.garymb.ygomobile.Constants;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.utils.FileUtils
;
public
class
ShareFileActivity
extends
BaseActivity
{
public
class
ShareFileActivity
extends
Activity
{
@Override
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
//TODO setContentView
//TODO setContentView
setContentView
(
R
.
layout
.
combobox_compat_layout
);
doIntent
(
getIntent
());
doIntent
(
getIntent
());
hideBottomUIMenu
();
}
}
@Override
@Override
...
@@ -31,21 +34,39 @@ public class ShareFileActivity extends BaseActivity{
...
@@ -31,21 +34,39 @@ public class ShareFileActivity extends BaseActivity{
super
.
onNewIntent
(
intent
);
super
.
onNewIntent
(
intent
);
}
}
private
void
doIntent
(
Intent
intent
){
private
void
doIntent
(
Intent
intent
)
{
String
title
=
intent
.
getStringExtra
(
IrrlichtBridge
.
EXTRA_SHARE_
TYP
E
);
String
title
=
intent
.
getStringExtra
(
IrrlichtBridge
.
EXTRA_SHARE_
FIL
E
);
String
ext
=
intent
.
getStringExtra
(
IrrlichtBridge
.
EXTRA_SHARE_
FIL
E
);
String
ext
=
intent
.
getStringExtra
(
IrrlichtBridge
.
EXTRA_SHARE_
TYP
E
);
//TODO
//TODO
Toast
.
makeText
(
this
,
title
+
"."
+
ext
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
"title="
+
title
+
",ext="
+
ext
,
Toast
.
LENGTH_SHORT
).
show
();
String
share
File
=
null
;
String
share
Path
=
""
;
if
(
ext
.
equals
(
"yrp"
))
{
if
(
ext
.
equals
(
"yrp"
))
{
share
File
=
AppsSettings
.
get
().
getResourcePath
()
+
"/"
+
Constants
.
CORE_REPLAY_PATH
+
"/"
+
title
;
share
Path
=
AppsSettings
.
get
().
getResourcePath
()
+
"/"
+
Constants
.
CORE_REPLAY_PATH
+
"/"
+
title
;
}
else
if
(
ext
.
equals
(
"lua"
))
{
}
else
if
(
ext
.
equals
(
"lua"
))
{
share
File
=
AppsSettings
.
get
().
getResourcePath
()+
"/"
+
Constants
.
CORE_SINGLE_PATH
+
"/"
+
title
;
share
Path
=
AppsSettings
.
get
().
getResourcePath
()+
"/"
+
Constants
.
CORE_SINGLE_PATH
+
"/"
+
title
;
}
}
File
shareFile
=
new
File
(
sharePath
);
Intent
shareIntent
=
new
Intent
(
Intent
.
ACTION_SEND
);
Intent
shareIntent
=
new
Intent
(
Intent
.
ACTION_SEND
);
shareIntent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
File
Provider
.
getUriForFile
(
this
,
BuildConfig
.
APPLICATION_ID
+
".fileprovider"
,
new
File
(
shareFile
)
));
shareIntent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
File
Utils
.
toUri
(
this
,
shareFile
));
shareIntent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
shareIntent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
shareIntent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
shareIntent
.
setType
(
"*/*"
);
//此处可发送多种文件
shareIntent
.
setType
(
"*/*"
);
//此处可发送多种文件
startActivity
(
Intent
.
createChooser
(
shareIntent
,
"分享到"
));
startActivity
(
Intent
.
createChooser
(
shareIntent
,
getString
(
R
.
string
.
send
)));
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
);
}
}
}
}
}
\ No newline at end of file
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
View file @
db226e7a
package
cn.garymb.ygomobile.utils
;
package
cn.garymb.ygomobile.utils
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.util.Log
;
import
android.util.Log
;
import
androidx.core.content.FileProvider
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
...
@@ -17,6 +21,10 @@ import java.util.List;
...
@@ -17,6 +21,10 @@ import java.util.List;
public
class
FileUtils
{
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
)
{
public
static
boolean
deleteFile
(
File
file
)
{
if
(
file
.
isFile
())
{
if
(
file
.
isFile
())
{
try
{
try
{
...
...
mobile/src/main/res/xml/file_paths.xml
0 → 100644
View file @
db226e7a
<?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