Fix camera bugs found overnight.

- Fix crash in CameraWidgetFrame after rotating to landscape
 - Fix pages drift to the left bug
 - Address Jim's comments on c/245706
 - Disable camera widget if landscape

Bug: 7419070
Bug: 7417798
Bug: 7418781
Change-Id: I5c730c7c1baf3c1872367b6392e6786578765298
This commit is contained in:
John Spurlock
2012-10-26 08:25:51 -04:00
parent 6f35209e72
commit 47cde77bc7
4 changed files with 37 additions and 15 deletions

View File

@@ -15,6 +15,7 @@
-->
<resources>
<bool name="kg_enable_camera_default_widget">false</bool>
<bool name="kg_share_status_area">false</bool>
<bool name="kg_sim_puk_account_full_screen">false</bool>
</resources>

View File

@@ -31,7 +31,6 @@ import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import com.android.internal.policy.impl.keyguard.KeyguardActivityLauncher.CameraWidgetInfo;
import com.android.internal.R;
public class CameraWidgetFrame extends KeyguardWidgetFrame {
private static final String TAG = CameraWidgetFrame.class.getSimpleName();
@@ -49,10 +48,12 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame {
private View mWidgetView;
private long mLaunchCameraStart;
private boolean mRendered;
private final Runnable mLaunchCameraRunnable = new Runnable() {
@Override
public void run() {
mLaunchCameraStart = SystemClock.uptimeMillis();
mActivityLauncher.launchCamera();
}};
@@ -85,7 +86,9 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame {
return null;
ImageView preview = new ImageView(context);
preview.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
preview.setLayoutParams(new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
preview.setScaleType(ScaleType.FIT_CENTER);
CameraWidgetFrame cameraWidgetFrame = new CameraWidgetFrame(context, callbacks, launcher);
cameraWidgetFrame.addView(preview);
@@ -123,15 +126,31 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame {
}
public void render() {
int width = getRootView().getWidth();
int height = getRootView().getHeight();
if (DEBUG) Log.d(TAG, String.format("render [%sx%s]", width, height));
Bitmap offscreen = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(offscreen);
mWidgetView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
mWidgetView.layout(0, 0, width, height);
mWidgetView.draw(c);
((ImageView)getChildAt(0)).setImageBitmap(offscreen);
if (mRendered) return;
try {
int width = getRootView().getWidth();
int height = getRootView().getHeight();
if (DEBUG) Log.d(TAG, String.format("render [%sx%s] %s",
width, height, Integer.toHexString(hashCode())));
if (width == 0 || height == 0) {
return;
}
Bitmap offscreen = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(offscreen);
mWidgetView.measure(
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
mWidgetView.layout(0, 0, width, height);
mWidgetView.draw(c);
((ImageView)getChildAt(0)).setImageBitmap(offscreen);
mRendered = true;
} catch (Throwable t) {
Log.w(TAG, "Error rendering camera widget", t);
removeAllViews();
View genericView = inflateGenericWidgetView(mContext);
addView(genericView);
}
}
private void transitionToCamera() {
@@ -161,10 +180,10 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame {
if (!hasWindowFocus) {
if (mLaunchCameraStart > 0) {
long launchTime = SystemClock.uptimeMillis() - mLaunchCameraStart;
if (DEBUG) Log.d(TAG, String.format("Camera took %s to launch", launchTime));
if (DEBUG) Log.d(TAG, String.format("Camera took %sms to launch", launchTime));
mLaunchCameraStart = 0;
onCameraLaunched();
}
onCameraLaunched();
}
}

View File

@@ -102,7 +102,6 @@ public abstract class KeyguardActivityLauncher {
launchActivity(SECURE_CAMERA_INTENT, true);
}
} else {
// wouldLaunchResolverActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
// Launch the normal camera
launchActivity(INSECURE_CAMERA_INTENT, false);
}

View File

@@ -850,7 +850,10 @@ public class KeyguardHostView extends KeyguardViewBase {
if (slider != null) {
slider.showHandle(true);
}
mAppWidgetContainer.scrollLeft();
View v = mAppWidgetContainer.getChildAt(mAppWidgetContainer.getCurrentPage());
if (v instanceof CameraWidgetFrame) {
mAppWidgetContainer.scrollLeft();
}
}
private SlidingChallengeLayout locateSlider() {