Project

General

Profile

Download (19.9 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / solvers / ScreenSetupPosition.java @ c2025412

1 cb30e768 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2023 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 7e9d918b leszek
package org.distorted.solvers;
11 cb30e768 leszek
12 f4b24b79 leszek
import static org.distorted.objectlib.metadata.ListObjects.*;
13
14 cb30e768 leszek
import android.content.SharedPreferences;
15
import android.graphics.Bitmap;
16
import android.graphics.Canvas;
17
import android.graphics.Paint;
18
import android.graphics.PorterDuff;
19
import android.graphics.drawable.Drawable;
20
import android.os.Bundle;
21
import android.view.View;
22
import android.widget.ImageButton;
23
import android.widget.LinearLayout;
24
25
import androidx.core.content.ContextCompat;
26 50bb18a1 leszek
import androidx.fragment.app.FragmentManager;
27 cb30e768 leszek
28 50bb18a1 leszek
import org.distorted.dialogs.DialogInterrupt;
29 8477cf44 leszek
import org.distorted.dialogs.DialogSolverError;
30
import org.distorted.dialogs.DialogSolverImpossible;
31
import org.distorted.dialogs.DialogSolvers;
32 cb30e768 leszek
import org.distorted.helpers.TransparentImageButton;
33
import org.distorted.main.MainActivity;
34
import org.distorted.main.R;
35 2f53a016 leszek
import org.distorted.objectlib.helpers.OperatingSystemInterface;
36 cb30e768 leszek
import org.distorted.objectlib.main.ObjectControl;
37
import org.distorted.objectlib.main.TwistyObject;
38 3bedda30 leszek
import org.distorted.objectlib.metadata.ListObjects;
39 f4b24b79 leszek
import org.distorted.objectlib.shape.*;
40 94ce8e53 leszek
import org.distorted.objectlib.solvers.verifiers.ResultScreen;
41
import org.distorted.objectlib.solvers.verifiers.SolverAbstract;
42 3a768e35 leszek
import org.distorted.objectlib.solvers.verifiers.ImplementedVerifierList;
43 cb30e768 leszek
44
import java.lang.ref.WeakReference;
45 50bb18a1 leszek
import java.util.Timer;
46
import java.util.TimerTask;
47 cb30e768 leszek
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49
50 a742d66b leszek
public class ScreenSetupPosition extends ScreenAbstract implements ResultScreen
51 cb30e768 leszek
  {
52
  private static final int RESET_DURATION = 1000;
53
  private static final int MODE_NORMAL = 0;
54
  private static final int MODE_DINO_4 = 1;
55
56
  private static Bitmap[] mBitmap;
57
  private ImageButton[] mColorButton;
58
  private TransparentImageButton mResetButton,mBackButton, mSolveButton;
59
  private boolean mSolving;
60
  private int mCurrentColor, mCurrentButton;
61
  private int[] mFaceColors;
62
  private int mColorMode;
63
  private int mNumColors;
64 a742d66b leszek
  private int mNumBitmapRows;
65 cb30e768 leszek
  private float mBitmapSize;
66
  private WeakReference<SolverActivity> mWeakAct;
67 7464b393 leszek
  private int mObjectOrdinal;
68 94ce8e53 leszek
  private String[] mPhaseNames;
69 50bb18a1 leszek
  private Timer mTimer;
70
  private SolverAbstract mSolver;
71 cb30e768 leszek
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73
74
  void leaveScreen(SolverActivity act)
75
    {
76
    ObjectControl control = act.getControl();
77
    control.unsetLock();
78
    }
79
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81
82
  void enterScreen(final SolverActivity act)
83
    {
84
    ObjectControl control = act.getControl();
85
    control.setLock(false);
86
87
    float width = act.getScreenWidthInPixels();
88
    float heigh = act.getScreenHeightInPixels();
89
90
    mWeakAct = new WeakReference<>(act);
91
    mSolving = false;
92 94ce8e53 leszek
    mPhaseNames = null;
93 cb30e768 leszek
94 7464b393 leszek
    mObjectOrdinal = act.getObjectOrdinal();
95 cb30e768 leszek
    control.solveOnly();
96 7464b393 leszek
    generateFaceColors(mObjectOrdinal);
97 cb30e768 leszek
98 a742d66b leszek
    mNumBitmapRows = mNumColors>8 ? 2 : 1;
99
    mBitmapSize = computeBitmapSize(width,heigh);
100 cb30e768 leszek
101
    // TOP ////////////////////////////
102
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
103
    layoutTop.removeAllViews();
104
105
    if( mNumColors>0 )
106
      {
107
      setupBitmaps();
108 a742d66b leszek
      setupColorButtons(act);
109 cb30e768 leszek
      markButton(act);
110 a742d66b leszek
      addButtonsToTopLayout(act,layoutTop);
111 cb30e768 leszek
      }
112
113
    // BOT ////////////////////////////
114
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
115
116
    LinearLayout layoutL = new LinearLayout(act);
117
    layoutL.setLayoutParams(params);
118
    LinearLayout layoutM = new LinearLayout(act);
119
    layoutM.setLayoutParams(params);
120
    LinearLayout layoutR = new LinearLayout(act);
121
    layoutR.setLayoutParams(params);
122
123
    LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
124
    layoutBot.removeAllViews();
125
126
    setupResetButton(act);
127
    setupSolveButton(act);
128
    setupBackButton(act);
129
130
    layoutL.addView(mResetButton);
131
    layoutM.addView(mSolveButton);
132
    layoutR.addView(mBackButton);
133
134
    layoutBot.addView(layoutL);
135
    layoutBot.addView(layoutM);
136
    layoutBot.addView(layoutR);
137
    }
138
139 a742d66b leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
140
141
  private float computeBitmapSize(float width, float heigh)
142
    {
143
    final float BUTTON_RATIO = 0.75f;
144
    float sizeV = (heigh/mNumBitmapRows)*MainActivity.RATIO_BAR;
145
    float sizeH = (width*mNumBitmapRows)/mNumColors;
146
147
    return BUTTON_RATIO*Math.min(sizeV,sizeH);
148
    }
149
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151
152
  private void addButtonsToTopLayout(SolverActivity act, LinearLayout layout)
153
    {
154
    if( mNumBitmapRows==1 )
155
      {
156
      for(ImageButton button: mColorButton) layout.addView(button);
157
      }
158
    else if( mNumBitmapRows==2 )
159
      {
160
      LinearLayout layoutV = new LinearLayout(act);
161
      layoutV.setOrientation(LinearLayout.VERTICAL);
162
      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
163
      layoutV.setLayoutParams(params);
164
      LinearLayout layoutT = new LinearLayout(act);
165
      layoutT.setOrientation(LinearLayout.HORIZONTAL);
166
      LinearLayout layoutB = new LinearLayout(act);
167
      layoutB.setOrientation(LinearLayout.HORIZONTAL);
168
169
      int numB = mColorButton.length;
170
      for(int b=0     ; b<numB/2; b++) layoutT.addView(mColorButton[b]);
171
      for(int b=numB/2; b<numB  ; b++) layoutB.addView(mColorButton[b]);
172
173
      layoutV.addView(layoutT);
174
      layoutV.addView(layoutB);
175
      layout.addView(layoutV);
176
      }
177
    }
178
179 cb30e768 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
180
// This doesn't quite work in many cases, but in case of the solvers that will pop up in foreseeable
181
// future it should be ok.
182
183
  public void generateFaceColors(int object)
184
    {
185
    mColorMode = MODE_NORMAL;
186
187 f4b24b79 leszek
    if( object==PYRA_3.ordinal() ||
188
        object==PYRA_4.ordinal() ||
189
        object==PYRA_5.ordinal() ||
190
        object==PDUO_2.ordinal() ||
191
        object==JING_2.ordinal() ||
192
        object==MORP_2.ordinal() ||
193
        object==MORP_3.ordinal() ||
194
        object==MORP_4.ordinal()  )
195 cb30e768 leszek
      {
196
      mNumColors  = ShapeTetrahedron.NUM_FACES;
197
      mFaceColors = ShapeTetrahedron.FACE_COLORS;
198
      }
199 f4b24b79 leszek
    else if( object==DIAM_2.ordinal() ||
200
             object==DIAM_3.ordinal() ||
201
             object==DIAM_4.ordinal() ||
202
             object==TRAJ_3.ordinal() ||
203
             object==TRAJ_4.ordinal() ||
204
             object==PDIA_3.ordinal()  )
205 cb30e768 leszek
      {
206
      mNumColors  = ShapeOctahedron.NUM_FACES;
207
      mFaceColors = ShapeOctahedron.FACE_COLORS;
208
      }
209 f4b24b79 leszek
    else if( object==CRYS_3.ordinal() ||
210
             object==STAR_3.ordinal() ||
211
             object==PENT_2.ordinal() ||
212
             object==KILO_3.ordinal() ||
213
             object==KILO_5.ordinal() ||
214
             object==MEGA_3.ordinal() ||
215
             object==MEGA_5.ordinal()  )
216 cb30e768 leszek
      {
217
      mNumColors  = ShapeDodecahedron.NUM_FACES;
218
      mFaceColors = ShapeDodecahedron.FACE_COLORS;
219
      }
220 f4b24b79 leszek
    else if( object==BALL_4.ordinal() )
221 cb30e768 leszek
      {
222
      mNumColors  = ShapeDiamond.NUM_FACES;
223
      mFaceColors = ShapeDiamond.FACE_COLORS;
224
      }
225 f4b24b79 leszek
    else if( object==ICOS_2.ordinal() )
226 cb30e768 leszek
      {
227
      mNumColors  = ShapeIcosahedron.NUM_FACES;
228
      mFaceColors = ShapeIcosahedron.FACE_COLORS;
229
      }
230 f4b24b79 leszek
    else if( object==DIN4_3.ordinal() )
231 cb30e768 leszek
      {
232
      mNumColors  = 4;
233 99c2e327 leszek
      mFaceColors = new int[] { ShapeColors.COLOR_YELLOW, ShapeColors.COLOR_RED, ShapeColors.COLOR_BLUE, ShapeColors.COLOR_WHITE};
234 cb30e768 leszek
      mColorMode  = MODE_DINO_4;
235
      }
236
    else
237
      {
238
      mNumColors  = ShapeHexahedron.NUM_FACES;
239
      mFaceColors = ShapeHexahedron.FACE_COLORS;
240
      }
241
    }
242
243
///////////////////////////////////////////////////////////////////////////////////////////////////
244
245
  private void setupBitmaps()
246
    {
247
    final int SIZE = (int)mBitmapSize;
248
    final float R = SIZE*0.15f;
249
    final float M = SIZE*0.08f;
250
251
    mBitmap = new Bitmap[mNumColors];
252
253
    Paint paint = new Paint();
254
    paint.setColor(0xff008800);
255
    paint.setStyle(Paint.Style.FILL);
256
257
    paint.setAntiAlias(true);
258
    paint.setTextAlign(Paint.Align.CENTER);
259
    paint.setStyle(Paint.Style.FILL);
260
261
    for(int i=0; i<mNumColors; i++)
262
      {
263
      mBitmap[i] = Bitmap.createBitmap(SIZE, SIZE, Bitmap.Config.ARGB_8888);
264
      Canvas canvas = new Canvas(mBitmap[i]);
265
266
      paint.setColor(0xff000000);
267
      canvas.drawRect(0, 0, SIZE, SIZE, paint);
268
269
      paint.setColor(mFaceColors[i]);
270
      canvas.drawRoundRect( M, M, SIZE-M, SIZE-M, R, R, paint);
271
      }
272
    }
273
274
///////////////////////////////////////////////////////////////////////////////////////////////////
275
276
  private int translateColor(int color)
277
    {
278
    if( mColorMode==MODE_DINO_4 )
279
      {
280
      int realColor = mFaceColors[color];
281
      int[] hexColors = ShapeHexahedron.FACE_COLORS;
282
283
      for(int i=0; i<6; i++)
284
        if( hexColors[i]==realColor ) return i;
285
      }
286
287
    return color;
288
    }
289
290 7464b393 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
291
292 50bb18a1 leszek
  private void pressSolve(SolverActivity act)
293 7464b393 leszek
    {
294 3a768e35 leszek
    int[] solverOrdinals = ImplementedVerifierList.getSolverOrdinals(mObjectOrdinal);
295 7464b393 leszek
296
    if( solverOrdinals!=null  )
297
      {
298 3a768e35 leszek
      ImplementedVerifierList slvList = ImplementedVerifierList.getSolver(solverOrdinals[0]);
299 3c39a2a0 leszek
      OperatingSystemInterface os = act.getInterface();
300
      TwistyObject object = act.getObject();
301
      SolverAbstract solver = slvList.create(os,object);
302 7464b393 leszek
303 3c39a2a0 leszek
      if( solver!=null )
304 7464b393 leszek
        {
305 3c39a2a0 leszek
        int[] result = solver.validatePosition(object);
306 94ce8e53 leszek
307 d00b5346 leszek
        if( result[0]>=0 ) // position is valid
308 94ce8e53 leszek
          {
309 3c39a2a0 leszek
          if( solverOrdinals.length==1 ) // just one solver - simply launch it
310
            {
311 50bb18a1 leszek
            mSolver = solver;
312 3c39a2a0 leszek
            solver.solve(this,result);
313
            }
314
          else // more than one solver - pop up a choosing dialog
315
            {
316
            ListObjects objList = ListObjects.getObject(mObjectOrdinal);
317
            String upperName = objList.name();
318
            Bundle bundle = new Bundle();
319
            bundle.putString("argument", upperName );
320 50bb18a1 leszek
            DialogSolvers dialog = new DialogSolvers();
321
            dialog.setArguments(bundle);
322
            dialog.show( act.getSupportFragmentManager(), DialogSolvers.getDialogTag());
323 3c39a2a0 leszek
            }
324
          }
325 50bb18a1 leszek
        else displayImpossibleDialog(result,solver.getFaceColors());
326 7464b393 leszek
        }
327 50bb18a1 leszek
      else displayErrorDialog(act.getString(R.string.solver_generic_not_implemented));
328 7464b393 leszek
      }
329 50bb18a1 leszek
    else displayErrorDialog("No solvers found for object "+mObjectOrdinal);
330 7464b393 leszek
    }
331
332 94ce8e53 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
333
334
  public void fail(String result) {}
335
  public void setPhaseNames(String[] names) { mPhaseNames = names; }
336
337 50bb18a1 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
338
339
  void setSolver(SolverAbstract solver )
340
    {
341
    mSolver = solver;
342
    }
343
344 32126daa leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
345
346
  public void startedSolving()
347
    {
348 50bb18a1 leszek
    if( !mSolving )
349
      {
350
      mSolving = true;
351
      mTimer = new Timer();
352 32126daa leszek
353 50bb18a1 leszek
      mTimer.schedule(new TimerTask()
354
        {
355
        @Override
356
        public void run()
357
          {
358
          if( mSolving ) showInterruptDialog();
359
          }
360
        }, 2000);
361
      }
362 32126daa leszek
    }
363
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365
366
  public void stoppedSolving()
367
    {
368 50bb18a1 leszek
    mSolving = false;
369
370
    if( mTimer!=null )
371
      {
372
      mTimer.cancel();
373
      mTimer = null;
374
      }
375 32126daa leszek
376 50bb18a1 leszek
    final SolverActivity act = mWeakAct.get();
377
    FragmentManager mana = act.getSupportFragmentManager();
378
    DialogInterrupt diag = (DialogInterrupt) mana.findFragmentByTag(DialogInterrupt.getDialogTag());
379
380
    if( diag!=null ) diag.dismiss();
381 32126daa leszek
    }
382
383 50bb18a1 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
384
385
  void interrupt()
386
    {
387
    final SolverActivity act = mWeakAct.get();
388
    FragmentManager mana = act.getSupportFragmentManager();
389
    DialogInterrupt diag = (DialogInterrupt) mana.findFragmentByTag(DialogInterrupt.getDialogTag());
390
391
    if( diag!=null ) diag.dismiss();
392
393
    if( mSolver!=null ) mSolver.interrupt();
394
    }
395
396
///////////////////////////////////////////////////////////////////////////////////////////////////
397
398
    private void showInterruptDialog()
399
      {
400
      final SolverActivity act = mWeakAct.get();
401
402
      act.runOnUiThread(new Runnable()
403
        {
404
        @Override
405
        public void run()
406
          {
407
          DialogInterrupt dialog = new DialogInterrupt();
408
          dialog.show(act.getSupportFragmentManager(), null );
409
          }
410
        });
411
      }
412
413 cb30e768 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
414
415 a742d66b leszek
  private void setupColorButtons(final SolverActivity act)
416 cb30e768 leszek
    {
417
    mColorButton = new ImageButton[mNumColors];
418
419
    for(int i=0; i<mNumColors; i++)
420
      {
421
      final int ii = i;
422
      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.0f);
423
424
      mColorButton[i] = new ImageButton(act);
425
      mColorButton[i].setLayoutParams(params);
426
      mColorButton[i].setImageBitmap(mBitmap[i]);
427
428
      mColorButton[i].setOnClickListener( new View.OnClickListener()
429
        {
430
        @Override
431
        public void onClick(View view)
432
          {
433
          mCurrentColor = translateColor(ii);
434
          mCurrentButton= ii;
435
          markButton(act);
436
          }
437
        });
438
      }
439
    }
440
441
///////////////////////////////////////////////////////////////////////////////////////////////////
442
443
  private void setupResetButton(final SolverActivity act)
444
    {
445
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
446
    mResetButton = new TransparentImageButton(act, R.drawable.ui_reset, params);
447
448
    mResetButton.setOnClickListener( new View.OnClickListener()
449
      {
450
      @Override
451
      public void onClick(View v)
452
        {
453
        ObjectControl control = act.getControl();
454
        control.resetTextureMapsEffect(RESET_DURATION);
455
        }
456
      });
457
    }
458
459
///////////////////////////////////////////////////////////////////////////////////////////////////
460
461
  private void setupSolveButton(final SolverActivity act)
462
    {
463
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
464
    mSolveButton = new TransparentImageButton(act,R.drawable.ui_solve,params);
465
466
    mSolveButton.setOnClickListener( new View.OnClickListener()
467
      {
468
      @Override
469
      public void onClick(View v)
470
        {
471 50bb18a1 leszek
        if( !mSolving ) pressSolve(act);
472 cb30e768 leszek
        }
473
      });
474
    }
475
476
///////////////////////////////////////////////////////////////////////////////////////////////////
477
478
  private void setupBackButton(final SolverActivity act)
479
    {
480
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
481
    mBackButton = new TransparentImageButton(act,R.drawable.ui_back,params);
482
483
    mBackButton.setOnClickListener( new View.OnClickListener()
484
      {
485
      @Override
486
      public void onClick(View v)
487
        {
488
        ObjectControl control = act.getControl();
489
        control.resetAllTextureMaps();
490
        ScreenList.goBack(act);
491
        }
492
      });
493
    }
494
495
///////////////////////////////////////////////////////////////////////////////////////////////////
496
497
  private void markButton(SolverActivity act)
498
    {
499
    if( mCurrentButton>=mNumColors )
500
      {
501
      mCurrentButton = 0;
502
      mCurrentColor = translateColor(0);
503
      }
504
505
    for(int b=0; b<mNumColors; b++)
506
      {
507
      Drawable d = mColorButton[b].getBackground();
508 0a9adc31 leszek
      int s = b==mCurrentButton ? act.getSelectedColor() : act.getNormalColor();
509
      d.setColorFilter(ContextCompat.getColor(act,s), PorterDuff.Mode.MULTIPLY);
510 cb30e768 leszek
      }
511
    }
512
513
///////////////////////////////////////////////////////////////////////////////////////////////////
514
515
  public void savePreferences(SharedPreferences.Editor editor)
516
    {
517
    editor.putInt("stateSolver_color" , mCurrentColor );
518
    editor.putInt("stateSolver_button", mCurrentButton);
519
    }
520
521
///////////////////////////////////////////////////////////////////////////////////////////////////
522
523
  public void restorePreferences(SharedPreferences preferences)
524
    {
525
    mCurrentColor = preferences.getInt("stateSolver_color" , 0);
526
    mCurrentButton= preferences.getInt("stateSolver_button", 0);
527
    }
528
529
///////////////////////////////////////////////////////////////////////////////////////////////////
530
531
  public int getCurrentColor()
532
    {
533
    return mCurrentColor;
534
    }
535
536
///////////////////////////////////////////////////////////////////////////////////////////////////
537
538 94ce8e53 leszek
  public void setSolved(final int[][] moves, final int phaseNumber, final int[][] subphases)
539 cb30e768 leszek
    {
540
    final SolverActivity act = mWeakAct.get();
541
542
    if( act!=null )
543
      {
544
      act.runOnUiThread(new Runnable()
545
        {
546
        @Override
547
        public void run()
548
          {
549 94ce8e53 leszek
          if( mPhaseNames!=null )
550
            {
551 a742d66b leszek
            ScreenSolutionMultiphased screen = (ScreenSolutionMultiphased) ScreenList.PHAS.getScreenClass();
552 94ce8e53 leszek
            if( phaseNumber==0 )
553
              {
554
              ScreenList.switchScreen(act, ScreenList.PHAS);
555
              screen.updateNames(mPhaseNames);
556
              }
557
            screen.setSolution(moves, phaseNumber,subphases);
558
            }
559
          else
560
            {
561
            ScreenList.switchScreen(act, ScreenList.SOLU);
562 a742d66b leszek
            ScreenSolutionSinglephased screen = (ScreenSolutionSinglephased) ScreenList.SOLU.getScreenClass();
563 94ce8e53 leszek
            screen.setSolution(moves);
564
            }
565
566 e1637420 leszek
          if( moves!=null && moves.length>0 ) act.doNotShowDialogAnymore();
567 cb30e768 leszek
          }
568
        });
569
      }
570
    }
571
572 2f53a016 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
573
574 94ce8e53 leszek
  public void displayErrorDialog(String message)
575 2f53a016 leszek
    {
576 94ce8e53 leszek
    SolverActivity act = mWeakAct.get();
577 2f53a016 leszek
578
    if( act!=null )
579
      {
580 8477cf44 leszek
      DialogSolverError dialog = new DialogSolverError();
581 94ce8e53 leszek
      Bundle bundle = new Bundle();
582
      bundle.putString("argument", message );
583
      dialog.setArguments(bundle);
584
      dialog.show( act.getSupportFragmentManager(), null);
585 2f53a016 leszek
      }
586
    }
587
588 cb30e768 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
589
590 94ce8e53 leszek
  public void displayImpossibleDialog(String message)
591 cb30e768 leszek
    {
592
    SolverActivity act = mWeakAct.get();
593
594
    if( act!=null )
595
      {
596 8477cf44 leszek
      DialogSolverImpossible dialog = new DialogSolverImpossible();
597 cb30e768 leszek
      Bundle bundle = new Bundle();
598
      bundle.putString("argument", message );
599
      dialog.setArguments(bundle);
600
      dialog.show( act.getSupportFragmentManager(), null);
601
      }
602
    }
603
604
///////////////////////////////////////////////////////////////////////////////////////////////////
605
606 94ce8e53 leszek
  public void displayImpossibleDialog(int[] errorCode, int[] faceColors)
607 cb30e768 leszek
    {
608
    SolverActivity act = mWeakAct.get();
609
610
    if( act!=null )
611
      {
612 50bb18a1 leszek
      String message = SolverErrors.error(act.getResources(),errorCode,faceColors);
613 94ce8e53 leszek
      displayImpossibleDialog(message);
614
      }
615
    }
616 cb30e768 leszek
  }