1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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.config;
|
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
|
|
19
|
import java.lang.ref.WeakReference;
|
20
|
|
21
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
22
|
|
23
|
public class ConfigObjectLibInterface implements ObjectLibInterface
|
24
|
{
|
25
|
private final WeakReference<ConfigActivity> mAct;
|
26
|
|
27
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28
|
|
29
|
ConfigObjectLibInterface(ConfigActivity act)
|
30
|
{
|
31
|
mAct = new WeakReference<>(act);
|
32
|
}
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35
|
|
36
|
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
|
37
|
public void onScrambleEffectFinished() { }
|
38
|
public void onBeginRotation() { }
|
39
|
public void onSolved() { }
|
40
|
public void onObjectCreated(long time) { }
|
41
|
public void onRemoveRotation(int axis, int row, int angle) { }
|
42
|
public void failedToDrag() { }
|
43
|
public void reportJSONError(String error, int ordinal) { }
|
44
|
|
45
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46
|
|
47
|
public void reportProblem(String problem, boolean reportException)
|
48
|
{
|
49
|
if( BuildConfig.DEBUG )
|
50
|
{
|
51
|
android.util.Log.e("interface", problem);
|
52
|
}
|
53
|
else
|
54
|
{
|
55
|
if( reportException )
|
56
|
{
|
57
|
Exception ex = new Exception(problem);
|
58
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
59
|
crashlytics.setCustomKey("problem" , problem);
|
60
|
crashlytics.recordException(ex);
|
61
|
}
|
62
|
else
|
63
|
{
|
64
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
65
|
crashlytics.log(problem);
|
66
|
}
|
67
|
}
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71
|
|
72
|
private void reportScramblingProblem(int place, long pause, long resume, long time)
|
73
|
{
|
74
|
String error = "SCRAMBLING BLOCK "+place+" blocked for "+time;
|
75
|
|
76
|
if( BuildConfig.DEBUG )
|
77
|
{
|
78
|
android.util.Log.e("D", error);
|
79
|
}
|
80
|
else
|
81
|
{
|
82
|
Exception ex = new Exception(error);
|
83
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
84
|
crashlytics.setCustomKey("pause" , pause );
|
85
|
crashlytics.setCustomKey("resume", resume );
|
86
|
crashlytics.recordException(ex);
|
87
|
}
|
88
|
}
|
89
|
|
90
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91
|
|
92
|
private void reportRotationProblem(int place, long pause, long resume, long time)
|
93
|
{
|
94
|
String error = "ROTATION BLOCK "+place+" blocked for "+time;
|
95
|
|
96
|
if( BuildConfig.DEBUG )
|
97
|
{
|
98
|
android.util.Log.e("D", error);
|
99
|
}
|
100
|
else
|
101
|
{
|
102
|
Exception ex = new Exception(error);
|
103
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
104
|
crashlytics.setCustomKey("pause" , pause );
|
105
|
crashlytics.setCustomKey("resume", resume);
|
106
|
crashlytics.recordException(ex);
|
107
|
}
|
108
|
}
|
109
|
|
110
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
111
|
|
112
|
private void reportThreadProblem(int place, long pause, long resume, long time)
|
113
|
{
|
114
|
String error = EffectMessageSender.reportState();
|
115
|
|
116
|
if( BuildConfig.DEBUG )
|
117
|
{
|
118
|
android.util.Log.e("D", error);
|
119
|
}
|
120
|
else
|
121
|
{
|
122
|
Exception ex = new Exception(error);
|
123
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
124
|
crashlytics.setCustomKey("pause" , pause );
|
125
|
crashlytics.setCustomKey("resume", resume );
|
126
|
crashlytics.recordException(ex);
|
127
|
}
|
128
|
}
|
129
|
|
130
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
131
|
|
132
|
public void reportBlockProblem(int type, int place, long pause, long resume, long time)
|
133
|
{
|
134
|
switch(type)
|
135
|
{
|
136
|
case BlockController.TYPE_SCRAMBLING: reportScramblingProblem(place,pause,resume,time); break;
|
137
|
case BlockController.TYPE_ROTATION : reportRotationProblem(place,pause,resume,time); break;
|
138
|
case BlockController.TYPE_THREAD : reportThreadProblem(place,pause,resume,time); break;
|
139
|
}
|
140
|
}
|
141
|
|
142
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
143
|
|
144
|
public void onReplaceModeDown(int cubit, int face)
|
145
|
{
|
146
|
ConfigActivity act = mAct.get();
|
147
|
act.repaintPuzzleFace(cubit,face);
|
148
|
}
|
149
|
|
150
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151
|
|
152
|
public void onReplaceModeUp()
|
153
|
{
|
154
|
|
155
|
}
|
156
|
}
|