1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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.screens;
|
21
|
|
22
|
import android.app.Activity;
|
23
|
import android.widget.LinearLayout;
|
24
|
|
25
|
import org.distorted.helpers.TransparentImageButton;
|
26
|
import org.distorted.main.RubikActivity;
|
27
|
import org.distorted.objectlib.main.ObjectControl;
|
28
|
|
29
|
import org.distorted.helpers.LockController;
|
30
|
import org.distorted.helpers.MovesController;
|
31
|
import org.distorted.main.R;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
abstract class RubikScreenBase extends RubikScreenAbstract
|
36
|
{
|
37
|
private final LockController mLockController;
|
38
|
protected MovesController mMovesController;
|
39
|
|
40
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41
|
|
42
|
void createBottomPane(final RubikActivity act, TransparentImageButton left, TransparentImageButton right)
|
43
|
{
|
44
|
mMovesController.clearMoves(act);
|
45
|
|
46
|
LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
|
47
|
layoutBot.removeAllViews();
|
48
|
|
49
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
|
50
|
|
51
|
LinearLayout layoutLeft = new LinearLayout(act);
|
52
|
layoutLeft.setLayoutParams(params);
|
53
|
LinearLayout layoutMid = new LinearLayout(act);
|
54
|
layoutMid.setLayoutParams(params);
|
55
|
LinearLayout layoutRight = new LinearLayout(act);
|
56
|
layoutRight.setLayoutParams(params);
|
57
|
|
58
|
ObjectControl control = act.getControl();
|
59
|
mMovesController.setupButton(act,control);
|
60
|
layoutLeft.addView(mMovesController.getButton());
|
61
|
mLockController.setupButton(act,control);
|
62
|
layoutMid.addView(mLockController.getButton());
|
63
|
|
64
|
if( left !=null ) layoutRight.addView(left);
|
65
|
if( right!=null ) layoutRight.addView(right);
|
66
|
|
67
|
layoutBot.addView(layoutLeft);
|
68
|
layoutBot.addView(layoutMid);
|
69
|
layoutBot.addView(layoutRight);
|
70
|
}
|
71
|
|
72
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
73
|
|
74
|
public void setLockState(final RubikActivity act)
|
75
|
{
|
76
|
boolean locked = act.getControl().retLocked();
|
77
|
mLockController.setState(act,locked);
|
78
|
}
|
79
|
|
80
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
81
|
// PUBLIC API
|
82
|
|
83
|
public RubikScreenBase()
|
84
|
{
|
85
|
mLockController = new LockController();
|
86
|
mMovesController= new MovesController();
|
87
|
}
|
88
|
|
89
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90
|
|
91
|
public void addMove(Activity act, int axis, int row, int angle)
|
92
|
{
|
93
|
mMovesController.addMove(act,axis,row,angle);
|
94
|
}
|
95
|
|
96
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97
|
|
98
|
public void reddenLock(final RubikActivity act)
|
99
|
{
|
100
|
ObjectControl control = act.getControl();
|
101
|
mLockController.reddenLock(act,control);
|
102
|
}
|
103
|
}
|