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
35c00d04
Commit
35c00d04
authored
Aug 01, 2021
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 分享的uri
parent
f723e29c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
12 deletions
+72
-12
mobile/src/main/AndroidManifest.xml
mobile/src/main/AndroidManifest.xml
+3
-6
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+8
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
.../cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
+50
-2
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
...le/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
+2
-1
mobile/src/main/res/xml/provider_paths.xml
mobile/src/main/res/xml/provider_paths.xml
+9
-3
No files found.
mobile/src/main/AndroidManifest.xml
View file @
35c00d04
...
...
@@ -107,6 +107,7 @@
android:name=
"cn.garymb.ygomobile.ui.activities.ShareFileActivity"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:launchMode=
"singleTop"
android:excludeFromRecents=
"true"
android:theme=
"@style/TranslucentTheme"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
>
<intent-filter>
...
...
@@ -208,14 +209,10 @@
android:name=
"cn.garymb.ygomobile.ui.preference.YGOPreferencesProvider"
android:authorities=
"cn.garymb.ygomobile.ui.preference.YGOPreferencesProvider"
android:exported=
"false"
android:grantUriPermissions=
"true"
>
<meta-data
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/provider_paths"
/>
</provider>
android:grantUriPermissions=
"true"
/>
<provider
android:name=
"androidx.core.content.FileProvider"
android:authorities=
"${applicationId}.
fileprovider
"
android:authorities=
"${applicationId}.
gamefiles
"
android:exported=
"false"
android:grantUriPermissions=
"true"
>
<meta-data
...
...
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
35c00d04
...
...
@@ -25,6 +25,7 @@ import cn.garymb.ygomobile.utils.IOUtils;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_DECK_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_EXPANSIONS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_PACK_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_REPLAY_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SYSTEM_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_FONT_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_KEEP_SCALE
;
...
...
@@ -471,6 +472,13 @@ public class AppsSettings {
mSharedPreferences
.
putString
(
Constants
.
PREF_GAME_PATH
,
path
);
}
/**
* @return 录像文件夹
*/
public
String
getReplayDir
()
{
return
new
File
(
getResourcePath
(),
CORE_REPLAY_PATH
).
getAbsolutePath
();
}
//获取卡组文件夹
public
String
getDeckDir
()
{
return
new
File
(
getResourcePath
(),
CORE_DECK_PATH
).
getAbsolutePath
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
View file @
35c00d04
...
...
@@ -2,14 +2,27 @@ package cn.garymb.ygomobile.ui.activities;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.ParcelFileDescriptor
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
androidx.core.content.FileProvider
;
import
java.io.File
;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_REPLAY_PATH
;
public
class
ShareFileActivity
extends
Activity
{
@Override
...
...
@@ -28,8 +41,43 @@ public class ShareFileActivity extends Activity {
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
();
File
file
;
String
title
;
if
(
"yrp"
.
equals
(
type
)){
file
=
new
File
(
AppsSettings
.
get
().
getReplayDir
(),
path
);
title
=
"分享录像"
;
}
else
if
(
"ydk"
.
equals
(
type
)){
file
=
new
File
(
AppsSettings
.
get
().
getDeckDir
(),
path
);
title
=
"分享卡组"
;
}
else
{
finish
();
return
;
}
Uri
uri
=
FileUtils
.
toUri
(
this
,
file
);
// Log.d("kk-test", "file="+file+", canRead="+(file.exists() && file.canRead()));
// Log.d("kk-test", "uri="+uri);
Intent
shareIntent
=
new
Intent
(
Intent
.
ACTION_SEND
);
shareIntent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
uri
);
shareIntent
.
setType
(
"text/plain"
);
try
{
// Log.d("kk-test", "uri="+uri);
// ParcelFileDescriptor pfd = getContentResolver().openFileDescriptor(uri, "r");
// if(pfd != null){
// pfd.close();
// Log.d("kk-test", "open ok");
// }
// List<ResolveInfo> resInfoList = this.getPackageManager()
// .queryIntentActivities(shareIntent, 0);
// for (ResolveInfo resolveInfo : resInfoList) {
// String packageName = resolveInfo.activityInfo.packageName;
// this.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION|Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
// }
startActivity
(
Intent
.
createChooser
(
shareIntent
,
title
));
}
catch
(
Throwable
e
){
Log
.
w
(
"kk-test"
,
"open uri error:"
+
uri
,
e
);
Toast
.
makeText
(
this
,
"没有可以分享的应用"
,
Toast
.
LENGTH_SHORT
).
show
();
}
finish
();
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
View file @
35c00d04
...
...
@@ -4,6 +4,7 @@ import android.content.Context;
import
android.net.Uri
;
import
android.util.Log
;
import
androidx.annotation.NonNull
;
import
androidx.core.content.FileProvider
;
import
java.io.BufferedReader
;
...
...
@@ -22,7 +23,7 @@ import java.util.List;
public
class
FileUtils
{
public
static
Uri
toUri
(
Context
context
,
File
file
){
return
FileProvider
.
getUriForFile
(
context
,
context
.
getPackageName
()+
".
fileprovider
"
,
file
);
return
FileProvider
.
getUriForFile
(
context
,
context
.
getPackageName
()+
".
gamefiles
"
,
file
);
}
public
static
boolean
deleteFile
(
File
file
)
{
...
...
mobile/src/main/res/xml/provider_paths.xml
View file @
35c00d04
<?xml version="1.0" encoding="utf-8"?>
<paths
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<!-- /storage/emulated/0/Download/${applicationId}/.beta/apk-->
<paths>
<external-path
name=
"external_files"
path=
"."
/>
<root-path
name=
"external_files"
path=
"/storage/"
/>
<!-- /storage/emulated/0/Download/com.bugly.upgrade.demo/.beta/apk-->
<external-path
name=
"beta_external_path"
path=
"Download/"
/>
<!--/storage/emulated/0/Android/data/
${applicationId}
/files/apk/-->
<!--/storage/emulated/0/Android/data/
com.bugly.upgrade.demo
/files/apk/-->
<external-path
name=
"beta_external_files_path"
path=
"Android/data/"
/>
</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