Revision 92843d3b
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/states/RubikStateDone.java | ||
---|---|---|
20 | 20 |
package org.distorted.states; |
21 | 21 |
|
22 | 22 |
import android.content.SharedPreferences; |
23 |
import android.util.DisplayMetrics; |
|
24 | 23 |
import android.util.TypedValue; |
25 | 24 |
import android.view.LayoutInflater; |
26 | 25 |
import android.view.View; |
... | ... | |
59 | 58 |
layoutTop.addView(label); |
60 | 59 |
|
61 | 60 |
// BOT //////////////////////////// |
62 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
|
|
63 |
layoutLeft.removeAllViews();
|
|
61 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
|
|
62 |
layoutBot.removeAllViews();
|
|
64 | 63 |
|
65 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
|
66 |
layoutRight.removeAllViews(); |
|
64 |
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1); |
|
65 |
LinearLayout layoutLeft = new LinearLayout(act); |
|
66 |
layoutLeft.setLayoutParams(paramsL); |
|
67 |
LinearLayout layoutRight = new LinearLayout(act); |
|
68 |
layoutRight.setLayoutParams(paramsL); |
|
67 | 69 |
|
68 | 70 |
int padding = (int)(width*RubikActivity.PADDING); |
69 | 71 |
int margin = (int)(width*RubikActivity.MARGIN); |
... | ... | |
90 | 92 |
}); |
91 | 93 |
|
92 | 94 |
layoutRight.addView(back); |
95 |
layoutBot.addView(layoutLeft); |
|
96 |
layoutBot.addView(layoutRight); |
|
93 | 97 |
} |
94 | 98 |
|
95 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/states/RubikStatePattern.java | ||
---|---|---|
22 | 22 |
import android.content.SharedPreferences; |
23 | 23 |
import android.os.Bundle; |
24 | 24 |
import androidx.fragment.app.FragmentManager; |
25 |
import android.util.DisplayMetrics; |
|
26 | 25 |
import android.util.TypedValue; |
27 | 26 |
import android.view.Gravity; |
28 | 27 |
import android.view.LayoutInflater; |
... | ... | |
112 | 111 |
layoutTop.addView(mText); |
113 | 112 |
|
114 | 113 |
// BOT //////////////////////////// |
115 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
|
114 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar); |
|
115 |
layoutBot.removeAllViews(); |
|
116 | 116 |
|
117 | 117 |
setupPrevButton(act,width); |
118 | 118 |
setupNextButton(act,width); |
... | ... | |
120 | 120 |
|
121 | 121 |
setTrioState(false); |
122 | 122 |
|
123 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft); |
|
124 |
layoutLeft.removeAllViews(); |
|
123 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1); |
|
124 |
|
|
125 |
LinearLayout layoutLeft = new LinearLayout(act); |
|
126 |
layoutLeft.setLayoutParams(params); |
|
127 |
|
|
125 | 128 |
layoutLeft.addView(mPrevButton); |
126 | 129 |
layoutLeft.addView(mMovesText); |
127 | 130 |
layoutLeft.addView(mNextButton); |
128 | 131 |
|
129 | 132 |
setupBackButton(act,width); |
130 | 133 |
|
131 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
|
132 |
layoutRight.removeAllViews(); |
|
134 |
LinearLayout layoutRight = new LinearLayout(act); |
|
135 |
layoutRight.setLayoutParams(params); |
|
136 |
|
|
133 | 137 |
layoutRight.addView(mBackButton); |
138 |
|
|
139 |
layoutBot.addView(layoutLeft); |
|
140 |
layoutBot.addView(layoutRight); |
|
134 | 141 |
} |
135 | 142 |
|
136 | 143 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/states/RubikStatePlay.java | ||
---|---|---|
27 | 27 |
import android.view.Gravity; |
28 | 28 |
import android.view.LayoutInflater; |
29 | 29 |
import android.view.View; |
30 |
import android.view.Window; |
|
31 | 30 |
import android.widget.Button; |
32 | 31 |
import android.widget.GridLayout; |
33 | 32 |
import android.widget.ImageButton; |
... | ... | |
63 | 62 |
private int mObject = DEF_OBJECT; |
64 | 63 |
private int mSize = DEF_SIZE; |
65 | 64 |
private int mObjectSize, mMenuLayoutWidth, mMenuLayoutHeight, mPlayLayoutWidth; |
66 |
private GridLayout mObjectGrid; |
|
67 | 65 |
private int mLevelValue; |
68 | 66 |
private float mButtonSize, mMenuItemSize, mMenuTextSize; |
69 | 67 |
private int mColCount, mRowCount; |
... | ... | |
125 | 123 |
layoutTop.addView(mPlayButton); |
126 | 124 |
|
127 | 125 |
// BOT //////////////////////////// |
128 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
|
|
129 |
layoutLeft.removeAllViews();
|
|
126 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
|
|
127 |
layoutBot.removeAllViews();
|
|
130 | 128 |
|
131 | 129 |
setupPrevButton(act,width); |
132 |
layoutLeft.addView(mPrevButton);
|
|
130 |
layoutBot.addView(mPrevButton);
|
|
133 | 131 |
setupSolveButton(act,width); |
134 |
layoutLeft.addView(mSolveButton); |
|
135 |
|
|
136 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
|
137 |
layoutRight.removeAllViews(); |
|
132 |
layoutBot.addView(mSolveButton); |
|
138 | 133 |
} |
139 | 134 |
|
140 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
328 | 323 |
{ |
329 | 324 |
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
330 | 325 |
final View layout = layoutInflater.inflate(R.layout.popup_objects, null); |
331 |
mObjectGrid = layout.findViewById(R.id.objectGrid);
|
|
326 |
GridLayout objectGrid = layout.findViewById(R.id.objectGrid);
|
|
332 | 327 |
|
333 | 328 |
int[] indices = RubikObjectList.getIndices(); |
334 | 329 |
|
335 | 330 |
GridLayout.Spec[] rowSpecs = new GridLayout.Spec[mRowCount]; |
336 | 331 |
GridLayout.Spec[] colSpecs = new GridLayout.Spec[mColCount]; |
337 | 332 |
|
338 |
mObjectGrid.setColumnCount(mColCount);
|
|
339 |
mObjectGrid.setRowCount(mRowCount);
|
|
333 |
objectGrid.setColumnCount(mColCount);
|
|
334 |
objectGrid.setRowCount(mRowCount);
|
|
340 | 335 |
|
341 | 336 |
int[] nextInColumn = new int[mColCount]; |
342 | 337 |
|
... | ... | |
401 | 396 |
|
402 | 397 |
nextInColumn[col]++; |
403 | 398 |
|
404 |
mObjectGrid.addView(button, params);
|
|
399 |
objectGrid.addView(button, params);
|
|
405 | 400 |
} |
406 | 401 |
} |
407 | 402 |
} |
src/main/java/org/distorted/states/RubikStateReady.java | ||
---|---|---|
63 | 63 |
layoutTop.addView(label); |
64 | 64 |
|
65 | 65 |
// BOT //////////////////////////// |
66 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft); |
|
67 |
layoutLeft.removeAllViews(); |
|
66 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar); |
|
67 |
layoutBot.removeAllViews(); |
|
68 |
|
|
69 |
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1); |
|
70 |
LinearLayout layoutLeft = new LinearLayout(act); |
|
71 |
layoutLeft.setLayoutParams(paramsL); |
|
72 |
LinearLayout layoutRight = new LinearLayout(act); |
|
73 |
layoutRight.setLayoutParams(paramsL); |
|
68 | 74 |
|
69 | 75 |
setupPrevMoveButtom(act,width); |
70 | 76 |
layoutLeft.addView(mPrevButton); |
71 | 77 |
|
72 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
|
73 |
layoutRight.removeAllViews(); |
|
74 |
|
|
75 | 78 |
int padding = (int)(width*RubikActivity.PADDING); |
76 | 79 |
int margin = (int)(width*RubikActivity.MARGIN); |
77 | 80 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
... | ... | |
96 | 99 |
}); |
97 | 100 |
|
98 | 101 |
layoutRight.addView(back); |
102 |
|
|
103 |
layoutBot.addView(layoutLeft); |
|
104 |
layoutBot.addView(layoutRight); |
|
99 | 105 |
} |
100 | 106 |
|
101 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
103 | 109 |
private void setupPrevMoveButtom(final RubikActivity act, float width) |
104 | 110 |
{ |
105 | 111 |
int padding = (int)(width*RubikActivity.PADDING); |
112 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
106 | 113 |
int widthBut= (int)(width/6); |
107 | 114 |
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 | 115 |
|
109 | 116 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut,LinearLayout.LayoutParams.MATCH_PARENT); |
117 |
params.topMargin = margin; |
|
118 |
params.bottomMargin = margin; |
|
119 |
params.leftMargin = margin; |
|
120 |
params.rightMargin = margin; |
|
121 |
|
|
110 | 122 |
mPrevButton = new ImageButton(act); |
111 | 123 |
mPrevButton.setLayoutParams(params); |
112 | 124 |
mPrevButton.setPadding(padding,0,padding,0); |
src/main/java/org/distorted/states/RubikStateSolution.java | ||
---|---|---|
77 | 77 |
layoutTop.addView(text); |
78 | 78 |
|
79 | 79 |
// BOT //////////////////////////// |
80 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar); |
|
81 |
layoutBot.removeAllViews(); |
|
82 |
|
|
83 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1); |
|
84 |
|
|
80 | 85 |
setupPrevButton(act,width); |
81 | 86 |
setupNextButton(act,width); |
82 | 87 |
setupTextView(act,width); |
83 | 88 |
|
84 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft); |
|
85 |
layoutLeft.removeAllViews(); |
|
89 |
LinearLayout layoutLeft = new LinearLayout(act); |
|
90 |
layoutLeft.setLayoutParams(params); |
|
91 |
|
|
86 | 92 |
layoutLeft.addView(mPrevButton); |
87 | 93 |
layoutLeft.addView(mMovesText); |
88 | 94 |
layoutLeft.addView(mNextButton); |
89 | 95 |
|
90 | 96 |
setupBackButton(act,width); |
91 | 97 |
|
92 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
|
93 |
layoutRight.removeAllViews(); |
|
98 |
LinearLayout layoutRight = new LinearLayout(act); |
|
99 |
layoutRight.setLayoutParams(params); |
|
100 |
|
|
94 | 101 |
layoutRight.addView(mBackButton); |
102 |
|
|
103 |
layoutBot.addView(layoutLeft); |
|
104 |
layoutBot.addView(layoutRight); |
|
95 | 105 |
} |
96 | 106 |
|
97 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/states/RubikStateSolver.java | ||
---|---|---|
107 | 107 |
for(ImageButton button: mColorButton) layoutTop.addView(button); |
108 | 108 |
|
109 | 109 |
// BOT //////////////////////////// |
110 |
setupSolveButton(act,width); |
|
111 |
|
|
112 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft); |
|
113 |
layoutLeft.removeAllViews(); |
|
114 |
layoutLeft.addView(mSolveButton); |
|
110 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar); |
|
111 |
layoutBot.removeAllViews(); |
|
115 | 112 |
|
113 |
setupSolveButton(act,width); |
|
116 | 114 |
setupBackButton(act,width); |
117 | 115 |
|
118 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
|
119 |
layoutRight.removeAllViews(); |
|
120 |
layoutRight.addView(mBackButton); |
|
116 |
layoutBot.addView(mSolveButton); |
|
117 |
layoutBot.addView(mBackButton); |
|
121 | 118 |
} |
122 | 119 |
|
123 | 120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
191 | 188 |
{ |
192 | 189 |
int padding = (int)(width*RubikActivity.PADDING); |
193 | 190 |
int margin = (int)(width*RubikActivity.MARGIN); |
194 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
191 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
|
|
195 | 192 |
params.topMargin = margin; |
196 | 193 |
params.bottomMargin = margin; |
197 | 194 |
params.leftMargin = margin; |
... | ... | |
226 | 223 |
{ |
227 | 224 |
int padding = (int)(width*RubikActivity.PADDING); |
228 | 225 |
int margin = (int)(width*RubikActivity.MARGIN); |
229 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
226 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
|
|
230 | 227 |
params.topMargin = margin; |
231 | 228 |
params.bottomMargin = margin; |
232 | 229 |
params.leftMargin = margin; |
src/main/java/org/distorted/states/RubikStateSolving.java | ||
---|---|---|
108 | 108 |
layoutTop.addView(mTime); |
109 | 109 |
|
110 | 110 |
// BOT //////////////////////////// |
111 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft); |
|
112 |
layoutLeft.removeAllViews(); |
|
111 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar); |
|
112 |
layoutBot.removeAllViews(); |
|
113 |
|
|
114 |
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1); |
|
115 |
LinearLayout layoutLeft = new LinearLayout(act); |
|
116 |
layoutLeft.setLayoutParams(paramsL); |
|
117 |
LinearLayout layoutRight = new LinearLayout(act); |
|
118 |
layoutRight.setLayoutParams(paramsL); |
|
113 | 119 |
|
114 | 120 |
setupPrevMoveButtom(act,width); |
115 | 121 |
layoutLeft.addView(mPrevButton); |
116 | 122 |
|
117 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
|
118 |
layoutRight.removeAllViews(); |
|
119 |
|
|
120 | 123 |
int padding = (int)(width*RubikActivity.PADDING); |
121 | 124 |
int margin = (int)(width*RubikActivity.MARGIN); |
122 | 125 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
... | ... | |
141 | 144 |
}); |
142 | 145 |
|
143 | 146 |
layoutRight.addView(back); |
147 |
|
|
148 |
layoutBot.addView(layoutLeft); |
|
149 |
layoutBot.addView(layoutRight); |
|
144 | 150 |
} |
145 | 151 |
|
146 | 152 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/res/layout/main.xml | ||
---|---|---|
25 | 25 |
android:layout_height="0dp" |
26 | 26 |
android:layout_weight="0.12" |
27 | 27 |
android:orientation="horizontal"> |
28 |
|
|
29 |
<LinearLayout |
|
30 |
android:id="@+id/mainBarLeft" |
|
31 |
android:layout_width="match_parent" |
|
32 |
android:layout_height="match_parent" |
|
33 |
android:layout_weight="1" |
|
34 |
android:orientation="horizontal"> |
|
35 |
</LinearLayout> |
|
36 |
|
|
37 |
<LinearLayout |
|
38 |
android:id="@+id/mainBarRight" |
|
39 |
android:layout_width="match_parent" |
|
40 |
android:layout_height="match_parent" |
|
41 |
android:layout_weight="1" |
|
42 |
android:orientation="horizontal"> |
|
43 |
</LinearLayout> |
|
44 |
|
|
45 | 28 |
</LinearLayout> |
46 | 29 |
|
47 | 30 |
</LinearLayout> |
Also available in: Unified diff
Rework the bottom pane