Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加屏幕方向设置[android独有] #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public void onMethodCall(MethodCall methodCall, @NonNull MethodChannel.Result re
if ("getPickerPaths".equals(methodCall.method)) {

String galleryMode = methodCall.argument("galleryMode");
Number screenOrientation = methodCall.argument("screenOrientation");
Boolean showGif = methodCall.argument("showGif");
Map<String,Number> uiColor = methodCall.argument("uiColor");
Number selectCount = methodCall.argument("selectCount");
Expand All @@ -136,6 +137,7 @@ public void onMethodCall(MethodCall methodCall, @NonNull MethodChannel.Result re
Intent intent = new Intent();

intent.putExtra(SelectPicsActivity.GALLERY_MODE,galleryMode);
intent.putExtra(SelectPicsActivity.SCREEN_ORIENTATION, screenOrientation);
intent.putExtra(SelectPicsActivity.UI_COLOR, (Serializable) uiColor);
intent.putExtra(SelectPicsActivity.SELECT_COUNT,selectCount);
intent.putExtra(SelectPicsActivity.SHOW_GIF,showGif);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class SelectPicsActivity extends BaseActivity {
private static final int WRITE_SDCARD = 101;

public static final String GALLERY_MODE = "GALLERY_MODE";
public static final String SCREEN_ORIENTATION = "SCREEN_ORIENTATION";
public static final String UI_COLOR = "UI_COLOR";
public static final String SHOW_GIF = "SHOW_GIF";
public static final String SHOW_CAMERA = "SHOW_CAMERA";
Expand Down Expand Up @@ -127,6 +128,7 @@ private int getLang(String language){
private void startSel() {

String mode = getIntent().getStringExtra(GALLERY_MODE);
Number screenOrientation = getIntent().getIntExtra(SCREEN_ORIENTATION, 1);
Map<String, Number> uiColor = (Map<String, Number>) getIntent().getSerializableExtra(UI_COLOR);

Number selectCount = getIntent().getIntExtra(SELECT_COUNT, 9);
Expand All @@ -145,6 +147,8 @@ private void startSel() {

String language = getIntent().getStringExtra(LANGUAGE);

// 屏幕方向
int requestedOrientation = screenOrientation.intValue() == 0 ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : (screenOrientation.intValue() == 1 ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

PictureStyleUtil pictureStyleUtil = new PictureStyleUtil(this);
pictureStyleUtil.setStyle(uiColor);
Expand Down Expand Up @@ -228,7 +232,7 @@ public void onCancel() {
PictureSelector.create(this).openGallery(selectMimeType)
.setImageEngine(GlideEngine.createGlideEngine())
.setSelectorUIStyle(pictureStyleUtil.getSelectorStyle())
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
.setRequestedOrientation(requestedOrientation)
.setRecordVideoMaxSecond(videoRecordMaxSecond.intValue())
.setRecordVideoMinSecond(videoRecordMinSecond.intValue())
.setLanguage(getLang(language))
Expand Down
15 changes: 14 additions & 1 deletion lib/image_pickers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ enum CameraMimeType {
video,
}

/// 屏幕方向设置,android独有
enum ScreenOrientation {
// 横屏
landscape,
// 竖屏
portrait,
// unspecified
unspecified,
}

class ImagePickers {
static const MethodChannel _channel =
const MethodChannel('flutter/image_pickers');
Expand Down Expand Up @@ -58,7 +68,8 @@ class ImagePickers {

Color uiColor = UIConfig.defUiThemeColor;
final Map<String, dynamic> params = <String, dynamic>{
'galleryMode': "image",
'galleryMode': GalleryMode.image.name,
'screenOrientation': ScreenOrientation.portrait.index,
'showGif': true,
'uiColor': {
"a": 255,
Expand Down Expand Up @@ -124,6 +135,7 @@ class ImagePickers {

static Future<List<Media>> pickerPaths({
GalleryMode galleryMode = GalleryMode.image,
ScreenOrientation screenOrientation = ScreenOrientation.portrait,
UIConfig? uiConfig,
int selectCount = 1,
bool showCamera = false,
Expand Down Expand Up @@ -152,6 +164,7 @@ class ImagePickers {

final Map<String, dynamic> params = <String, dynamic>{
'galleryMode': galleryMode.name,
'screenOrientation': screenOrientation.index,
'showGif': showGif,
'uiColor': {
"a": 255,
Expand Down