// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.domokit.sky.shell;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;

/**
 * Base class for activities that use Sky.
 */
public class SkyActivity extends Activity {
    private TracingController mTracingController;
    private PlatformView mView;

    /**
     * @see android.app.Activity#onCreate(android.os.Bundle)
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            getWindow().setStatusBarColor(0x40000000);
        }
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

        SkyMain.ensureInitialized(getApplicationContext());
        mView = new PlatformView(this);
        setContentView(mView);
        mTracingController = new TracingController(this);
    }

    /**
     * @see android.app.Activity#onStop()
     */
    @Override
    protected void onStop() {
        // Do we need to shut down Sky too?
        mTracingController.stop();
        super.onStop();
    }

    public void loadUrl(String url) {
        mView.loadUrl(url);
    }
}

@@ -1340,20 +1340,23 @@
 ivity#on
-Stop
+Destroy
 ()%0A     
@@ -1393,20 +1393,23 @@
  void on
-Stop
+Destroy
 () %7B%0A   
@@ -1504,12 +1504,15 @@
 r.on
-Stop
+Destroy
 ();%0A

Fix Sky not to crash when clicking the Home button.