mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 07:40:42 +00:00
Bug 779366 - Part 2c: Query resources for DisplayMetrics, not the WindowManager. r=sriram
This commit is contained in:
parent
8ddeeaaf87
commit
237dc8079e
@ -476,10 +476,8 @@ abstract public class GeckoApp
|
|||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
|
||||||
((Activity) GeckoApp.mAppContext).getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
|
||||||
|
|
||||||
// heightPixels changes during rotation.
|
// heightPixels changes during rotation.
|
||||||
|
DisplayMetrics metrics = GeckoApp.mAppContext.getResources().getDisplayMetrics();
|
||||||
int restrictedHeightSpec = MeasureSpec.makeMeasureSpec((int) (0.75 * metrics.heightPixels), MeasureSpec.AT_MOST);
|
int restrictedHeightSpec = MeasureSpec.makeMeasureSpec((int) (0.75 * metrics.heightPixels), MeasureSpec.AT_MOST);
|
||||||
|
|
||||||
super.onMeasure(widthMeasureSpec, restrictedHeightSpec);
|
super.onMeasure(widthMeasureSpec, restrictedHeightSpec);
|
||||||
@ -605,16 +603,10 @@ abstract public class GeckoApp
|
|||||||
outState.putString(SAVED_STATE_TITLE, tab.getDisplayTitle());
|
outState.putString(SAVED_STATE_TITLE, tab.getDisplayTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplayMetrics getDisplayMetrics() {
|
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
|
||||||
return metrics;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getAndProcessThumbnailForTab(final Tab tab) {
|
public void getAndProcessThumbnailForTab(final Tab tab) {
|
||||||
boolean isSelectedTab = Tabs.getInstance().isSelectedTab(tab);
|
boolean isSelectedTab = Tabs.getInstance().isSelectedTab(tab);
|
||||||
final Bitmap bitmap = isSelectedTab ? mLayerClient.getBitmap() : null;
|
final Bitmap bitmap = isSelectedTab ? mLayerClient.getBitmap() : null;
|
||||||
|
|
||||||
if ("about:home".equals(tab.getURL())) {
|
if ("about:home".equals(tab.getURL())) {
|
||||||
tab.updateThumbnail(null);
|
tab.updateThumbnail(null);
|
||||||
return;
|
return;
|
||||||
|
@ -523,7 +523,7 @@ public class GeckoAppShell
|
|||||||
if (restoreMode != RESTORE_NONE)
|
if (restoreMode != RESTORE_NONE)
|
||||||
combinedArgs += " -restoremode " + restoreMode;
|
combinedArgs += " -restoremode " + restoreMode;
|
||||||
|
|
||||||
DisplayMetrics metrics = GeckoApp.mAppContext.getDisplayMetrics();
|
DisplayMetrics metrics = GeckoApp.mAppContext.getResources().getDisplayMetrics();
|
||||||
combinedArgs += " -width " + metrics.widthPixels + " -height " + metrics.heightPixels;
|
combinedArgs += " -width " + metrics.widthPixels + " -height " + metrics.heightPixels;
|
||||||
|
|
||||||
GeckoApp.mAppContext.runOnUiThread(new Runnable() {
|
GeckoApp.mAppContext.runOnUiThread(new Runnable() {
|
||||||
@ -1394,7 +1394,7 @@ public class GeckoAppShell
|
|||||||
|
|
||||||
public static int getDpi() {
|
public static int getDpi() {
|
||||||
if (sDensityDpi == 0) {
|
if (sDensityDpi == 0) {
|
||||||
sDensityDpi = GeckoApp.mAppContext.getDisplayMetrics().densityDpi;
|
sDensityDpi = GeckoApp.mAppContext.getResources().getDisplayMetrics().densityDpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sDensityDpi;
|
return sDensityDpi;
|
||||||
|
@ -8,6 +8,7 @@ package org.mozilla.gecko;
|
|||||||
import org.mozilla.gecko.gfx.DisplayPortMetrics;
|
import org.mozilla.gecko.gfx.DisplayPortMetrics;
|
||||||
import org.mozilla.gecko.gfx.ViewportMetrics;
|
import org.mozilla.gecko.gfx.ViewportMetrics;
|
||||||
|
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
@ -256,7 +257,8 @@ public class GeckoEvent {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
float size = event.getSize(eventIndex);
|
float size = event.getSize(eventIndex);
|
||||||
DisplayMetrics displaymetrics = GeckoApp.mAppContext.getDisplayMetrics();
|
Resources resources = GeckoApp.mAppContext.getResources();
|
||||||
|
DisplayMetrics displaymetrics = resources.getDisplayMetrics();
|
||||||
size = size*Math.min(displaymetrics.heightPixels, displaymetrics.widthPixels);
|
size = size*Math.min(displaymetrics.heightPixels, displaymetrics.widthPixels);
|
||||||
mPointRadii[index] = new Point((int)size,(int)size);
|
mPointRadii[index] = new Point((int)size,(int)size);
|
||||||
mOrientations[index] = 0;
|
mOrientations[index] = 0;
|
||||||
|
@ -840,7 +840,7 @@ public class GeckoInputConnection
|
|||||||
outAttrs.actionLabel = mIMEActionHint;
|
outAttrs.actionLabel = mIMEActionHint;
|
||||||
|
|
||||||
GeckoApp app = GeckoApp.mAppContext;
|
GeckoApp app = GeckoApp.mAppContext;
|
||||||
DisplayMetrics metrics = app.getDisplayMetrics();
|
DisplayMetrics metrics = app.getResources().getDisplayMetrics();
|
||||||
if (Math.min(metrics.widthPixels, metrics.heightPixels) > INLINE_IME_MIN_DISPLAY_SIZE) {
|
if (Math.min(metrics.widthPixels, metrics.heightPixels) > INLINE_IME_MIN_DISPLAY_SIZE) {
|
||||||
// prevent showing full-screen keyboard only when the screen is tall enough
|
// prevent showing full-screen keyboard only when the screen is tall enough
|
||||||
// to show some reasonable amount of the page (see bug 752709)
|
// to show some reasonable amount of the page (see bug 752709)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user