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.Intent;
|
14
|
import android.content.pm.PackageInfo;
|
15
|
import android.content.pm.PackageManager;
|
16
|
import android.content.res.Resources;
|
17
|
import android.net.Uri;
|
18
|
import android.view.View;
|
19
|
import android.view.Window;
|
20
|
import android.view.WindowManager;
|
21
|
import android.widget.LinearLayout;
|
22
|
import android.widget.TextView;
|
23
|
|
24
|
import androidx.fragment.app.FragmentActivity;
|
25
|
|
26
|
import org.distorted.main.BuildConfig;
|
27
|
import org.distorted.main.R;
|
28
|
import org.distorted.main.RubikActivity;
|
29
|
|
30
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31
|
|
32
|
public class RubikDialogAbout extends RubikDialogAbstract
|
33
|
{
|
34
|
private static final String WHATS_NEW =
|
35
|
"1. Solvers: 2x2x3, Pyraminx & Skewb Diamond.\n" +
|
36
|
"2. Implement Icosamate & Master Icosamate\n" +
|
37
|
"3. Connect the solvers to the scrambling engine. Which means: from now on, " +
|
38
|
"all puzzles which have a solver implemented will be perfectly scrambled " +
|
39
|
" - i.e. any scramble at Level 7 will always require exactly 7 moves to solve. " +
|
40
|
"Which also means that in some point in the future, we'll have to clear the High Scores.";
|
41
|
|
42
|
private static final String WHATS_COMING =
|
43
|
"1. More solvers (2x2, Skewb, Dino).\n" +
|
44
|
"2. Support for adjustable stickers.\n" +
|
45
|
"3. In-game currency (stars)\n" +
|
46
|
"4. More objects (Penrose Cubes, higher-order Jings, Ghost Cubes, more Mirrors, more Mixups)";
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
@Override
|
51
|
public void onResume()
|
52
|
{
|
53
|
super.onResume();
|
54
|
|
55
|
Window window = getDialog().getWindow();
|
56
|
|
57
|
if( window!=null )
|
58
|
{
|
59
|
WindowManager.LayoutParams params = window.getAttributes();
|
60
|
params.width = (int)Math.min( mHeight*0.60f,mWidth*0.90f );
|
61
|
window.setAttributes(params);
|
62
|
}
|
63
|
}
|
64
|
|
65
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66
|
|
67
|
public int getResource() { return R.layout.dialog_about; }
|
68
|
public int getTitleResource() { return PARAMETRIC_TITLE; }
|
69
|
public boolean hasArgument() { return true; }
|
70
|
public int getPositive() { return R.string.ok; }
|
71
|
public int getNegative() { return -1; }
|
72
|
public void positiveAction() { }
|
73
|
public void negativeAction() { }
|
74
|
|
75
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76
|
|
77
|
private String findCurrentVersion(RubikActivity act)
|
78
|
{
|
79
|
String version;
|
80
|
try
|
81
|
{
|
82
|
PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
|
83
|
version= pInfo.versionName;
|
84
|
}
|
85
|
catch (PackageManager.NameNotFoundException e)
|
86
|
{
|
87
|
version= "unknown";
|
88
|
}
|
89
|
|
90
|
return version;
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
|
95
|
@Override
|
96
|
String getTitleString(FragmentActivity act)
|
97
|
{
|
98
|
Resources res= getResources();
|
99
|
RubikActivity ract= (RubikActivity) getContext();
|
100
|
String version= ract!=null ? findCurrentVersion(ract) : "unknown";
|
101
|
return res.getString(R.string.ab_placeholder,version);
|
102
|
}
|
103
|
|
104
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105
|
|
106
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
107
|
{
|
108
|
int margin= (int)(mHeight*0.010f);
|
109
|
int titleH= (int)(mHeight*0.035f);
|
110
|
int padd = (int)(mHeight*0.010f);
|
111
|
|
112
|
TextView newV = view.findViewById(R.id.new_message);
|
113
|
newV.setText(WHATS_NEW);
|
114
|
TextView comV = view.findViewById(R.id.coming_message);
|
115
|
comV.setText(WHATS_COMING);
|
116
|
|
117
|
LinearLayout layoutShare = view.findViewById(R.id.about_share_layout);
|
118
|
|
119
|
layoutShare.setOnClickListener(new View.OnClickListener()
|
120
|
{
|
121
|
@Override
|
122
|
public void onClick(View v)
|
123
|
{
|
124
|
share(act);
|
125
|
}
|
126
|
});
|
127
|
|
128
|
LinearLayout layoutEmail = view.findViewById(R.id.about_email_layout);
|
129
|
|
130
|
layoutEmail.setOnClickListener(new View.OnClickListener()
|
131
|
{
|
132
|
@Override
|
133
|
public void onClick(View v)
|
134
|
{
|
135
|
email(act);
|
136
|
}
|
137
|
});
|
138
|
}
|
139
|
|
140
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
141
|
|
142
|
private void share(FragmentActivity act)
|
143
|
{
|
144
|
Resources res = act.getResources();
|
145
|
String name = res.getString(R.string.app_name);
|
146
|
|
147
|
Intent intent = new Intent();
|
148
|
intent.setAction(Intent.ACTION_SEND);
|
149
|
intent.putExtra(Intent.EXTRA_TEXT,
|
150
|
name+": https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID);
|
151
|
intent.setType("text/plain");
|
152
|
|
153
|
if (intent.resolveActivity(act.getPackageManager()) != null)
|
154
|
{
|
155
|
startActivity(intent);
|
156
|
}
|
157
|
}
|
158
|
|
159
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
160
|
|
161
|
private void email(FragmentActivity act)
|
162
|
{
|
163
|
Resources res = act.getResources();
|
164
|
String[] email = { res.getString(R.string.email_address) };
|
165
|
String version = findCurrentVersion((RubikActivity)act);
|
166
|
String name = res.getString(R.string.app_name);
|
167
|
|
168
|
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
169
|
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
|
170
|
intent.putExtra(Intent.EXTRA_EMAIL, email);
|
171
|
intent.putExtra(Intent.EXTRA_SUBJECT, name+" "+version);
|
172
|
|
173
|
if (intent.resolveActivity(act.getPackageManager()) != null)
|
174
|
{
|
175
|
startActivity(intent);
|
176
|
}
|
177
|
}
|
178
|
|
179
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
180
|
|
181
|
public static String getDialogTag()
|
182
|
{
|
183
|
return "DialogAbout";
|
184
|
}
|
185
|
}
|