1 |
1cd323dd
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
05c20dad
|
Leszek Koltunski
|
// Copyright 2021 Leszek Koltunski //
|
3 |
1cd323dd
|
Leszek Koltunski
|
// //
|
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 |
95472aca
|
Leszek Koltunski
|
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 |
e019c70b
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectLibInterface;
|
28 |
1cd323dd
|
Leszek Koltunski
|
|
29 |
e019c70b
|
Leszek Koltunski
|
import java.lang.ref.WeakReference;
|
30 |
|
|
|
31 |
1cd323dd
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32 |
|
|
|
33 |
e019c70b
|
Leszek Koltunski
|
public class TutorialObjectLibInterface implements ObjectLibInterface
|
34 |
1cd323dd
|
Leszek Koltunski
|
{
|
35 |
e019c70b
|
Leszek Koltunski
|
WeakReference<TutorialActivity> mAct;
|
36 |
|
|
|
37 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38 |
|
|
|
39 |
|
|
TutorialObjectLibInterface(TutorialActivity act)
|
40 |
|
|
{
|
41 |
|
|
mAct = new WeakReference<>(act);
|
42 |
|
|
}
|
43 |
|
|
|
44 |
1fa125c2
|
Leszek Koltunski
|
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
|
45 |
95472aca
|
Leszek Koltunski
|
public void onScrambleEffectFinished() { }
|
46 |
|
|
public void onBeginRotation() { }
|
47 |
|
|
public void onSolved() { }
|
48 |
|
|
public void onObjectCreated(long time) { }
|
49 |
5c4ed8ed
|
Leszek Koltunski
|
public void onReplaceModeDown(int cubit, int face) { }
|
50 |
|
|
public void onReplaceModeUp() { }
|
51 |
95472aca
|
Leszek Koltunski
|
|
52 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53 |
|
|
|
54 |
eb647d5e
|
Leszek Koltunski
|
public void reportProblem(String problem, boolean reportException)
|
55 |
95472aca
|
Leszek Koltunski
|
{
|
56 |
|
|
if( BuildConfig.DEBUG )
|
57 |
|
|
{
|
58 |
|
|
android.util.Log.e("interface", problem);
|
59 |
|
|
}
|
60 |
|
|
else
|
61 |
|
|
{
|
62 |
eb647d5e
|
Leszek Koltunski
|
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 |
95472aca
|
Leszek Koltunski
|
}
|
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 |
dd1a65c1
|
Leszek Koltunski
|
|
149 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
150 |
|
|
|
151 |
e019c70b
|
Leszek Koltunski
|
public void onFinishRotation(int axis, int row, int angle)
|
152 |
dd1a65c1
|
Leszek Koltunski
|
{
|
153 |
e019c70b
|
Leszek Koltunski
|
TutorialActivity act = mAct.get();
|
154 |
|
|
TutorialScreen state = act.getState();
|
155 |
4cad53b4
|
Leszek Koltunski
|
if( state!=null ) state.addMove(act, axis, row, angle);
|
156 |
dd1a65c1
|
Leszek Koltunski
|
}
|
157 |
|
|
|
158 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
159 |
|
|
|
160 |
e019c70b
|
Leszek Koltunski
|
public void failedToDrag()
|
161 |
dd1a65c1
|
Leszek Koltunski
|
{
|
162 |
e019c70b
|
Leszek Koltunski
|
TutorialActivity act = mAct.get();
|
163 |
|
|
TutorialScreen state = act.getState();
|
164 |
dd1a65c1
|
Leszek Koltunski
|
state.reddenLock(act);
|
165 |
|
|
}
|
166 |
1cd323dd
|
Leszek Koltunski
|
}
|