Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47cde77b authored by John Spurlock's avatar John Spurlock
Browse files

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
parent 6f35209e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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>
+32 −13
Original line number Diff line number Diff line
@@ -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() {
        if (mRendered) return;

        try {
            int width = getRootView().getWidth();
            int height = getRootView().getHeight();
        if (DEBUG) Log.d(TAG, String.format("render [%sx%s]", width, height));
            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.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,12 +180,12 @@ 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();
            }
        }
    }

    @Override
    public void onActive(boolean isActive) {
+0 −1
Original line number Diff line number Diff line
@@ -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);
        }
+4 −1
Original line number Diff line number Diff line
@@ -850,8 +850,11 @@ public class KeyguardHostView extends KeyguardViewBase {
                if (slider != null) {
                    slider.showHandle(true);
                }
                View v = mAppWidgetContainer.getChildAt(mAppWidgetContainer.getCurrentPage());
                if (v instanceof CameraWidgetFrame) {
                    mAppWidgetContainer.scrollLeft();
                }
            }

            private SlidingChallengeLayout locateSlider() {
                return (SlidingChallengeLayout) findViewById(R.id.sliding_layout);