26 |
26 |
import android.view.LayoutInflater;
|
27 |
27 |
import android.view.View;
|
28 |
28 |
import android.widget.Button;
|
|
29 |
import android.widget.ImageButton;
|
29 |
30 |
import android.widget.LinearLayout;
|
30 |
31 |
import android.widget.TextView;
|
31 |
32 |
|
... | ... | |
44 |
45 |
|
45 |
46 |
private TextView mText;
|
46 |
47 |
private Button mBackButton;
|
|
48 |
private ImageButton mPrevButton, mNextButton;
|
|
49 |
private TextView mMovesText;
|
47 |
50 |
private int mSize;
|
48 |
51 |
|
49 |
52 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
104 |
107 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics();
|
105 |
108 |
final float scale = metrics.density;
|
106 |
109 |
|
|
110 |
if( mPrevButton==null ) setupPrevButton(act,scale);
|
|
111 |
if( mNextButton==null ) setupNextButton(act,scale);
|
|
112 |
if( mMovesText ==null ) setupTextView(act,scale);
|
|
113 |
|
|
114 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
|
|
115 |
layoutLeft.removeAllViews();
|
|
116 |
layoutLeft.addView(mPrevButton);
|
|
117 |
layoutLeft.addView(mMovesText);
|
|
118 |
layoutLeft.addView(mNextButton);
|
|
119 |
|
107 |
120 |
if( mBackButton==null ) setupBackButton(act,scale);
|
108 |
121 |
|
109 |
122 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
|
... | ... | |
133 |
146 |
LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
134 |
147 |
mBackButton = new Button(act);
|
135 |
148 |
mBackButton.setLayoutParams(backParams);
|
136 |
|
mBackButton.setId(BUTTON_ID_BACK);
|
137 |
149 |
mBackButton.setPadding(padding,0,padding,0);
|
138 |
150 |
mBackButton.setText(R.string.back);
|
139 |
151 |
|
... | ... | |
161 |
173 |
});
|
162 |
174 |
}
|
163 |
175 |
|
|
176 |
|
|
177 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
178 |
|
|
179 |
private void setupPrevButton(final RubikActivity act, final float scale)
|
|
180 |
{
|
|
181 |
int padding = (int)(3*scale + 0.5f);
|
|
182 |
int length = (int)(40*scale + 0.5f);
|
|
183 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(length,LinearLayout.LayoutParams.MATCH_PARENT);
|
|
184 |
mPrevButton = new ImageButton(act);
|
|
185 |
mPrevButton.setLayoutParams(params);
|
|
186 |
mPrevButton.setPadding(padding,0,padding,0);
|
|
187 |
mPrevButton.setImageResource(R.drawable.left);
|
|
188 |
|
|
189 |
mPrevButton.setOnClickListener( new View.OnClickListener()
|
|
190 |
{
|
|
191 |
@Override
|
|
192 |
public void onClick(View v)
|
|
193 |
{
|
|
194 |
android.util.Log.e("patt", "prev button clicked!");
|
|
195 |
}
|
|
196 |
});
|
|
197 |
}
|
|
198 |
|
|
199 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
200 |
|
|
201 |
private void setupNextButton(final RubikActivity act, final float scale)
|
|
202 |
{
|
|
203 |
int padding = (int)( 3*scale + 0.5f);
|
|
204 |
int length = (int)(40*scale + 0.5f);
|
|
205 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(length,LinearLayout.LayoutParams.MATCH_PARENT);
|
|
206 |
mNextButton = new ImageButton(act);
|
|
207 |
mNextButton.setLayoutParams(params);
|
|
208 |
mNextButton.setPadding(padding,0,padding,0);
|
|
209 |
mNextButton.setImageResource(R.drawable.right);
|
|
210 |
|
|
211 |
mNextButton.setOnClickListener( new View.OnClickListener()
|
|
212 |
{
|
|
213 |
@Override
|
|
214 |
public void onClick(View v)
|
|
215 |
{
|
|
216 |
android.util.Log.e("patt", "next button clicked!");
|
|
217 |
}
|
|
218 |
});
|
|
219 |
}
|
|
220 |
|
|
221 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
222 |
|
|
223 |
private void setupTextView(final RubikActivity act, final float scale)
|
|
224 |
{
|
|
225 |
int padding = (int)( 3*scale + 0.5f);
|
|
226 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
|
227 |
|
|
228 |
mMovesText = new TextView(act);
|
|
229 |
mMovesText.setLayoutParams(params);
|
|
230 |
mMovesText.setPadding(padding,0,padding,0);
|
|
231 |
|
|
232 |
mMovesText.setText("aaa");
|
|
233 |
}
|
|
234 |
|
164 |
235 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165 |
236 |
|
166 |
237 |
public void setPattern(int sizeIndex, int category, int pattern)
|
... | ... | |
177 |
248 |
public void savePreferences(SharedPreferences.Editor editor)
|
178 |
249 |
{
|
179 |
250 |
mBackButton= null;
|
|
251 |
mPrevButton= null;
|
|
252 |
mNextButton= null;
|
|
253 |
mMovesText = null;
|
180 |
254 |
}
|
181 |
255 |
|
182 |
256 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
Beginnings of support for actual patterns!