Revision 5b22f901
Added by Leszek Koltunski over 1 year ago
| src/main/AndroidManifest.xml | ||
|---|---|---|
| 31 | 31 |
</activity> |
| 32 | 32 |
|
| 33 | 33 |
<activity android:name="org.distorted.tutorials.TutorialActivity" android:exported="false" android:screenOrientation="portrait"/> |
| 34 |
<activity android:name="org.distorted.config.ConfigActivity" android:exported="false" android:screenOrientation="portrait"/>
|
|
| 34 |
<activity android:name="org.distorted.info.InfoActivity" android:exported="false" android:screenOrientation="portrait"/>
|
|
| 35 | 35 |
<activity android:name="org.distorted.bandaged.BandagedActivity" android:exported="false" android:screenOrientation="portrait"/> |
| 36 | 36 |
<activity android:name="org.distorted.purchase.PurchaseActivity" android:exported="false" android:screenOrientation="portrait"/> |
| 37 | 37 |
<activity android:name="org.distorted.solverui.SolverActivity" android:exported="false" android:screenOrientation="portrait"/> |
| src/main/java/org/distorted/config/ConfigActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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 java.io.InputStream; |
|
| 13 |
|
|
| 14 |
import android.os.Build; |
|
| 15 |
import android.os.Bundle; |
|
| 16 |
import android.util.DisplayMetrics; |
|
| 17 |
import android.view.View; |
|
| 18 |
import android.view.ViewGroup; |
|
| 19 |
import android.view.WindowManager; |
|
| 20 |
import android.widget.LinearLayout; |
|
| 21 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 22 |
|
|
| 23 |
import org.distorted.library.main.DistortedLibrary; |
|
| 24 |
import org.distorted.main.MainActivity; |
|
| 25 |
import org.distorted.objectlib.main.InitAssets; |
|
| 26 |
import org.distorted.objectlib.main.ObjectControl; |
|
| 27 |
import org.distorted.main.R; |
|
| 28 |
import org.distorted.dialogs.RubikDialogError; |
|
| 29 |
import org.distorted.objectlib.main.TwistyObject; |
|
| 30 |
import org.distorted.objects.RubikObject; |
|
| 31 |
import org.distorted.objects.RubikObjectList; |
|
| 32 |
|
|
| 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 34 |
|
|
| 35 |
public class ConfigActivity extends AppCompatActivity |
|
| 36 |
{
|
|
| 37 |
private static final int ACTIVITY_NUMBER = 1; |
|
| 38 |
private static final float RATIO_BAR = MainActivity.RATIO_BAR; |
|
| 39 |
public static final int FLAGS = MainActivity.FLAGS; |
|
| 40 |
|
|
| 41 |
private static int mScreenWidth, mScreenHeight; |
|
| 42 |
private int mCurrentApiVersion; |
|
| 43 |
private ConfigScreen mScreen; |
|
| 44 |
private int mObjectOrdinal; |
|
| 45 |
private int mHeightBar; |
|
| 46 |
|
|
| 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 48 |
|
|
| 49 |
@Override |
|
| 50 |
protected void onCreate(Bundle savedState) |
|
| 51 |
{
|
|
| 52 |
super.onCreate(savedState); |
|
| 53 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
|
| 54 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 55 |
setContentView(R.layout.config); |
|
| 56 |
|
|
| 57 |
Bundle b = getIntent().getExtras(); |
|
| 58 |
|
|
| 59 |
if(b != null) mObjectOrdinal = b.getInt("obj");
|
|
| 60 |
|
|
| 61 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 62 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 63 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 64 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 65 |
|
|
| 66 |
hideNavigationBar(); |
|
| 67 |
cutoutHack(); |
|
| 68 |
computeBarHeights(); |
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 72 |
// this does not include possible insets |
|
| 73 |
|
|
| 74 |
private void computeBarHeights() |
|
| 75 |
{
|
|
| 76 |
int barHeight = (int)(mScreenHeight*RATIO_BAR); |
|
| 77 |
mHeightBar = barHeight; |
|
| 78 |
|
|
| 79 |
LinearLayout layout = findViewById(R.id.lowerBar); |
|
| 80 |
ViewGroup.LayoutParams params = layout.getLayoutParams(); |
|
| 81 |
params.height = barHeight; |
|
| 82 |
layout.setLayoutParams(params); |
|
| 83 |
} |
|
| 84 |
|
|
| 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 86 |
|
|
| 87 |
private void hideNavigationBar() |
|
| 88 |
{
|
|
| 89 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 90 |
|
|
| 91 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 92 |
{
|
|
| 93 |
final View decorView = getWindow().getDecorView(); |
|
| 94 |
|
|
| 95 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 96 |
|
|
| 97 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 98 |
{
|
|
| 99 |
@Override |
|
| 100 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 101 |
{
|
|
| 102 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 103 |
{
|
|
| 104 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 105 |
} |
|
| 106 |
} |
|
| 107 |
}); |
|
| 108 |
} |
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 112 |
// do not avoid cutouts |
|
| 113 |
|
|
| 114 |
private void cutoutHack() |
|
| 115 |
{
|
|
| 116 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
| 117 |
{
|
|
| 118 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 119 |
} |
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 123 |
|
|
| 124 |
@Override |
|
| 125 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 126 |
{
|
|
| 127 |
super.onWindowFocusChanged(hasFocus); |
|
| 128 |
|
|
| 129 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
| 130 |
{
|
|
| 131 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 132 |
} |
|
| 133 |
} |
|
| 134 |
|
|
| 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 136 |
|
|
| 137 |
@Override |
|
| 138 |
protected void onPause() |
|
| 139 |
{
|
|
| 140 |
super.onPause(); |
|
| 141 |
ConfigSurfaceView view = findViewById(R.id.configSurfaceView); |
|
| 142 |
view.onPause(); |
|
| 143 |
DistortedLibrary.onPause(ACTIVITY_NUMBER); |
|
| 144 |
} |
|
| 145 |
|
|
| 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 147 |
|
|
| 148 |
@Override |
|
| 149 |
protected void onResume() |
|
| 150 |
{
|
|
| 151 |
super.onResume(); |
|
| 152 |
DistortedLibrary.onResume(ACTIVITY_NUMBER); |
|
| 153 |
ConfigSurfaceView view = findViewById(R.id.configSurfaceView); |
|
| 154 |
view.onResume(); |
|
| 155 |
|
|
| 156 |
if( mScreen==null ) mScreen = new ConfigScreen(); |
|
| 157 |
mScreen.onAttachedToWindow(this,mObjectOrdinal); |
|
| 158 |
|
|
| 159 |
if( mObjectOrdinal>=0 && mObjectOrdinal< RubikObjectList.getNumObjects() ) |
|
| 160 |
{
|
|
| 161 |
RubikObject object = RubikObjectList.getObject(mObjectOrdinal); |
|
| 162 |
changeIfDifferent(object,mObjectOrdinal,view.getObjectControl()); |
|
| 163 |
} |
|
| 164 |
} |
|
| 165 |
|
|
| 166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 167 |
|
|
| 168 |
@Override |
|
| 169 |
protected void onDestroy() |
|
| 170 |
{
|
|
| 171 |
super.onDestroy(); |
|
| 172 |
DistortedLibrary.onDestroy(ACTIVITY_NUMBER); |
|
| 173 |
} |
|
| 174 |
|
|
| 175 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 176 |
|
|
| 177 |
void OpenGLError() |
|
| 178 |
{
|
|
| 179 |
RubikDialogError errDiag = new RubikDialogError(); |
|
| 180 |
errDiag.show(getSupportFragmentManager(), null); |
|
| 181 |
} |
|
| 182 |
|
|
| 183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 184 |
|
|
| 185 |
private void changeIfDifferent(RubikObject object,int ordinal,ObjectControl control) |
|
| 186 |
{
|
|
| 187 |
if( object!=null ) |
|
| 188 |
{
|
|
| 189 |
int iconMode = TwistyObject.MODE_NORM; |
|
| 190 |
InputStream jsonStream = object.getObjectStream(this); |
|
| 191 |
InputStream meshStream = object.getMeshStream(this); |
|
| 192 |
String name = object.getUpperName(); |
|
| 193 |
InitAssets asset = new InitAssets(jsonStream,meshStream,null); |
|
| 194 |
control.changeIfDifferent(ordinal,name,iconMode,asset); |
|
| 195 |
} |
|
| 196 |
} |
|
| 197 |
|
|
| 198 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 199 |
// PUBLIC API |
|
| 200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 201 |
|
|
| 202 |
public void changeObject(int ordinal) |
|
| 203 |
{
|
|
| 204 |
mObjectOrdinal = ordinal; |
|
| 205 |
RubikObject object = RubikObjectList.getObject(ordinal); |
|
| 206 |
ConfigSurfaceView view = findViewById(R.id.configSurfaceView); |
|
| 207 |
ObjectControl control = view.getObjectControl(); |
|
| 208 |
changeIfDifferent(object,ordinal,control); |
|
| 209 |
} |
|
| 210 |
|
|
| 211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 212 |
|
|
| 213 |
public int getHeightBar() |
|
| 214 |
{
|
|
| 215 |
return mHeightBar; |
|
| 216 |
} |
|
| 217 |
|
|
| 218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 219 |
|
|
| 220 |
public int getScreenWidthInPixels() |
|
| 221 |
{
|
|
| 222 |
return mScreenWidth; |
|
| 223 |
} |
|
| 224 |
|
|
| 225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 226 |
|
|
| 227 |
public int getScreenHeightInPixels() |
|
| 228 |
{
|
|
| 229 |
return mScreenHeight; |
|
| 230 |
} |
|
| 231 |
|
|
| 232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 233 |
|
|
| 234 |
public ObjectControl getControl() |
|
| 235 |
{
|
|
| 236 |
ConfigSurfaceView view = findViewById(R.id.configSurfaceView); |
|
| 237 |
return view.getObjectControl(); |
|
| 238 |
} |
|
| 239 |
} |
|
| src/main/java/org/distorted/config/ConfigObjectLibInterface.java | ||
|---|---|---|
| 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 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 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 onRemoveRotation(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 |
} |
|
| src/main/java/org/distorted/config/ConfigRenderer.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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 android.content.res.Resources; |
|
| 13 |
import android.opengl.GLSurfaceView; |
|
| 14 |
|
|
| 15 |
import org.distorted.library.effect.EffectType; |
|
| 16 |
import org.distorted.library.effect.VertexEffectQuaternion; |
|
| 17 |
import org.distorted.library.effect.VertexEffectRotate; |
|
| 18 |
import org.distorted.library.main.DistortedLibrary; |
|
| 19 |
import org.distorted.library.main.DistortedScreen; |
|
| 20 |
import org.distorted.objectlib.effects.BaseEffect; |
|
| 21 |
import org.distorted.objectlib.main.ObjectControl; |
|
| 22 |
|
|
| 23 |
import java.io.InputStream; |
|
| 24 |
|
|
| 25 |
import javax.microedition.khronos.egl.EGLConfig; |
|
| 26 |
import javax.microedition.khronos.opengles.GL10; |
|
| 27 |
|
|
| 28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 29 |
|
|
| 30 |
public class ConfigRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser |
|
| 31 |
{
|
|
| 32 |
private final ConfigSurfaceView mView; |
|
| 33 |
private final Resources mResources; |
|
| 34 |
private final DistortedScreen mScreen; |
|
| 35 |
|
|
| 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 37 |
|
|
| 38 |
ConfigRenderer(ConfigSurfaceView v) |
|
| 39 |
{
|
|
| 40 |
final float BRIGHTNESS = 0.333f; |
|
| 41 |
|
|
| 42 |
mView = v; |
|
| 43 |
mResources = v.getResources(); |
|
| 44 |
mScreen = new DistortedScreen(); |
|
| 45 |
mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f); |
|
| 46 |
} |
|
| 47 |
|
|
| 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 49 |
|
|
| 50 |
@Override |
|
| 51 |
public void onDrawFrame(GL10 glUnused) |
|
| 52 |
{
|
|
| 53 |
long time = System.currentTimeMillis(); |
|
| 54 |
mView.getObjectControl().preRender(); |
|
| 55 |
mScreen.render(time); |
|
| 56 |
} |
|
| 57 |
|
|
| 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 59 |
|
|
| 60 |
@Override |
|
| 61 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
| 62 |
{
|
|
| 63 |
mScreen.resize(width,height); |
|
| 64 |
mView.setScreenSize(width,height); |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 68 |
|
|
| 69 |
DistortedScreen getScreen() |
|
| 70 |
{
|
|
| 71 |
return mScreen; |
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 75 |
|
|
| 76 |
@Override |
|
| 77 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
|
| 78 |
{
|
|
| 79 |
DistortedLibrary.setMax(EffectType.VERTEX, ObjectControl.MAX_QUATS+1); |
|
| 80 |
VertexEffectRotate.enable(); |
|
| 81 |
VertexEffectQuaternion.enable(); |
|
| 82 |
BaseEffect.Type.enableEffects(); |
|
| 83 |
|
|
| 84 |
DistortedLibrary.onSurfaceCreated(this,1); |
|
| 85 |
DistortedLibrary.setCull(true); |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 89 |
|
|
| 90 |
public void distortedException(Exception ex) |
|
| 91 |
{
|
|
| 92 |
android.util.Log.e("Config", "unexpected exception: "+ex.getMessage() );
|
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 96 |
|
|
| 97 |
public InputStream localFile(int fileID) |
|
| 98 |
{
|
|
| 99 |
return mResources.openRawResource(fileID); |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 103 |
|
|
| 104 |
public void logMessage(String message) |
|
| 105 |
{
|
|
| 106 |
android.util.Log.e("Config", message );
|
|
| 107 |
} |
|
| 108 |
} |
|
| src/main/java/org/distorted/config/ConfigScreen.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2020 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 android.os.Build; |
|
| 13 |
import android.util.TypedValue; |
|
| 14 |
import android.view.Gravity; |
|
| 15 |
import android.view.View; |
|
| 16 |
import android.widget.GridLayout; |
|
| 17 |
import android.widget.ImageButton; |
|
| 18 |
import android.widget.LinearLayout; |
|
| 19 |
import android.widget.PopupWindow; |
|
| 20 |
import android.widget.ScrollView; |
|
| 21 |
import android.widget.TextView; |
|
| 22 |
|
|
| 23 |
import org.distorted.helpers.ObjectGridCreator; |
|
| 24 |
|
|
| 25 |
import org.distorted.helpers.TransparentImageButton; |
|
| 26 |
import org.distorted.main.MainActivity; |
|
| 27 |
import org.distorted.main.R; |
|
| 28 |
import org.distorted.objects.RubikObject; |
|
| 29 |
import org.distorted.objects.RubikObjectList; |
|
| 30 |
|
|
| 31 |
import static android.view.View.inflate; |
|
| 32 |
|
|
| 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 34 |
|
|
| 35 |
public class ConfigScreen |
|
| 36 |
{
|
|
| 37 |
private static final float TEXT_SIZE = 0.0310f; |
|
| 38 |
private static final float PADDING = 0.0060f; |
|
| 39 |
private static final float MARGIN = 0.0024f; |
|
| 40 |
private static final int[] mLocation = new int[2]; |
|
| 41 |
private static final float POPUP_W = 0.8f; |
|
| 42 |
|
|
| 43 |
private TransparentImageButton mBackButton, mObjectButton, mPrevButton, mNextButton; |
|
| 44 |
private TextView mMovesText; |
|
| 45 |
private PopupWindow mObjectPopup; |
|
| 46 |
private ConfigScreenPane mPane; |
|
| 47 |
private int mObjectOrdinal; |
|
| 48 |
private float mButtonSize; |
|
| 49 |
|
|
| 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 51 |
|
|
| 52 |
private void setupObjectWindow(final ConfigActivity act, final float width, final float height) |
|
| 53 |
{
|
|
| 54 |
int numObjects= RubikObjectList.getNumObjects(); |
|
| 55 |
ScrollView view = (ScrollView)inflate( act, R.layout.popup_object_simple, null); |
|
| 56 |
GridLayout objectGrid = view.findViewById(R.id.objectGrid); |
|
| 57 |
|
|
| 58 |
int[] objects = new int[numObjects]; |
|
| 59 |
for(int i=0; i<numObjects; i++) objects[i] = i; |
|
| 60 |
|
|
| 61 |
ObjectGridCreator creator = new ObjectGridCreator(width); |
|
| 62 |
creator.createObjectGridClassic(objectGrid,act,objects); |
|
| 63 |
|
|
| 64 |
for(int child=0; child<numObjects; child++) |
|
| 65 |
{
|
|
| 66 |
final RubikObject obj = RubikObjectList.getObject(child); |
|
| 67 |
View v = objectGrid.getChildAt(child); |
|
| 68 |
ImageButton button = creator.getButton(obj,v); |
|
| 69 |
final int ordinal = child; |
|
| 70 |
|
|
| 71 |
button.setOnClickListener( new View.OnClickListener() |
|
| 72 |
{
|
|
| 73 |
@Override |
|
| 74 |
public void onClick(View v) |
|
| 75 |
{
|
|
| 76 |
if( mObjectOrdinal!=ordinal ) |
|
| 77 |
{
|
|
| 78 |
mObjectOrdinal = ordinal; |
|
| 79 |
act.changeObject(mObjectOrdinal); |
|
| 80 |
mMovesText.setText(act.getString(R.string.mo_placeholder,mObjectOrdinal+1,numObjects)); |
|
| 81 |
mPane.updatePane(act,mObjectOrdinal); |
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
mObjectPopup.dismiss(); |
|
| 85 |
} |
|
| 86 |
}); |
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
mObjectPopup = new PopupWindow(act); |
|
| 90 |
mObjectPopup.setFocusable(true); |
|
| 91 |
mObjectPopup.setContentView(view); |
|
| 92 |
} |
|
| 93 |
|
|
| 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 95 |
|
|
| 96 |
private void setupBackButton(final ConfigActivity act) |
|
| 97 |
{
|
|
| 98 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 99 |
mBackButton = new TransparentImageButton(act,R.drawable.ui_smallback,params); |
|
| 100 |
|
|
| 101 |
mBackButton.setOnClickListener( new View.OnClickListener() |
|
| 102 |
{
|
|
| 103 |
@Override |
|
| 104 |
public void onClick(View v) |
|
| 105 |
{
|
|
| 106 |
act.finish(); |
|
| 107 |
} |
|
| 108 |
}); |
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 112 |
|
|
| 113 |
private void setupObjectButton(final ConfigActivity act, final int width, final int height) |
|
| 114 |
{
|
|
| 115 |
final int margin= (int)(height*MARGIN); |
|
| 116 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 117 |
mObjectButton = new TransparentImageButton(act,R.drawable.ui_cube_menu,params); |
|
| 118 |
|
|
| 119 |
mObjectButton.setOnClickListener( new View.OnClickListener() |
|
| 120 |
{
|
|
| 121 |
@Override |
|
| 122 |
public void onClick(View view) |
|
| 123 |
{
|
|
| 124 |
if( mObjectPopup==null ) setupObjectWindow(act,width,height); |
|
| 125 |
View popupView = mObjectPopup.getContentView(); |
|
| 126 |
popupView.setSystemUiVisibility(MainActivity.FLAGS); |
|
| 127 |
displayPopup(act,view,mObjectPopup,width,height,margin,margin); |
|
| 128 |
} |
|
| 129 |
}); |
|
| 130 |
} |
|
| 131 |
|
|
| 132 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 133 |
// work around lame bugs in Android's version <= 10 pop-up and split-screen modes |
|
| 134 |
|
|
| 135 |
private void displayPopup(ConfigActivity act, View view, PopupWindow window, int w, int h, int xoff, int yoff) |
|
| 136 |
{
|
|
| 137 |
View topLayout = act.findViewById(R.id.mainLayout); |
|
| 138 |
boolean isFullScreen; |
|
| 139 |
|
|
| 140 |
if( topLayout!=null ) |
|
| 141 |
{
|
|
| 142 |
topLayout.getLocationOnScreen(mLocation); |
|
| 143 |
isFullScreen = (mLocation[1]==0); |
|
| 144 |
} |
|
| 145 |
else |
|
| 146 |
{
|
|
| 147 |
isFullScreen = true; |
|
| 148 |
} |
|
| 149 |
|
|
| 150 |
try |
|
| 151 |
{
|
|
| 152 |
// if on Android 11 or we are fullscreen |
|
| 153 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || isFullScreen ) |
|
| 154 |
{
|
|
| 155 |
window.showAsDropDown(view, xoff, yoff, Gravity.CENTER); |
|
| 156 |
window.update(view, w, h); |
|
| 157 |
} |
|
| 158 |
else // Android 10 or below in pop-up mode or split-screen mode |
|
| 159 |
{
|
|
| 160 |
view.getLocationOnScreen(mLocation); |
|
| 161 |
int width = view.getWidth(); |
|
| 162 |
int height = view.getHeight(); |
|
| 163 |
int x = mLocation[0]+(width-w)/2; |
|
| 164 |
int y = mLocation[1]+height+yoff; |
|
| 165 |
|
|
| 166 |
window.showAsDropDown(view); |
|
| 167 |
window.update(x,y,w,h); |
|
| 168 |
} |
|
| 169 |
} |
|
| 170 |
catch( IllegalArgumentException iae ) |
|
| 171 |
{
|
|
| 172 |
// ignore, this means window is 'not attached to window manager' - |
|
| 173 |
// which most probably is because we are already exiting the app. |
|
| 174 |
} |
|
| 175 |
} |
|
| 176 |
|
|
| 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 178 |
|
|
| 179 |
private void prevObject(ConfigActivity act, int numObjects) |
|
| 180 |
{
|
|
| 181 |
mObjectOrdinal--; |
|
| 182 |
if( mObjectOrdinal<0 ) mObjectOrdinal=numObjects-1; |
|
| 183 |
|
|
| 184 |
act.changeObject(mObjectOrdinal); |
|
| 185 |
mPane.updatePane(act,mObjectOrdinal); |
|
| 186 |
} |
|
| 187 |
|
|
| 188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 189 |
|
|
| 190 |
private void nextObject(ConfigActivity act, int numObjects) |
|
| 191 |
{
|
|
| 192 |
mObjectOrdinal++; |
|
| 193 |
if( mObjectOrdinal>=numObjects ) mObjectOrdinal=0; |
|
| 194 |
|
|
| 195 |
act.changeObject(mObjectOrdinal); |
|
| 196 |
mPane.updatePane(act,mObjectOrdinal); |
|
| 197 |
} |
|
| 198 |
|
|
| 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 200 |
|
|
| 201 |
private void setupPrevButton(final ConfigActivity act) |
|
| 202 |
{
|
|
| 203 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
| 204 |
mPrevButton = new TransparentImageButton(act,R.drawable.ui_left,params); |
|
| 205 |
|
|
| 206 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
|
| 207 |
{
|
|
| 208 |
@Override |
|
| 209 |
public void onClick(View v) |
|
| 210 |
{
|
|
| 211 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 212 |
prevObject(act,numObjects); |
|
| 213 |
mMovesText.setText(act.getString(R.string.mo_placeholder,mObjectOrdinal+1,numObjects)); |
|
| 214 |
} |
|
| 215 |
}); |
|
| 216 |
} |
|
| 217 |
|
|
| 218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 219 |
|
|
| 220 |
private void setupNextButton(final ConfigActivity act) |
|
| 221 |
{
|
|
| 222 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
| 223 |
mNextButton = new TransparentImageButton(act,R.drawable.ui_right,params); |
|
| 224 |
|
|
| 225 |
mNextButton.setOnClickListener( new View.OnClickListener() |
|
| 226 |
{
|
|
| 227 |
@Override |
|
| 228 |
public void onClick(View v) |
|
| 229 |
{
|
|
| 230 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 231 |
nextObject(act,numObjects); |
|
| 232 |
mMovesText.setText(act.getString(R.string.mo_placeholder,mObjectOrdinal+1,numObjects)); |
|
| 233 |
} |
|
| 234 |
}); |
|
| 235 |
} |
|
| 236 |
|
|
| 237 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 238 |
|
|
| 239 |
private void setupTextView(final ConfigActivity act, final float height, int numObjects) |
|
| 240 |
{
|
|
| 241 |
int padding = (int)(height*PADDING); |
|
| 242 |
int margin = (int)(height*MARGIN); |
|
| 243 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,2.0f); |
|
| 244 |
params.topMargin = margin; |
|
| 245 |
params.bottomMargin = margin; |
|
| 246 |
params.leftMargin = margin; |
|
| 247 |
params.rightMargin = margin; |
|
| 248 |
|
|
| 249 |
mMovesText = new TextView(act); |
|
| 250 |
mMovesText.setTextSize(20); |
|
| 251 |
mMovesText.setLayoutParams(params); |
|
| 252 |
mMovesText.setPadding(padding,0,padding,0); |
|
| 253 |
mMovesText.setGravity(Gravity.CENTER); |
|
| 254 |
mMovesText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize); |
|
| 255 |
mMovesText.setText(act.getString(R.string.mo_placeholder,mObjectOrdinal+1,numObjects)); |
|
| 256 |
} |
|
| 257 |
|
|
| 258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 259 |
|
|
| 260 |
void onAttachedToWindow(final ConfigActivity act, final int objectOrdinal) |
|
| 261 |
{
|
|
| 262 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 263 |
int width = act.getScreenWidthInPixels(); |
|
| 264 |
int height= act.getScreenHeightInPixels(); |
|
| 265 |
int barHeight = act.getHeightBar(); |
|
| 266 |
mButtonSize = height*TEXT_SIZE; |
|
| 267 |
mObjectOrdinal = objectOrdinal; |
|
| 268 |
|
|
| 269 |
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 270 |
LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 271 |
LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 272 |
|
|
| 273 |
LinearLayout layoutLeft = new LinearLayout(act); |
|
| 274 |
layoutLeft.setLayoutParams(paramsL); |
|
| 275 |
LinearLayout layoutMid = new LinearLayout(act); |
|
| 276 |
layoutMid.setLayoutParams(paramsM); |
|
| 277 |
LinearLayout layoutRight= new LinearLayout(act); |
|
| 278 |
layoutRight.setLayoutParams(paramsR); |
|
| 279 |
|
|
| 280 |
int popupW = (int)(POPUP_W*width); |
|
| 281 |
int popupH = (int)(height-barHeight); |
|
| 282 |
|
|
| 283 |
setupObjectButton(act,popupW,popupH); |
|
| 284 |
setupPrevButton(act); |
|
| 285 |
setupNextButton(act); |
|
| 286 |
setupTextView(act,height,numObjects); |
|
| 287 |
setupBackButton(act); |
|
| 288 |
|
|
| 289 |
layoutLeft.addView(mObjectButton); |
|
| 290 |
layoutMid.addView(mPrevButton); |
|
| 291 |
layoutMid.addView(mMovesText); |
|
| 292 |
layoutMid.addView(mNextButton); |
|
| 293 |
layoutRight.addView(mBackButton); |
|
| 294 |
|
|
| 295 |
LinearLayout layout = act.findViewById(R.id.lowerBar); |
|
| 296 |
layout.removeAllViews(); |
|
| 297 |
layout.addView(layoutLeft); |
|
| 298 |
layout.addView(layoutMid); |
|
| 299 |
layout.addView(layoutRight); |
|
| 300 |
|
|
| 301 |
mPane = new ConfigScreenPane(act,mObjectOrdinal); |
|
| 302 |
} |
|
| 303 |
} |
|
| src/main/java/org/distorted/config/ConfigScreenPane.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2020 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 static org.distorted.objects.RubikObjectCategories.DIFF_IDS; |
|
| 13 |
import static org.distorted.objects.RubikObjectCategories.DIFF_IMAGES; |
|
| 14 |
|
|
| 15 |
import java.io.InputStream; |
|
| 16 |
|
|
| 17 |
import android.graphics.PorterDuff; |
|
| 18 |
import android.util.TypedValue; |
|
| 19 |
import android.widget.ImageView; |
|
| 20 |
import android.widget.LinearLayout; |
|
| 21 |
import android.widget.TextView; |
|
| 22 |
|
|
| 23 |
import org.distorted.main.R; |
|
| 24 |
import org.distorted.objectlib.json.JsonReader; |
|
| 25 |
import org.distorted.objects.RubikObject; |
|
| 26 |
import org.distorted.objects.RubikObjectList; |
|
| 27 |
|
|
| 28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 29 |
|
|
| 30 |
public class ConfigScreenPane |
|
| 31 |
{
|
|
| 32 |
private static final int NUM_IDS = DIFF_IDS.length; |
|
| 33 |
private static final float PADDING_RATIO = 0.016f; |
|
| 34 |
private static final float TEXT_RATIO = 0.025f; |
|
| 35 |
|
|
| 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 37 |
|
|
| 38 |
void updatePane(ConfigActivity act, int objectOrdinal) |
|
| 39 |
{
|
|
| 40 |
RubikObject object = RubikObjectList.getObject(objectOrdinal); |
|
| 41 |
|
|
| 42 |
if( object!=null ) |
|
| 43 |
{
|
|
| 44 |
InputStream stream = object.getObjectStream(act); |
|
| 45 |
|
|
| 46 |
JsonReader reader = new JsonReader(); |
|
| 47 |
String name,author; |
|
| 48 |
int year, difficulty; |
|
| 49 |
|
|
| 50 |
try |
|
| 51 |
{
|
|
| 52 |
reader.parseJsonFileMetadata(stream); |
|
| 53 |
name = reader.getObjectName(); |
|
| 54 |
author = reader.getAuthor(); |
|
| 55 |
year = reader.getYearOfInvention(); |
|
| 56 |
difficulty = (int)reader.getDifficulty(); |
|
| 57 |
} |
|
| 58 |
catch(Exception ex) |
|
| 59 |
{
|
|
| 60 |
name = "?"; |
|
| 61 |
author = "?"; |
|
| 62 |
year = 0; |
|
| 63 |
difficulty = 0; |
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
LinearLayout layout = act.findViewById(R.id.configLayout); |
|
| 67 |
TextView view = layout.findViewById(R.id.configDetailsName2); |
|
| 68 |
view.setText(name); |
|
| 69 |
view = layout.findViewById(R.id.configDetailsAuthor2); |
|
| 70 |
view.setText(author); |
|
| 71 |
view = layout.findViewById(R.id.configDetailsYear2); |
|
| 72 |
view.setText( year>0 ? String.valueOf(year) : "?" ); |
|
| 73 |
|
|
| 74 |
if( difficulty<0 ) difficulty=0; |
|
| 75 |
if( difficulty>=NUM_IDS ) difficulty=NUM_IDS-1; |
|
| 76 |
|
|
| 77 |
for(int i=0; i<NUM_IDS; i++) |
|
| 78 |
{
|
|
| 79 |
ImageView image = layout.findViewById(DIFF_IDS[i]); |
|
| 80 |
image.setImageResource(DIFF_IMAGES[i]); |
|
| 81 |
image.setColorFilter( difficulty==i ? 0xffff0000 : 0xffffffff, PorterDuff.Mode.MULTIPLY ); |
|
| 82 |
} |
|
| 83 |
} |
|
| 84 |
} |
|
| 85 |
|
|
| 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 87 |
|
|
| 88 |
ConfigScreenPane(final ConfigActivity act, int objectOrdinal) |
|
| 89 |
{
|
|
| 90 |
int height = act.getScreenHeightInPixels(); |
|
| 91 |
float textSize = height*TEXT_RATIO; |
|
| 92 |
int padding = (int)(height*PADDING_RATIO); |
|
| 93 |
|
|
| 94 |
LinearLayout configLayout = act.findViewById(R.id.configLayout); |
|
| 95 |
LinearLayout nameLayout = configLayout.findViewById(R.id.configLayoutName); |
|
| 96 |
LinearLayout difficultyLayout= configLayout.findViewById(R.id.configLayoutDifficulty); |
|
| 97 |
LinearLayout authorLayout = configLayout.findViewById(R.id.configLayoutAuthor); |
|
| 98 |
LinearLayout yearLayout = configLayout.findViewById(R.id.configLayoutYear); |
|
| 99 |
|
|
| 100 |
nameLayout.setPadding(padding,padding,padding,padding/2); |
|
| 101 |
difficultyLayout.setPadding(padding,padding/2,padding,padding/2); |
|
| 102 |
authorLayout.setPadding(padding,padding/2,padding,padding/2); |
|
| 103 |
yearLayout.setPadding(padding,padding/2,padding,padding/2); |
|
| 104 |
|
|
| 105 |
LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.00f); |
|
| 106 |
params1.bottomMargin = 0; |
|
| 107 |
params1.topMargin = padding; |
|
| 108 |
params1.leftMargin = padding; |
|
| 109 |
params1.rightMargin = padding; |
|
| 110 |
|
|
| 111 |
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.00f); |
|
| 112 |
params2.bottomMargin = padding; |
|
| 113 |
params2.topMargin = padding; |
|
| 114 |
params2.leftMargin = padding; |
|
| 115 |
params2.rightMargin = padding; |
|
| 116 |
|
|
| 117 |
nameLayout.setLayoutParams(params1); |
|
| 118 |
difficultyLayout.setLayoutParams(params1); |
|
| 119 |
authorLayout.setLayoutParams(params1); |
|
| 120 |
yearLayout.setLayoutParams(params2); |
|
| 121 |
|
|
| 122 |
TextView text; |
|
| 123 |
text = nameLayout.findViewById(R.id.configDetailsName1); |
|
| 124 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 125 |
text = nameLayout.findViewById(R.id.configDetailsName2); |
|
| 126 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 127 |
text = authorLayout.findViewById(R.id.configDetailsAuthor1); |
|
| 128 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 129 |
text = authorLayout.findViewById(R.id.configDetailsAuthor2); |
|
| 130 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 131 |
text = difficultyLayout.findViewById(R.id.configDifficultyTitle); |
|
| 132 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 133 |
text = yearLayout.findViewById(R.id.configDetailsYear1); |
|
| 134 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 135 |
text = yearLayout.findViewById(R.id.configDetailsYear2); |
|
| 136 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 137 |
|
|
| 138 |
LinearLayout layoutDiff = difficultyLayout.findViewById(R.id.configDifficultyLayout); |
|
| 139 |
layoutDiff.setPadding(padding,padding,padding,padding); |
|
| 140 |
|
|
| 141 |
updatePane(act,objectOrdinal); |
|
| 142 |
} |
|
| 143 |
} |
|
| src/main/java/org/distorted/config/ConfigSurfaceView.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2020 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 android.app.ActivityManager; |
|
| 13 |
import android.content.Context; |
|
| 14 |
import android.content.pm.ConfigurationInfo; |
|
| 15 |
import android.opengl.GLES30; |
|
| 16 |
import android.opengl.GLSurfaceView; |
|
| 17 |
import android.util.AttributeSet; |
|
| 18 |
|
|
| 19 |
import com.google.firebase.crashlytics.FirebaseCrashlytics; |
|
| 20 |
|
|
| 21 |
import org.distorted.objectlib.main.ObjectControl; |
|
| 22 |
import org.distorted.objectlib.main.TwistyObjectNode; |
|
| 23 |
import org.distorted.os.OSInterface; |
|
| 24 |
|
|
| 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 26 |
|
|
| 27 |
public class ConfigSurfaceView extends GLSurfaceView |
|
| 28 |
{
|
|
| 29 |
private ObjectControl mObjectController; |
|
| 30 |
private OSInterface mInterface; |
|
| 31 |
private ConfigRenderer mRenderer; |
|
| 32 |
private int mScreenWidth, mScreenHeight; |
|
| 33 |
private boolean mCreated; |
|
| 34 |
|
|
| 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 36 |
|
|
| 37 |
void setScreenSize(int width, int height) |
|
| 38 |
{
|
|
| 39 |
mScreenWidth = width; |
|
| 40 |
mScreenHeight= height; |
|
| 41 |
mObjectController.setScreenSizeAndScaling(width,height, Math.min(width,height)); |
|
| 42 |
mObjectController.setObjectScale(1.00f); |
|
| 43 |
|
|
| 44 |
if( !mCreated ) |
|
| 45 |
{
|
|
| 46 |
mCreated = true; |
|
| 47 |
mObjectController.createNode(width,height); |
|
| 48 |
TwistyObjectNode objectNode = mObjectController.getNode(); |
|
| 49 |
mRenderer.getScreen().attach(objectNode); |
|
| 50 |
} |
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 54 |
|
|
| 55 |
ObjectControl getObjectControl() |
|
| 56 |
{
|
|
| 57 |
return mObjectController; |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
// PUBLIC API |
|
| 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 63 |
|
|
| 64 |
public ConfigSurfaceView(Context context, AttributeSet attrs) |
|
| 65 |
{
|
|
| 66 |
super(context,attrs); |
|
| 67 |
|
|
| 68 |
mCreated = false; |
|
| 69 |
|
|
| 70 |
if(!isInEditMode()) |
|
| 71 |
{
|
|
| 72 |
ConfigActivity act = (ConfigActivity)context; |
|
| 73 |
ConfigObjectLibInterface ref = new ConfigObjectLibInterface(); |
|
| 74 |
mInterface = new OSInterface(act,ref); |
|
| 75 |
mObjectController = new ObjectControl(mInterface); |
|
| 76 |
mObjectController.setRotateOnCreation(true); |
|
| 77 |
mRenderer = new ConfigRenderer(this); |
|
| 78 |
|
|
| 79 |
final ActivityManager activityManager= (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
| 80 |
|
|
| 81 |
try |
|
| 82 |
{
|
|
| 83 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
| 84 |
int esVersion = configurationInfo.reqGlEsVersion>>16; |
|
| 85 |
setEGLContextClientVersion(esVersion); |
|
| 86 |
setRenderer(mRenderer); |
|
| 87 |
} |
|
| 88 |
catch(Exception ex) |
|
| 89 |
{
|
|
| 90 |
act.OpenGLError(); |
|
| 91 |
|
|
| 92 |
String shading = GLES30.glGetString(GLES30.GL_SHADING_LANGUAGE_VERSION); |
|
| 93 |
String version = GLES30.glGetString(GLES30.GL_VERSION); |
|
| 94 |
String vendor = GLES30.glGetString(GLES30.GL_VENDOR); |
|
| 95 |
String renderer= GLES30.glGetString(GLES30.GL_RENDERER); |
|
| 96 |
|
|
| 97 |
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); |
|
| 98 |
crashlytics.setCustomKey("GLSL Version" , shading );
|
|
| 99 |
crashlytics.setCustomKey("GL version" , version );
|
|
| 100 |
crashlytics.setCustomKey("GL Vendor " , vendor );
|
|
| 101 |
crashlytics.setCustomKey("GLSL renderer" , renderer);
|
|
| 102 |
crashlytics.recordException(ex); |
|
| 103 |
} |
|
| 104 |
} |
|
| 105 |
} |
|
| 106 |
|
|
| 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 108 |
|
|
| 109 |
@Override |
|
| 110 |
public void onPause() |
|
| 111 |
{
|
|
| 112 |
super.onPause(); |
|
| 113 |
mObjectController.onPause(); |
|
| 114 |
} |
|
| 115 |
|
|
| 116 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 117 |
|
|
| 118 |
@Override |
|
| 119 |
public void onResume() |
|
| 120 |
{
|
|
| 121 |
super.onResume(); |
|
| 122 |
mObjectController.onResume(); |
|
| 123 |
} |
|
| 124 |
} |
|
| 125 |
|
|
| src/main/java/org/distorted/info/InfoActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.info; |
|
| 11 |
|
|
| 12 |
import java.io.InputStream; |
|
| 13 |
|
|
| 14 |
import android.os.Build; |
|
| 15 |
import android.os.Bundle; |
|
| 16 |
import android.util.DisplayMetrics; |
|
| 17 |
import android.view.View; |
|
| 18 |
import android.view.ViewGroup; |
|
| 19 |
import android.view.WindowManager; |
|
| 20 |
import android.widget.LinearLayout; |
|
| 21 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 22 |
|
|
| 23 |
import org.distorted.library.main.DistortedLibrary; |
|
| 24 |
import org.distorted.main.MainActivity; |
|
| 25 |
import org.distorted.objectlib.main.InitAssets; |
|
| 26 |
import org.distorted.objectlib.main.ObjectControl; |
|
| 27 |
import org.distorted.main.R; |
|
| 28 |
import org.distorted.dialogs.RubikDialogError; |
|
| 29 |
import org.distorted.objectlib.main.TwistyObject; |
|
| 30 |
import org.distorted.objects.RubikObject; |
|
| 31 |
import org.distorted.objects.RubikObjectList; |
|
| 32 |
|
|
| 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 34 |
|
|
| 35 |
public class InfoActivity extends AppCompatActivity |
|
| 36 |
{
|
|
| 37 |
private static final int ACTIVITY_NUMBER = 1; |
|
| 38 |
private static final float RATIO_BAR = MainActivity.RATIO_BAR; |
|
| 39 |
public static final int FLAGS = MainActivity.FLAGS; |
|
| 40 |
|
|
| 41 |
private static int mScreenWidth, mScreenHeight; |
|
| 42 |
private int mCurrentApiVersion; |
|
| 43 |
private InfoScreen mScreen; |
|
| 44 |
private int mObjectOrdinal; |
|
| 45 |
private int mHeightBar; |
|
| 46 |
|
|
| 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 48 |
|
|
| 49 |
@Override |
|
| 50 |
protected void onCreate(Bundle savedState) |
|
| 51 |
{
|
|
| 52 |
super.onCreate(savedState); |
|
| 53 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
|
| 54 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 55 |
setContentView(R.layout.info); |
|
| 56 |
|
|
| 57 |
Bundle b = getIntent().getExtras(); |
|
| 58 |
|
|
| 59 |
if(b != null) mObjectOrdinal = b.getInt("obj");
|
|
| 60 |
|
|
| 61 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 62 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 63 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 64 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 65 |
|
|
| 66 |
hideNavigationBar(); |
|
| 67 |
cutoutHack(); |
|
| 68 |
computeBarHeights(); |
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 72 |
// this does not include possible insets |
|
| 73 |
|
|
| 74 |
private void computeBarHeights() |
|
| 75 |
{
|
|
| 76 |
int barHeight = (int)(mScreenHeight*RATIO_BAR); |
|
| 77 |
mHeightBar = barHeight; |
|
| 78 |
|
|
| 79 |
LinearLayout layout = findViewById(R.id.lowerBar); |
|
| 80 |
ViewGroup.LayoutParams params = layout.getLayoutParams(); |
|
| 81 |
params.height = barHeight; |
|
| 82 |
layout.setLayoutParams(params); |
|
| 83 |
} |
|
| 84 |
|
|
| 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 86 |
|
|
| 87 |
private void hideNavigationBar() |
|
| 88 |
{
|
|
| 89 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 90 |
|
|
| 91 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 92 |
{
|
|
| 93 |
final View decorView = getWindow().getDecorView(); |
|
| 94 |
|
|
| 95 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 96 |
|
|
| 97 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 98 |
{
|
|
| 99 |
@Override |
|
| 100 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 101 |
{
|
|
| 102 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 103 |
{
|
|
| 104 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 105 |
} |
|
| 106 |
} |
|
| 107 |
}); |
|
| 108 |
} |
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 112 |
// do not avoid cutouts |
|
| 113 |
|
|
| 114 |
private void cutoutHack() |
|
| 115 |
{
|
|
| 116 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
| 117 |
{
|
|
| 118 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 119 |
} |
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 123 |
|
|
| 124 |
@Override |
|
| 125 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 126 |
{
|
|
| 127 |
super.onWindowFocusChanged(hasFocus); |
|
| 128 |
|
|
| 129 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
| 130 |
{
|
|
| 131 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 132 |
} |
|
| 133 |
} |
|
| 134 |
|
|
| 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 136 |
|
|
| 137 |
@Override |
|
| 138 |
protected void onPause() |
|
| 139 |
{
|
|
| 140 |
super.onPause(); |
|
| 141 |
InfoSurfaceView view = findViewById(R.id.infoSurfaceView); |
|
| 142 |
view.onPause(); |
|
| 143 |
DistortedLibrary.onPause(ACTIVITY_NUMBER); |
|
| 144 |
} |
|
| 145 |
|
|
| 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 147 |
|
|
| 148 |
@Override |
|
| 149 |
protected void onResume() |
|
| 150 |
{
|
|
| 151 |
super.onResume(); |
|
| 152 |
DistortedLibrary.onResume(ACTIVITY_NUMBER); |
|
| 153 |
InfoSurfaceView view = findViewById(R.id.infoSurfaceView); |
|
| 154 |
view.onResume(); |
|
| 155 |
|
|
| 156 |
if( mScreen==null ) mScreen = new InfoScreen(); |
|
| 157 |
mScreen.onAttachedToWindow(this,mObjectOrdinal); |
|
| 158 |
|
|
| 159 |
if( mObjectOrdinal>=0 && mObjectOrdinal< RubikObjectList.getNumObjects() ) |
|
| 160 |
{
|
|
| 161 |
RubikObject object = RubikObjectList.getObject(mObjectOrdinal); |
|
| 162 |
changeIfDifferent(object,mObjectOrdinal,view.getObjectControl()); |
|
| 163 |
} |
|
| 164 |
} |
|
| 165 |
|
|
| 166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 167 |
|
|
| 168 |
@Override |
|
| 169 |
protected void onDestroy() |
|
| 170 |
{
|
|
| 171 |
super.onDestroy(); |
|
| 172 |
DistortedLibrary.onDestroy(ACTIVITY_NUMBER); |
|
| 173 |
} |
|
| 174 |
|
|
| 175 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 176 |
|
|
| 177 |
void OpenGLError() |
|
| 178 |
{
|
|
| 179 |
RubikDialogError errDiag = new RubikDialogError(); |
|
| 180 |
errDiag.show(getSupportFragmentManager(), null); |
|
| 181 |
} |
|
| 182 |
|
|
| 183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 184 |
|
|
| 185 |
private void changeIfDifferent(RubikObject object,int ordinal,ObjectControl control) |
|
| 186 |
{
|
|
| 187 |
if( object!=null ) |
|
| 188 |
{
|
|
| 189 |
int iconMode = TwistyObject.MODE_NORM; |
|
| 190 |
InputStream jsonStream = object.getObjectStream(this); |
|
| 191 |
InputStream meshStream = object.getMeshStream(this); |
|
| 192 |
String name = object.getUpperName(); |
|
| 193 |
InitAssets asset = new InitAssets(jsonStream,meshStream,null); |
|
| 194 |
control.changeIfDifferent(ordinal,name,iconMode,asset); |
|
| 195 |
} |
|
| 196 |
} |
|
| 197 |
|
|
| 198 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 199 |
// PUBLIC API |
|
| 200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 201 |
|
|
| 202 |
public void changeObject(int ordinal) |
|
| 203 |
{
|
|
| 204 |
mObjectOrdinal = ordinal; |
|
| 205 |
RubikObject object = RubikObjectList.getObject(ordinal); |
|
| 206 |
InfoSurfaceView view = findViewById(R.id.infoSurfaceView); |
|
| 207 |
ObjectControl control = view.getObjectControl(); |
|
| 208 |
changeIfDifferent(object,ordinal,control); |
|
| 209 |
} |
|
| 210 |
|
|
| 211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 212 |
|
|
| 213 |
public int getHeightBar() |
|
| 214 |
{
|
|
| 215 |
return mHeightBar; |
|
| 216 |
} |
|
| 217 |
|
|
| 218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 219 |
|
|
| 220 |
public int getScreenWidthInPixels() |
|
| 221 |
{
|
|
| 222 |
return mScreenWidth; |
|
| 223 |
} |
|
| 224 |
|
|
| 225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 226 |
|
|
| 227 |
public int getScreenHeightInPixels() |
|
| 228 |
{
|
|
| 229 |
return mScreenHeight; |
|
| 230 |
} |
|
| 231 |
|
|
| 232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 233 |
|
|
| 234 |
public ObjectControl getControl() |
|
| 235 |
{
|
|
| 236 |
InfoSurfaceView view = findViewById(R.id.infoSurfaceView); |
|
| 237 |
return view.getObjectControl(); |
|
| 238 |
} |
|
| 239 |
} |
|
| src/main/java/org/distorted/info/InfoObjectLibInterface.java | ||
|---|---|---|
| 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.info; |
|
| 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 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 20 |
|
|
| 21 |
public class InfoObjectLibInterface 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 onRemoveRotation(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 |
} |
|
| src/main/java/org/distorted/info/InfoRenderer.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.info; |
|
| 11 |
|
|
Also available in: Unified diff
rename the 'Config' package to 'Info'