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.bandaged;
|
21
|
|
22
|
import android.view.View;
|
23
|
import android.widget.LinearLayout;
|
24
|
|
25
|
import org.distorted.helpers.TransparentImageButton;
|
26
|
import org.distorted.main.R;
|
27
|
import org.distorted.main.RubikActivity;
|
28
|
|
29
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
30
|
|
31
|
public class BandagedCreatorScreen
|
32
|
{
|
33
|
private TransparentImageButton mBackButton, mResetButton, mDoneButton;
|
34
|
private int mObjectOrdinal;
|
35
|
private int mBarHeight;
|
36
|
private float mButtonSize;
|
37
|
|
38
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39
|
|
40
|
public BandagedCreatorScreen()
|
41
|
{
|
42
|
|
43
|
}
|
44
|
|
45
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46
|
|
47
|
private void setupBackButton(final BandagedCreatorActivity act)
|
48
|
{
|
49
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback);
|
50
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
51
|
mBackButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
|
52
|
|
53
|
mBackButton.setOnClickListener( new View.OnClickListener()
|
54
|
{
|
55
|
@Override
|
56
|
public void onClick(View v)
|
57
|
{
|
58
|
act.finish();
|
59
|
}
|
60
|
});
|
61
|
}
|
62
|
|
63
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
64
|
|
65
|
private void setupDoneButton(final BandagedCreatorActivity act)
|
66
|
{
|
67
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_done,R.drawable.ui_medium_done, R.drawable.ui_big_done, R.drawable.ui_huge_done);
|
68
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
69
|
mDoneButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
|
70
|
|
71
|
mDoneButton.setOnClickListener( new View.OnClickListener()
|
72
|
{
|
73
|
@Override
|
74
|
public void onClick(View v)
|
75
|
{
|
76
|
|
77
|
}
|
78
|
});
|
79
|
}
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
|
83
|
private void setupResetButton(final BandagedCreatorActivity act)
|
84
|
{
|
85
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_reset,R.drawable.ui_medium_reset, R.drawable.ui_big_reset, R.drawable.ui_huge_reset);
|
86
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
87
|
mResetButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
|
88
|
|
89
|
mResetButton.setOnClickListener( new View.OnClickListener()
|
90
|
{
|
91
|
@Override
|
92
|
public void onClick(View v)
|
93
|
{
|
94
|
|
95
|
}
|
96
|
});
|
97
|
}
|
98
|
|
99
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
100
|
|
101
|
void onAttachedToWindow(final BandagedCreatorActivity act, final int objectOrdinal)
|
102
|
{
|
103
|
int width = act.getScreenWidthInPixels();
|
104
|
mBarHeight = act.getHeightBar();
|
105
|
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
|
106
|
|
107
|
mObjectOrdinal = objectOrdinal;
|
108
|
|
109
|
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
|
110
|
LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
|
111
|
LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
|
112
|
|
113
|
LinearLayout layoutLeft = new LinearLayout(act);
|
114
|
layoutLeft.setLayoutParams(paramsL);
|
115
|
LinearLayout layoutMid = new LinearLayout(act);
|
116
|
layoutMid.setLayoutParams(paramsM);
|
117
|
LinearLayout layoutRight= new LinearLayout(act);
|
118
|
layoutRight.setLayoutParams(paramsR);
|
119
|
|
120
|
setupBackButton(act);
|
121
|
layoutRight.addView(mBackButton);
|
122
|
setupDoneButton(act);
|
123
|
layoutMid.addView(mDoneButton);
|
124
|
setupResetButton(act);
|
125
|
layoutLeft.addView(mResetButton);
|
126
|
|
127
|
LinearLayout layout = act.findViewById(R.id.lowerBar);
|
128
|
layout.removeAllViews();
|
129
|
layout.addView(layoutLeft);
|
130
|
layout.addView(layoutMid);
|
131
|
layout.addView(layoutRight);
|
132
|
}
|
133
|
}
|