commit ef2709dc478ea435efe9f64459bcc69ba4f83d72
Author: leszek <leszek@koltunski.pl>
Date:   Fri Jan 19 22:22:42 2024 +0100

    Catch the error when WebView is not installed.

diff --git a/src/main/java/org/distorted/tutorials/TutorialActivity.java b/src/main/java/org/distorted/tutorials/TutorialActivity.java
index ba71ffa4..48417158 100644
--- a/src/main/java/org/distorted/tutorials/TutorialActivity.java
+++ b/src/main/java/org/distorted/tutorials/TutorialActivity.java
@@ -51,6 +51,7 @@ public class TutorialActivity extends AppCompatActivity
     private int mObjectOrdinal;
     private TutorialWebView mWebView;
     private boolean mIsFree;
+    private boolean mErrorLoadingWebView;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -60,7 +61,17 @@ public class TutorialActivity extends AppCompatActivity
       super.onCreate(savedState);
       DistortedLibrary.onCreate(ACTIVITY_NUMBER);
       setTheme(R.style.MaterialThemeNoActionBar);
-      setContentView(R.layout.tutorial);
+
+      try
+        {
+        setContentView(R.layout.tutorial);
+        mErrorLoadingWebView = false;
+        }
+      catch(Exception e)
+        {
+        setContentView(R.layout.tutorial_no_webview);
+        mErrorLoadingWebView = true;
+        }
 
       mIsFree = true;
 
@@ -87,11 +98,14 @@ public class TutorialActivity extends AppCompatActivity
 
     public void showDialog()
       {
-      Bundle bundle = new Bundle();
-      bundle.putString("argument", String.valueOf(mObjectOrdinal) );
-      RubikDialogTutorial diag = new RubikDialogTutorial();
-      diag.setArguments(bundle);
-      diag.show( getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() );
+      if( !mErrorLoadingWebView )
+        {
+        Bundle bundle = new Bundle();
+        bundle.putString("argument", String.valueOf(mObjectOrdinal));
+        RubikDialogTutorial diag = new RubikDialogTutorial();
+        diag.setArguments(bundle);
+        diag.show(getSupportFragmentManager(), RubikDialogTutorial.getDialogTag());
+        }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -124,13 +138,16 @@ public class TutorialActivity extends AppCompatActivity
 
     public void loadTutorial(String url)
       {
-      if( mWebView==null )
+      if( !mErrorLoadingWebView )
         {
-        WebView videoView = findViewById(R.id.tutorialVideoView);
-        mWebView = new TutorialWebView(videoView);
-        }
+        if(mWebView==null)
+          {
+          WebView videoView = findViewById(R.id.tutorialVideoView);
+          mWebView = new TutorialWebView(videoView);
+          }
 
-      mWebView.load(URL+url);
+        mWebView.load(URL+url);
+        }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/res/layout/tutorial_no_webview.xml b/src/main/res/layout/tutorial_no_webview.xml
new file mode 100644
index 00000000..890c56a1
--- /dev/null
+++ b/src/main/res/layout/tutorial_no_webview.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_marginLeft="0dp"
+    android:layout_marginRight="0dp"
+    android:background="@android:color/transparent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:id="@+id/tutorialError"
+        android:layout_width="match_parent"
+        android:text="@string/webview_error"
+        android:gravity="center"
+        android:layout_height="0dp"
+        android:layout_weight="1"/>
+
+    <RelativeLayout
+        android:id="@+id/tutorialLowerPart"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1.2">
+
+        <org.distorted.tutorials.TutorialSurfaceView
+           android:id="@+id/tutorialSurfaceView"
+           android:layout_width="match_parent"
+           android:layout_height="match_parent"
+           android:layout_alignParentStart="true"/>
+
+        <LinearLayout
+           android:id="@+id/tutorialRightBar"
+           android:layout_alignParentRight="true"
+           android:layout_width="0dp"
+           android:layout_height="match_parent"
+           android:orientation="vertical"
+           android:background="@android:color/transparent">
+        </LinearLayout>
+
+    </RelativeLayout>
+</LinearLayout>
+
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index fce5d383..c1c29b5f 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -109,6 +109,7 @@
     <string name="config_mesh_fast">Fast</string>
     <string name="config_mesh_nice">Nice</string>
 
+    <string name="webview_error" translatable="false">Error Loading WebView</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>
 
