Commit 05e4651a authored by fallenstardust's avatar fallenstardust

fix 分享的uri

arrange code
parent db226e7a
......@@ -195,10 +195,10 @@ const wchar_t* DataManager::GetText(int code) {
return unknown_string;
}
const wchar_t* DataManager::GetDesc(int strCode) {
if(strCode < 10000)
if((unsigned int)strCode < 10000u)
return GetSysString(strCode);
int code = strCode >> 4;
int offset = strCode & 0xf;
unsigned int code = strCode >> 4;
unsigned int offset = strCode & 0xf;
auto csit = _strings.find(code);
if(csit == _strings.end())
return unknown_string;
......
......@@ -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
......
......@@ -3,7 +3,6 @@ package cn.garymb.ygomobile;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Point;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager;
......@@ -25,6 +24,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;
......@@ -48,11 +48,11 @@ import static cn.garymb.ygomobile.Constants.YDK_FILE_EX;
public class AppsSettings {
private static final String PREF_VERSION = "app_version";
private static AppsSettings sAppsSettings;
private final Point mScreenSize = new Point();
private final Point mRealScreenSize = new Point();
private Context context;
private PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences;
private float mDensity;
private final Point mScreenSize = new Point();
private final Point mRealScreenSize = new Point();
private AppsSettings(Context context) {
this.context = context;
......@@ -471,6 +471,11 @@ public class AppsSettings {
mSharedPreferences.putString(Constants.PREF_GAME_PATH, path);
}
//获取录像文件夹
public String getReplayDir() {
return new File(getResourcePath(), CORE_REPLAY_PATH).getAbsolutePath();
}
//获取卡组文件夹
public String getDeckDir() {
return new File(getResourcePath(), CORE_DECK_PATH).getAbsolutePath();
......
......@@ -4,19 +4,15 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
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 cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.core.IrrlichtBridge;
import cn.garymb.ygomobile.lite.BuildConfig;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.utils.FileUtils;
......@@ -38,12 +34,11 @@ public class ShareFileActivity extends Activity {
String title = intent.getStringExtra(IrrlichtBridge.EXTRA_SHARE_FILE);
String ext = intent.getStringExtra(IrrlichtBridge.EXTRA_SHARE_TYPE);
//TODO
Toast.makeText(this, "title=" + title + ",ext=" + ext, Toast.LENGTH_SHORT).show();
String sharePath = "";
if (ext.equals("yrp")) {
sharePath = AppsSettings.get().getResourcePath() + "/" + Constants.CORE_REPLAY_PATH + "/" + title;
sharePath = AppsSettings.get().getReplayDir() + "/" + title;
} else if (ext.equals("lua")) {
sharePath = AppsSettings.get().getResourcePath()+ "/" + Constants.CORE_SINGLE_PATH + "/" + title;
sharePath = AppsSettings.get().getSingleDir() + "/" + title;
}
File shareFile = new File(sharePath);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
......@@ -51,7 +46,11 @@ public class ShareFileActivity extends Activity {
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setType("*/*");//此处可发送多种文件
startActivity(Intent.createChooser(shareIntent, getString(R.string.send)));
try {
startActivity(Intent.createChooser(shareIntent, getString(R.string.send)));
} catch (Exception e) {
Toast.makeText(this, getString(R.string.sending_failed) + e, Toast.LENGTH_SHORT).show();
}
finish();
}
......
......@@ -22,7 +22,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) {
......
<?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/"/>
<external-path
path="Android/data/${applicationId}/"
name="files_root" />
<external-path
path="."
name="external_storage_root" />
</paths>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment