1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2022 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.bandaged;
|
21
|
|
22
|
import java.lang.ref.WeakReference;
|
23
|
|
24
|
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
25
|
|
26
|
import org.distorted.library.message.EffectMessageSender;
|
27
|
import org.distorted.objectlib.BuildConfig;
|
28
|
import org.distorted.objectlib.helpers.BlockController;
|
29
|
import org.distorted.objectlib.helpers.ObjectLibInterface;
|
30
|
|
31
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32
|
|
33
|
public class BandagedPlayLibInterface implements ObjectLibInterface
|
34
|
{
|
35
|
private final WeakReference<BandagedPlayActivity> mAct;
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
BandagedPlayLibInterface(BandagedPlayActivity act)
|
40
|
{
|
41
|
mAct = new WeakReference<>(act);
|
42
|
}
|
43
|
|
44
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
45
|
|
46
|
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
|
47
|
public void onScrambleEffectFinished() { }
|
48
|
public void onBeginRotation() { }
|
49
|
public void onSolved() { }
|
50
|
public void onObjectCreated(long time) { }
|
51
|
public void onReplaceModeDown(int cubit, int face) { }
|
52
|
public void onReplaceModeUp() { }
|
53
|
public void reportJSONError(String error, int ordinal) { }
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
|
57
|
public void onFinishRotation(int axis, int row, int angle)
|
58
|
{
|
59
|
BandagedPlayActivity act = mAct.get();
|
60
|
|
61
|
if( act!=null )
|
62
|
{
|
63
|
BandagedPlayScreen play = act.getScreen();
|
64
|
play.addMove(act,axis,row,angle);
|
65
|
}
|
66
|
}
|
67
|
|
68
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69
|
|
70
|
public void failedToDrag()
|
71
|
{
|
72
|
BandagedPlayActivity act = mAct.get();
|
73
|
|
74
|
if( act!=null )
|
75
|
{
|
76
|
BandagedPlayScreen play = act.getScreen();
|
77
|
play.reddenLock(act);
|
78
|
}
|
79
|
}
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
|
83
|
public void reportProblem(String problem, boolean reportException)
|
84
|
{
|
85
|
if( BuildConfig.DEBUG )
|
86
|
{
|
87
|
android.util.Log.e("interface", problem);
|
88
|
}
|
89
|
else
|
90
|
{
|
91
|
if( reportException )
|
92
|
{
|
93
|
Exception ex = new Exception(problem);
|
94
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
95
|
crashlytics.setCustomKey("problem" , problem);
|
96
|
crashlytics.recordException(ex);
|
97
|
}
|
98
|
else
|
99
|
{
|
100
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
101
|
crashlytics.log(problem);
|
102
|
}
|
103
|
}
|
104
|
}
|
105
|
|
106
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107
|
|
108
|
private void reportUIProblem(int place, long pause, long resume, long time)
|
109
|
{
|
110
|
String error = "UI BLOCK "+place+" blocked for "+time;
|
111
|
|
112
|
if( BuildConfig.DEBUG )
|
113
|
{
|
114
|
android.util.Log.e("D", error);
|
115
|
}
|
116
|
else
|
117
|
{
|
118
|
Exception ex = new Exception(error);
|
119
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
120
|
crashlytics.setCustomKey("pause" , pause );
|
121
|
crashlytics.setCustomKey("resume", resume );
|
122
|
crashlytics.recordException(ex);
|
123
|
}
|
124
|
}
|
125
|
|
126
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
127
|
|
128
|
private void reportTouchProblem(int place, long pause, long resume, long time)
|
129
|
{
|
130
|
String error = "TOUCH BLOCK "+place+" blocked for "+time;
|
131
|
|
132
|
if( BuildConfig.DEBUG )
|
133
|
{
|
134
|
android.util.Log.e("D", error);
|
135
|
}
|
136
|
else
|
137
|
{
|
138
|
Exception ex = new Exception(error);
|
139
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
140
|
crashlytics.setCustomKey("pause" , pause );
|
141
|
crashlytics.setCustomKey("resume", resume);
|
142
|
crashlytics.recordException(ex);
|
143
|
}
|
144
|
}
|
145
|
|
146
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
147
|
|
148
|
private void reportThreadProblem(int place, long pause, long resume, long time)
|
149
|
{
|
150
|
String error = EffectMessageSender.reportState();
|
151
|
|
152
|
if( BuildConfig.DEBUG )
|
153
|
{
|
154
|
android.util.Log.e("D", error);
|
155
|
}
|
156
|
else
|
157
|
{
|
158
|
Exception ex = new Exception(error);
|
159
|
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
160
|
crashlytics.setCustomKey("pause" , pause );
|
161
|
crashlytics.setCustomKey("resume", resume );
|
162
|
crashlytics.recordException(ex);
|
163
|
}
|
164
|
}
|
165
|
|
166
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
167
|
|
168
|
public void reportBlockProblem(int type, int place, long pause, long resume, long time)
|
169
|
{
|
170
|
switch(type)
|
171
|
{
|
172
|
case BlockController.TYPE_UI : reportUIProblem(place,pause,resume,time); break;
|
173
|
case BlockController.TYPE_TOUCH : reportTouchProblem(place,pause,resume,time); break;
|
174
|
case BlockController.TYPE_THREAD: reportThreadProblem(place,pause,resume,time); break;
|
175
|
}
|
176
|
}
|
177
|
}
|