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