| 1 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 2 | 
        
         | 
        
         | 
        // Copyright 2022 Leszek Koltunski                                                               //
  | 
      
      
        | 3 | 
        
         | 
        
         | 
        //                                                                                               //
  | 
      
      
        | 4 | 
        
         | 
        
         | 
        // This file is part of Magic Cube.                                                              //
  | 
      
      
        | 5 | 
        
         | 
        
         | 
        //                                                                                               //
  | 
      
      
        | 6 | 
        
         | 
        
         | 
        // Magic Cube is proprietary software licensed under an EULA which you should have received      //
  | 
      
      
        | 7 | 
        
         | 
        
         | 
        // along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
  | 
      
      
        | 8 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 9 | 
        
         | 
        
         | 
        
  | 
      
      
        | 10 | 
        
         | 
        
         | 
        package org.distorted.dialogs;
  | 
      
      
        | 11 | 
        
         | 
        
         | 
        
  | 
      
      
        | 12 | 
        
         | 
        
         | 
        import android.app.Dialog;
  | 
      
      
        | 13 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
        import android.content.pm.PackageInfo;
  | 
      
      
        | 14 | 
        
         | 
        
         | 
        import android.content.pm.PackageManager;
  | 
      
      
        | 15 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
        import android.view.View;
  | 
      
      
        | 16 | 
        
         | 
        
         | 
        import android.view.Window;
  | 
      
      
        | 17 | 
        
         | 
        
         | 
        import android.view.WindowManager;
  | 
      
      
        | 18 | 
        
         | 
        
         | 
        import android.widget.LinearLayout;
  | 
      
      
        | 19 | 
        
         | 
        
         | 
        import android.widget.TextView;
  | 
      
      
        | 20 | 
        
         | 
        
         | 
        
  | 
      
      
        | 21 | 
        
         | 
        
         | 
        import androidx.fragment.app.FragmentActivity;
  | 
      
      
        | 22 | 
        
         | 
        
         | 
        
  | 
      
      
        | 23 | 
        
         | 
        
         | 
        import org.distorted.main.R;
  | 
      
      
        | 24 | 
        
         | 
        
         | 
        import org.distorted.main.RubikActivity;
  | 
      
      
        | 25 | 
        
         | 
        
         | 
        
  | 
      
      
        | 26 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 27 | 
        
         | 
        
         | 
        
  | 
      
      
        | 28 | 
        
         | 
        
         | 
        public class RubikDialogWhatsNew extends RubikDialogAbstract
  | 
      
      
        | 29 | 
        
         | 
        
         | 
          {
 | 
      
      
        | 30 | 
        
         | 
        
         | 
          private static final String[] MESSAGES =
  | 
      
      
        | 31 | 
        
         | 
        
         | 
              {
 | 
      
      
        | 32 | 
        
            a22a18dd
         | 
        
            Leszek Koltunski
         | 
              "1.12.1",
  | 
      
      
        | 33 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
        
  | 
      
      
        | 34 | 
        
         | 
        
         | 
              "1. This dialog :)\n" +
  | 
      
      
        | 35 | 
        
         | 
        
         | 
              "2. UI ready for NEW SOLVERS\n" +
  | 
      
      
        | 36 | 
        
         | 
        
         | 
              "3. Important fix for a bug which used to let players solve any scramble with just one move\n" +
  | 
      
      
        | 37 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
              "4. Support for curved walls of cubies (preparation for Penrose Cubes)\n" +
  | 
      
      
        | 38 | 
        
         | 
        
         | 
              "5. Support for scrambling algorithms (preparation for AI Cube & Camouflage Cubes)",
  | 
      
      
        | 39 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
        
  | 
      
      
        | 40 | 
        
            45bc9f25
         | 
        
            Leszek Koltunski
         | 
              "1.12.2",
  | 
      
      
        | 41 | 
        
         | 
        
         | 
        
  | 
      
      
        | 42 | 
        
         | 
        
         | 
              "1. Fixes for two critical crashers that appeared in the previous version.",
  | 
      
      
        | 43 | 
        
         | 
        
         | 
        
  | 
      
      
        | 44 | 
        
            52a69ff3
         | 
        
            Leszek Koltunski
         | 
              "1.12.3",
  | 
      
      
        | 45 | 
        
         | 
        
         | 
        
  | 
      
      
        | 46 | 
        
            24414279
         | 
        
            Leszek Koltunski
         | 
              "1. Implement the first two solvers - Pyraminx Duo & Ivy Cube\n" +
  | 
      
      
        | 47 | 
        
            52a69ff3
         | 
        
            Leszek Koltunski
         | 
              "2. Implement AI Cube and Burr Cube\n" +
  | 
      
      
        | 48 | 
        
            24414279
         | 
        
            Leszek Koltunski
         | 
              "3. Many fixes - for Trajber 4x4, touch control, creation of Bandaged Cuboids, scores dialog...\n",
  | 
      
      
        | 49 | 
        
            52a69ff3
         | 
        
            Leszek Koltunski
         | 
        
  | 
      
      
        | 50 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
              "Coming",
  | 
      
      
        | 51 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
        
  | 
      
      
        | 52 | 
        
            24414279
         | 
        
            Leszek Koltunski
         | 
              "1. Implemented Pyraminx, 2x2x3, Skewb, Skewb Diamond solvers.\n" +
  | 
      
      
        | 53 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
              "2. More solvers (2x2x2?)\n" +
  | 
      
      
        | 54 | 
        
         | 
        
         | 
              "2. Support for adjustable stickers.\n" +
  | 
      
      
        | 55 | 
        
         | 
        
         | 
              "3. In-game currency (stars)\n" +
  | 
      
      
        | 56 | 
        
            52a69ff3
         | 
        
            Leszek Koltunski
         | 
              "4. More objects (Penrose Cubes, the Double-Crazy, Ghost Cubes, more Mirrors)"
  | 
      
      
        | 57 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
              };
  | 
      
      
        | 58 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
        
  | 
      
      
        | 59 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 60 | 
        
         | 
        
         | 
        
  | 
      
      
        | 61 | 
        
         | 
        
         | 
          @Override
  | 
      
      
        | 62 | 
        
         | 
        
         | 
          public void onResume()
  | 
      
      
        | 63 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 64 | 
        
         | 
        
         | 
            super.onResume();
  | 
      
      
        | 65 | 
        
         | 
        
         | 
        
  | 
      
      
        | 66 | 
        
         | 
        
         | 
            Window window = getDialog().getWindow();
  | 
      
      
        | 67 | 
        
         | 
        
         | 
        
  | 
      
      
        | 68 | 
        
         | 
        
         | 
            if( window!=null )
  | 
      
      
        | 69 | 
        
         | 
        
         | 
              {
 | 
      
      
        | 70 | 
        
         | 
        
         | 
              WindowManager.LayoutParams params = window.getAttributes();
  | 
      
      
        | 71 | 
        
         | 
        
         | 
              params.width  = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
  | 
      
      
        | 72 | 
        
         | 
        
         | 
              window.setAttributes(params);
  | 
      
      
        | 73 | 
        
         | 
        
         | 
              }
  | 
      
      
        | 74 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 75 | 
        
         | 
        
         | 
        
  | 
      
      
        | 76 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 77 | 
        
         | 
        
         | 
        
  | 
      
      
        | 78 | 
        
         | 
        
         | 
          public int getResource()      { return R.layout.dialog_scrollable_panes; }
 | 
      
      
        | 79 | 
        
         | 
        
         | 
          public int getTitleResource() { return R.string.whatsnew; }
 | 
      
      
        | 80 | 
        
         | 
        
         | 
          public boolean hasArgument()  { return true; }
 | 
      
      
        | 81 | 
        
         | 
        
         | 
          public int getPositive()      { return R.string.ok; }
 | 
      
      
        | 82 | 
        
         | 
        
         | 
          public int getNegative()      { return -1; }
 | 
      
      
        | 83 | 
        
         | 
        
         | 
        
  | 
      
      
        | 84 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 85 | 
        
         | 
        
         | 
        
  | 
      
      
        | 86 | 
        
         | 
        
         | 
          public void positiveAction()
  | 
      
      
        | 87 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 88 | 
        
         | 
        
         | 
        
  | 
      
      
        | 89 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 90 | 
        
         | 
        
         | 
        
  | 
      
      
        | 91 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 92 | 
        
         | 
        
         | 
        
  | 
      
      
        | 93 | 
        
         | 
        
         | 
          public void negativeAction()
  | 
      
      
        | 94 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 95 | 
        
         | 
        
         | 
        
  | 
      
      
        | 96 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 97 | 
        
         | 
        
         | 
        
  | 
      
      
        | 98 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 99 | 
        
         | 
        
         | 
        
  | 
      
      
        | 100 | 
        
         | 
        
         | 
          public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
  | 
      
      
        | 101 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 102 | 
        
         | 
        
         | 
            int margin= (int)(mHeight*0.010f);
  | 
      
      
        | 103 | 
        
         | 
        
         | 
            int titleH= (int)(mHeight*0.035f);
  | 
      
      
        | 104 | 
        
         | 
        
         | 
            int padd  = (int)(mHeight*0.010f);
  | 
      
      
        | 105 | 
        
         | 
        
         | 
        
  | 
      
      
        | 106 | 
        
         | 
        
         | 
            LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
  | 
      
      
        | 107 | 
        
         | 
        
         | 
            TextView text  = view.findViewById(R.id.dialog_scrollable_message);
  | 
      
      
        | 108 | 
        
         | 
        
         | 
            text.setVisibility(View.GONE);
  | 
      
      
        | 109 | 
        
         | 
        
         | 
        
  | 
      
      
        | 110 | 
        
         | 
        
         | 
            LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
  | 
      
      
        | 111 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
            pV.setMargins(margin, margin, margin, 0);
  | 
      
      
        | 112 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
            LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
  | 
      
      
        | 113 | 
        
         | 
        
         | 
            pL.setMargins(margin, margin, margin, margin);
  | 
      
      
        | 114 | 
        
         | 
        
         | 
            LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, titleH );
  | 
      
      
        | 115 | 
        
         | 
        
         | 
            LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
  | 
      
      
        | 116 | 
        
            7b191fe5
         | 
        
            Leszek Koltunski
         | 
            pM.setMargins(0,2*margin,0,0);
  | 
      
      
        | 117 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
        
  | 
      
      
        | 118 | 
        
         | 
        
         | 
            RubikActivity ract = (RubikActivity) getContext();
  | 
      
      
        | 119 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
            int numMessages= MESSAGES.length/2;
  | 
      
      
        | 120 | 
        
         | 
        
         | 
            String thisVersion = findCurrentVersion(ract);
  | 
      
      
        | 121 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
        
  | 
      
      
        | 122 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
            for(int i=0; i<numMessages; i++)
  | 
      
      
        | 123 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
              {
 | 
      
      
        | 124 | 
        
            7bdd481b
         | 
        
            Leszek Koltunski
         | 
              String version = MESSAGES[2*i];
  | 
      
      
        | 125 | 
        
         | 
        
         | 
              String message = MESSAGES[2*i+1];
  | 
      
      
        | 126 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
              boolean isCurrent = version.equals(thisVersion);
  | 
      
      
        | 127 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
        
  | 
      
      
        | 128 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
              RubikDialogWhatsNewView pane = new RubikDialogWhatsNewView(ract,version,message,padd, isCurrent, (i==(numMessages-1) ? pL:pV),pT,pM);
  | 
      
      
        | 129 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
              layout.addView(pane.getView());
  | 
      
      
        | 130 | 
        
         | 
        
         | 
              }
  | 
      
      
        | 131 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 132 | 
        
         | 
        
         | 
        
  | 
      
      
        | 133 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 134 | 
        
         | 
        
         | 
        
  | 
      
      
        | 135 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
          private String findCurrentVersion(RubikActivity act)
  | 
      
      
        | 136 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
            {
 | 
      
      
        | 137 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
            String version;
  | 
      
      
        | 138 | 
        
         | 
        
         | 
            try
  | 
      
      
        | 139 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
              {
 | 
      
      
        | 140 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
              PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
  | 
      
      
        | 141 | 
        
         | 
        
         | 
              version= pInfo.versionName;
  | 
      
      
        | 142 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
              }
  | 
      
      
        | 143 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
            catch (PackageManager.NameNotFoundException e)
  | 
      
      
        | 144 | 
        
         | 
        
         | 
              {
 | 
      
      
        | 145 | 
        
         | 
        
         | 
              version= "unknown";
  | 
      
      
        | 146 | 
        
         | 
        
         | 
              }
  | 
      
      
        | 147 | 
        
         | 
        
         | 
        
  | 
      
      
        | 148 | 
        
         | 
        
         | 
            return version;
  | 
      
      
        | 149 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
            }
  | 
      
      
        | 150 | 
        
         | 
        
         | 
        
  | 
      
      
        | 151 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 152 | 
        
         | 
        
         | 
        
  | 
      
      
        | 153 | 
        
         | 
        
         | 
          private int findVersion(String version)
  | 
      
      
        | 154 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 155 | 
        
         | 
        
         | 
            int len = MESSAGES.length;
  | 
      
      
        | 156 | 
        
         | 
        
         | 
        
  | 
      
      
        | 157 | 
        
         | 
        
         | 
            for(int i=0; i<len; i++)
  | 
      
      
        | 158 | 
        
         | 
        
         | 
              {
 | 
      
      
        | 159 | 
        
         | 
        
         | 
              if( MESSAGES[i].equals(version) ) return i;
  | 
      
      
        | 160 | 
        
         | 
        
         | 
              }
  | 
      
      
        | 161 | 
        
         | 
        
         | 
        
  | 
      
      
        | 162 | 
        
            34d6b123
         | 
        
            Leszek Koltunski
         | 
            return 0;
  | 
      
      
        | 163 | 
        
            1c89e2a7
         | 
        
            Leszek Koltunski
         | 
            }
  | 
      
      
        | 164 | 
        
         | 
        
         | 
        
  | 
      
      
        | 165 | 
        
         | 
        
         | 
        ///////////////////////////////////////////////////////////////////////////////////////////////////
  | 
      
      
        | 166 | 
        
         | 
        
         | 
        
  | 
      
      
        | 167 | 
        
         | 
        
         | 
          public static String getDialogTag()
  | 
      
      
        | 168 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 169 | 
        
         | 
        
         | 
            return "DialogSolvers";
  | 
      
      
        | 170 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 171 | 
        
         | 
        
         | 
          }
  |