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