// Copyright (C) 2016 Elviss Strazdins
// This file is part of the Ouzel engine.

package lv.elviss.ouzel;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.os.Build;
import android.os.Bundle;
import android.widget.Toast;
import android.content.res.Configuration;

public class MainActivity extends Activity
{
    private OuzelSurfaceView surfaceView;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        OuzelLibJNIWrapper.setAssetManager(getAssets());

        ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();

        final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000 || isProbablyEmulator();

        if (supportsEs2)
        {
            surfaceView = new OuzelSurfaceView(this);

            if (isProbablyEmulator())
            {
                // Avoids crashes on startup with some emulator images.
                surfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
            }

            surfaceView.setEGLContextClientVersion(2);
            surfaceView.setRenderer(new RendererWrapper());
            setContentView(surfaceView);
        }
        else
        {
            // Should never be seen in production, since the manifest filters
            // unsupported devices.
            Toast.makeText(this, "This device does not support OpenGL ES 2.0.", Toast.LENGTH_LONG).show();
            return;
        }
    }

    private boolean isProbablyEmulator()
    {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD
                && (Build.FINGERPRINT.startsWith("generic")
                        || Build.FINGERPRINT.startsWith("unknown")
                        || Build.MODEL.contains("google_sdk")
                        || Build.MODEL.contains("Emulator")
                        || Build.MODEL.contains("Android SDK built for x86"));
    }

    @Override
    protected void onPause()
    {
        super.onPause();

        if (surfaceView != null)
        {
            surfaceView.onPause();
        }
    }

    @Override
    protected void onResume()
    {
        super.onResume();

        if (surfaceView != null)
        {
            surfaceView.onResume();
        }
    }
}

@@ -1147,18 +1147,17 @@
 r images
-.
 %0A
+
         
@@ -1497,31 +1497,16 @@
  filters
-%0A            //
  unsuppo
@@ -1517,17 +1517,16 @@
  devices
-.
 %0A       
@@ -1780,16 +1780,19 @@
 GERBREAD
+ &&
 %0A       
@@ -1799,15 +1799,8 @@
     
-     &&
  (Bu
@@ -1836,24 +1836,20 @@
 eneric%22)
-%0A       
+ %7C%7C%0A
         
@@ -1848,31 +1848,24 @@
             
-     %7C%7C
  Build.FINGE
@@ -1892,29 +1892,20 @@
 nknown%22)
-%0A            
+ %7C%7C%0A
         
@@ -1900,34 +1900,32 @@
  %7C%7C%0A            
-%7C%7C
  Build.MODEL.con
@@ -1943,28 +1943,20 @@
 le_sdk%22)
-%0A           
+ %7C%7C%0A
         
@@ -1951,35 +1951,32 @@
  %7C%7C%0A            
- %7C%7C
  Build.MODEL.con
@@ -1992,23 +1992,20 @@
 ulator%22)
-%0A      
+ %7C%7C%0A
         
@@ -2012,16 +2012,8 @@
     
-      %7C%7C
  Bui

Clean up Java code