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.view.View;
|
14
|
import android.view.Window;
|
15
|
import android.view.WindowManager;
|
16
|
import android.widget.LinearLayout;
|
17
|
import android.widget.TextView;
|
18
|
|
19
|
import androidx.fragment.app.FragmentActivity;
|
20
|
|
21
|
import org.distorted.main.R;
|
22
|
import org.distorted.main.RubikActivity;
|
23
|
|
24
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25
|
|
26
|
public class RubikDialogWhatsNew extends RubikDialogAbstract
|
27
|
{
|
28
|
private static final String[] MESSAGES =
|
29
|
{
|
30
|
"1.11.6",
|
31
|
|
32
|
"1. This dialog :)\n" +
|
33
|
"2. UI ready for NEW SOLVERS\n" +
|
34
|
"3. Important fix for a bug which used to let players solve any scramble with just one move\n" +
|
35
|
"4. UI fixes for squarish screens\n" +
|
36
|
"5. Preparation for Penrose Cubes.\n",
|
37
|
|
38
|
"current",
|
39
|
};
|
40
|
|
41
|
private int mLowerVersion, mUpperVersion;
|
42
|
|
43
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44
|
|
45
|
@Override
|
46
|
public void onResume()
|
47
|
{
|
48
|
super.onResume();
|
49
|
|
50
|
Window window = getDialog().getWindow();
|
51
|
|
52
|
if( window!=null )
|
53
|
{
|
54
|
WindowManager.LayoutParams params = window.getAttributes();
|
55
|
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
|
56
|
window.setAttributes(params);
|
57
|
}
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
public int getResource() { return R.layout.dialog_scrollable_panes; }
|
63
|
public int getTitleResource() { return R.string.whatsnew; }
|
64
|
public boolean hasArgument() { return true; }
|
65
|
public int getPositive() { return R.string.ok; }
|
66
|
public int getNegative() { return -1; }
|
67
|
|
68
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69
|
|
70
|
public void positiveAction()
|
71
|
{
|
72
|
|
73
|
}
|
74
|
|
75
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76
|
|
77
|
public void negativeAction()
|
78
|
{
|
79
|
|
80
|
}
|
81
|
|
82
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
83
|
|
84
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
85
|
{
|
86
|
int margin= (int)(mHeight*0.010f);
|
87
|
int titleH= (int)(mHeight*0.035f);
|
88
|
int padd = (int)(mHeight*0.010f);
|
89
|
|
90
|
LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
|
91
|
TextView text = view.findViewById(R.id.dialog_scrollable_message);
|
92
|
text.setVisibility(View.GONE);
|
93
|
|
94
|
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
95
|
pV.setMargins(margin, margin, margin, margin);
|
96
|
LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
97
|
pL.setMargins(margin, margin, margin, margin);
|
98
|
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, titleH );
|
99
|
LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
100
|
pM.setMargins(0,2*margin,0,0);
|
101
|
|
102
|
parseArgument(mArgument);
|
103
|
RubikActivity ract = (RubikActivity) getContext();
|
104
|
|
105
|
for(int i=mLowerVersion; i<mUpperVersion; i+=2)
|
106
|
{
|
107
|
String lower = MESSAGES[i];
|
108
|
String message = MESSAGES[i+1];
|
109
|
String upper = MESSAGES[i+2];
|
110
|
|
111
|
RubikDialogWhatsNewView pane = new RubikDialogWhatsNewView(ract,lower,upper,message,padd,(i==mUpperVersion-1 ? pL:pV),pT,pM);
|
112
|
layout.addView(pane.getView());
|
113
|
}
|
114
|
}
|
115
|
|
116
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117
|
|
118
|
private void parseArgument(String argument)
|
119
|
{
|
120
|
String[] parts = argument.split(" ");
|
121
|
|
122
|
if( parts.length==2 )
|
123
|
{
|
124
|
mLowerVersion = findVersion(parts[0]);
|
125
|
mUpperVersion = findVersion(parts[1]);
|
126
|
}
|
127
|
}
|
128
|
|
129
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
130
|
|
131
|
private int findVersion(String version)
|
132
|
{
|
133
|
int len = MESSAGES.length;
|
134
|
|
135
|
for(int i=0; i<len; i++)
|
136
|
{
|
137
|
if( MESSAGES[i].equals(version) ) return i;
|
138
|
}
|
139
|
|
140
|
return len-1;
|
141
|
}
|
142
|
|
143
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
144
|
|
145
|
public static String getDialogTag()
|
146
|
{
|
147
|
return "DialogSolvers";
|
148
|
}
|
149
|
}
|