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.util.TypedValue;
|
19
|
import android.view.View;
|
20
|
import android.view.Window;
|
21
|
import android.view.WindowManager;
|
22
|
import android.widget.LinearLayout;
|
23
|
import android.widget.TextView;
|
24
|
|
25
|
import androidx.fragment.app.FragmentActivity;
|
26
|
|
27
|
import org.distorted.main.BuildConfig;
|
28
|
import org.distorted.main.R;
|
29
|
import org.distorted.main.RubikActivity;
|
30
|
|
31
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32
|
|
33
|
public class RubikDialogAbout extends RubikDialogAbstract
|
34
|
{
|
35
|
private static final String WHATS_NEW =
|
36
|
"1. 3x3x2 Cuboid solver.\n" +
|
37
|
"2. Support for 'coin' puzzles (Coin Tetrahedron, Ancient Coin Cube).\n" +
|
38
|
"3. Improvements to the Highscores dialog.";
|
39
|
|
40
|
private static final String WHATS_COMING =
|
41
|
"1. iOS version.\n" +
|
42
|
"2. Algorithmic solvers.\n" +
|
43
|
"3. Support for adjustable stickers.\n" +
|
44
|
"4. In-game currency (stars)\n" +
|
45
|
"5. More objects:\n - Penrose Cubes\n - higher-order Jings\n - Ghost Cubes\n - more Mirrors\n - more Mixups\n - Ancient Coin Cube\n" +
|
46
|
"6. Creator of bandaged Pyraminxes.";
|
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
|
// params.height = (int)(mHeight*0.85f);
|
62
|
window.setAttributes(params);
|
63
|
}
|
64
|
}
|
65
|
|
66
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67
|
|
68
|
public int getResource() { return R.layout.dialog_about; }
|
69
|
public int getTitleResource() { return PARAMETRIC_TITLE; }
|
70
|
public boolean hasArgument() { return true; }
|
71
|
public int getPositive() { return R.string.ok; }
|
72
|
public int getNegative() { return -1; }
|
73
|
public void positiveAction() { }
|
74
|
public void negativeAction() { }
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
|
78
|
private String findCurrentVersion(RubikActivity act)
|
79
|
{
|
80
|
String version;
|
81
|
try
|
82
|
{
|
83
|
PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
|
84
|
version= pInfo.versionName;
|
85
|
}
|
86
|
catch (PackageManager.NameNotFoundException e)
|
87
|
{
|
88
|
version= "unknown";
|
89
|
}
|
90
|
|
91
|
return version;
|
92
|
}
|
93
|
|
94
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
95
|
|
96
|
@Override
|
97
|
String getTitleString(FragmentActivity act)
|
98
|
{
|
99
|
Resources res= getResources();
|
100
|
RubikActivity ract= (RubikActivity) getContext();
|
101
|
String version= ract!=null ? findCurrentVersion(ract) : "unknown";
|
102
|
return res.getString(R.string.ab_placeholder,version);
|
103
|
}
|
104
|
|
105
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
106
|
|
107
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
108
|
{
|
109
|
int width = (int)Math.min( mHeight*0.60f,mWidth*0.90f );
|
110
|
int sS= (int)(width*0.043f);
|
111
|
int bS= (int)(width*0.060f);
|
112
|
|
113
|
TextView shaV = view.findViewById(R.id.about_share_string);
|
114
|
TextView emaV = view.findViewById(R.id.about_mail_string);
|
115
|
TextView addV = view.findViewById(R.id.about_mail_address);
|
116
|
|
117
|
TextView newV = view.findViewById(R.id.about_new_message);
|
118
|
newV.setText(WHATS_NEW);
|
119
|
TextView comV = view.findViewById(R.id.about_coming_message);
|
120
|
comV.setText(WHATS_COMING);
|
121
|
|
122
|
LinearLayout layoutShare = view.findViewById(R.id.about_share_layout);
|
123
|
|
124
|
layoutShare.setOnClickListener(new View.OnClickListener()
|
125
|
{
|
126
|
@Override
|
127
|
public void onClick(View v)
|
128
|
{
|
129
|
share(act);
|
130
|
}
|
131
|
});
|
132
|
|
133
|
LinearLayout layoutEmail = view.findViewById(R.id.about_email_layout);
|
134
|
|
135
|
layoutEmail.setOnClickListener(new View.OnClickListener()
|
136
|
{
|
137
|
@Override
|
138
|
public void onClick(View v)
|
139
|
{
|
140
|
email(act);
|
141
|
}
|
142
|
});
|
143
|
|
144
|
shaV.setTextSize(TypedValue.COMPLEX_UNIT_PX, bS);
|
145
|
emaV.setTextSize(TypedValue.COMPLEX_UNIT_PX, bS);
|
146
|
addV.setTextSize(TypedValue.COMPLEX_UNIT_PX, sS);
|
147
|
newV.setTextSize(TypedValue.COMPLEX_UNIT_PX, sS);
|
148
|
comV.setTextSize(TypedValue.COMPLEX_UNIT_PX, sS);
|
149
|
}
|
150
|
|
151
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
152
|
|
153
|
private void share(FragmentActivity act)
|
154
|
{
|
155
|
Resources res = act.getResources();
|
156
|
String name = res.getString(R.string.app_name);
|
157
|
|
158
|
Intent intent = new Intent();
|
159
|
intent.setAction(Intent.ACTION_SEND);
|
160
|
intent.putExtra(Intent.EXTRA_TEXT,
|
161
|
name+": https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID);
|
162
|
intent.setType("text/plain");
|
163
|
|
164
|
if (intent.resolveActivity(act.getPackageManager()) != null)
|
165
|
{
|
166
|
startActivity(intent);
|
167
|
}
|
168
|
}
|
169
|
|
170
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
171
|
|
172
|
private void email(FragmentActivity act)
|
173
|
{
|
174
|
Resources res = act.getResources();
|
175
|
String[] email = { res.getString(R.string.email_address) };
|
176
|
String version = findCurrentVersion((RubikActivity)act);
|
177
|
String name = res.getString(R.string.app_name);
|
178
|
|
179
|
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
180
|
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
|
181
|
intent.putExtra(Intent.EXTRA_EMAIL, email);
|
182
|
intent.putExtra(Intent.EXTRA_SUBJECT, name+" "+version);
|
183
|
|
184
|
if (intent.resolveActivity(act.getPackageManager()) != null)
|
185
|
{
|
186
|
startActivity(intent);
|
187
|
}
|
188
|
}
|
189
|
|
190
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
191
|
|
192
|
public static String getDialogTag()
|
193
|
{
|
194
|
return "DialogAbout";
|
195
|
}
|
196
|
}
|