commit e7e0a94daea2bdcc7548cd3c6920c249917c03ce
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu Oct 1 17:18:52 2020 +0100

    Simplify OpenGL error dialog. Show it only once.

diff --git a/build.gradle b/build.gradle
index df3e5b55..a2d06454 100644
--- a/build.gradle
+++ b/build.gradle
@@ -36,7 +36,7 @@ android {
 dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
     implementation 'com.google.firebase:firebase-analytics:17.5.0'
-    implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
+    implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
 
     api project(':distorted-library')
     implementation 'androidx.appcompat:appcompat:1.2.0'
diff --git a/src/main/java/org/distorted/dialogs/RubikDialogError.java b/src/main/java/org/distorted/dialogs/RubikDialogError.java
index 1641d497..a3a07102 100644
--- a/src/main/java/org/distorted/dialogs/RubikDialogError.java
+++ b/src/main/java/org/distorted/dialogs/RubikDialogError.java
@@ -47,7 +47,7 @@ public class RubikDialogError extends AppCompatDialogFragment
   @Override
   public Dialog onCreateDialog(Bundle savedInstanceState)
     {
-    FragmentActivity act = getActivity();
+    final FragmentActivity act = getActivity();
     LayoutInflater inflater = act.getLayoutInflater();
     AlertDialog.Builder builder = new AlertDialog.Builder(act);
 
@@ -56,18 +56,6 @@ public class RubikDialogError extends AppCompatDialogFragment
     final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
     final float okSize   = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE;
 
-    Bundle args = getArguments();
-    String error;
-
-    try
-      {
-      error = args.getString("error");
-      }
-    catch(Exception e)
-      {
-      error = "Error getting error";
-      }
-
     TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
     tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
     tv.setText(R.string.opengl_error);
@@ -75,16 +63,14 @@ public class RubikDialogError extends AppCompatDialogFragment
 
     final View view = inflater.inflate(R.layout.dialog_error, null);
     TextView text = view.findViewById(R.id.error_string);
-    text.setText(error);
-
-    builder.setCancelable(true);
+    text.setText(R.string.opengl_error_text);
 
     builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
       {
       @Override
       public void onClick(DialogInterface dialog, int which)
         {
-
+        act.finish();
         }
       });
 
diff --git a/src/main/java/org/distorted/main/RubikActivity.java b/src/main/java/org/distorted/main/RubikActivity.java
index 95bbfb07..f81067d0 100644
--- a/src/main/java/org/distorted/main/RubikActivity.java
+++ b/src/main/java/org/distorted/main/RubikActivity.java
@@ -334,13 +334,9 @@ public class RubikActivity extends AppCompatActivity
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    void OpenGLError(String message)
+    void OpenGLError()
       {
-      Bundle bundle = new Bundle();
-      bundle.putString("error", message );
-
       RubikDialogError errDiag = new RubikDialogError();
-      errDiag.setArguments(bundle);
       errDiag.show(getSupportFragmentManager(), null);
       }
 
diff --git a/src/main/java/org/distorted/main/RubikRenderer.java b/src/main/java/org/distorted/main/RubikRenderer.java
index 1a3c6a41..50ba8449 100644
--- a/src/main/java/org/distorted/main/RubikRenderer.java
+++ b/src/main/java/org/distorted/main/RubikRenderer.java
@@ -41,6 +41,7 @@ public class RubikRenderer implements GLSurfaceView.Renderer, DistortedLibrary.E
    private RubikSurfaceView mView;
    private DistortedScreen mScreen;
    private Fps mFPS;
+   private boolean mErrorShown;
 
    private static class Fps
      {
@@ -86,6 +87,7 @@ public class RubikRenderer implements GLSurfaceView.Renderer, DistortedLibrary.E
      {
      final float BRIGHTNESS = 0.30f;
 
+     mErrorShown = false;
      mView = v;
      mFPS = new Fps();
      mScreen = new DistortedScreen();
@@ -161,10 +163,11 @@ public class RubikRenderer implements GLSurfaceView.Renderer, DistortedLibrary.E
 
      int glsl = DistortedLibrary.getGLSL();
 
-     if( glsl< 300 )
+     if( glsl< 300 && !mErrorShown )
        {
+       mErrorShown = true;
        RubikActivity act = (RubikActivity)mView.getContext();
-       act.OpenGLError(message);
+       act.OpenGLError();
        }
      }
 
diff --git a/src/main/java/org/distorted/main/RubikSurfaceView.java b/src/main/java/org/distorted/main/RubikSurfaceView.java
index 967b72e7..e7ef73c4 100644
--- a/src/main/java/org/distorted/main/RubikSurfaceView.java
+++ b/src/main/java/org/distorted/main/RubikSurfaceView.java
@@ -703,12 +703,13 @@ public class RubikSurfaceView extends GLSurfaceView
         try
           {
           final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
-          setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
+          int esVersion = configurationInfo.reqGlEsVersion>>16;
+          setEGLContextClientVersion(esVersion);
           setRenderer(mRenderer);
           }
         catch(Exception ex)
           {
-          act.OpenGLError("This device does not support OpenGL ES 3.0");
+          act.OpenGLError();
 
           String shading = GLES30.glGetString(GLES30.GL_SHADING_LANGUAGE_VERSION);
           String version = GLES30.glGetString(GLES30.GL_VERSION);
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 247c9d8a..2b1a4124 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -1,7 +1,8 @@
 <resources>
     <string name="app_name">Magic Cube</string>
     <string name="distorted" translatable="false">DISTORTED</string>
-    <string name="opengl_error" translatable="false">Graphics Error</string>
+    <string name="opengl_error" translatable="false">Error</string>
+    <string name="opengl_error_text" translatable="false">This device does not support OpenGL 3.0</string>
     <string name="scramble">Scramble</string>
     <string name="solve">Solve</string>
     <string name="exit">Exit</string>
