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
a71867e9
Commit
a71867e9
authored
Aug 24, 2019
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
使用新文件选择
parent
920efe05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
22 deletions
+54
-22
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/PreferenceFragmentPlus.java
...arymb/ygomobile/ui/preference/PreferenceFragmentPlus.java
+54
-22
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/PreferenceFragmentPlus.java
View file @
a71867e9
package
cn.garymb.ygomobile.ui.preference
;
package
cn.garymb.ygomobile.ui.preference
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.graphics.
Bitmap
;
import
android.graphics.
Color
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.preference.Preference
;
import
android.preference.Preference
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
androidx.core.content.FileProvider
;
import
com.yuyh.library.imgsel.ISNav
;
import
com.yuyh.library.imgsel.config.ISListConfig
;
import
java.io.File
;
import
java.io.File
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.file.FileActivity
;
import
cn.garymb.ygomobile.ui.file.FileActivity
;
import
cn.garymb.ygomobile.ui.file.FileOpenType
;
import
cn.garymb.ygomobile.ui.file.FileOpenType
;
import
static
android
.
app
.
Activity
.
RESULT_OK
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
REQUEST_CHOOSE_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
REQUEST_CHOOSE_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
REQUEST_CHOOSE_FOLDER
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
REQUEST_CHOOSE_FOLDER
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
REQUEST_CHOOSE_IMG
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
REQUEST_CHOOSE_IMG
;
...
@@ -31,7 +30,7 @@ import static cn.garymb.ygomobile.Constants.REQUEST_CHOOSE_IMG;
...
@@ -31,7 +30,7 @@ import static cn.garymb.ygomobile.Constants.REQUEST_CHOOSE_IMG;
public
abstract
class
PreferenceFragmentPlus
extends
BasePreferenceFragment
{
public
abstract
class
PreferenceFragmentPlus
extends
BasePreferenceFragment
{
private
Preference
curPreference
;
private
Preference
curPreference
;
private
CurImageInfo
mCurImageInfo
;
private
CurImageInfo
mCurImageInfo
;
private
Uri
saveimgUri
;
private
Uri
saveimgUri
;
protected
void
onChooseFileOk
(
Preference
preference
,
String
file
)
{
protected
void
onChooseFileOk
(
Preference
preference
,
String
file
)
{
onPreferenceChange
(
preference
,
file
);
onPreferenceChange
(
preference
,
file
);
...
@@ -92,19 +91,38 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
...
@@ -92,19 +91,38 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
// startActivityForResult(intent, REQUEST_CHOOSE_IMG);
// startActivityForResult(intent, REQUEST_CHOOSE_IMG);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
//// intent.addCategory(Intent.CATEGORY_OPENABLE);
// intent.addCategory(Intent.CATEGORY_OPENABLE);
intent
.
setType
(
"image/*"
);
// intent.setType("image/*");
//// intent.putExtra("crop", "true");
ISListConfig
config
=
new
ISListConfig
.
Builder
()
//// intent.putExtra("aspectX", width);
// 是否多选, 默认true
//// intent.putExtra("aspectY", height);
.
multiSelect
(
false
)
//// intent.putExtra("outputX", width);
// 是否记住上次选中记录, 仅当multiSelect为true的时候配置,默认为true
//// intent.putExtra("outputY", height);
.
rememberSelected
(
false
)
//// intent.putExtra("scale", true);
// “确定”按钮背景色
//// intent.putExtra("scaleUpIfNeeded", true);// 黑边
.
btnBgColor
(
Color
.
BLACK
)
//// intent.putExtra("return-data", false);
// “确定”按钮文字颜色
//// intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(outFile)));
.
btnTextColor
(
Color
.
WHITE
)
//// intent.putExtra("outputFormat", isJpeg ? Bitmap.CompressFormat.JPEG.toString() : Bitmap.CompressFormat.PNG.toString());
// 使用沉浸式状态栏
//// intent.putExtra("noFaceDetection", true); // no face detection
.
statusBarColor
(
Color
.
parseColor
(
"#11113d"
))
// 返回图标ResId
.
backResId
(
R
.
drawable
.
ic_back
)
// 标题
.
title
(
"图片"
)
// 标题文字颜色
.
titleColor
(
Color
.
WHITE
)
// TitleBar背景色
.
titleBgColor
(
Color
.
parseColor
(
"#11113d"
))
// 裁剪大小。needCrop为true的时候配置
.
cropSize
(
mCurImageInfo
.
width
,
mCurImageInfo
.
height
,
mCurImageInfo
.
width
,
mCurImageInfo
.
height
)
.
needCrop
(
true
)
// 第一个是否显示相机,默认true
.
needCamera
(
false
)
// 最大选择图片数量,默认9
.
maxNum
(
1
)
.
build
();
// 跳转到图片选择器
ISNav
.
getInstance
().
toListActivity
(
this
,
config
,
REQUEST_CHOOSE_IMG
);
try
{
try
{
startActivityForResult
(
intent
,
REQUEST_CHOOSE_IMG
);
startActivityForResult
(
intent
,
REQUEST_CHOOSE_IMG
);
}
catch
(
android
.
content
.
ActivityNotFoundException
ex
)
{
}
catch
(
android
.
content
.
ActivityNotFoundException
ex
)
{
...
@@ -114,6 +132,20 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
...
@@ -114,6 +132,20 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
}
}
}
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
// 图片选择结果回调
if
(
requestCode
==
REQUEST_CHOOSE_IMG
&&
resultCode
==
RESULT_OK
&&
data
!=
null
)
{
List
<
String
>
pathList
=
data
.
getStringArrayListExtra
(
"result"
);
/*for (String path : pathList) {
tvResult.append(path + "\n");
}*/
}
}
//已弃用裁剪和回调
/*
protected void openPhotoCut(Preference preference, Uri srcfile, CurImageInfo info) {
protected void openPhotoCut(Preference preference, Uri srcfile, CurImageInfo info) {
// 裁剪图片
// 裁剪图片
if (srcfile == null || info == null) {
if (srcfile == null || info == null) {
...
@@ -199,7 +231,7 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
...
@@ -199,7 +231,7 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
onChooseFileFail(curPreference);
onChooseFileFail(curPreference);
}
}
}
}
*/
public
static
class
SharedPreferencesPlus
implements
SharedPreferences
{
public
static
class
SharedPreferencesPlus
implements
SharedPreferences
{
private
SharedPreferences
mSharedPreferences
;
private
SharedPreferences
mSharedPreferences
;
...
...
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