1 |
1cd323dd
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2019 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
296219b4
|
Leszek Koltunski
|
// 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 |
1cd323dd
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
package org.distorted.main;
|
11 |
|
|
|
12 |
|
|
import android.os.Bundle;
|
13 |
|
|
|
14 |
|
|
import androidx.annotation.NonNull;
|
15 |
|
|
|
16 |
|
|
import com.google.android.play.core.review.ReviewInfo;
|
17 |
|
|
import com.google.android.play.core.review.ReviewManager;
|
18 |
|
|
import com.google.android.play.core.review.ReviewManagerFactory;
|
19 |
|
|
import com.google.android.play.core.tasks.OnCompleteListener;
|
20 |
|
|
import com.google.android.play.core.tasks.OnFailureListener;
|
21 |
|
|
import com.google.android.play.core.tasks.Task;
|
22 |
|
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
23 |
95472aca
|
Leszek Koltunski
|
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
24 |
1cd323dd
|
Leszek Koltunski
|
|
25 |
0da4feff
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedScreen;
|
26 |
95472aca
|
Leszek Koltunski
|
import org.distorted.library.message.EffectMessageSender;
|
27 |
8723caee
|
Leszek Koltunski
|
|
28 |
acabdd83
|
Leszek Koltunski
|
import org.distorted.external.RubikNetwork;
|
29 |
95472aca
|
Leszek Koltunski
|
import org.distorted.objectlib.BuildConfig;
|
30 |
|
|
import org.distorted.objectlib.helpers.BlockController;
|
31 |
e019c70b
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectLibInterface;
|
32 |
5c4ed8ed
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectControl;
|
33 |
1cd323dd
|
Leszek Koltunski
|
|
34 |
|
|
import org.distorted.dialogs.RubikDialogNewRecord;
|
35 |
|
|
import org.distorted.dialogs.RubikDialogSolved;
|
36 |
acabdd83
|
Leszek Koltunski
|
import org.distorted.external.RubikScores;
|
37 |
d433b50e
|
Leszek Koltunski
|
import org.distorted.objects.RubikObject;
|
38 |
|
|
import org.distorted.objects.RubikObjectList;
|
39 |
0da4feff
|
Leszek Koltunski
|
import org.distorted.overlays.DataStars;
|
40 |
d7f0c07d
|
Leszek Koltunski
|
import org.distorted.overlays.ListenerOverlay;
|
41 |
0da4feff
|
Leszek Koltunski
|
import org.distorted.overlays.OverlayStars;
|
42 |
1cd323dd
|
Leszek Koltunski
|
import org.distorted.screens.RubikScreenPlay;
|
43 |
dd1a65c1
|
Leszek Koltunski
|
import org.distorted.screens.RubikScreenReady;
|
44 |
|
|
import org.distorted.screens.RubikScreenSolver;
|
45 |
1cd323dd
|
Leszek Koltunski
|
import org.distorted.screens.RubikScreenSolving;
|
46 |
|
|
import org.distorted.screens.ScreenList;
|
47 |
dd1a65c1
|
Leszek Koltunski
|
import org.distorted.solvers.SolverMain;
|
48 |
1cd323dd
|
Leszek Koltunski
|
|
49 |
e019c70b
|
Leszek Koltunski
|
import java.lang.ref.WeakReference;
|
50 |
|
|
|
51 |
24679c47
|
Leszek Koltunski
|
import static org.distorted.external.RubikScores.RECORD_FIRST;
|
52 |
d7f0c07d
|
Leszek Koltunski
|
import static org.distorted.external.RubikScores.RECORD_NEW;
|
53 |
24679c47
|
Leszek Koltunski
|
import static org.distorted.external.RubikScores.RECORD_NOT_NEW;
|
54 |
|
|
|
55 |
1cd323dd
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56 |
|
|
|
57 |
d7f0c07d
|
Leszek Koltunski
|
public class RubikObjectLibInterface implements ObjectLibInterface, ListenerOverlay
|
58 |
1cd323dd
|
Leszek Koltunski
|
{
|
59 |
5c4ed8ed
|
Leszek Koltunski
|
private final WeakReference<RubikActivity> mAct;
|
60 |
24679c47
|
Leszek Koltunski
|
private int mIsNewRecord;
|
61 |
1cd323dd
|
Leszek Koltunski
|
private long mNewRecord;
|
62 |
5c4ed8ed
|
Leszek Koltunski
|
private int mLastCubitColor, mLastCubit, mLastCubitFace;
|
63 |
1cd323dd
|
Leszek Koltunski
|
|
64 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65 |
|
|
|
66 |
e019c70b
|
Leszek Koltunski
|
RubikObjectLibInterface(RubikActivity act)
|
67 |
|
|
{
|
68 |
|
|
mAct = new WeakReference<>(act);
|
69 |
5c4ed8ed
|
Leszek Koltunski
|
mLastCubitColor = -1;
|
70 |
e019c70b
|
Leszek Koltunski
|
}
|
71 |
|
|
|
72 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
73 |
|
|
|
74 |
|
|
private void analyticsReport(RubikActivity act, String message, String name, long timeBegin)
|
75 |
1cd323dd
|
Leszek Koltunski
|
{
|
76 |
|
|
long elapsed = System.currentTimeMillis() - timeBegin;
|
77 |
|
|
String msg = message+" startTime: "+timeBegin+" elapsed: "+elapsed+" name: "+name;
|
78 |
|
|
|
79 |
|
|
if( BuildConfig.DEBUG )
|
80 |
|
|
{
|
81 |
d38a302b
|
Leszek Koltunski
|
android.util.Log.d("libInterface", msg);
|
82 |
1cd323dd
|
Leszek Koltunski
|
}
|
83 |
|
|
else
|
84 |
|
|
{
|
85 |
e019c70b
|
Leszek Koltunski
|
FirebaseAnalytics analytics = act.getAnalytics();
|
86 |
1cd323dd
|
Leszek Koltunski
|
|
87 |
|
|
if( analytics!=null )
|
88 |
|
|
{
|
89 |
|
|
Bundle bundle = new Bundle();
|
90 |
|
|
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, msg);
|
91 |
|
|
analytics.logEvent(FirebaseAnalytics.Event.SHARE, bundle);
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97 |
|
|
|
98 |
1fa125c2
|
Leszek Koltunski
|
private void reportRecord(RubikActivity act, long startTime, long endTime, String debug, int scrambleNum)
|
99 |
1cd323dd
|
Leszek Koltunski
|
{
|
100 |
8ab435b9
|
Leszek Koltunski
|
RubikScreenPlay play= (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
101 |
|
|
RubikScores scores = RubikScores.getInstance();
|
102 |
400ff34d
|
Leszek Koltunski
|
int object = RubikObjectList.getCurrObject();
|
103 |
d433b50e
|
Leszek Koltunski
|
int level = play.getLevel();
|
104 |
|
|
String name = scores.getName();
|
105 |
|
|
RubikObject obj = RubikObjectList.getObject(object);
|
106 |
84d746d7
|
Leszek Koltunski
|
String objName = obj==null ? "NULL" : obj.getUpperName();
|
107 |
d433b50e
|
Leszek Koltunski
|
|
108 |
d38a302b
|
Leszek Koltunski
|
String record = objName+" level "+level+" time "+mNewRecord+" isNew: "+mIsNewRecord+" scrambleNum: "+scrambleNum;
|
109 |
1cd323dd
|
Leszek Koltunski
|
|
110 |
|
|
if( BuildConfig.DEBUG )
|
111 |
|
|
{
|
112 |
d38a302b
|
Leszek Koltunski
|
android.util.Log.e("libInterface", debug);
|
113 |
|
|
android.util.Log.e("libInterface", name);
|
114 |
|
|
android.util.Log.e("libInterface", record);
|
115 |
1cd323dd
|
Leszek Koltunski
|
}
|
116 |
|
|
else
|
117 |
|
|
{
|
118 |
1fa125c2
|
Leszek Koltunski
|
if( level>=9 && mNewRecord<300*level )
|
119 |
|
|
{
|
120 |
6eb4c104
|
Leszek Koltunski
|
long timeNow = System.currentTimeMillis();
|
121 |
|
|
long elapsed = timeNow - startTime;
|
122 |
1fa125c2
|
Leszek Koltunski
|
String suspicious ="start"+startTime+"end"+endTime+"elapsed"+elapsed+"obj"+objName+"level"+level+"record"+mNewRecord+"scrambles"+scrambleNum+debug;
|
123 |
|
|
RubikNetwork network = RubikNetwork.getInstance();
|
124 |
e4854e54
|
Leszek Koltunski
|
network.suspicious(suspicious,act);
|
125 |
1fa125c2
|
Leszek Koltunski
|
}
|
126 |
|
|
|
127 |
e019c70b
|
Leszek Koltunski
|
FirebaseAnalytics analytics = act.getAnalytics();
|
128 |
1cd323dd
|
Leszek Koltunski
|
|
129 |
|
|
if( analytics!=null )
|
130 |
|
|
{
|
131 |
|
|
Bundle bundle = new Bundle();
|
132 |
|
|
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, debug);
|
133 |
|
|
bundle.putString(FirebaseAnalytics.Param.CHARACTER, name);
|
134 |
|
|
bundle.putString(FirebaseAnalytics.Param.LEVEL, record);
|
135 |
|
|
analytics.logEvent(FirebaseAnalytics.Event.LEVEL_UP, bundle);
|
136 |
|
|
}
|
137 |
|
|
}
|
138 |
|
|
}
|
139 |
|
|
|
140 |
c02fa107
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
141 |
|
|
|
142 |
|
|
private Bundle createDialogBundle()
|
143 |
|
|
{
|
144 |
|
|
Bundle bundle = new Bundle();
|
145 |
|
|
String arg = String.valueOf((mNewRecord/10)/100.0f);
|
146 |
|
|
bundle.putString("argument", arg );
|
147 |
|
|
return bundle;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
1cd323dd
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151 |
|
|
|
152 |
e019c70b
|
Leszek Koltunski
|
private void requestReview(RubikActivity act)
|
153 |
1cd323dd
|
Leszek Koltunski
|
{
|
154 |
|
|
final RubikScores scores = RubikScores.getInstance();
|
155 |
|
|
int numWins = scores.incrementNumWins();
|
156 |
53b4c7ad
|
Leszek Koltunski
|
int numRuns = scores.getNumRuns();
|
157 |
1cd323dd
|
Leszek Koltunski
|
|
158 |
53b4c7ad
|
Leszek Koltunski
|
if( numRuns==3 || numRuns==6 || numWins==7 || numWins==30 || numWins==50 || numWins==80 || numWins==100)
|
159 |
1cd323dd
|
Leszek Koltunski
|
{
|
160 |
|
|
final long timeBegin = System.currentTimeMillis();
|
161 |
|
|
final ReviewManager manager = ReviewManagerFactory.create(act);
|
162 |
|
|
Task<ReviewInfo> request = manager.requestReviewFlow();
|
163 |
|
|
|
164 |
|
|
request.addOnCompleteListener(new OnCompleteListener<ReviewInfo>()
|
165 |
|
|
{
|
166 |
|
|
@Override
|
167 |
|
|
public void onComplete (@NonNull Task<ReviewInfo> task)
|
168 |
|
|
{
|
169 |
|
|
if (task.isSuccessful())
|
170 |
|
|
{
|
171 |
|
|
final String name = scores.getName();
|
172 |
|
|
ReviewInfo reviewInfo = task.getResult();
|
173 |
|
|
Task<Void> flow = manager.launchReviewFlow(act, reviewInfo);
|
174 |
|
|
|
175 |
|
|
flow.addOnFailureListener(new OnFailureListener()
|
176 |
|
|
{
|
177 |
|
|
@Override
|
178 |
|
|
public void onFailure(Exception e)
|
179 |
|
|
{
|
180 |
|
|
analyticsReport(act,"Failed", name, timeBegin);
|
181 |
|
|
}
|
182 |
|
|
});
|
183 |
|
|
|
184 |
|
|
flow.addOnCompleteListener(new OnCompleteListener<Void>()
|
185 |
|
|
{
|
186 |
|
|
@Override
|
187 |
|
|
public void onComplete(@NonNull Task<Void> task)
|
188 |
|
|
{
|
189 |
|
|
analyticsReport(act,"Complete", name, timeBegin);
|
190 |
|
|
}
|
191 |
|
|
});
|
192 |
|
|
}
|
193 |
|
|
else
|
194 |
|
|
{
|
195 |
|
|
String name = scores.getName();
|
196 |
|
|
analyticsReport(act,"Not Successful", name, timeBegin);
|
197 |
|
|
}
|
198 |
|
|
}
|
199 |
|
|
});
|
200 |
|
|
}
|
201 |
|
|
}
|
202 |
|
|
|
203 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
204 |
|
|
|
205 |
e019c70b
|
Leszek Koltunski
|
public void onScrambleEffectFinished()
|
206 |
|
|
{
|
207 |
dd874ae8
|
Leszek Koltunski
|
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
208 |
1cd323dd
|
Leszek Koltunski
|
|
209 |
dd874ae8
|
Leszek Koltunski
|
if( play.shouldReactToEndOfScrambling() )
|
210 |
e019c70b
|
Leszek Koltunski
|
{
|
211 |
dd874ae8
|
Leszek Koltunski
|
RubikActivity act = mAct.get();
|
212 |
|
|
RubikScores.getInstance().incrementNumPlays();
|
213 |
|
|
|
214 |
|
|
act.runOnUiThread(new Runnable()
|
215 |
|
|
{
|
216 |
|
|
@Override
|
217 |
|
|
public void run()
|
218 |
617b7b66
|
Leszek Koltunski
|
{
|
219 |
|
|
ScreenList.switchScreen( act, ScreenList.READ);
|
220 |
|
|
ObjectControl control = act.getControl();
|
221 |
|
|
control.unblockEverything();
|
222 |
|
|
}
|
223 |
dd874ae8
|
Leszek Koltunski
|
});
|
224 |
|
|
}
|
225 |
e019c70b
|
Leszek Koltunski
|
}
|
226 |
1cd323dd
|
Leszek Koltunski
|
|
227 |
e019c70b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
228 |
|
|
|
229 |
|
|
public void onFinishRotation(int axis, int row, int angle)
|
230 |
|
|
{
|
231 |
|
|
if( ScreenList.getCurrentScreen()== ScreenList.SOLV )
|
232 |
|
|
{
|
233 |
|
|
RubikScreenSolving solv = (RubikScreenSolving) ScreenList.SOLV.getScreenClass();
|
234 |
|
|
solv.addMove(mAct.get(), axis, row, angle);
|
235 |
|
|
}
|
236 |
|
|
if( ScreenList.getCurrentScreen()== ScreenList.PLAY )
|
237 |
|
|
{
|
238 |
|
|
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
239 |
|
|
play.addMove(mAct.get(), axis, row, angle);
|
240 |
|
|
}
|
241 |
|
|
}
|
242 |
1cd323dd
|
Leszek Koltunski
|
|
243 |
dd1a65c1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
244 |
|
|
|
245 |
e019c70b
|
Leszek Koltunski
|
public void onBeginRotation()
|
246 |
|
|
{
|
247 |
|
|
if( ScreenList.getCurrentScreen()== ScreenList.READ )
|
248 |
|
|
{
|
249 |
|
|
RubikScreenSolving solving = (RubikScreenSolving) ScreenList.SOLV.getScreenClass();
|
250 |
|
|
solving.resetElapsed();
|
251 |
|
|
RubikActivity act = mAct.get();
|
252 |
|
|
|
253 |
|
|
act.runOnUiThread(new Runnable()
|
254 |
|
|
{
|
255 |
|
|
@Override
|
256 |
|
|
public void run()
|
257 |
|
|
{
|
258 |
|
|
ScreenList.switchScreen( act, ScreenList.SOLV);
|
259 |
|
|
}
|
260 |
|
|
});
|
261 |
|
|
}
|
262 |
|
|
}
|
263 |
dd1a65c1
|
Leszek Koltunski
|
|
264 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
265 |
|
|
|
266 |
e019c70b
|
Leszek Koltunski
|
public void failedToDrag()
|
267 |
|
|
{
|
268 |
|
|
ScreenList curr = ScreenList.getCurrentScreen();
|
269 |
|
|
|
270 |
|
|
if( curr==ScreenList.PLAY )
|
271 |
|
|
{
|
272 |
|
|
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
273 |
|
|
play.reddenLock(mAct.get());
|
274 |
|
|
}
|
275 |
|
|
else if( curr==ScreenList.READ )
|
276 |
|
|
{
|
277 |
|
|
RubikScreenReady read = (RubikScreenReady) ScreenList.READ.getScreenClass();
|
278 |
|
|
read.reddenLock(mAct.get());
|
279 |
|
|
}
|
280 |
|
|
else if( curr==ScreenList.SOLV )
|
281 |
|
|
{
|
282 |
|
|
RubikScreenSolving solv = (RubikScreenSolving) ScreenList.SOLV.getScreenClass();
|
283 |
|
|
solv.reddenLock(mAct.get());
|
284 |
|
|
}
|
285 |
|
|
}
|
286 |
dd1a65c1
|
Leszek Koltunski
|
|
287 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
288 |
|
|
|
289 |
e019c70b
|
Leszek Koltunski
|
public void onSolved()
|
290 |
|
|
{
|
291 |
|
|
if( ScreenList.getCurrentScreen()== ScreenList.SOLV )
|
292 |
dd1a65c1
|
Leszek Koltunski
|
{
|
293 |
e019c70b
|
Leszek Koltunski
|
RubikScreenSolving solving = (RubikScreenSolving) ScreenList.SOLV.getScreenClass();
|
294 |
24679c47
|
Leszek Koltunski
|
mNewRecord = solving.stopTimerAndGetRecord();
|
295 |
|
|
mIsNewRecord = solving.setRecord();
|
296 |
dd1a65c1
|
Leszek Koltunski
|
}
|
297 |
e019c70b
|
Leszek Koltunski
|
}
|
298 |
dd1a65c1
|
Leszek Koltunski
|
|
299 |
e709e44d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
300 |
|
|
|
301 |
|
|
public void onObjectCreated(long time)
|
302 |
|
|
{
|
303 |
|
|
|
304 |
|
|
}
|
305 |
|
|
|
306 |
95472aca
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
307 |
|
|
|
308 |
eb647d5e
|
Leszek Koltunski
|
public void reportProblem(String problem, boolean recordException)
|
309 |
95472aca
|
Leszek Koltunski
|
{
|
310 |
|
|
if( BuildConfig.DEBUG )
|
311 |
|
|
{
|
312 |
d38a302b
|
Leszek Koltunski
|
android.util.Log.e("libInterface", problem);
|
313 |
95472aca
|
Leszek Koltunski
|
}
|
314 |
|
|
else
|
315 |
|
|
{
|
316 |
eb647d5e
|
Leszek Koltunski
|
if( recordException )
|
317 |
|
|
{
|
318 |
|
|
Exception ex = new Exception(problem);
|
319 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
320 |
|
|
crashlytics.setCustomKey("problem" , problem);
|
321 |
|
|
crashlytics.recordException(ex);
|
322 |
|
|
}
|
323 |
|
|
else
|
324 |
|
|
{
|
325 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
326 |
|
|
crashlytics.log(problem);
|
327 |
|
|
}
|
328 |
95472aca
|
Leszek Koltunski
|
}
|
329 |
|
|
}
|
330 |
|
|
|
331 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
332 |
|
|
|
333 |
919b830e
|
Leszek Koltunski
|
private void reportScramblingProblem(int place, long pause, long resume, long time)
|
334 |
95472aca
|
Leszek Koltunski
|
{
|
335 |
919b830e
|
Leszek Koltunski
|
String error = "SCRAMBLING BLOCK "+place+" blocked for "+time;
|
336 |
95472aca
|
Leszek Koltunski
|
|
337 |
|
|
if( BuildConfig.DEBUG )
|
338 |
|
|
{
|
339 |
d38a302b
|
Leszek Koltunski
|
android.util.Log.e("libInterface", error);
|
340 |
95472aca
|
Leszek Koltunski
|
}
|
341 |
|
|
else
|
342 |
|
|
{
|
343 |
|
|
Exception ex = new Exception(error);
|
344 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
345 |
|
|
crashlytics.setCustomKey("pause" , pause );
|
346 |
|
|
crashlytics.setCustomKey("resume", resume );
|
347 |
|
|
crashlytics.recordException(ex);
|
348 |
|
|
}
|
349 |
|
|
}
|
350 |
|
|
|
351 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
352 |
|
|
|
353 |
919b830e
|
Leszek Koltunski
|
private void reportRotationProblem(int place, long pause, long resume, long time)
|
354 |
95472aca
|
Leszek Koltunski
|
{
|
355 |
919b830e
|
Leszek Koltunski
|
String error = "ROTATION BLOCK "+place+" blocked for "+time;
|
356 |
95472aca
|
Leszek Koltunski
|
|
357 |
|
|
if( BuildConfig.DEBUG )
|
358 |
|
|
{
|
359 |
d38a302b
|
Leszek Koltunski
|
android.util.Log.e("libInterface", error);
|
360 |
95472aca
|
Leszek Koltunski
|
}
|
361 |
|
|
else
|
362 |
|
|
{
|
363 |
|
|
Exception ex = new Exception(error);
|
364 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
365 |
|
|
crashlytics.setCustomKey("pause" , pause );
|
366 |
|
|
crashlytics.setCustomKey("resume", resume);
|
367 |
|
|
crashlytics.recordException(ex);
|
368 |
|
|
}
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372 |
|
|
|
373 |
|
|
private void reportThreadProblem(int place, long pause, long resume, long time)
|
374 |
|
|
{
|
375 |
|
|
String error = EffectMessageSender.reportState();
|
376 |
|
|
|
377 |
|
|
if( BuildConfig.DEBUG )
|
378 |
|
|
{
|
379 |
d38a302b
|
Leszek Koltunski
|
android.util.Log.e("libInterface", error);
|
380 |
95472aca
|
Leszek Koltunski
|
}
|
381 |
|
|
else
|
382 |
|
|
{
|
383 |
|
|
Exception ex = new Exception(error);
|
384 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
385 |
|
|
crashlytics.setCustomKey("pause" , pause );
|
386 |
|
|
crashlytics.setCustomKey("resume", resume );
|
387 |
|
|
crashlytics.recordException(ex);
|
388 |
|
|
}
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
392 |
|
|
|
393 |
|
|
public void reportBlockProblem(int type, int place, long pause, long resume, long time)
|
394 |
|
|
{
|
395 |
|
|
switch(type)
|
396 |
|
|
{
|
397 |
919b830e
|
Leszek Koltunski
|
case BlockController.TYPE_SCRAMBLING: reportScramblingProblem(place,pause,resume,time); break;
|
398 |
|
|
case BlockController.TYPE_ROTATION : reportRotationProblem(place,pause,resume,time); break;
|
399 |
|
|
case BlockController.TYPE_THREAD : reportThreadProblem(place,pause,resume,time); break;
|
400 |
95472aca
|
Leszek Koltunski
|
}
|
401 |
|
|
}
|
402 |
|
|
|
403 |
c020555e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
404 |
|
|
|
405 |
|
|
public void reportJSONError(String error, int ordinal)
|
406 |
|
|
{
|
407 |
|
|
RubikObject object = RubikObjectList.getObject(ordinal);
|
408 |
|
|
String name = object==null ? "NULL" : object.getUpperName();
|
409 |
|
|
|
410 |
|
|
if( BuildConfig.DEBUG )
|
411 |
|
|
{
|
412 |
|
|
android.util.Log.e("libInterface", "name="+name+" JSON error: "+error);
|
413 |
|
|
}
|
414 |
|
|
else
|
415 |
|
|
{
|
416 |
|
|
Exception ex = new Exception(error);
|
417 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
418 |
|
|
crashlytics.setCustomKey("name" , name );
|
419 |
|
|
crashlytics.setCustomKey("JSONerror", error );
|
420 |
|
|
crashlytics.recordException(ex);
|
421 |
|
|
}
|
422 |
|
|
}
|
423 |
|
|
|
424 |
1cd323dd
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
425 |
|
|
|
426 |
5c4ed8ed
|
Leszek Koltunski
|
public void onReplaceModeDown(int cubit, int face)
|
427 |
e019c70b
|
Leszek Koltunski
|
{
|
428 |
|
|
RubikScreenSolver solver = (RubikScreenSolver) ScreenList.SVER.getScreenClass();
|
429 |
5c4ed8ed
|
Leszek Koltunski
|
int color = solver.getCurrentColor();
|
430 |
400ff34d
|
Leszek Koltunski
|
int currObject = RubikObjectList.getCurrObject();
|
431 |
5c4ed8ed
|
Leszek Koltunski
|
mLastCubitColor = SolverMain.cubitIsLocked(currObject,cubit);
|
432 |
|
|
mLastCubit = cubit;
|
433 |
|
|
mLastCubitFace = face;
|
434 |
|
|
ObjectControl control = mAct.get().getControl();
|
435 |
|
|
control.setTextureMap( cubit, face, color );
|
436 |
e019c70b
|
Leszek Koltunski
|
}
|
437 |
1cd323dd
|
Leszek Koltunski
|
|
438 |
e019c70b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
439 |
|
|
|
440 |
5c4ed8ed
|
Leszek Koltunski
|
public void onReplaceModeUp()
|
441 |
e019c70b
|
Leszek Koltunski
|
{
|
442 |
5c4ed8ed
|
Leszek Koltunski
|
if( mLastCubitColor>=0 )
|
443 |
|
|
{
|
444 |
|
|
ObjectControl control = mAct.get().getControl();
|
445 |
|
|
control.setTextureMap( mLastCubit, mLastCubitFace, mLastCubitColor );
|
446 |
|
|
mLastCubitColor = -1;
|
447 |
|
|
}
|
448 |
e019c70b
|
Leszek Koltunski
|
}
|
449 |
d7f0c07d
|
Leszek Koltunski
|
|
450 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
451 |
|
|
|
452 |
|
|
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum)
|
453 |
|
|
{
|
454 |
|
|
if( ScreenList.getCurrentScreen()== ScreenList.SOLV )
|
455 |
|
|
{
|
456 |
|
|
RubikActivity act = mAct.get();
|
457 |
|
|
reportRecord(act,startTime,endTime,debug,scrambleNum);
|
458 |
|
|
requestReview(act);
|
459 |
|
|
|
460 |
|
|
switch(mIsNewRecord)
|
461 |
|
|
{
|
462 |
e9e744f7
|
Leszek Koltunski
|
case RECORD_FIRST : if( RubikActivity.USE_IAP )
|
463 |
|
|
{
|
464 |
|
|
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
465 |
|
|
int level = play.getLevel();
|
466 |
|
|
RubikScores scores = RubikScores.getInstance();
|
467 |
|
|
int newStars = scores.computeNumStars(level);
|
468 |
|
|
int totStars = scores.getNumStars();
|
469 |
|
|
scores.changeNumStars(newStars);
|
470 |
|
|
DistortedScreen screen = act.getScreen();
|
471 |
|
|
OverlayStars stars = new OverlayStars();
|
472 |
|
|
DataStars data = new DataStars(totStars,newStars,act.getResources());
|
473 |
|
|
stars.startOverlay(screen,this,data);
|
474 |
|
|
}
|
475 |
|
|
else
|
476 |
|
|
{
|
477 |
c02fa107
|
Leszek Koltunski
|
Bundle bundle = createDialogBundle();
|
478 |
e9e744f7
|
Leszek Koltunski
|
RubikDialogNewRecord d2 = new RubikDialogNewRecord();
|
479 |
|
|
d2.setArguments(bundle);
|
480 |
|
|
d2.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
|
481 |
|
|
}
|
482 |
d7f0c07d
|
Leszek Koltunski
|
break;
|
483 |
c02fa107
|
Leszek Koltunski
|
case RECORD_NEW : Bundle byes = createDialogBundle();
|
484 |
|
|
RubikDialogNewRecord dyes = new RubikDialogNewRecord();
|
485 |
|
|
dyes.setArguments(byes);
|
486 |
|
|
dyes.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
|
487 |
d7f0c07d
|
Leszek Koltunski
|
break;
|
488 |
c02fa107
|
Leszek Koltunski
|
case RECORD_NOT_NEW: Bundle bno = createDialogBundle();
|
489 |
|
|
RubikDialogSolved dno = new RubikDialogSolved();
|
490 |
|
|
dno.setArguments(bno);
|
491 |
|
|
dno.show( act.getSupportFragmentManager(), RubikDialogSolved.getDialogTag() );
|
492 |
d7f0c07d
|
Leszek Koltunski
|
break;
|
493 |
|
|
}
|
494 |
|
|
|
495 |
|
|
act.runOnUiThread(new Runnable()
|
496 |
|
|
{
|
497 |
|
|
@Override
|
498 |
|
|
public void run()
|
499 |
|
|
{
|
500 |
|
|
ScreenList.switchScreen( act, ScreenList.DONE);
|
501 |
|
|
}
|
502 |
|
|
});
|
503 |
|
|
}
|
504 |
|
|
}
|
505 |
|
|
|
506 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
507 |
|
|
|
508 |
|
|
public void overlayFinished(long id)
|
509 |
|
|
{
|
510 |
|
|
RubikActivity act = mAct.get();
|
511 |
c02fa107
|
Leszek Koltunski
|
Bundle bundle = createDialogBundle();
|
512 |
|
|
RubikDialogNewRecord d = new RubikDialogNewRecord();
|
513 |
|
|
d.setArguments(bundle);
|
514 |
|
|
d.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
|
515 |
d7f0c07d
|
Leszek Koltunski
|
}
|
516 |
1cd323dd
|
Leszek Koltunski
|
}
|