Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogWhatsNew.java @ 617b7b66

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 34d6b123 Leszek Koltunski
      "1.12.0",
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 34d6b123 Leszek Koltunski
      "Coming",
41 1c89e2a7 Leszek Koltunski
42 34d6b123 Leszek Koltunski
      "1. Implemented Pyraminx, Ivy, 2x2x3, Skewb Diamond solvers.\n" +
43
      "2. More solvers (2x2x2?)\n" +
44
      "2. Support for adjustable stickers.\n" +
45
      "3. In-game currency (stars)\n" +
46
      "4. More objects (Camouflage Cubes, AI Cube, Burr Cube, Penrose Cubes, the Double-Crazy)"
47
      };
48 1c89e2a7 Leszek Koltunski
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
51
  @Override
52
  public void onResume()
53
    {
54
    super.onResume();
55
56
    Window window = getDialog().getWindow();
57
58
    if( window!=null )
59
      {
60
      WindowManager.LayoutParams params = window.getAttributes();
61
      params.width  = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
62
      window.setAttributes(params);
63
      }
64
    }
65
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67
68
  public int getResource()      { return R.layout.dialog_scrollable_panes; }
69
  public int getTitleResource() { return R.string.whatsnew; }
70
  public boolean hasArgument()  { return true; }
71
  public int getPositive()      { return R.string.ok; }
72
  public int getNegative()      { return -1; }
73
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
76
  public void positiveAction()
77
    {
78
79
    }
80
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
83
  public void negativeAction()
84
    {
85
86
    }
87
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
90
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
91
    {
92
    int margin= (int)(mHeight*0.010f);
93
    int titleH= (int)(mHeight*0.035f);
94
    int padd  = (int)(mHeight*0.010f);
95
96
    LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
97
    TextView text  = view.findViewById(R.id.dialog_scrollable_message);
98
    text.setVisibility(View.GONE);
99
100
    LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
101 34d6b123 Leszek Koltunski
    pV.setMargins(margin, margin, margin, 0);
102 1c89e2a7 Leszek Koltunski
    LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
103
    pL.setMargins(margin, margin, margin, margin);
104
    LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, titleH );
105
    LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
106 7b191fe5 Leszek Koltunski
    pM.setMargins(0,2*margin,0,0);
107 1c89e2a7 Leszek Koltunski
108
    RubikActivity ract = (RubikActivity) getContext();
109 34d6b123 Leszek Koltunski
    int start      = findVersion(mArgument);
110
    int numMessages= MESSAGES.length/2;
111
    String thisVersion = findCurrentVersion(ract);
112 1c89e2a7 Leszek Koltunski
113 34d6b123 Leszek Koltunski
    for(int i=0; i<numMessages; i++)
114 1c89e2a7 Leszek Koltunski
      {
115 34d6b123 Leszek Koltunski
      String version = MESSAGES[start+2*i];
116
      String message = MESSAGES[start+2*i+1];
117
      boolean isCurrent = version.equals(thisVersion);
118 1c89e2a7 Leszek Koltunski
119 34d6b123 Leszek Koltunski
      RubikDialogWhatsNewView pane = new RubikDialogWhatsNewView(ract,version,message,padd, isCurrent, (i==(numMessages-1) ? pL:pV),pT,pM);
120 1c89e2a7 Leszek Koltunski
      layout.addView(pane.getView());
121
      }
122
    }
123
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125
126 34d6b123 Leszek Koltunski
  private String findCurrentVersion(RubikActivity act)
127 1c89e2a7 Leszek Koltunski
    {
128 34d6b123 Leszek Koltunski
    String version;
129
    try
130 1c89e2a7 Leszek Koltunski
      {
131 34d6b123 Leszek Koltunski
      PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
132
      version= pInfo.versionName;
133 1c89e2a7 Leszek Koltunski
      }
134 34d6b123 Leszek Koltunski
    catch (PackageManager.NameNotFoundException e)
135
      {
136
      version= "unknown";
137
      }
138
139
    return version;
140 1c89e2a7 Leszek Koltunski
    }
141
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143
144
  private int findVersion(String version)
145
    {
146
    int len = MESSAGES.length;
147
148
    for(int i=0; i<len; i++)
149
      {
150
      if( MESSAGES[i].equals(version) ) return i;
151
      }
152
153 34d6b123 Leszek Koltunski
    return 0;
154 1c89e2a7 Leszek Koltunski
    }
155
156
///////////////////////////////////////////////////////////////////////////////////////////////////
157
158
  public static String getDialogTag()
159
    {
160
    return "DialogSolvers";
161
    }
162
  }