commit 05fb345cd91979f3cfff68e9c332960da4cadc27
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Jul 12 18:19:59 2022 +0200

    - we need to export the main activity
    - we need to detect if the downloaded JSON is corrupt and if yes, do not save it.

diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index f014f6e9..fbc0a94b 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -21,7 +21,7 @@
             android:value="${crashlyticsCollectionEnabled}"
         />
 
-        <activity android:name="org.distorted.main.RubikActivity" android:exported="false" android:screenOrientation="portrait">
+        <activity android:name="org.distorted.main.RubikActivity" android:exported="true" android:screenOrientation="portrait">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
diff --git a/src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java b/src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java
index 44178d85..5f9bf5f0 100644
--- a/src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java
+++ b/src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java
@@ -191,67 +191,66 @@ public class RubikDialogUpdateView implements RubikNetwork.Downloadee
       {
       makeProgress(50,R.string.installing);
       RubikFiles files = RubikFiles.getInstance();
-      boolean oSuccess=false, eSuccess=false;
+      boolean oSuccess, eSuccess=false;
 
       if( mInfo.mObjectStream!=null )
         {
-        String name = mInfo.mObjectShortName + "_object.json";
+        String objectName = mInfo.mObjectShortName + "_object.json";
         Activity act = mAct.get();
-        oSuccess = files.saveFile(act,mInfo.mObjectStream, name);
+        oSuccess = files.saveFile(act,mInfo.mObjectStream, objectName);
 
-        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Saving JSON "+name+" to a file "+oSuccess);
+        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Saving JSON "+objectName+" to a file "+oSuccess);
 
         try
           {
           JsonReader reader = JsonReader.getInstance();
-          mInfo.mNumScrambles = reader.readNumScrambles(act,name);
+          mInfo.mNumScrambles = reader.readNumScrambles(act,objectName);
           if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Read from JSON numScrambles="+mInfo.mNumScrambles);
-          }
-        catch(Exception ex)
-          {
-          mInfo.mNumScrambles = 25;
-          if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Error reading numScrambles");
-          }
-        }
 
-      if( mInfo.mExtrasStream!=null )
-        {
-        String name = mInfo.mObjectShortName + "_extras.json";
-        Activity act = mAct.get();
-        eSuccess = files.saveFile(act,mInfo.mExtrasStream, name);
+          if( mInfo.mExtrasStream!=null )
+            {
+            String name = mInfo.mObjectShortName + "_extras.json";
+            eSuccess = files.saveFile(act,mInfo.mExtrasStream, name);
 
-        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Saving Extras "+name+" to a file "+eSuccess);
-        }
+            if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Saving Extras "+name+" to a file "+eSuccess);
+            }
 
-      if( mIconSaved || oSuccess || eSuccess )
-        {
-        makeProgress(75,R.string.configuring);
+          if( mIconSaved || oSuccess || eSuccess )
+            {
+            makeProgress(75,R.string.configuring);
 
-        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "1");
+            if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "1");
 
-        Activity act = mAct.get();
-        RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion,
-                                            mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess);
+            RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion,
+                                                mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess);
 
-        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2");
+            if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2");
 
-        RubikNetwork network = RubikNetwork.getInstance();
-        network.updateDone(mInfo.mObjectShortName);
+            RubikNetwork network = RubikNetwork.getInstance();
+            network.updateDone(mInfo.mObjectShortName);
 
-        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "3");
+            if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "3");
 
-        RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
-        play.recreatePopup();
+            RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
+            play.recreatePopup();
 
-        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "4");
+            if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "4");
 
-        makeProgress(100,R.string.success);
+            makeProgress(100,R.string.success);
 
-        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "5");
-        }
-      else
-        {
-        displayError(R.string.saveError);
+            if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "5");
+            }
+          else
+            {
+            displayError(R.string.saveError);
+            }
+          }
+        catch(Exception ex)
+          {
+          displayError(R.string.saveError);
+          files.deleteJsonObject(act,objectName);
+          if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Error reading numScrambles");
+          }
         }
       }
     }
