Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogWhatsNew.java @ b3091b98

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import android.content.pm.PackageInfo;
14
import android.content.pm.PackageManager;
15
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
      "1.12.1",
33

    
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
      "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

    
40
      "1.12.2",
41

    
42
      "1. Fixes for two critical crashers that appeared in the previous version.",
43

    
44
      "1.12.3",
45

    
46
      "1. Implement the first two solvers - Pyraminx Duo & Ivy Cube\n" +
47
      "2. Implement AI Cube and Burr Cube\n" +
48
      "3. Many fixes - for Trajber 4x4, touch control, creation of Bandaged Cuboids, scores dialog...",
49

    
50
      "1.12.4",
51

    
52
      "1. Implement 2x2x3, Pyraminx & Skewb Diamond solvers.",
53

    
54
      "Coming",
55

    
56
      "1. Implemented Pocket Cube, Skewb solvers.\n" +
57
      "2. Support for adjustable stickers.\n" +
58
      "3. In-game currency (stars)\n" +
59
      "4. More objects (Icosamate, Penrose Cubes, the Double-Crazy, Ghost Cubes, more Mirrors)"
60
      };
61

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

    
64
  @Override
65
  public void onResume()
66
    {
67
    super.onResume();
68

    
69
    Window window = getDialog().getWindow();
70

    
71
    if( window!=null )
72
      {
73
      WindowManager.LayoutParams params = window.getAttributes();
74
      params.width  = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
75
      window.setAttributes(params);
76
      }
77
    }
78

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

    
81
  public int getResource()      { return R.layout.dialog_scrollable_panes; }
82
  public int getTitleResource() { return R.string.whatsnew; }
83
  public boolean hasArgument()  { return true; }
84
  public int getPositive()      { return R.string.ok; }
85
  public int getNegative()      { return -1; }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
  public void positiveAction()
90
    {
91

    
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
  public void negativeAction()
97
    {
98

    
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
104
    {
105
    int margin= (int)(mHeight*0.010f);
106
    int titleH= (int)(mHeight*0.035f);
107
    int padd  = (int)(mHeight*0.010f);
108

    
109
    LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
110
    TextView text  = view.findViewById(R.id.dialog_scrollable_message);
111
    text.setVisibility(View.GONE);
112

    
113
    LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
114
    pV.setMargins(margin, margin, margin, 0);
115
    LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
116
    pL.setMargins(margin, margin, margin, margin);
117
    LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, titleH );
118
    LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
119
    pM.setMargins(0,2*margin,0,0);
120

    
121
    RubikActivity ract = (RubikActivity) getContext();
122
    int numMessages= MESSAGES.length/2;
123
    String thisVersion = findCurrentVersion(ract);
124

    
125
    for(int i=0; i<numMessages; i++)
126
      {
127
      String version = MESSAGES[2*i];
128
      String message = MESSAGES[2*i+1];
129
      boolean isCurrent = version.equals(thisVersion);
130

    
131
      RubikDialogWhatsNewView pane = new RubikDialogWhatsNewView(ract,version,message,padd, isCurrent, (i==(numMessages-1) ? pL:pV),pT,pM);
132
      layout.addView(pane.getView());
133
      }
134
    }
135

    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

    
138
  private String findCurrentVersion(RubikActivity act)
139
    {
140
    String version;
141
    try
142
      {
143
      PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
144
      version= pInfo.versionName;
145
      }
146
    catch (PackageManager.NameNotFoundException e)
147
      {
148
      version= "unknown";
149
      }
150

    
151
    return version;
152
    }
153

    
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

    
156
  private int findVersion(String version)
157
    {
158
    int len = MESSAGES.length;
159

    
160
    for(int i=0; i<len; i++)
161
      {
162
      if( MESSAGES[i].equals(version) ) return i;
163
      }
164

    
165
    return 0;
166
    }
167

    
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169

    
170
  public static String getDialogTag()
171
    {
172
    return "DialogSolvers";
173
    }
174
  }
(26-26/27)