Revision 3551a818
Added by Leszek Koltunski 1 day ago
| src/main/java/org/distorted/dialogs/DialogAbandon.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.dialogs; |
|
| 11 |
|
|
| 12 |
import android.app.Dialog; |
|
| 13 |
import android.view.View; |
|
| 14 |
import android.widget.TextView; |
|
| 15 |
import androidx.fragment.app.FragmentActivity; |
|
| 16 |
import org.distorted.main.R; |
|
| 17 |
import org.distorted.play.PlayActivity; |
|
| 18 |
import org.distorted.play.ScreenList; |
|
| 19 |
|
|
| 20 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 21 |
|
|
| 22 |
public class DialogAbandon extends DialogAbstract |
|
| 23 |
{
|
|
| 24 |
public int getResource() { return R.layout.dialog_message; }
|
|
| 25 |
public int getTitleResource() { return -1; }
|
|
| 26 |
public boolean hasArgument() { return true; }
|
|
| 27 |
public int getPositive() { return R.string.yes; }
|
|
| 28 |
public int getNegative() { return R.string.no; }
|
|
| 29 |
public int getNeutral() { return -1; }
|
|
| 30 |
public void negativeAction() { }
|
|
| 31 |
public void neutralAction() { }
|
|
| 32 |
|
|
| 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 34 |
|
|
| 35 |
public void positiveAction() |
|
| 36 |
{
|
|
| 37 |
final PlayActivity act = (PlayActivity)getContext(); |
|
| 38 |
ScreenList.goBack(act); |
|
| 39 |
|
|
| 40 |
try |
|
| 41 |
{
|
|
| 42 |
int elapsed = Integer.parseInt(mArgument); |
|
| 43 |
if( act!=null && elapsed>0 ) act.rememberSolve(elapsed); |
|
| 44 |
} |
|
| 45 |
catch( NumberFormatException nfe ) |
|
| 46 |
{
|
|
| 47 |
android.util.Log.e("D", "DialogAbandon: number format exception: "+mArgument);
|
|
| 48 |
} |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 52 |
|
|
| 53 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
| 54 |
{
|
|
| 55 |
TextView mess = view.findViewById(R.id.dialog_message); |
|
| 56 |
mess.setText(R.string.abandon_solve); |
|
| 57 |
} |
|
| 58 |
} |
|
| src/main/java/org/distorted/dialogs/DialogAbstract.java | ||
|---|---|---|
| 14 | 14 |
import android.os.Bundle; |
| 15 | 15 |
import android.util.DisplayMetrics; |
| 16 | 16 |
import android.util.TypedValue; |
| 17 |
import android.view.Gravity; |
|
| 18 | 17 |
import android.view.LayoutInflater; |
| 19 | 18 |
import android.view.View; |
| 20 | 19 |
import android.view.Window; |
| 21 | 20 |
import android.widget.Button; |
| 22 |
import android.widget.LinearLayout; |
|
| 23 | 21 |
import android.widget.TextView; |
| 24 | 22 |
|
| 25 | 23 |
import androidx.annotation.NonNull; |
| src/main/java/org/distorted/main/MainActivity.java | ||
|---|---|---|
| 354 | 354 |
intent.putExtra("local", local );
|
| 355 | 355 |
intent.putExtra("ordinal", ordinal );
|
| 356 | 356 |
intent.putExtra("elapsed", elapsed);
|
| 357 |
intent.putExtra("savemode", mSaveMode);
|
|
| 357 | 358 |
|
| 358 | 359 |
if( rot!=null ) |
| 359 | 360 |
{
|
| ... | ... | |
| 399 | 400 |
public void changeSaveTo(int saveMode) |
| 400 | 401 |
{
|
| 401 | 402 |
mSaveMode = saveMode; |
| 402 |
|
|
| 403 |
// TODO |
|
| 404 | 403 |
} |
| 405 | 404 |
|
| 406 | 405 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/main/MainSettingsPopup.java | ||
|---|---|---|
| 34 | 34 |
public static final int SORT_DIFFICULTY = 2; |
| 35 | 35 |
public static final int SORT_AUTHOR = 3; |
| 36 | 36 |
public static final int SORT_YEAR = 4; |
| 37 |
|
|
| 38 | 37 |
public static final int SORT_DEFAULT = SORT_SHAPE; |
| 39 |
public static final int SAVE_DEFAULT = 2; // ask |
|
| 38 |
|
|
| 39 |
public static final int SAVE_ALWAYS = 0; |
|
| 40 |
public static final int SAVE_NEVER = 1; |
|
| 41 |
public static final int SAVE_ASK = 2; |
|
| 42 |
public static final int SAVE_DEFAULT = SAVE_ASK; |
|
| 40 | 43 |
|
| 41 | 44 |
private static final int[] mLocation = new int[2]; |
| 42 | 45 |
|
| src/main/java/org/distorted/play/PlayActivity.java | ||
|---|---|---|
| 61 | 61 |
private boolean mObjectLocal, mModeResume; |
| 62 | 62 |
private int mObjectOrdinal; |
| 63 | 63 |
private int mLevel; |
| 64 |
private int mSaveMode; |
|
| 64 | 65 |
private boolean mModeFree; |
| 65 | 66 |
private boolean mJustStarted; |
| 66 | 67 |
private FirebaseAnalytics mFirebaseAnalytics; |
| ... | ... | |
| 87 | 88 |
mObjectLocal = b.getBoolean("local");
|
| 88 | 89 |
mObjectOrdinal = b.getInt("ordinal");
|
| 89 | 90 |
mElapsed = b.getInt("elapsed");
|
| 91 |
mSaveMode = b.getInt("savemode");
|
|
| 90 | 92 |
|
| 91 | 93 |
if( mElapsed>0 ) |
| 92 | 94 |
{
|
| ... | ... | |
| 290 | 292 |
} |
| 291 | 293 |
} |
| 292 | 294 |
|
| 295 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 296 |
|
|
| 297 |
int getSaveMode() |
|
| 298 |
{
|
|
| 299 |
return mSaveMode; |
|
| 300 |
} |
|
| 301 |
|
|
| 293 | 302 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 294 | 303 |
|
| 295 | 304 |
void OpenGLError() |
| src/main/java/org/distorted/play/ScreenSolving.java | ||
|---|---|---|
| 11 | 11 |
|
| 12 | 12 |
import android.app.Activity; |
| 13 | 13 |
import android.content.SharedPreferences; |
| 14 |
import android.os.Bundle; |
|
| 14 | 15 |
import android.util.TypedValue; |
| 15 | 16 |
import android.view.LayoutInflater; |
| 16 | 17 |
import android.view.View; |
| 17 | 18 |
import android.widget.LinearLayout; |
| 18 | 19 |
import android.widget.TextView; |
| 19 | 20 |
|
| 21 |
import org.distorted.dialogs.DialogAbandon; |
|
| 20 | 22 |
import org.distorted.dialogs.DialogRememberSolve; |
| 21 | 23 |
import org.distorted.helpers.RubikScores; |
| 22 | 24 |
import org.distorted.helpers.TransparentImageButton; |
| ... | ... | |
| 25 | 27 |
import java.util.Timer; |
| 26 | 28 |
import java.util.TimerTask; |
| 27 | 29 |
|
| 30 |
import static org.distorted.main.MainSettingsPopup.SAVE_ALWAYS; |
|
| 31 |
import static org.distorted.main.MainSettingsPopup.SAVE_NEVER; |
|
| 32 |
import static org.distorted.main.MainSettingsPopup.SAVE_ASK; |
|
| 33 |
|
|
| 28 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 29 | 35 |
|
| 30 | 36 |
public class ScreenSolving extends ScreenBase |
| ... | ... | |
| 77 | 83 |
{
|
| 78 | 84 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
| 79 | 85 |
mBackButton = new TransparentImageButton(act,R.drawable.ui_back,params); |
| 86 |
int saveMode = act.getSaveMode(); |
|
| 80 | 87 |
|
| 81 | 88 |
mBackButton.setOnClickListener( new View.OnClickListener() |
| 82 | 89 |
{
|
| 83 | 90 |
@Override |
| 84 | 91 |
public void onClick(View v) |
| 85 | 92 |
{
|
| 86 |
if( mMovesController.getNumMoves() > MOVES_THRESHHOLD )
|
|
| 93 |
if( saveMode==SAVE_ASK )
|
|
| 87 | 94 |
{
|
| 88 | 95 |
DialogRememberSolve abaDiag = new DialogRememberSolve(); |
| 89 | 96 |
abaDiag.show(act.getSupportFragmentManager(), null); |
| 90 | 97 |
} |
| 91 | 98 |
else |
| 92 | 99 |
{
|
| 93 |
ScreenList.goBack(act); |
|
| 100 |
int num = mMovesController.getNumMoves(); |
|
| 101 |
|
|
| 102 |
if( num > MOVES_THRESHHOLD ) |
|
| 103 |
{
|
|
| 104 |
Bundle bundle = new Bundle(); |
|
| 105 |
String arg = (saveMode==SAVE_NEVER ? "0" : Integer.toString(stopTimerAndGetRecord()) ); |
|
| 106 |
bundle.putString("argument", arg );
|
|
| 107 |
DialogAbandon diag = new DialogAbandon(); |
|
| 108 |
diag.setArguments(bundle); |
|
| 109 |
diag.show( act.getSupportFragmentManager(), null); |
|
| 110 |
} |
|
| 111 |
else |
|
| 112 |
{
|
|
| 113 |
if( saveMode==SAVE_ALWAYS && num>0 ) act.rememberSolve(stopTimerAndGetRecord()); |
|
| 114 |
ScreenList.goBack(act); |
|
| 115 |
} |
|
| 94 | 116 |
} |
| 95 | 117 |
} |
| 96 | 118 |
}); |
Also available in: Unified diff
actually use the three save modes