Revision 4235de9b
Added by Leszek Koltunski almost 6 years ago
| src/main/java/org/distorted/magic/RubikActivity.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.magic; |
| 21 | 21 |
|
| 22 |
import android.content.SharedPreferences; |
|
| 23 |
import android.opengl.GLSurfaceView; |
|
| 24 | 22 |
import android.os.Bundle; |
| 25 |
import android.preference.PreferenceManager; |
|
| 26 | 23 |
import android.support.v7.app.AppCompatActivity; |
| 27 | 24 |
import android.view.View; |
| 28 | 25 |
|
| 29 |
import org.distorted.component.HorizontalNumberPicker; |
|
| 30 | 26 |
import org.distorted.library.main.DistortedLibrary; |
| 31 |
import org.distorted.effect.BaseEffect; |
|
| 32 | 27 |
|
| 33 | 28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 29 |
|
| 35 | 30 |
public class RubikActivity extends AppCompatActivity implements View.OnClickListener |
| 36 | 31 |
{
|
| 37 |
public static final int MIN_SCRAMBLE = 1; |
|
| 38 |
public static final int DEF_SCRAMBLE = 1; |
|
| 39 |
public static final int MAX_SCRAMBLE = 18; |
|
| 40 |
|
|
| 41 |
private HorizontalNumberPicker mPicker; |
|
| 42 |
|
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 |
|
|
| 45 |
private void savePreferences() |
|
| 46 |
{
|
|
| 47 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
|
| 48 |
SharedPreferences.Editor editor = preferences.edit(); |
|
| 49 |
|
|
| 50 |
for (int i=0; i< BaseEffect.Type.LENGTH; i++) |
|
| 51 |
{
|
|
| 52 |
BaseEffect.Type.getType(i).savePreferences(editor); |
|
| 53 |
} |
|
| 54 |
|
|
| 55 |
editor.putInt("scramble", mPicker.getValue() );
|
|
| 56 |
|
|
| 57 |
editor.apply(); |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
|
|
| 62 |
private void restorePreferences() |
|
| 63 |
{
|
|
| 64 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
|
| 65 |
|
|
| 66 |
for (int i=0; i< BaseEffect.Type.LENGTH; i++) |
|
| 67 |
{
|
|
| 68 |
BaseEffect.Type.getType(i).restorePreferences(preferences); |
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
int scramble= preferences.getInt("scramble", DEF_SCRAMBLE);
|
|
| 72 |
|
|
| 73 |
mPicker.setValue(scramble); |
|
| 74 |
} |
|
| 32 |
private RubikDialogMain mMain; |
|
| 75 | 33 |
|
| 76 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 77 | 35 |
|
| ... | ... | |
| 81 | 39 |
super.onCreate(savedState); |
| 82 | 40 |
setTheme(R.style.CustomActivityThemeNoActionBar); |
| 83 | 41 |
setContentView(R.layout.main); |
| 84 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
| 85 |
view.addSizeButtons(this); |
|
| 86 |
view.markButton(RubikSurfaceView.getRedButton()); |
|
| 87 | 42 |
|
| 88 |
mPicker = findViewById(R.id.rubikNumberPicker); |
|
| 89 |
mPicker.setMin(MIN_SCRAMBLE); |
|
| 90 |
mPicker.setMax(MAX_SCRAMBLE); |
|
| 43 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
| 44 |
view.enterMainState(this); |
|
| 91 | 45 |
|
| 92 |
restorePreferences(); |
|
| 46 |
if( savedState==null ) |
|
| 47 |
{
|
|
| 48 |
mMain = new RubikDialogMain(); |
|
| 49 |
mMain.show(getSupportFragmentManager(), null); |
|
| 50 |
} |
|
| 93 | 51 |
} |
| 94 | 52 |
|
| 95 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 97 | 55 |
@Override |
| 98 | 56 |
protected void onPause() |
| 99 | 57 |
{
|
| 100 |
GLSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
|
| 58 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
|
| 101 | 59 |
view.onPause(); |
| 102 | 60 |
DistortedLibrary.onPause(); |
| 103 | 61 |
RubikScoresDownloader.onPause(); |
| 104 |
savePreferences(); |
|
| 62 |
view.savePreferences();
|
|
| 105 | 63 |
super.onPause(); |
| 106 | 64 |
} |
| 107 | 65 |
|
| ... | ... | |
| 111 | 69 |
protected void onResume() |
| 112 | 70 |
{
|
| 113 | 71 |
super.onResume(); |
| 114 |
GLSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
|
| 72 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
|
| 115 | 73 |
view.onResume(); |
| 74 |
view.restorePreferences(); |
|
| 116 | 75 |
} |
| 117 | 76 |
|
| 118 | 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 143 | 102 |
view.markButton(id); |
| 144 | 103 |
} |
| 145 | 104 |
} |
| 105 |
|
|
| 106 |
if( id == RubikSurfaceView.BUTTON_ID_BACK ) |
|
| 107 |
{
|
|
| 108 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
| 109 |
view.enterMainState(this); |
|
| 110 |
mMain.show(getSupportFragmentManager(), null); |
|
| 111 |
} |
|
| 112 |
if( id == RubikSurfaceView.BUTTON_ID_EXIT ) |
|
| 113 |
{
|
|
| 114 |
finish(); |
|
| 115 |
} |
|
| 146 | 116 |
} |
| 147 | 117 |
|
| 148 | 118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 149 | 119 |
// PUBLIC API |
| 120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 121 |
|
|
| 122 |
public void Play(View v) |
|
| 123 |
{
|
|
| 124 |
mMain.dismiss(); |
|
| 125 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
| 126 |
view.enterPlayState(this); |
|
| 127 |
} |
|
| 128 |
|
|
| 150 | 129 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 151 | 130 |
|
| 152 | 131 |
public void Settings(View v) |
| ... | ... | |
| 159 | 138 |
|
| 160 | 139 |
public void Scores(View v) |
| 161 | 140 |
{
|
| 162 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
| 163 | 141 |
Bundle bundle = new Bundle(); |
| 164 |
bundle.putInt("tab", view.getRedButton());
|
|
| 142 |
bundle.putInt("tab", RubikSurfaceView.getRedButton());
|
|
| 165 | 143 |
|
| 166 | 144 |
RubikDialogScores scores = new RubikDialogScores(); |
| 167 | 145 |
scores.setArguments(bundle); |
| ... | ... | |
| 180 | 158 |
|
| 181 | 159 |
public void Scramble(View v) |
| 182 | 160 |
{
|
| 183 |
int scramble = mPicker.getValue(); |
|
| 184 |
|
|
| 185 | 161 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
| 186 |
view.getRenderer().scrambleCube(scramble); |
|
| 187 |
view.enterScrambleMode(); |
|
| 162 |
view.scramble(); |
|
| 188 | 163 |
} |
| 189 | 164 |
|
| 190 | 165 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 193 | 168 |
{
|
| 194 | 169 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
| 195 | 170 |
view.getRenderer().solveCube(); |
| 196 |
view.leaveScrambleMode(); |
|
| 197 | 171 |
} |
| 198 | 172 |
} |
| src/main/java/org/distorted/magic/RubikDialogAbout.java | ||
|---|---|---|
| 28 | 28 |
import android.support.v7.app.AppCompatDialogFragment; |
| 29 | 29 |
import android.view.LayoutInflater; |
| 30 | 30 |
import android.view.View; |
| 31 |
import android.view.Window; |
|
| 32 |
import android.view.WindowManager; |
|
| 31 | 33 |
import android.widget.TextView; |
| 32 | 34 |
|
| 33 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 36 |
|
| 35 | 37 |
public class RubikDialogAbout extends AppCompatDialogFragment |
| 36 | 38 |
{
|
| 39 |
@Override |
|
| 40 |
public void onStart() |
|
| 41 |
{
|
|
| 42 |
super.onStart(); |
|
| 43 |
|
|
| 44 |
Window window = getDialog().getWindow(); |
|
| 45 |
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, |
|
| 46 |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); |
|
| 47 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 51 |
|
|
| 37 | 52 |
@NonNull |
| 38 | 53 |
@Override |
| 39 | 54 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
| ... | ... | |
| 43 | 58 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
| 44 | 59 |
|
| 45 | 60 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
| 46 |
tv.setText(R.string.about_title);
|
|
| 61 |
tv.setText(R.string.about); |
|
| 47 | 62 |
builder.setCustomTitle(tv); |
| 48 | 63 |
|
| 49 | 64 |
builder.setCancelable(true); |
| src/main/java/org/distorted/magic/RubikDialogMain.java | ||
|---|---|---|
| 20 | 20 |
package org.distorted.magic; |
| 21 | 21 |
|
| 22 | 22 |
import android.app.Dialog; |
| 23 |
import android.content.DialogInterface; |
|
| 24 | 23 |
import android.os.Bundle; |
| 25 | 24 |
import android.support.annotation.NonNull; |
| 26 | 25 |
import android.support.v4.app.FragmentActivity; |
| ... | ... | |
| 28 | 27 |
import android.support.v7.app.AppCompatDialogFragment; |
| 29 | 28 |
import android.view.LayoutInflater; |
| 30 | 29 |
import android.view.View; |
| 30 |
import android.view.Window; |
|
| 31 |
import android.view.WindowManager; |
|
| 31 | 32 |
|
| 32 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 33 | 34 |
|
| 34 | 35 |
public class RubikDialogMain extends AppCompatDialogFragment |
| 35 | 36 |
{
|
| 37 |
@Override |
|
| 38 |
public void onStart() |
|
| 39 |
{
|
|
| 40 |
super.onStart(); |
|
| 41 |
|
|
| 42 |
Window window = getDialog().getWindow(); |
|
| 43 |
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, |
|
| 44 |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); |
|
| 45 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
|
| 46 |
} |
|
| 47 |
|
|
| 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 49 |
|
|
| 36 | 50 |
@NonNull |
| 37 | 51 |
@Override |
| 38 | 52 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
| 39 | 53 |
{
|
| 40 | 54 |
FragmentActivity act = getActivity(); |
| 41 | 55 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
| 42 |
|
|
| 43 |
builder.setTitle(R.string.app_version); |
|
| 44 |
builder.setIcon(R.drawable.button3); |
|
| 45 |
builder.setCancelable(false); |
|
| 46 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
|
| 47 |
{
|
|
| 48 |
@Override |
|
| 49 |
public void onClick(DialogInterface dialog, int which) |
|
| 50 |
{
|
|
| 51 |
|
|
| 52 |
} |
|
| 53 |
}); |
|
| 54 |
|
|
| 55 | 56 |
LayoutInflater inflater = act.getLayoutInflater(); |
| 56 |
final View view = inflater.inflate(R.layout.dialog_about, null);
|
|
| 57 |
final View view = inflater.inflate(R.layout.dialog_main, null);
|
|
| 57 | 58 |
builder.setView(view); |
| 58 | 59 |
|
| 59 | 60 |
return builder.create(); |
| 60 | 61 |
} |
| 61 |
} |
|
| 62 |
} |
|
| src/main/java/org/distorted/magic/RubikDialogScores.java | ||
|---|---|---|
| 30 | 30 |
import android.support.design.widget.TabLayout; |
| 31 | 31 |
import android.view.LayoutInflater; |
| 32 | 32 |
import android.view.View; |
| 33 |
import android.view.Window; |
|
| 34 |
import android.view.WindowManager; |
|
| 33 | 35 |
import android.widget.ImageView; |
| 34 | 36 |
import android.widget.TextView; |
| 35 | 37 |
|
| ... | ... | |
| 39 | 41 |
{
|
| 40 | 42 |
RubikDialogScoresPagerAdapter mPagerAdapter; |
| 41 | 43 |
|
| 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 45 |
|
|
| 46 |
@Override |
|
| 47 |
public void onStart() |
|
| 48 |
{
|
|
| 49 |
super.onStart(); |
|
| 50 |
|
|
| 51 |
Window window = getDialog().getWindow(); |
|
| 52 |
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, |
|
| 53 |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); |
|
| 54 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
|
| 55 |
} |
|
| 56 |
|
|
| 42 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 43 | 58 |
|
| 44 | 59 |
@NonNull |
| ... | ... | |
| 50 | 65 |
|
| 51 | 66 |
LayoutInflater layoutInflater = act.getLayoutInflater(); |
| 52 | 67 |
TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null); |
| 53 |
tv.setText(R.string.scores_title);
|
|
| 68 |
tv.setText(R.string.scores); |
|
| 54 | 69 |
builder.setCustomTitle(tv); |
| 55 | 70 |
|
| 56 | 71 |
builder.setCancelable(true); |
| src/main/java/org/distorted/magic/RubikDialogScoresPagerAdapter.java | ||
|---|---|---|
| 81 | 81 |
|
| 82 | 82 |
private void addPage(final RubikDialogScoresView view, final int[][] country, final String[][] name, final String[][] time) |
| 83 | 83 |
{
|
| 84 |
for(int section=0; section<RubikActivity.MAX_SCRAMBLE; section++)
|
|
| 84 |
for(int section=0; section<RubikSurfaceView.MAX_SCRAMBLE; section++)
|
|
| 85 | 85 |
{
|
| 86 | 86 |
final int sec = section; |
| 87 | 87 |
final int[] c = country[section]; |
| src/main/java/org/distorted/magic/RubikDialogSettings.java | ||
|---|---|---|
| 31 | 31 |
import android.view.Gravity; |
| 32 | 32 |
import android.view.LayoutInflater; |
| 33 | 33 |
import android.view.View; |
| 34 |
import android.view.Window; |
|
| 35 |
import android.view.WindowManager; |
|
| 34 | 36 |
import android.widget.AdapterView; |
| 35 | 37 |
import android.widget.ArrayAdapter; |
| 36 | 38 |
import android.widget.LinearLayout; |
| ... | ... | |
| 57 | 59 |
int textH=32; |
| 58 | 60 |
int layoH=36; |
| 59 | 61 |
int margH=10; |
| 60 |
/* |
|
| 61 |
if( metrics.widthPixels > metrics.heightPixels ) |
|
| 62 |
{
|
|
| 63 |
textH = 18; |
|
| 64 |
layoH = 25; |
|
| 65 |
margH = 5; |
|
| 66 |
} |
|
| 67 |
else |
|
| 68 |
{
|
|
| 69 |
textH = 32; |
|
| 70 |
layoH = 36; |
|
| 71 |
margH = 10; |
|
| 72 |
} |
|
| 73 |
*/ |
|
| 62 |
|
|
| 74 | 63 |
///// OUTER LAYOUT /////////////////////////////////////////////////////////////////// |
| 75 | 64 |
|
| 76 | 65 |
int margin = (int)(scale*margH + 0.5f); |
| ... | ... | |
| 201 | 190 |
mDurationText = new TextView[BaseEffect.Type.LENGTH]; |
| 202 | 191 |
} |
| 203 | 192 |
|
| 193 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 194 |
|
|
| 195 |
@Override |
|
| 196 |
public void onStart() |
|
| 197 |
{
|
|
| 198 |
super.onStart(); |
|
| 199 |
|
|
| 200 |
Window window = getDialog().getWindow(); |
|
| 201 |
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, |
|
| 202 |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); |
|
| 203 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
|
| 204 |
} |
|
| 205 |
|
|
| 204 | 206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 205 | 207 |
|
| 206 | 208 |
@NonNull |
| ... | ... | |
| 211 | 213 |
LayoutInflater inflater = act.getLayoutInflater(); |
| 212 | 214 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
| 213 | 215 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
| 214 |
tv.setText(R.string.settings_title);
|
|
| 216 |
tv.setText(R.string.settings); |
|
| 215 | 217 |
builder.setCustomTitle(tv); |
| 216 | 218 |
|
| 217 | 219 |
builder.setCancelable(true); |
| src/main/java/org/distorted/magic/RubikRenderer.java | ||
|---|---|---|
| 242 | 242 |
mCanRotate = false; |
| 243 | 243 |
mCanUI = false; |
| 244 | 244 |
doEffectNow( BaseEffect.Type.WIN ); |
| 245 |
mView.leaveScrambleModeNonUI(); |
|
| 246 | 245 |
} |
| 247 | 246 |
else |
| 248 | 247 |
{
|
| src/main/java/org/distorted/magic/RubikScoresDownloader.java | ||
|---|---|---|
| 86 | 86 |
private static String mPackageName; |
| 87 | 87 |
|
| 88 | 88 |
private static String mScores = ""; |
| 89 |
private static int[][][] mCountry = new int [RubikSize.LENGTH][RubikActivity.MAX_SCRAMBLE][MAX_PLACES];
|
|
| 90 |
private static String[][][] mName = new String[RubikSize.LENGTH][RubikActivity.MAX_SCRAMBLE][MAX_PLACES];
|
|
| 91 |
private static String[][][] mTime = new String[RubikSize.LENGTH][RubikActivity.MAX_SCRAMBLE][MAX_PLACES];
|
|
| 89 |
private static int[][][] mCountry = new int [RubikSize.LENGTH][RubikSurfaceView.MAX_SCRAMBLE][MAX_PLACES];
|
|
| 90 |
private static String[][][] mName = new String[RubikSize.LENGTH][RubikSurfaceView.MAX_SCRAMBLE][MAX_PLACES];
|
|
| 91 |
private static String[][][] mTime = new String[RubikSize.LENGTH][RubikSurfaceView.MAX_SCRAMBLE][MAX_PLACES];
|
|
| 92 | 92 |
|
| 93 | 93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 94 | 94 |
|
| ... | ... | |
| 129 | 129 |
String country = row.substring(s5+1, s6); |
| 130 | 130 |
String realTime= String.valueOf(time/10.0f); |
| 131 | 131 |
|
| 132 |
if(level>=0 && level<RubikActivity.MAX_SCRAMBLE && place>=0 && place<MAX_PLACES)
|
|
| 132 |
if(level>=0 && level<RubikSurfaceView.MAX_SCRAMBLE && place>=0 && place<MAX_PLACES)
|
|
| 133 | 133 |
{
|
| 134 | 134 |
int resID = mResources.getIdentifier( country, "drawable", mPackageName); |
| 135 | 135 |
mCountry[size][level][place] = resID!=0 ? resID:R.drawable.unk; |
| src/main/java/org/distorted/magic/RubikSurfaceView.java | ||
|---|---|---|
| 21 | 21 |
|
| 22 | 22 |
import android.app.ActivityManager; |
| 23 | 23 |
import android.content.Context; |
| 24 |
import android.content.SharedPreferences; |
|
| 24 | 25 |
import android.content.pm.ConfigurationInfo; |
| 25 | 26 |
import android.graphics.PorterDuff; |
| 26 | 27 |
import android.graphics.drawable.Drawable; |
| 27 | 28 |
import android.opengl.GLSurfaceView; |
| 29 |
import android.preference.PreferenceManager; |
|
| 28 | 30 |
import android.support.v4.content.ContextCompat; |
| 29 | 31 |
import android.util.AttributeSet; |
| 30 | 32 |
import android.util.DisplayMetrics; |
| 33 |
import android.view.LayoutInflater; |
|
| 31 | 34 |
import android.view.MotionEvent; |
| 35 |
import android.view.View; |
|
| 32 | 36 |
import android.view.ViewGroup; |
| 33 | 37 |
import android.widget.Button; |
| 34 | 38 |
import android.widget.ImageButton; |
| 35 | 39 |
import android.widget.LinearLayout; |
| 36 | 40 |
|
| 41 |
import org.distorted.component.HorizontalNumberPicker; |
|
| 42 |
import org.distorted.effect.BaseEffect; |
|
| 37 | 43 |
import org.distorted.library.type.Static2D; |
| 38 | 44 |
import org.distorted.library.type.Static4D; |
| 39 | 45 |
import org.distorted.object.RubikCube; |
| ... | ... | |
| 43 | 49 |
|
| 44 | 50 |
public class RubikSurfaceView extends GLSurfaceView |
| 45 | 51 |
{
|
| 52 |
public static final int BUTTON_ID_BACK= 1023; |
|
| 53 |
public static final int BUTTON_ID_EXIT= 1022; |
|
| 54 |
|
|
| 55 |
public static final int MIN_SCRAMBLE = 1; |
|
| 56 |
public static final int DEF_SCRAMBLE = 1; |
|
| 57 |
public static final int MAX_SCRAMBLE = 18; |
|
| 58 |
|
|
| 46 | 59 |
// Moving the finger from the middle of the vertical screen to the right edge will rotate a |
| 47 | 60 |
// given face by SWIPING_SENSITIVITY/2 degrees. |
| 48 | 61 |
private final static int SWIPING_SENSITIVITY = 240; |
| ... | ... | |
| 55 | 68 |
|
| 56 | 69 |
private RubikRenderer mRenderer; |
| 57 | 70 |
private RubikCubeMovement mMovement; |
| 58 |
private boolean mInScrambleMode; |
|
| 59 | 71 |
private boolean mDragging, mBeginningRotation, mContinuingRotation; |
| 60 | 72 |
private float mX, mY; |
| 61 | 73 |
private int mScreenWidth, mScreenHeight, mScreenMin; |
| 62 | 74 |
|
| 75 |
private HorizontalNumberPicker mPicker; |
|
| 76 |
private int mScrambleValue; |
|
| 77 |
|
|
| 63 | 78 |
private static int mButton = RubikSize.SIZE3.ordinal(); |
| 64 | 79 |
private static Static4D mQuatCurrent = new Static4D(0,0,0,1); |
| 65 | 80 |
private static Static4D mQuatAccumulated= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f); |
| 66 | 81 |
private static Static4D mTempCurrent = new Static4D(0,0,0,1); |
| 67 | 82 |
private static Static4D mTempAccumulated= new Static4D(0,0,0,1); |
| 68 | 83 |
|
| 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 85 |
|
|
| 86 |
void scramble() |
|
| 87 |
{
|
|
| 88 |
int scramble = mPicker.getValue(); |
|
| 89 |
mRenderer.scrambleCube(scramble); |
|
| 90 |
} |
|
| 91 |
|
|
| 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 93 |
|
|
| 94 |
void savePreferences() |
|
| 95 |
{
|
|
| 96 |
RubikActivity act = (RubikActivity)getContext(); |
|
| 97 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(act); |
|
| 98 |
SharedPreferences.Editor editor = preferences.edit(); |
|
| 99 |
|
|
| 100 |
for (int i = 0; i< BaseEffect.Type.LENGTH; i++) |
|
| 101 |
{
|
|
| 102 |
BaseEffect.Type.getType(i).savePreferences(editor); |
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
editor.putInt("scramble", mScrambleValue );
|
|
| 106 |
|
|
| 107 |
editor.apply(); |
|
| 108 |
} |
|
| 109 |
|
|
| 110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 111 |
|
|
| 112 |
void restorePreferences() |
|
| 113 |
{
|
|
| 114 |
RubikActivity act = (RubikActivity)getContext(); |
|
| 115 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(act); |
|
| 116 |
|
|
| 117 |
for (int i=0; i< BaseEffect.Type.LENGTH; i++) |
|
| 118 |
{
|
|
| 119 |
BaseEffect.Type.getType(i).restorePreferences(preferences); |
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
mScrambleValue= preferences.getInt("scramble", DEF_SCRAMBLE);
|
|
| 123 |
} |
|
| 124 |
|
|
| 69 | 125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 70 | 126 |
|
| 71 | 127 |
void setScreenSize(int width, int height) |
| ... | ... | |
| 224 | 280 |
|
| 225 | 281 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 226 | 282 |
|
| 227 |
void addSizeButtons(RubikActivity act) |
|
| 283 |
void enterMainState(RubikActivity act) |
|
| 284 |
{
|
|
| 285 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 286 |
|
|
| 287 |
// TOP //////////////////////////// |
|
| 288 |
LinearLayout layoutTop = act.findViewById(R.id.mainTitle); |
|
| 289 |
layoutTop.removeAllViews(); |
|
| 290 |
final View viewTop = inflater.inflate(R.layout.main_title, null); |
|
| 291 |
layoutTop.addView(viewTop); |
|
| 292 |
|
|
| 293 |
// BOT //////////////////////////// |
|
| 294 |
LinearLayout layoutBot = act.findViewById(R.id.mainBar); |
|
| 295 |
layoutBot.removeAllViews(); |
|
| 296 |
|
|
| 297 |
DisplayMetrics metrics = getResources().getDisplayMetrics(); |
|
| 298 |
float scale = metrics.density; |
|
| 299 |
int size = (int)(60*scale +0.5f); |
|
| 300 |
int padding = (int)(5*scale + 0.5f); |
|
| 301 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,size,0.5f); |
|
| 302 |
|
|
| 303 |
Button buttonL = new Button(act); |
|
| 304 |
buttonL.setLayoutParams(params); |
|
| 305 |
buttonL.setId(BUTTON_ID_EXIT); |
|
| 306 |
buttonL.setPadding(padding,0,padding,0); |
|
| 307 |
buttonL.setText(R.string.back); |
|
| 308 |
buttonL.setOnClickListener(act); |
|
| 309 |
layoutBot.addView(buttonL); |
|
| 310 |
|
|
| 311 |
Button buttonR = new Button(act); |
|
| 312 |
buttonR.setLayoutParams(params); |
|
| 313 |
buttonR.setId(BUTTON_ID_EXIT); |
|
| 314 |
buttonR.setPadding(padding,0,padding,0); |
|
| 315 |
buttonR.setText(R.string.exit); |
|
| 316 |
buttonR.setOnClickListener(act); |
|
| 317 |
layoutBot.addView(buttonR); |
|
| 318 |
|
|
| 319 |
buttonL.setVisibility(INVISIBLE); |
|
| 320 |
} |
|
| 321 |
|
|
| 322 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 323 |
|
|
| 324 |
void enterPlayState(RubikActivity act) |
|
| 228 | 325 |
{
|
| 229 |
LinearLayout layout = act.findViewById(R.id.sizeLayout); |
|
| 326 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 327 |
|
|
| 328 |
// TOP //////////////////////////// |
|
| 329 |
LinearLayout layoutTop = act.findViewById(R.id.mainTitle); |
|
| 330 |
layoutTop.removeAllViews(); |
|
| 331 |
|
|
| 332 |
final View viewTop = inflater.inflate(R.layout.play_title, null); |
|
| 333 |
layoutTop.addView(viewTop); |
|
| 334 |
|
|
| 335 |
// BOT //////////////////////////// |
|
| 336 |
LinearLayout layoutBot = act.findViewById(R.id.mainBar); |
|
| 337 |
layoutBot.removeAllViews(); |
|
| 338 |
|
|
| 230 | 339 |
DisplayMetrics metrics = getResources().getDisplayMetrics(); |
| 231 | 340 |
float scale = metrics.density; |
| 232 |
int size = (int)(64*scale +0.5f);
|
|
| 341 |
int size = (int)(60*scale +0.5f);
|
|
| 233 | 342 |
int padding = (int)(3*scale + 0.5f); |
| 234 | 343 |
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(size,size); |
| 235 | 344 |
|
| ... | ... | |
| 242 | 351 |
int iconID = RubikSize.getSize(i).getIconID(); |
| 243 | 352 |
button.setImageResource(iconID); |
| 244 | 353 |
button.setOnClickListener(act); |
| 245 |
layout.addView(button); |
|
| 354 |
layoutBot.addView(button);
|
|
| 246 | 355 |
} |
| 247 |
} |
|
| 248 |
|
|
| 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 250 |
|
|
| 251 |
void enterScrambleMode() |
|
| 252 |
{
|
|
| 253 |
if( !mInScrambleMode ) |
|
| 254 |
{
|
|
| 255 |
mInScrambleMode = true; |
|
| 256 | 356 |
|
| 257 |
android.util.Log.e("view", "entering scramble mode");
|
|
| 357 |
ViewGroup.LayoutParams params2 = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,size);
|
|
| 258 | 358 |
|
| 259 |
RubikActivity act = (RubikActivity)getContext(); |
|
| 359 |
Button button = new Button(act); |
|
| 360 |
button.setLayoutParams(params2); |
|
| 361 |
button.setId(BUTTON_ID_BACK); |
|
| 362 |
button.setPadding(padding,0,padding,0); |
|
| 363 |
button.setText(R.string.back); |
|
| 364 |
button.setOnClickListener(act); |
|
| 365 |
layoutBot.addView(button); |
|
| 260 | 366 |
|
| 261 |
Button scrambleButt = act.findViewById(R.id.rubikScramble);
|
|
| 367 |
markButton(mButton);
|
|
| 262 | 368 |
|
| 263 |
if( scrambleButt!=null ) |
|
| 264 |
{
|
|
| 265 |
scrambleButt.setClickable(false); |
|
| 266 |
scrambleButt.setVisibility(INVISIBLE); |
|
| 267 |
} |
|
| 268 |
else |
|
| 269 |
{
|
|
| 270 |
android.util.Log.e("view", "button null!");
|
|
| 271 |
} |
|
| 272 |
} |
|
| 273 |
} |
|
| 369 |
mPicker = act.findViewById(R.id.rubikNumberPicker); |
|
| 274 | 370 |
|
| 275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 276 |
|
|
| 277 |
void leaveScrambleMode() |
|
| 278 |
{
|
|
| 279 |
if( mInScrambleMode ) |
|
| 371 |
if( mPicker!=null ) |
|
| 280 | 372 |
{
|
| 281 |
mInScrambleMode = false; |
|
| 282 |
|
|
| 283 |
android.util.Log.e("view", "leaving scramble mode");
|
|
| 284 |
|
|
| 285 |
RubikActivity act = (RubikActivity)getContext(); |
|
| 286 |
|
|
| 287 |
Button scrambleButt = act.findViewById(R.id.rubikScramble); |
|
| 288 |
|
|
| 289 |
if( scrambleButt!=null ) |
|
| 290 |
{
|
|
| 291 |
scrambleButt.setClickable(true); |
|
| 292 |
scrambleButt.setVisibility(VISIBLE); |
|
| 293 |
} |
|
| 294 |
else |
|
| 295 |
{
|
|
| 296 |
android.util.Log.e("view", "button null!");
|
|
| 297 |
} |
|
| 373 |
mPicker.setMin(MIN_SCRAMBLE); |
|
| 374 |
mPicker.setMax(MAX_SCRAMBLE); |
|
| 375 |
mPicker.setValue(mScrambleValue); |
|
| 298 | 376 |
} |
| 299 | 377 |
} |
| 300 | 378 |
|
| 301 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 302 |
|
|
| 303 |
void leaveScrambleModeNonUI() |
|
| 304 |
{
|
|
| 305 |
RubikActivity act = (RubikActivity)getContext(); |
|
| 306 |
|
|
| 307 |
act.runOnUiThread(new Runnable() |
|
| 308 |
{
|
|
| 309 |
@Override |
|
| 310 |
public void run() |
|
| 311 |
{
|
|
| 312 |
leaveScrambleMode(); |
|
| 313 |
} |
|
| 314 |
}); |
|
| 315 |
} |
|
| 316 |
|
|
| 317 | 379 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 318 | 380 |
// PUBLIC API |
| 319 | 381 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 324 | 386 |
|
| 325 | 387 |
if(!isInEditMode()) |
| 326 | 388 |
{
|
| 327 |
mInScrambleMode = false; |
|
| 328 | 389 |
mRenderer = new RubikRenderer(this); |
| 329 | 390 |
mMovement = new RubikCubeMovement(); |
| 330 | 391 |
|
| src/main/res/layout/dialog_main.xml | ||
|---|---|---|
| 1 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 |
android:layout_width="match_parent" |
|
| 4 |
android:layout_height="match_parent" |
|
| 5 |
android:gravity="center_horizontal" |
|
| 6 |
android:orientation="vertical"> |
|
| 3 |
android:layout_width="fill_parent" |
|
| 4 |
android:layout_height="fill_parent" |
|
| 5 |
android:gravity="center|fill_horizontal" |
|
| 6 |
android:layout_marginLeft="10dp" |
|
| 7 |
android:layout_marginRight="10dp" |
|
| 8 |
android:layout_marginTop="10dp" |
|
| 9 |
android:layout_marginBottom="10dp" |
|
| 10 |
android:background="@color/grey" |
|
| 11 |
android:orientation="vertical"> |
|
| 7 | 12 |
|
| 13 |
<Button |
|
| 14 |
android:id="@+id/rubikPlay" |
|
| 15 |
android:layout_width="fill_parent" |
|
| 16 |
android:layout_height="fill_parent" |
|
| 17 |
android:layout_weight="1" |
|
| 18 |
android:onClick="Play" |
|
| 19 |
android:layout_marginTop="10dp" |
|
| 20 |
android:layout_marginLeft="10dp" |
|
| 21 |
android:layout_marginRight="10dp" |
|
| 22 |
android:text="@string/play" /> |
|
| 8 | 23 |
|
| 9 |
<LinearLayout
|
|
| 10 |
android:layout_width="fill_parent"
|
|
| 11 |
android:layout_height="fill_parent"
|
|
| 12 |
android:gravity="center|fill_horizontal"
|
|
| 13 |
android:layout_marginLeft="10dp"
|
|
| 14 |
android:layout_marginRight="10dp"
|
|
| 15 |
android:layout_marginTop="20dp"
|
|
| 16 |
android:background="@color/grey"
|
|
| 17 |
android:orientation="vertical">
|
|
| 24 |
<Button
|
|
| 25 |
android:id="@+id/rubikSettings"
|
|
| 26 |
android:layout_width="fill_parent"
|
|
| 27 |
android:layout_height="fill_parent"
|
|
| 28 |
android:layout_weight="1"
|
|
| 29 |
android:onClick="Settings"
|
|
| 30 |
android:layout_marginLeft="10dp"
|
|
| 31 |
android:layout_marginRight="10dp"
|
|
| 32 |
android:text="@string/settings" />
|
|
| 18 | 33 |
|
| 19 |
<TextView
|
|
| 20 |
android:layout_width="match_parent"
|
|
| 21 |
android:layout_height="fill_parent"
|
|
| 22 |
android:layout_weight="0.40"
|
|
| 23 |
android:layout_marginTop="10dp"
|
|
| 24 |
android:layout_marginLeft="10dp"
|
|
| 25 |
android:layout_marginRight="10dp"
|
|
| 26 |
android:layout_marginBottom="10dp"
|
|
| 27 |
android:text="@string/credits1"/>
|
|
| 34 |
<Button
|
|
| 35 |
android:id="@+id/rubikScores"
|
|
| 36 |
android:layout_width="fill_parent"
|
|
| 37 |
android:layout_height="fill_parent"
|
|
| 38 |
android:layout_weight="1"
|
|
| 39 |
android:onClick="Scores"
|
|
| 40 |
android:layout_marginLeft="10dp"
|
|
| 41 |
android:layout_marginRight="10dp"
|
|
| 42 |
android:text="@string/scores" />
|
|
| 28 | 43 |
|
| 29 |
<TextView |
|
| 30 |
android:layout_width="match_parent" |
|
| 31 |
android:layout_height="fill_parent" |
|
| 32 |
android:layout_weight="0.60" |
|
| 33 |
android:layout_marginBottom="10dp" |
|
| 34 |
android:layout_marginTop="10dp" |
|
| 35 |
android:layout_marginLeft="10dp" |
|
| 36 |
android:layout_marginRight="10dp" |
|
| 37 |
android:linksClickable="true" |
|
| 38 |
android:autoLink="web" |
|
| 39 |
android:text="@string/credits2"/> |
|
| 40 |
|
|
| 41 |
</LinearLayout> |
|
| 44 |
<Button |
|
| 45 |
android:id="@+id/rubikAbout" |
|
| 46 |
android:layout_width="fill_parent" |
|
| 47 |
android:layout_height="fill_parent" |
|
| 48 |
android:layout_weight="1" |
|
| 49 |
android:onClick="About" |
|
| 50 |
android:layout_marginLeft="10dp" |
|
| 51 |
android:layout_marginRight="10dp" |
|
| 52 |
android:layout_marginBottom="10dp" |
|
| 53 |
android:text="@string/about" /> |
|
| 42 | 54 |
|
| 43 | 55 |
</LinearLayout> |
| src/main/res/layout/main.xml | ||
|---|---|---|
| 5 | 5 |
android:orientation="vertical" > |
| 6 | 6 |
|
| 7 | 7 |
<LinearLayout |
| 8 |
android:id="@+id/mainTitle" |
|
| 8 | 9 |
android:layout_width="fill_parent" |
| 9 | 10 |
android:layout_height="50dp" |
| 10 |
android:gravity="center|fill_horizontal" > |
|
| 11 |
|
|
| 12 |
<Button |
|
| 13 |
android:id="@+id/rubikScramble" |
|
| 14 |
android:layout_width="wrap_content" |
|
| 15 |
android:layout_height="fill_parent" |
|
| 16 |
android:layout_weight="0.5" |
|
| 17 |
android:onClick="Scramble" |
|
| 18 |
android:paddingLeft="5dp" |
|
| 19 |
android:paddingRight="5dp" |
|
| 20 |
android:text="@string/scramble" /> |
|
| 21 |
|
|
| 22 |
<org.distorted.component.HorizontalNumberPicker |
|
| 23 |
android:id="@+id/rubikNumberPicker" |
|
| 24 |
android:layout_width="192dp" |
|
| 25 |
android:layout_height="fill_parent"/> |
|
| 26 |
|
|
| 27 |
<Button |
|
| 28 |
android:id="@+id/rubikSolve" |
|
| 29 |
android:layout_width="wrap_content" |
|
| 30 |
android:layout_height="fill_parent" |
|
| 31 |
android:layout_weight="0.5" |
|
| 32 |
android:onClick="Solve" |
|
| 33 |
android:paddingLeft="5dp" |
|
| 34 |
android:paddingRight="5dp" |
|
| 35 |
android:text="@string/solve" /> |
|
| 36 |
|
|
| 11 |
android:gravity="center" |
|
| 12 |
android:orientation="horizontal"> |
|
| 37 | 13 |
</LinearLayout> |
| 38 | 14 |
|
| 39 | 15 |
<org.distorted.magic.RubikSurfaceView |
| ... | ... | |
| 43 | 19 |
android:layout_weight="1" /> |
| 44 | 20 |
|
| 45 | 21 |
<LinearLayout |
| 46 |
android:id="@+id/sizeLayout" |
|
| 47 |
android:layout_width="match_parent" |
|
| 48 |
android:layout_height="wrap_content" |
|
| 49 |
android:gravity="center" |
|
| 50 |
android:orientation="horizontal"> |
|
| 51 |
</LinearLayout> |
|
| 52 |
|
|
| 53 |
<LinearLayout |
|
| 22 |
android:id="@+id/mainBar" |
|
| 54 | 23 |
android:layout_width="fill_parent" |
| 55 |
android:layout_height="50dp" |
|
| 56 |
android:gravity="center|fill_horizontal" > |
|
| 57 |
|
|
| 58 |
<Button |
|
| 59 |
android:id="@+id/rubikSettings" |
|
| 60 |
android:layout_width="wrap_content" |
|
| 61 |
android:layout_height="fill_parent" |
|
| 62 |
android:layout_weight="1" |
|
| 63 |
android:onClick="Settings" |
|
| 64 |
android:paddingLeft="3dp" |
|
| 65 |
android:paddingRight="3dp" |
|
| 66 |
android:text="@string/settings" /> |
|
| 67 |
|
|
| 68 |
<Button |
|
| 69 |
android:id="@+id/rubikScores" |
|
| 70 |
android:layout_width="wrap_content" |
|
| 71 |
android:layout_height="fill_parent" |
|
| 72 |
android:layout_weight="1" |
|
| 73 |
android:onClick="Scores" |
|
| 74 |
android:paddingLeft="3dp" |
|
| 75 |
android:paddingRight="3dp" |
|
| 76 |
android:text="@string/scores" /> |
|
| 77 |
|
|
| 78 |
<Button |
|
| 79 |
android:id="@+id/rubikAbout" |
|
| 80 |
android:layout_width="wrap_content" |
|
| 81 |
android:layout_height="fill_parent" |
|
| 82 |
android:layout_weight="1" |
|
| 83 |
android:onClick="About" |
|
| 84 |
android:paddingLeft="3dp" |
|
| 85 |
android:paddingRight="3dp" |
|
| 86 |
android:text="@string/about" /> |
|
| 87 |
|
|
| 24 |
android:layout_height="60dp" |
|
| 25 |
android:gravity="right" |
|
| 26 |
android:orientation="horizontal"> |
|
| 88 | 27 |
</LinearLayout> |
| 89 | 28 |
|
| 90 | 29 |
</LinearLayout> |
| src/main/res/layout/main_title.xml | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
<TextView xmlns:android="http://schemas.android.com/apk/res/android" |
|
| 3 |
android:layout_width="fill_parent" |
|
| 4 |
android:layout_height="50dp" |
|
| 5 |
android:textAlignment="center" |
|
| 6 |
android:textSize="30sp" |
|
| 7 |
android:text="@string/app_name"/> |
|
| src/main/res/layout/play.xml | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
| 3 |
android:layout_width="fill_parent" |
|
| 4 |
android:layout_height="fill_parent" |
|
| 5 |
android:orientation="vertical" > |
|
| 6 |
|
|
| 7 |
<LinearLayout |
|
| 8 |
android:layout_width="fill_parent" |
|
| 9 |
android:layout_height="50dp" |
|
| 10 |
android:gravity="center|fill_horizontal" > |
|
| 11 |
|
|
| 12 |
<Button |
|
| 13 |
android:id="@+id/rubikScramble" |
|
| 14 |
android:layout_width="wrap_content" |
|
| 15 |
android:layout_height="fill_parent" |
|
| 16 |
android:layout_weight="0.5" |
|
| 17 |
android:onClick="Scramble" |
|
| 18 |
android:paddingLeft="5dp" |
|
| 19 |
android:paddingRight="5dp" |
|
| 20 |
android:text="@string/scramble" /> |
|
| 21 |
|
|
| 22 |
<org.distorted.component.HorizontalNumberPicker |
|
| 23 |
android:id="@+id/rubikNumberPicker" |
|
| 24 |
android:layout_width="192dp" |
|
| 25 |
android:layout_height="fill_parent"/> |
|
| 26 |
|
|
| 27 |
<Button |
|
| 28 |
android:id="@+id/rubikSolve" |
|
| 29 |
android:layout_width="wrap_content" |
|
| 30 |
android:layout_height="fill_parent" |
|
| 31 |
android:layout_weight="0.5" |
|
| 32 |
android:onClick="Solve" |
|
| 33 |
android:paddingLeft="5dp" |
|
| 34 |
android:paddingRight="5dp" |
|
| 35 |
android:text="@string/solve" /> |
|
| 36 |
|
|
| 37 |
</LinearLayout> |
|
| 38 |
|
|
| 39 |
<org.distorted.magic.RubikSurfaceView |
|
| 40 |
android:id="@+id/rubikSurfaceView" |
|
| 41 |
android:layout_width="fill_parent" |
|
| 42 |
android:layout_height="0dp" |
|
| 43 |
android:layout_weight="1" /> |
|
| 44 |
|
|
| 45 |
<LinearLayout |
|
| 46 |
android:id="@+id/sizeLayout" |
|
| 47 |
android:layout_width="match_parent" |
|
| 48 |
android:layout_height="wrap_content" |
|
| 49 |
android:gravity="center" |
|
| 50 |
android:orientation="horizontal"> |
|
| 51 |
</LinearLayout> |
|
| 52 |
|
|
| 53 |
</LinearLayout> |
|
| src/main/res/layout/play_title.xml | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
| 3 |
android:layout_width="fill_parent" |
|
| 4 |
android:layout_height="fill_parent" |
|
| 5 |
android:orientation="horizontal" > |
|
| 6 |
|
|
| 7 |
<Button |
|
| 8 |
android:id="@+id/rubikScramble" |
|
| 9 |
android:layout_width="fill_parent" |
|
| 10 |
android:layout_height="fill_parent" |
|
| 11 |
android:layout_weight="0.2" |
|
| 12 |
android:onClick="Scramble" |
|
| 13 |
android:paddingLeft="5dp" |
|
| 14 |
android:paddingRight="5dp" |
|
| 15 |
android:text="@string/scramble" /> |
|
| 16 |
|
|
| 17 |
<org.distorted.component.HorizontalNumberPicker |
|
| 18 |
android:id="@+id/rubikNumberPicker" |
|
| 19 |
android:layout_width="192dp" |
|
| 20 |
android:layout_height="fill_parent"/> |
|
| 21 |
|
|
| 22 |
<Button |
|
| 23 |
android:id="@+id/rubikSolve" |
|
| 24 |
android:layout_width="fill_parent" |
|
| 25 |
android:layout_height="fill_parent" |
|
| 26 |
android:layout_weight="0.2" |
|
| 27 |
android:onClick="Solve" |
|
| 28 |
android:paddingLeft="5dp" |
|
| 29 |
android:paddingRight="5dp" |
|
| 30 |
android:text="@string/solve" /> |
|
| 31 |
|
|
| 32 |
</LinearLayout> |
|
| src/main/res/values/strings.xml | ||
|---|---|---|
| 4 | 4 |
<string name="distorted">DISTORTED</string> |
| 5 | 5 |
<string name="scramble">Scramble</string> |
| 6 | 6 |
<string name="solve">Solve</string> |
| 7 |
<string name="exit">Exit</string> |
|
| 8 |
<string name="play">Play</string> |
|
| 7 | 9 |
<string name="settings">Settings</string> |
| 8 |
<string name="scores">Scores</string> |
|
| 9 |
<string name="scores_title">High Scores</string> |
|
| 10 |
<string name="settings_title">Settings</string> |
|
| 11 |
<string name="about_title">About</string> |
|
| 10 |
<string name="scores">High Scores</string> |
|
| 12 | 11 |
<string name="about">About</string> |
| 12 |
<string name="back">Back</string> |
|
| 13 | 13 |
<string name="save">SAVE</string> |
| 14 | 14 |
<string name="ok">OK</string> |
| 15 | 15 |
<string name="sizechange_effect">Size Change Effect</string> |
Also available in: Unified diff
Major rearrangement of the UI.