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 |
1c04d054
|
leszek
|
import android.app.Activity;
|
13 |
1c89e2a7
|
Leszek Koltunski
|
import android.app.Dialog;
|
14 |
d2f9fa0d
|
Leszek Koltunski
|
import android.content.Intent;
|
15 |
34d6b123
|
Leszek Koltunski
|
import android.content.pm.PackageInfo;
|
16 |
|
|
import android.content.pm.PackageManager;
|
17 |
e71baee1
|
Leszek Koltunski
|
import android.content.res.Resources;
|
18 |
d2f9fa0d
|
Leszek Koltunski
|
import android.net.Uri;
|
19 |
b4ee249e
|
Leszek Koltunski
|
import android.util.TypedValue;
|
20 |
1c89e2a7
|
Leszek Koltunski
|
import android.view.View;
|
21 |
|
|
import android.view.Window;
|
22 |
|
|
import android.view.WindowManager;
|
23 |
d2f9fa0d
|
Leszek Koltunski
|
import android.widget.LinearLayout;
|
24 |
24da418d
|
Leszek Koltunski
|
import android.widget.TextView;
|
25 |
1c89e2a7
|
Leszek Koltunski
|
|
26 |
|
|
import androidx.fragment.app.FragmentActivity;
|
27 |
|
|
|
28 |
d2f9fa0d
|
Leszek Koltunski
|
import org.distorted.main.BuildConfig;
|
29 |
1c89e2a7
|
Leszek Koltunski
|
import org.distorted.main.R;
|
30 |
|
|
|
31 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32 |
|
|
|
33 |
e71baee1
|
Leszek Koltunski
|
public class RubikDialogAbout extends RubikDialogAbstract
|
34 |
1c89e2a7
|
Leszek Koltunski
|
{
|
35 |
e71baee1
|
Leszek Koltunski
|
private static final String WHATS_NEW =
|
36 |
1c04d054
|
leszek
|
"1. New puzzle-centric UI. All actions one can do to a given puzzle in one context menu. ";
|
37 |
8d1b2017
|
leszek
|
|
38 |
|
|
private static final String WHATS_COMING =
|
39 |
1c04d054
|
leszek
|
"1. Improvements to the new UI - possibility to sort the puzzles by various criteria.\n" +
|
40 |
167e7724
|
leszek
|
"2. Support for adjustable stickers (not only the colors, but support for texturing the whole cube with images of your choice).\n" +
|
41 |
|
|
"3. Algorithmic solvers. (sub-optimal solvers for larger puzzles such as the 4x4)\n" +
|
42 |
|
|
"4. iOS version (no time for this, anyone can help? Code is open-source)\n" +
|
43 |
73f563b0
|
leszek
|
"5. More objects:\n - Ghost Cubes\n - more Mirrors\n - more Mixups\n - Penrose Cubes\n";
|
44 |
1c89e2a7
|
Leszek Koltunski
|
|
45 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46 |
|
|
|
47 |
|
|
@Override
|
48 |
|
|
public void onResume()
|
49 |
|
|
{
|
50 |
|
|
super.onResume();
|
51 |
|
|
|
52 |
|
|
Window window = getDialog().getWindow();
|
53 |
|
|
|
54 |
|
|
if( window!=null )
|
55 |
|
|
{
|
56 |
|
|
WindowManager.LayoutParams params = window.getAttributes();
|
57 |
e71baee1
|
Leszek Koltunski
|
params.width = (int)Math.min( mHeight*0.60f,mWidth*0.90f );
|
58 |
1c04d054
|
leszek
|
params.height = (int)(mHeight*0.90f);
|
59 |
1c89e2a7
|
Leszek Koltunski
|
window.setAttributes(params);
|
60 |
|
|
}
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
64 |
|
|
|
65 |
e71baee1
|
Leszek Koltunski
|
public int getResource() { return R.layout.dialog_about; }
|
66 |
|
|
public int getTitleResource() { return PARAMETRIC_TITLE; }
|
67 |
1c89e2a7
|
Leszek Koltunski
|
public boolean hasArgument() { return true; }
|
68 |
|
|
public int getPositive() { return R.string.ok; }
|
69 |
|
|
public int getNegative() { return -1; }
|
70 |
e71baee1
|
Leszek Koltunski
|
public void positiveAction() { }
|
71 |
|
|
public void negativeAction() { }
|
72 |
1c89e2a7
|
Leszek Koltunski
|
|
73 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74 |
|
|
|
75 |
1c04d054
|
leszek
|
private String findCurrentVersion(Activity act)
|
76 |
1c89e2a7
|
Leszek Koltunski
|
{
|
77 |
34d6b123
|
Leszek Koltunski
|
String version;
|
78 |
|
|
try
|
79 |
1c89e2a7
|
Leszek Koltunski
|
{
|
80 |
34d6b123
|
Leszek Koltunski
|
PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
|
81 |
|
|
version= pInfo.versionName;
|
82 |
1c89e2a7
|
Leszek Koltunski
|
}
|
83 |
34d6b123
|
Leszek Koltunski
|
catch (PackageManager.NameNotFoundException e)
|
84 |
|
|
{
|
85 |
|
|
version= "unknown";
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
return version;
|
89 |
1c89e2a7
|
Leszek Koltunski
|
}
|
90 |
|
|
|
91 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
92 |
|
|
|
93 |
e71baee1
|
Leszek Koltunski
|
@Override
|
94 |
1c04d054
|
leszek
|
String getTitleString(FragmentActivity fact)
|
95 |
1c89e2a7
|
Leszek Koltunski
|
{
|
96 |
e71baee1
|
Leszek Koltunski
|
Resources res= getResources();
|
97 |
1c04d054
|
leszek
|
Activity act= (Activity) getContext();
|
98 |
|
|
String version= act!=null ? findCurrentVersion(act) : "unknown";
|
99 |
e71baee1
|
Leszek Koltunski
|
return res.getString(R.string.ab_placeholder,version);
|
100 |
|
|
}
|
101 |
1c89e2a7
|
Leszek Koltunski
|
|
102 |
e71baee1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103 |
1c89e2a7
|
Leszek Koltunski
|
|
104 |
e71baee1
|
Leszek Koltunski
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
105 |
|
|
{
|
106 |
b4ee249e
|
Leszek Koltunski
|
int width = (int)Math.min( mHeight*0.60f,mWidth*0.90f );
|
107 |
|
|
int sS= (int)(width*0.043f);
|
108 |
|
|
int bS= (int)(width*0.060f);
|
109 |
24da418d
|
Leszek Koltunski
|
|
110 |
b4ee249e
|
Leszek Koltunski
|
TextView shaV = view.findViewById(R.id.about_share_string);
|
111 |
|
|
TextView emaV = view.findViewById(R.id.about_mail_string);
|
112 |
|
|
TextView addV = view.findViewById(R.id.about_mail_address);
|
113 |
|
|
|
114 |
|
|
TextView newV = view.findViewById(R.id.about_new_message);
|
115 |
24da418d
|
Leszek Koltunski
|
newV.setText(WHATS_NEW);
|
116 |
b4ee249e
|
Leszek Koltunski
|
TextView comV = view.findViewById(R.id.about_coming_message);
|
117 |
24da418d
|
Leszek Koltunski
|
comV.setText(WHATS_COMING);
|
118 |
d2f9fa0d
|
Leszek Koltunski
|
|
119 |
|
|
LinearLayout layoutShare = view.findViewById(R.id.about_share_layout);
|
120 |
|
|
|
121 |
|
|
layoutShare.setOnClickListener(new View.OnClickListener()
|
122 |
|
|
{
|
123 |
|
|
@Override
|
124 |
|
|
public void onClick(View v)
|
125 |
|
|
{
|
126 |
|
|
share(act);
|
127 |
|
|
}
|
128 |
|
|
});
|
129 |
|
|
|
130 |
|
|
LinearLayout layoutEmail = view.findViewById(R.id.about_email_layout);
|
131 |
|
|
|
132 |
|
|
layoutEmail.setOnClickListener(new View.OnClickListener()
|
133 |
|
|
{
|
134 |
|
|
@Override
|
135 |
|
|
public void onClick(View v)
|
136 |
|
|
{
|
137 |
|
|
email(act);
|
138 |
|
|
}
|
139 |
|
|
});
|
140 |
b4ee249e
|
Leszek Koltunski
|
|
141 |
|
|
shaV.setTextSize(TypedValue.COMPLEX_UNIT_PX, bS);
|
142 |
|
|
emaV.setTextSize(TypedValue.COMPLEX_UNIT_PX, bS);
|
143 |
|
|
addV.setTextSize(TypedValue.COMPLEX_UNIT_PX, sS);
|
144 |
|
|
newV.setTextSize(TypedValue.COMPLEX_UNIT_PX, sS);
|
145 |
|
|
comV.setTextSize(TypedValue.COMPLEX_UNIT_PX, sS);
|
146 |
d2f9fa0d
|
Leszek Koltunski
|
}
|
147 |
|
|
|
148 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
149 |
|
|
|
150 |
|
|
private void share(FragmentActivity act)
|
151 |
|
|
{
|
152 |
|
|
Resources res = act.getResources();
|
153 |
|
|
String name = res.getString(R.string.app_name);
|
154 |
|
|
|
155 |
|
|
Intent intent = new Intent();
|
156 |
|
|
intent.setAction(Intent.ACTION_SEND);
|
157 |
|
|
intent.putExtra(Intent.EXTRA_TEXT,
|
158 |
|
|
name+": https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID);
|
159 |
|
|
intent.setType("text/plain");
|
160 |
|
|
|
161 |
|
|
if (intent.resolveActivity(act.getPackageManager()) != null)
|
162 |
|
|
{
|
163 |
|
|
startActivity(intent);
|
164 |
|
|
}
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
168 |
|
|
|
169 |
|
|
private void email(FragmentActivity act)
|
170 |
|
|
{
|
171 |
|
|
Resources res = act.getResources();
|
172 |
|
|
String[] email = { res.getString(R.string.email_address) };
|
173 |
1c04d054
|
leszek
|
String version = findCurrentVersion((Activity)act);
|
174 |
d2f9fa0d
|
Leszek Koltunski
|
String name = res.getString(R.string.app_name);
|
175 |
|
|
|
176 |
|
|
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
177 |
|
|
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
|
178 |
|
|
intent.putExtra(Intent.EXTRA_EMAIL, email);
|
179 |
|
|
intent.putExtra(Intent.EXTRA_SUBJECT, name+" "+version);
|
180 |
|
|
|
181 |
|
|
if (intent.resolveActivity(act.getPackageManager()) != null)
|
182 |
|
|
{
|
183 |
|
|
startActivity(intent);
|
184 |
|
|
}
|
185 |
1c89e2a7
|
Leszek Koltunski
|
}
|
186 |
|
|
|
187 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
188 |
|
|
|
189 |
|
|
public static String getDialogTag()
|
190 |
|
|
{
|
191 |
e71baee1
|
Leszek Koltunski
|
return "DialogAbout";
|
192 |
1c89e2a7
|
Leszek Koltunski
|
}
|
193 |
|
|
}
|