1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2022 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.bandaged;
|
11
|
|
12
|
import android.os.Bundle;
|
13
|
import android.view.LayoutInflater;
|
14
|
import android.view.View;
|
15
|
import android.widget.LinearLayout;
|
16
|
|
17
|
import org.distorted.dialogs.RubikDialogBandagedDelete;
|
18
|
import org.distorted.helpers.TransparentButton;
|
19
|
import org.distorted.helpers.TransparentImageButton;
|
20
|
import org.distorted.main.R;
|
21
|
import org.distorted.main.RubikActivity;
|
22
|
|
23
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
24
|
|
25
|
public class BandagedCreatorObjectView
|
26
|
{
|
27
|
static final float RATIO_PANE = 0.36f;
|
28
|
static final float RATIO_ICON = 0.15f;
|
29
|
|
30
|
private final LinearLayout mPane;
|
31
|
private final String mName;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
public BandagedCreatorObjectView(final BandagedCreatorActivity act, String name, boolean leftmost)
|
36
|
{
|
37
|
mName = name;
|
38
|
LayoutInflater inflater = act.getLayoutInflater();
|
39
|
mPane = (LinearLayout) inflater.inflate(R.layout.bandaged_pane, null);
|
40
|
|
41
|
int width = act.getScreenWidthInPixels();
|
42
|
int margin = (int)(width*RubikActivity.LARGE_MARGIN);
|
43
|
int textSize = (int)(width*RubikActivity.BUTTON_TEXT_SIZE);
|
44
|
|
45
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( (int)(width*RATIO_PANE), LinearLayout.LayoutParams.MATCH_PARENT);
|
46
|
params.bottomMargin = margin;
|
47
|
params.topMargin = margin;
|
48
|
params.leftMargin = leftmost ? margin : 0;
|
49
|
params.rightMargin = margin;
|
50
|
|
51
|
mPane.setLayoutParams(params);
|
52
|
|
53
|
LinearLayout bottom = mPane.findViewById(R.id.bandagedCreatorObjectLayout);
|
54
|
|
55
|
TransparentButton plaButton = new TransparentButton(act, R.string.play, textSize);
|
56
|
plaButton.setSingleLine();
|
57
|
|
58
|
final int icon = R.drawable.ui_trash;
|
59
|
LinearLayout.LayoutParams paramsB = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,3.0f);
|
60
|
TransparentImageButton delButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, paramsB);
|
61
|
|
62
|
int height = act.getScreenHeightInPixels();
|
63
|
int iconHeight = (int)(RATIO_ICON*(BandagedCreatorActivity.RATIO_SCROLL-2*RubikActivity.PADDING)*height);
|
64
|
delButton.setIconSize(iconHeight);
|
65
|
|
66
|
bottom.addView(plaButton);
|
67
|
bottom.addView(delButton);
|
68
|
|
69
|
plaButton.setOnClickListener( new View.OnClickListener()
|
70
|
{
|
71
|
@Override
|
72
|
public void onClick(View v)
|
73
|
{
|
74
|
act.playObject(mName);
|
75
|
}
|
76
|
});
|
77
|
|
78
|
delButton.setOnClickListener( new View.OnClickListener()
|
79
|
{
|
80
|
@Override
|
81
|
public void onClick(View v)
|
82
|
{
|
83
|
Bundle bundle = new Bundle();
|
84
|
bundle.putString("name", mName );
|
85
|
RubikDialogBandagedDelete dialog = new RubikDialogBandagedDelete();
|
86
|
dialog.setArguments(bundle);
|
87
|
dialog.show( act.getSupportFragmentManager(), RubikDialogBandagedDelete.getDialogTag() );
|
88
|
}
|
89
|
});
|
90
|
}
|
91
|
|
92
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
93
|
|
94
|
public LinearLayout getPane()
|
95
|
{
|
96
|
return mPane;
|
97
|
}
|
98
|
|
99
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
100
|
|
101
|
public String getName()
|
102
|
{
|
103
|
return mName;
|
104
|
}
|
105
|
}
|