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

Bad Dialog size on large screens #30

Closed
Korriged opened this issue Jun 16, 2010 · 4 comments
Closed

Bad Dialog size on large screens #30

Korriged opened this issue Jun 16, 2010 · 4 comments

Comments

@Korriged
Copy link

FbDialog (which displays the Facebook login web page) is well displayed on 320x480 "default-size" screens (e.g. HTC Hero and Motorola Dext)... but is very small on larger screens (e.g. 480x800 HTC Desire and 480x854 Motorola Droid/Milestone).

The cause is that sizes are hard-coded in FbDialog:
static final LayoutParams DEFAULT_LANDSCAPE = new LayoutParams(460, 260);
static final LayoutParams DEFAULT_PORTRAIT = new LayoutParams(280, 420);

@Korriged
Copy link
Author

A patch:

1/ change the declaration of attributes DEFAULT_LANDSCAPE and DEFAULT_PORTRAIT in FbDialog with:

// Patch bug #30 - BEGIN
// Refer to http://github.com/facebook/facebook-android-sdk/issues/issue/30
static LayoutParams DEFAULT_LANDSCAPE = null;
static LayoutParams DEFAULT_PORTRAIT = null;
// Patch bug #30 - END

2/ Add the following code to method FbDialog.onCreate(Bundle savedInstanceState), just after super.onCreate(savedInstanceState);

// Patch bug #30 - BEGIN
// Refer to http://github.com/facebook/facebook-android-sdk/issues/issue/30
// Gets screen size (depends on screen orientation):
int height = ((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
int width = ((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
if(width > height) {
// Landscape
int temp = height;
height = width;
width = temp;
}
// Height = larger dimension
// Sets screen size: height-60; width-20
LayoutParams DEFAULT_LANDSCAPE = new LayoutParams(height-60, width-20);
// Sets screen size: height-40; width-60
LayoutParams DEFAULT_PORTRAIT = new LayoutParams(width-60, height-40);
// Patch bug #30 - END

@Pretz
Copy link

Pretz commented Jun 16, 2010

I have a slightly different solution than Korriged in my fork of facebook-android-sdk:
http://github.com/Pretz/facebook-android-sdk/commit/4d6d0f0d583c49c804b67c93073ef82e159b50b6
I've sent a pull request to Facebook so hopefully my changes will get merged upstream.

I scale the pixel values by the resolution density, but Korriged solution which insets the dialog from the screen size is also viable. However, it will be inset differently on high and low resolution screens, since 60px will be a different physical difference on an hdpi screen as opposed to an mdpi screen; probably the best solution would scale those values based on the screen density.

@soneff
Copy link

soneff commented Jun 18, 2010

Hey, sorry for not being able to look into this sooner. I just read up on Android screen configurations, and I think that Pretz's solution is more robust (essentially density independent pixels approach). I'll pull your branch, test it, and try to push a change today.

@soneff
Copy link

soneff commented Jun 18, 2010

I've tested on all the devices I have and it looks alright, so I've push this out. Thanks Alex! Let me know if you have any more problems / fixes.

rotorgames pushed a commit to rotorgames/facebook-android-sdk that referenced this issue Aug 2, 2022
Update all Facebook SKDs to 4.18

Reviewed by @Redth and @SotoiGhost
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants