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.content.res.Resources;
|
16
|
import android.view.View;
|
17
|
import android.view.Window;
|
18
|
import android.view.WindowManager;
|
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 RubikDialogAbout extends RubikDialogAbstract
|
29
|
{
|
30
|
private static final String WHATS_NEW =
|
31
|
"1. Solvers: 2x2x3, Pyraminx & Skewb Diamond.\n" +
|
32
|
"2. Implement Icosamate & Master Icosamate\n" +
|
33
|
"3. Connect the solvers to the scrambling engine. Which means: from now on, " +
|
34
|
"all puzzles which have a solver implemented will be perfectly scrambled " +
|
35
|
" - i.e. any scramble at Level 7 will always require exactly 7 moves to solve. " +
|
36
|
"Which also means that in some point in the future, we'll have to clear the High Scores.";
|
37
|
|
38
|
private static final String WHATS_COMING =
|
39
|
"1. More solvers (2x2, Skewb, Dino).\n" +
|
40
|
"2. Support for adjustable stickers.\n" +
|
41
|
"3. In-game currency (stars)\n" +
|
42
|
"4. More objects (Penrose Cubes, higher-order Jings, Ghost Cubes, more Mirrors, more Mixups)";
|
43
|
|
44
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
45
|
|
46
|
@Override
|
47
|
public void onResume()
|
48
|
{
|
49
|
super.onResume();
|
50
|
|
51
|
Window window = getDialog().getWindow();
|
52
|
|
53
|
if( window!=null )
|
54
|
{
|
55
|
WindowManager.LayoutParams params = window.getAttributes();
|
56
|
params.width = (int)Math.min( mHeight*0.60f,mWidth*0.90f );
|
57
|
window.setAttributes(params);
|
58
|
}
|
59
|
}
|
60
|
|
61
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62
|
|
63
|
public int getResource() { return R.layout.dialog_about; }
|
64
|
public int getTitleResource() { return PARAMETRIC_TITLE; }
|
65
|
public boolean hasArgument() { return true; }
|
66
|
public int getPositive() { return R.string.ok; }
|
67
|
public int getNegative() { return -1; }
|
68
|
public void positiveAction() { }
|
69
|
public void negativeAction() { }
|
70
|
|
71
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
72
|
|
73
|
private String findCurrentVersion(RubikActivity act)
|
74
|
{
|
75
|
String version;
|
76
|
try
|
77
|
{
|
78
|
PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
|
79
|
version= pInfo.versionName;
|
80
|
}
|
81
|
catch (PackageManager.NameNotFoundException e)
|
82
|
{
|
83
|
version= "unknown";
|
84
|
}
|
85
|
|
86
|
return version;
|
87
|
}
|
88
|
|
89
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90
|
|
91
|
@Override
|
92
|
String getTitleString(FragmentActivity act)
|
93
|
{
|
94
|
Resources res= getResources();
|
95
|
RubikActivity ract= (RubikActivity) getContext();
|
96
|
String version= ract!=null ? findCurrentVersion(ract) : "unknown";
|
97
|
return res.getString(R.string.ab_placeholder,version);
|
98
|
}
|
99
|
|
100
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101
|
|
102
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
103
|
{
|
104
|
int margin= (int)(mHeight*0.010f);
|
105
|
int titleH= (int)(mHeight*0.035f);
|
106
|
int padd = (int)(mHeight*0.010f);
|
107
|
|
108
|
TextView newV = view.findViewById(R.id.new_message);
|
109
|
newV.setText(WHATS_NEW);
|
110
|
TextView comV = view.findViewById(R.id.coming_message);
|
111
|
comV.setText(WHATS_COMING);
|
112
|
}
|
113
|
|
114
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
115
|
|
116
|
public static String getDialogTag()
|
117
|
{
|
118
|
return "DialogAbout";
|
119
|
}
|
120
|
}
|