mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
backout 9f81c93ea0ea and 40badd9d545a
This commit is contained in:
parent
833906186e
commit
6efe0aaf9b
@ -5,7 +5,6 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.gfx.LayerView;
|
||||
import org.mozilla.gecko.widget.ThumbnailView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
@ -111,8 +110,6 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
|
||||
return new GeckoTextSwitcher(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "TextView"))
|
||||
return new GeckoTextView(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "widget.ThumbnailView"))
|
||||
return new ThumbnailView(context, attrs);
|
||||
else
|
||||
Log.d(LOGTAG, "Warning: unknown custom view: " + viewName);
|
||||
}
|
||||
|
@ -183,7 +183,6 @@ FENNEC_JAVA_FILES = \
|
||||
ui/SimpleScaleGestureDetector.java \
|
||||
ui/SubdocumentScrollHelper.java \
|
||||
widget/DateTimePicker.java \
|
||||
widget/ThumbnailView.java \
|
||||
GeckoNetworkManager.java \
|
||||
GeckoScreenOrientationListener.java \
|
||||
UpdateService.java \
|
||||
|
@ -22,14 +22,15 @@
|
||||
android:layout_weight="1.0"
|
||||
android:layout_margin="10dip">
|
||||
|
||||
<org.mozilla.gecko.widget.ThumbnailView android:id="@+id/thumbnail"
|
||||
<ImageView android:id="@+id/thumbnail"
|
||||
android:layout_width="@dimen/tab_thumbnail_width"
|
||||
android:layout_height="@dimen/tab_thumbnail_height"
|
||||
android:layout_marginLeft="1dip"
|
||||
android:layout_marginTop="1dip"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/tab_thumbnail_default"/>
|
||||
android:src="@drawable/tab_thumbnail_default"
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<ImageView android:id="@+id/shadow"
|
||||
android:layout_width="138dip"
|
||||
|
@ -17,14 +17,15 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dip">
|
||||
|
||||
<org.mozilla.gecko.widget.ThumbnailView android:id="@+id/thumbnail"
|
||||
<ImageView android:id="@+id/thumbnail"
|
||||
android:layout_width="@dimen/tab_thumbnail_width"
|
||||
android:layout_height="@dimen/tab_thumbnail_height"
|
||||
android:layout_marginLeft="1dip"
|
||||
android:layout_marginTop="1dip"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/tab_thumbnail_default"/>
|
||||
android:src="@drawable/tab_thumbnail_default"
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<ImageView android:id="@+id/shadow"
|
||||
android:layout_width="138dip"
|
||||
|
@ -1,68 +0,0 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.Matrix;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/* Special version of ImageView for thumbnails. Scales a thumbnail so that it maintains its aspect
|
||||
* ratio and so that the images width and height are the same size or greater than the view size
|
||||
*/
|
||||
public class ThumbnailView extends ImageView {
|
||||
private static final String LOGTAG = "GeckoThumbnailView";
|
||||
private Matrix mMatrix = null;
|
||||
private int mWidthSpec = -1;
|
||||
private int mHeightSpec = -1;
|
||||
|
||||
public ThumbnailView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mMatrix = new Matrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
Drawable d = getDrawable();
|
||||
if (mMatrix == null) {
|
||||
int w1 = d.getIntrinsicWidth();
|
||||
int h1 = d.getIntrinsicHeight();
|
||||
int w2 = getWidth();
|
||||
int h2 = getHeight();
|
||||
|
||||
float scale = 1.0f;
|
||||
if (w2/h2 < w1/h1) {
|
||||
scale = (float)h2/h1;
|
||||
} else {
|
||||
scale = (float)w2/w1;
|
||||
}
|
||||
|
||||
mMatrix.reset();
|
||||
mMatrix.setScale(scale, scale);
|
||||
}
|
||||
|
||||
int saveCount = canvas.save();
|
||||
canvas.concat(mMatrix);
|
||||
d.draw(canvas);
|
||||
canvas.restoreToCount(saveCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
// OnLayout.changed isn't a reliable measure of whether or not the size of this view has changed
|
||||
// neither is onSizeChanged called often enough. Instead, we track changes in size ourselves, and
|
||||
// only invalidate this matrix if we have a new width/height spec
|
||||
if (widthMeasureSpec != mWidthSpec || heightMeasureSpec != mHeightSpec) {
|
||||
mWidthSpec = widthMeasureSpec;
|
||||
mHeightSpec = heightMeasureSpec;
|
||||
mMatrix = null;
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user