1 |
807d82b7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
|
|
package org.distorted.states;
|
21 |
|
|
|
22 |
|
|
import android.content.SharedPreferences;
|
23 |
e3c74c0f
|
Leszek Koltunski
|
import android.util.TypedValue;
|
24 |
807d82b7
|
Leszek Koltunski
|
import android.view.LayoutInflater;
|
25 |
|
|
import android.view.View;
|
26 |
|
|
import android.widget.Button;
|
27 |
15846fe4
|
Leszek Koltunski
|
import android.widget.ImageButton;
|
28 |
807d82b7
|
Leszek Koltunski
|
import android.widget.LinearLayout;
|
29 |
|
|
import android.widget.TextView;
|
30 |
|
|
|
31 |
|
|
import org.distorted.main.R;
|
32 |
|
|
import org.distorted.main.RubikActivity;
|
33 |
|
|
|
34 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35 |
|
|
|
36 |
|
|
public class RubikStateReady extends RubikStateAbstract
|
37 |
|
|
{
|
38 |
15846fe4
|
Leszek Koltunski
|
private ImageButton mPrevButton;
|
39 |
|
|
|
40 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41 |
|
|
|
42 |
807d82b7
|
Leszek Koltunski
|
void leaveState(RubikActivity act)
|
43 |
|
|
{
|
44 |
|
|
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
48 |
|
|
|
49 |
|
|
void enterState(final RubikActivity act)
|
50 |
|
|
{
|
51 |
e3c74c0f
|
Leszek Koltunski
|
float width = act.getScreenWidthInPixels();
|
52 |
|
|
float buttonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
|
53 |
|
|
float titleSize = width*RubikActivity.TITLE_TEXT_SIZE;
|
54 |
|
|
|
55 |
807d82b7
|
Leszek Koltunski
|
LayoutInflater inflater = act.getLayoutInflater();
|
56 |
|
|
|
57 |
|
|
// TOP ////////////////////////////
|
58 |
|
|
LinearLayout layoutTop = act.findViewById(R.id.upperBar);
|
59 |
|
|
layoutTop.removeAllViews();
|
60 |
|
|
TextView label = (TextView)inflater.inflate(R.layout.upper_text, null);
|
61 |
e3c74c0f
|
Leszek Koltunski
|
label.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
|
62 |
807d82b7
|
Leszek Koltunski
|
label.setText(R.string.ready);
|
63 |
|
|
layoutTop.addView(label);
|
64 |
|
|
|
65 |
|
|
// BOT ////////////////////////////
|
66 |
|
|
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
|
67 |
|
|
layoutLeft.removeAllViews();
|
68 |
|
|
|
69 |
ad0c8e0e
|
Leszek Koltunski
|
setupPrevMoveButtom(act,width);
|
70 |
15846fe4
|
Leszek Koltunski
|
layoutLeft.addView(mPrevButton);
|
71 |
|
|
|
72 |
807d82b7
|
Leszek Koltunski
|
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
|
73 |
|
|
layoutRight.removeAllViews();
|
74 |
|
|
|
75 |
ad0c8e0e
|
Leszek Koltunski
|
int padding = (int)(width*RubikActivity.PADDING);
|
76 |
|
|
int margin = (int)(width*RubikActivity.MARGIN);
|
77 |
807d82b7
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
78 |
ad0c8e0e
|
Leszek Koltunski
|
params.topMargin = margin;
|
79 |
|
|
params.bottomMargin = margin;
|
80 |
|
|
params.leftMargin = margin;
|
81 |
|
|
params.rightMargin = margin;
|
82 |
807d82b7
|
Leszek Koltunski
|
|
83 |
|
|
Button back = new Button(act);
|
84 |
|
|
back.setLayoutParams(params);
|
85 |
|
|
back.setPadding(padding,0,padding,0);
|
86 |
e3c74c0f
|
Leszek Koltunski
|
back.setTextSize(TypedValue.COMPLEX_UNIT_PX, buttonSize);
|
87 |
807d82b7
|
Leszek Koltunski
|
back.setText(R.string.back);
|
88 |
|
|
|
89 |
|
|
back.setOnClickListener( new View.OnClickListener()
|
90 |
|
|
{
|
91 |
|
|
@Override
|
92 |
|
|
public void onClick(View v)
|
93 |
|
|
{
|
94 |
|
|
RubikState.goBack(act);
|
95 |
|
|
}
|
96 |
|
|
});
|
97 |
|
|
|
98 |
|
|
layoutRight.addView(back);
|
99 |
|
|
}
|
100 |
|
|
|
101 |
15846fe4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102 |
|
|
|
103 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupPrevMoveButtom(final RubikActivity act, float width)
|
104 |
15846fe4
|
Leszek Koltunski
|
{
|
105 |
ad0c8e0e
|
Leszek Koltunski
|
int padding = (int)(width*RubikActivity.PADDING);
|
106 |
15846fe4
|
Leszek Koltunski
|
int widthBut= (int)(width/6);
|
107 |
31a9f38d
|
Leszek Koltunski
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back, R.drawable.ui_huge_cube_back);
|
108 |
15846fe4
|
Leszek Koltunski
|
|
109 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut,LinearLayout.LayoutParams.MATCH_PARENT);
|
110 |
|
|
mPrevButton = new ImageButton(act);
|
111 |
|
|
mPrevButton.setLayoutParams(params);
|
112 |
|
|
mPrevButton.setPadding(padding,0,padding,0);
|
113 |
f6a9c538
|
Leszek Koltunski
|
mPrevButton.setImageResource(icon);
|
114 |
15846fe4
|
Leszek Koltunski
|
|
115 |
|
|
mPrevButton.setOnClickListener( new View.OnClickListener()
|
116 |
|
|
{
|
117 |
|
|
@Override
|
118 |
|
|
public void onClick(View v)
|
119 |
|
|
{
|
120 |
|
|
// empty
|
121 |
|
|
}
|
122 |
|
|
});
|
123 |
|
|
}
|
124 |
|
|
|
125 |
807d82b7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
126 |
|
|
|
127 |
|
|
public void savePreferences(SharedPreferences.Editor editor)
|
128 |
|
|
{
|
129 |
|
|
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
133 |
|
|
|
134 |
|
|
public void restorePreferences(SharedPreferences preferences)
|
135 |
|
|
{
|
136 |
|
|
|
137 |
|
|
}
|
138 |
|
|
}
|