Project

General

Profile

« Previous | Next » 

Revision e1637420

Added by Leszek Koltunski 8 months ago

3 message dialogs.

View differences:

src/main/java/org/distorted/bandaged/BandagedActivity.java
29 29
import androidx.preference.PreferenceManager;
30 30

  
31 31
import org.distorted.dialogs.RubikDialogError;
32
import org.distorted.dialogs.RubikDialogMessage;
32 33
import org.distorted.external.RubikFiles;
33 34
import org.distorted.library.main.DistortedLibrary;
34 35
import org.distorted.main.MainActivity;
......
58 59
    private BandagedScreen mScreen;
59 60
    private boolean mRTL;
60 61
    private int mObjectOrdinal;
62
    private boolean mDisplayMessageDialog;
61 63

  
62 64
///////////////////////////////////////////////////////////////////////////////////////////////////
63 65

  
......
78 80
      mScreenWidth =displaymetrics.widthPixels;
79 81
      mScreenHeight=displaymetrics.heightPixels;
80 82

  
83
      mDisplayMessageDialog = true;
84

  
81 85
      final Configuration config = getResources().getConfiguration();
82 86
      final int layoutDirection = config.getLayoutDirection();
83 87
      mRTL = layoutDirection==LAYOUT_DIRECTION_RTL;
......
230 234
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
231 235
      SharedPreferences.Editor editor = preferences.edit();
232 236
      mScreen.savePreferences(editor);
237

  
238
      editor.putBoolean("bandageDisplayDialog", mDisplayMessageDialog );
239

  
233 240
      editor.apply();
234 241
      }
235 242

  
......
239 246
      {
240 247
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
241 248
      mScreen.restorePreferences(this,preferences);
249

  
250
      mDisplayMessageDialog = preferences.getBoolean("bandageDisplayDialog",true);
251

  
252
      if( mDisplayMessageDialog )
253
        {
254
        Bundle bundle = new Bundle();
255
        bundle.putString("argument", getString(R.string.bandage_message) );
256
        RubikDialogMessage diag = new RubikDialogMessage();
257
        diag.setArguments(bundle);
258
        diag.show( getSupportFragmentManager(), RubikDialogMessage.getDialogTag() );
259
        }
260
      }
261

  
262
///////////////////////////////////////////////////////////////////////////////////////////////////
263

  
264
    void doNotShowDialogAnymore()
265
      {
266
      mDisplayMessageDialog = false;
242 267
      }
243 268

  
244 269
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/bandaged/BandagedRenderer.java
290 290
       {
291 291
       setupIconCreation(act);
292 292
       act.addObject(obj.getShortName());
293
       act.doNotShowDialogAnymore();
293 294
       }
294 295
     }
295 296

  
src/main/java/org/distorted/config/ConfigActivity.java
22 22
import androidx.preference.PreferenceManager;
23 23

  
24 24
import org.distorted.dialogs.RubikDialogError;
25
import org.distorted.dialogs.RubikDialogMessage;
25 26
import org.distorted.library.main.DistortedLibrary;
26 27
import org.distorted.main.MainActivity;
27 28
import org.distorted.main.R;
......
48 49
    private int mCurrentApiVersion;
49 50
    private int mObjectOrdinal;
50 51
    private boolean mSupportsAdjColors;
52
    private boolean mDisplayMessageDialog;
51 53

  
52 54
///////////////////////////////////////////////////////////////////////////////////////////////////
53 55

  
......
60 62
      setContentView(R.layout.config);
61 63

  
62 64
      Bundle b = getIntent().getExtras();
63

  
64 65
      if(b != null) mObjectOrdinal = b.getInt("obj");
65 66

  
67
      mDisplayMessageDialog = true;
68

  
66 69
      DisplayMetrics displaymetrics = new DisplayMetrics();
67 70
      getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics);
68 71
      mScreenWidth =displaymetrics.widthPixels;
......
175 178
      OSInterface os = view.getInterface();
176 179
      os.setPreferences(preferences);
177 180

  
178
      restorePreferences();
181
      restorePreferences(preferences);
179 182

  
180 183
      if( mScreen==null ) mScreen = new ConfigScreen();
181 184
      mScreen.onAttachedToWindow(this,mObjectOrdinal);
......
193 196
        ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
194 197
        ObjectControl control = view.getObjectControl();
195 198
        control.repaintPuzzleFace(cubit,face,color);
199
        mDisplayMessageDialog = false;
196 200
        }
197 201
      }
198 202

  
......
240 244
      os.setEditor(editor);
241 245
      view.getObjectControl().savePreferences();
242 246

  
247
      editor.putBoolean("configDisplayDialog", mDisplayMessageDialog );
248

  
243 249
      editor.apply();
244 250
      }
245 251

  
246 252
///////////////////////////////////////////////////////////////////////////////////////////////////
247 253

  
248
    private void restorePreferences()
254
    private void restorePreferences(SharedPreferences preferences)
249 255
      {
250 256
      ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
251 257
      view.getObjectControl().restoreStickers();
258

  
259
      mDisplayMessageDialog = preferences.getBoolean("configDisplayDialog",true);
260

  
261
      if( mDisplayMessageDialog )
262
        {
263
        Bundle bundle = new Bundle();
264
        bundle.putString("argument", getString(R.string.config_message) );
265
        RubikDialogMessage diag = new RubikDialogMessage();
266
        diag.setArguments(bundle);
267
        diag.show( getSupportFragmentManager(), RubikDialogMessage.getDialogTag() );
268
        }
252 269
      }
253 270

  
254 271
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogAbandon.java
11 11

  
12 12
import android.app.Dialog;
13 13
import android.view.View;
14
import android.widget.TextView;
14 15

  
15 16
import androidx.fragment.app.FragmentActivity;
16 17

  
......
22 23

  
23 24
public class RubikDialogAbandon extends RubikDialogAbstract
24 25
  {
25
  public int getResource()      { return R.layout.abandon_solve; }
26
  public int getResource()      { return R.layout.dialog_message; }
26 27
  public int getTitleResource() { return -1; }
27 28
  public boolean hasArgument()  { return false; }
28 29
  public int getPositive()      { return R.string.yes; }
29 30
  public int getNegative()      { return R.string.no; }
30 31
  public void negativeAction()  { }
31
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) { }
32 32

  
33 33
///////////////////////////////////////////////////////////////////////////////////////////////////
34 34

  
......
37 37
    final PlayActivity act = (PlayActivity)getContext();
38 38
    ScreenList.goBack(act);
39 39
    }
40

  
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

  
43
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
44
    {
45
    TextView mess = view.findViewById(R.id.dialog_message);
46
    mess.setText(R.string.abandon_solve);
47
    }
40 48
  }
src/main/java/org/distorted/dialogs/RubikDialogBandagedDelete.java
28 28
  public boolean hasArgument()  { return true; }
29 29
  public int getPositive()      { return R.string.yes; }
30 30
  public int getNegative()      { return R.string.no; }
31
  public void negativeAction()  { }
31 32

  
32 33
///////////////////////////////////////////////////////////////////////////////////////////////////
33 34

  
......
37 38
    if( bact!=null ) bact.deleteObject(mArgument);
38 39
    }
39 40

  
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

  
42
  public void negativeAction()
43
    {
44

  
45
    }
46

  
47 41
///////////////////////////////////////////////////////////////////////////////////////////////////
48 42

  
49 43
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
src/main/java/org/distorted/dialogs/RubikDialogMessage.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2024 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
import android.view.View;
14
import android.widget.TextView;
15

  
16
import androidx.fragment.app.FragmentActivity;
17

  
18
import org.distorted.main.R;
19

  
20
///////////////////////////////////////////////////////////////////////////////////////////////////
21

  
22
public class RubikDialogMessage extends RubikDialogAbstract
23
  {
24
  public int getResource()      { return R.layout.dialog_message; }
25
  public int getTitleResource() { return -1; }
26
  public boolean hasArgument()  { return true; }
27
  public int getPositive()      { return R.string.ok; }
28
  public int getNegative()      { return -1; }
29
  public void negativeAction()  { }
30
  public void positiveAction()  { }
31

  
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

  
34
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
35
    {
36
    TextView mess = view.findViewById(R.id.dialog_message);
37
    mess.setText(mArgument);
38
    }
39

  
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

  
42
  public static String getDialogTag()
43
    {
44
    return "DialogBandageMessage";
45
    }
46
  }
src/main/java/org/distorted/main/MainActivity.java
473 473
      int vw = v.getWidth();
474 474

  
475 475
      MainSettingsPopup popup = new MainSettingsPopup(this,mSortMode,mScreenWidth,mScreenHeight);
476
      popup.displayPopup(this,v,sw,sh,(int)((vw-sw)/2),0);
476
      popup.displayPopup(this,v,sw,sh,((vw-sw)/2),0);
477 477
      }
478 478

  
479 479
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/solverui/ScreenSolver.java
426 426
          ScreenList.switchScreen(act, ScreenList.SOLU);
427 427
          ScreenSolution solution = (ScreenSolution) ScreenList.SOLU.getScreenClass();
428 428
          solution.setupMoves(act, moves);
429
          if( moves.length()>0 ) act.doNotShowDialogAnymore();
429 430
          }
430 431
        });
431 432
      }
......
448 449
          ScreenList.switchScreen(act, ScreenList.SOLU);
449 450
          ScreenSolution solution = (ScreenSolution) ScreenList.SOLU.getScreenClass();
450 451
          solution.setupMoves(act, moves);
452
          if( moves!=null && moves.length>0 ) act.doNotShowDialogAnymore();
451 453
          }
452 454
        });
453 455
      }
src/main/java/org/distorted/solverui/SolverActivity.java
23 23
import androidx.preference.PreferenceManager;
24 24

  
25 25
import org.distorted.dialogs.RubikDialogError;
26
import org.distorted.dialogs.RubikDialogMessage;
26 27
import org.distorted.library.main.DistortedLibrary;
27 28
import org.distorted.library.main.DistortedScreen;
28 29
import org.distorted.main.MainActivity;
......
56 57
    private int mHeightUpperBar;
57 58
    private int mSolverOrdinal;
58 59
    private int mObjectOrdinal;
60
    private boolean mDisplayMessageDialog;
59 61

  
60 62
///////////////////////////////////////////////////////////////////////////////////////////////////
61 63

  
......
77 79
      mScreenWidth =displaymetrics.widthPixels;
78 80
      mScreenHeight=displaymetrics.heightPixels;
79 81

  
82
      mDisplayMessageDialog = true;
83

  
80 84
      cutoutHack();
81 85
      computeBarHeights();
82 86
      }
......
222 226

  
223 227
      ScreenList.savePreferences(editor);
224 228

  
229
      editor.putBoolean("solverDisplayDialog", mDisplayMessageDialog );
230

  
225 231
      boolean success = editor.commit();
226 232
      if( !success ) android.util.Log.e("D", "Failed to save preferences");
227 233
      }
......
236 242
        }
237 243

  
238 244
      ScreenList.restorePreferences(preferences);
245

  
246
      mDisplayMessageDialog = preferences.getBoolean("solverDisplayDialog",true);
247

  
248
      if( mDisplayMessageDialog )
249
        {
250
        Bundle bundle = new Bundle();
251
        bundle.putString("argument", getString(R.string.solver_message) );
252
        RubikDialogMessage diag = new RubikDialogMessage();
253
        diag.setArguments(bundle);
254
        diag.show( getSupportFragmentManager(), RubikDialogMessage.getDialogTag() );
255
        }
256
      }
257

  
258
///////////////////////////////////////////////////////////////////////////////////////////////////
259

  
260
    void doNotShowDialogAnymore()
261
      {
262
      mDisplayMessageDialog = false;
239 263
      }
240 264

  
241 265
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/res/layout/abandon_solve.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="fill_parent"
4
    android:layout_height="fill_parent"
5
    android:layout_marginLeft="10dp"
6
    android:layout_marginTop="0dp"
7
    android:layout_marginRight="10dp"
8
    android:background="@color/grey"
9
    android:gravity="center|fill_horizontal">
10

  
11
    <TextView
12
        android:id="@+id/privacy_string"
13
        android:layout_width="match_parent"
14
        android:layout_height="match_parent"
15
        android:layout_marginLeft="10dp"
16
        android:layout_marginTop="10dp"
17
        android:layout_marginRight="10dp"
18
        android:layout_marginBottom="10dp"
19
        android:gravity="center"
20
        android:text="@string/abandon_solve"
21
        android:textSize="24sp" />
22
</LinearLayout>
src/main/res/layout/dialog_message.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="fill_parent"
4
    android:layout_height="fill_parent"
5
    android:layout_marginLeft="10dp"
6
    android:layout_marginTop="0dp"
7
    android:layout_marginRight="10dp"
8
    android:background="@color/grey"
9
    android:gravity="center|fill_horizontal">
10

  
11
    <TextView
12
        android:id="@+id/dialog_message"
13
        android:layout_width="match_parent"
14
        android:layout_height="match_parent"
15
        android:layout_marginLeft="10dp"
16
        android:layout_marginTop="10dp"
17
        android:layout_marginRight="10dp"
18
        android:layout_marginBottom="10dp"
19
        android:gravity="center"
20
        android:textSize="24sp" />
21
</LinearLayout>
src/main/res/values/strings.xml
114 114
    <string name="config_corner">Corners</string>
115 115
    <string name="config_no_support">Current puzzle does not support adjusting colors.</string>
116 116

  
117
    <string name="config_message">Touch the stickers to change their color.</string>
118
    <string name="bandage_message">Bandage the cube by touching it.</string>
119
    <string name="solver_message">Set up scrambled position by touching the stickers.</string>
120

  
117 121
    <string name="sort_classic">classic</string>
118 122
    <string name="sort_shape">shape</string>
119 123
    <string name="sort_difficulty">difficulty</string>

Also available in: Unified diff