Prevent SDK updater dialog from showing offscreen.

This commit is contained in:
Xavier Ducrohet
2009-07-27 15:24:38 -07:00
parent 1ff4f596bf
commit bc8b16505e
2 changed files with 21 additions and 1 deletions

View File

@@ -242,6 +242,9 @@ final class PlatformTarget implements IAndroidTarget {
int apiDiff = mVersion.getApiLevel() - target.getVersion().getApiLevel();
if (mVersion.getCodename() != null && apiDiff == 0) {
if (target.getVersionName() == null) {
return +1; // preview showed last
}
return mVersion.getCodename().compareTo(target.getVersion().getCodename());
}

View File

@@ -63,6 +63,12 @@ import java.util.TreeMap;
*/
final class UpdateChooserDialog extends Dialog {
/**
* Min Y location for dialog. Need to deal with the menu bar on mac os.
*/
private final static int MIN_Y = SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN ?
20 : 0;
/** Last dialog size for this session. */
private static Point sLastSize;
private boolean mCompleted;
@@ -373,7 +379,18 @@ final class UpdateChooserDialog extends Dialog {
int cw = childSize.x;
int ch = childSize.y;
child.setLocation(px + (pw - cw) / 2, py + (ph - ch) / 2);
int x = px + (pw - cw) / 2;
int y = py + (ph - ch) / 2;
if (x < 0) {
x = 0;
}
if (y < MIN_Y) {
y = MIN_Y;
}
child.setLocation(x, y);
child.setSize(cw, ch);
}
}