1 |
e48ad1af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2022 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.LayoutInflater;
|
23 |
7cb8d4b0
|
Leszek Koltunski
|
import android.view.View;
|
24 |
e48ad1af
|
Leszek Koltunski
|
import android.widget.LinearLayout;
|
25 |
|
|
|
26 |
|
|
import org.distorted.helpers.TransparentButton;
|
27 |
|
|
import org.distorted.helpers.TransparentImageButton;
|
28 |
|
|
import org.distorted.main.R;
|
29 |
|
|
import org.distorted.main.RubikActivity;
|
30 |
|
|
|
31 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32 |
|
|
|
33 |
|
|
public class BandagedCreatorObjectView
|
34 |
|
|
{
|
35 |
|
|
private final LinearLayout mPane;
|
36 |
|
|
private final String mName;
|
37 |
|
|
|
38 |
7cb8d4b0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
|
40 |
d3d639b1
|
Leszek Koltunski
|
public BandagedCreatorObjectView(final BandagedCreatorActivity act, String name, boolean leftmost)
|
41 |
e48ad1af
|
Leszek Koltunski
|
{
|
42 |
|
|
mName = name;
|
43 |
|
|
LayoutInflater inflater = act.getLayoutInflater();
|
44 |
|
|
mPane = (LinearLayout) inflater.inflate(R.layout.bandaged_pane, null);
|
45 |
|
|
|
46 |
c41c5ae3
|
Leszek Koltunski
|
int width = act.getScreenWidthInPixels();
|
47 |
|
|
int lMargin = (int)(width*RubikActivity.LARGE_MARGIN);
|
48 |
|
|
int textSize = (int)(width*RubikActivity.BUTTON_TEXT_SIZE);
|
49 |
e48ad1af
|
Leszek Koltunski
|
|
50 |
83e021c5
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( (int)(width*0.36f), LinearLayout.LayoutParams.MATCH_PARENT);
|
51 |
e48ad1af
|
Leszek Koltunski
|
params.bottomMargin = lMargin;
|
52 |
|
|
params.topMargin = lMargin;
|
53 |
|
|
params.leftMargin = leftmost ? lMargin : 0;
|
54 |
|
|
params.rightMargin = lMargin;
|
55 |
|
|
|
56 |
|
|
mPane.setLayoutParams(params);
|
57 |
|
|
|
58 |
|
|
LinearLayout bottom = mPane.findViewById(R.id.bandagedCreatorObjectLayout);
|
59 |
|
|
|
60 |
c41c5ae3
|
Leszek Koltunski
|
TransparentButton plaButton = new TransparentButton(act, R.string.play, textSize);
|
61 |
83e021c5
|
Leszek Koltunski
|
plaButton.setSingleLine();
|
62 |
e48ad1af
|
Leszek Koltunski
|
|
63 |
83e021c5
|
Leszek Koltunski
|
final int icon = R.drawable.ui_trash;
|
64 |
c41c5ae3
|
Leszek Koltunski
|
LinearLayout.LayoutParams paramsB = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,3.0f);
|
65 |
e48ad1af
|
Leszek Koltunski
|
TransparentImageButton delButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, paramsB);
|
66 |
|
|
|
67 |
83e021c5
|
Leszek Koltunski
|
int height = act.getScreenHeightInPixels();
|
68 |
|
|
int iconHeight = (int)(0.15f*(BandagedCreatorActivity.RATIO_SCROLL-2*RubikActivity.PADDING)*height);
|
69 |
|
|
delButton.setIconSize(iconHeight);
|
70 |
|
|
|
71 |
e48ad1af
|
Leszek Koltunski
|
bottom.addView(plaButton);
|
72 |
|
|
bottom.addView(delButton);
|
73 |
7cb8d4b0
|
Leszek Koltunski
|
|
74 |
|
|
plaButton.setOnClickListener( new View.OnClickListener()
|
75 |
|
|
{
|
76 |
|
|
@Override
|
77 |
|
|
public void onClick(View v)
|
78 |
|
|
{
|
79 |
d3d639b1
|
Leszek Koltunski
|
act.playObject(mName);
|
80 |
7cb8d4b0
|
Leszek Koltunski
|
}
|
81 |
|
|
});
|
82 |
|
|
|
83 |
|
|
delButton.setOnClickListener( new View.OnClickListener()
|
84 |
|
|
{
|
85 |
|
|
@Override
|
86 |
|
|
public void onClick(View v)
|
87 |
|
|
{
|
88 |
d3d639b1
|
Leszek Koltunski
|
act.deleteObject(mName);
|
89 |
7cb8d4b0
|
Leszek Koltunski
|
}
|
90 |
|
|
});
|
91 |
e48ad1af
|
Leszek Koltunski
|
}
|
92 |
|
|
|
93 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94 |
|
|
|
95 |
|
|
public LinearLayout getPane()
|
96 |
|
|
{
|
97 |
|
|
return mPane;
|
98 |
|
|
}
|
99 |
d3d639b1
|
Leszek Koltunski
|
|
100 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101 |
|
|
|
102 |
|
|
public boolean objectNameIs(String name)
|
103 |
|
|
{
|
104 |
|
|
return mName.equals(name);
|
105 |
|
|
}
|
106 |
e48ad1af
|
Leszek Koltunski
|
}
|