1 |
e9245b7b
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2023 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.patternui;
|
11 |
|
|
|
12 |
|
|
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
13 |
|
|
|
14 |
|
|
import org.distorted.library.message.EffectMessageSender;
|
15 |
|
|
import org.distorted.main.BuildConfig;
|
16 |
|
|
import org.distorted.objectlib.helpers.BlockController;
|
17 |
|
|
import org.distorted.objectlib.helpers.ObjectLibInterface;
|
18 |
|
|
import org.distorted.objects.RubikObject;
|
19 |
|
|
import org.distorted.objects.RubikObjectList;
|
20 |
|
|
|
21 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
22 |
|
|
|
23 |
|
|
public class PatternObjectLibInterface implements ObjectLibInterface
|
24 |
|
|
{
|
25 |
|
|
PatternObjectLibInterface(PatternActivity act) { }
|
26 |
|
|
public void onScrambleEffectFinished() { }
|
27 |
4c6cbfa2
|
leszek
|
public void onRemoveRotation(int axis, int row, int angle) { }
|
28 |
e9245b7b
|
leszek
|
public void onBeginRotation() { }
|
29 |
|
|
public void failedToDrag() { }
|
30 |
|
|
public void onSolved() { }
|
31 |
|
|
public void onObjectCreated(long time) { }
|
32 |
|
|
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
|
33 |
|
|
public void onReplaceModeDown(int cubit, int face) { }
|
34 |
|
|
public void onReplaceModeUp() { }
|
35 |
|
|
|
36 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37 |
|
|
|
38 |
|
|
public void reportProblem(String problem, boolean recordException)
|
39 |
|
|
{
|
40 |
|
|
if( BuildConfig.DEBUG )
|
41 |
|
|
{
|
42 |
|
|
android.util.Log.e("libInterface", problem);
|
43 |
|
|
}
|
44 |
|
|
else
|
45 |
|
|
{
|
46 |
|
|
if( recordException )
|
47 |
|
|
{
|
48 |
|
|
Exception ex = new Exception(problem);
|
49 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
50 |
|
|
crashlytics.setCustomKey("problem" , problem);
|
51 |
|
|
crashlytics.recordException(ex);
|
52 |
|
|
}
|
53 |
|
|
else
|
54 |
|
|
{
|
55 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
56 |
|
|
crashlytics.log(problem);
|
57 |
|
|
}
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
|
|
|
63 |
|
|
private void reportScramblingProblem(int place, long pause, long resume, long time)
|
64 |
|
|
{
|
65 |
|
|
String error = "SCRAMBLING BLOCK "+place+" blocked for "+time;
|
66 |
|
|
|
67 |
|
|
if( BuildConfig.DEBUG )
|
68 |
|
|
{
|
69 |
|
|
android.util.Log.e("libInterface", error);
|
70 |
|
|
}
|
71 |
|
|
else
|
72 |
|
|
{
|
73 |
|
|
Exception ex = new Exception(error);
|
74 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
75 |
|
|
crashlytics.setCustomKey("pause" , pause );
|
76 |
|
|
crashlytics.setCustomKey("resume", resume );
|
77 |
|
|
crashlytics.recordException(ex);
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82 |
|
|
|
83 |
|
|
private void reportRotationProblem(int place, long pause, long resume, long time)
|
84 |
|
|
{
|
85 |
|
|
String error = "ROTATION BLOCK "+place+" blocked for "+time;
|
86 |
|
|
|
87 |
|
|
if( BuildConfig.DEBUG )
|
88 |
|
|
{
|
89 |
|
|
android.util.Log.e("libInterface", error);
|
90 |
|
|
}
|
91 |
|
|
else
|
92 |
|
|
{
|
93 |
|
|
Exception ex = new Exception(error);
|
94 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
95 |
|
|
crashlytics.setCustomKey("pause" , pause );
|
96 |
|
|
crashlytics.setCustomKey("resume", resume);
|
97 |
|
|
crashlytics.recordException(ex);
|
98 |
|
|
}
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102 |
|
|
|
103 |
|
|
private void reportThreadProblem(int place, long pause, long resume, long time)
|
104 |
|
|
{
|
105 |
|
|
String error = EffectMessageSender.reportState();
|
106 |
|
|
|
107 |
|
|
if( BuildConfig.DEBUG )
|
108 |
|
|
{
|
109 |
|
|
android.util.Log.e("libInterface", error);
|
110 |
|
|
}
|
111 |
|
|
else
|
112 |
|
|
{
|
113 |
|
|
Exception ex = new Exception(error);
|
114 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
115 |
|
|
crashlytics.setCustomKey("pause" , pause );
|
116 |
|
|
crashlytics.setCustomKey("resume", resume );
|
117 |
|
|
crashlytics.recordException(ex);
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122 |
|
|
|
123 |
|
|
public void reportBlockProblem(int type, int place, long pause, long resume, long time)
|
124 |
|
|
{
|
125 |
|
|
switch(type)
|
126 |
|
|
{
|
127 |
|
|
case BlockController.TYPE_SCRAMBLING: reportScramblingProblem(place,pause,resume,time); break;
|
128 |
|
|
case BlockController.TYPE_ROTATION : reportRotationProblem(place,pause,resume,time); break;
|
129 |
|
|
case BlockController.TYPE_THREAD : reportThreadProblem(place,pause,resume,time); break;
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134 |
|
|
|
135 |
|
|
public void reportJSONError(String error, int ordinal)
|
136 |
|
|
{
|
137 |
|
|
RubikObject object = RubikObjectList.getObject(ordinal);
|
138 |
|
|
String name = object==null ? "NULL" : object.getUpperName();
|
139 |
|
|
|
140 |
|
|
if( BuildConfig.DEBUG )
|
141 |
|
|
{
|
142 |
|
|
android.util.Log.e("libInterface", "name="+name+" JSON error: "+error);
|
143 |
|
|
}
|
144 |
|
|
else
|
145 |
|
|
{
|
146 |
|
|
Exception ex = new Exception(error);
|
147 |
|
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
148 |
|
|
crashlytics.setCustomKey("name" , name );
|
149 |
|
|
crashlytics.setCustomKey("JSONerror", error );
|
150 |
|
|
crashlytics.recordException(ex);
|
151 |
|
|
}
|
152 |
|
|
}
|
153 |
|
|
}
|