1 |
e48ad1af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2022 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
44fec653
|
Leszek Koltunski
|
// 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 |
e48ad1af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
package org.distorted.bandaged;
|
11 |
|
|
|
12 |
6647b730
|
Leszek Koltunski
|
import android.os.Bundle;
|
13 |
e48ad1af
|
Leszek Koltunski
|
import android.view.LayoutInflater;
|
14 |
7cb8d4b0
|
Leszek Koltunski
|
import android.view.View;
|
15 |
e48ad1af
|
Leszek Koltunski
|
import android.widget.LinearLayout;
|
16 |
|
|
|
17 |
6647b730
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogBandagedDelete;
|
18 |
e48ad1af
|
Leszek Koltunski
|
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 |
35e32f0c
|
Leszek Koltunski
|
private static final float MARGIN = 0.015f;
|
28 |
|
|
private static final float TEXT_SIZE = 0.032f;
|
29 |
|
|
private static final float RATIO_ICON= 0.15f;
|
30 |
66cbab36
|
Leszek Koltunski
|
|
31 |
e48ad1af
|
Leszek Koltunski
|
private final LinearLayout mPane;
|
32 |
|
|
private final String mName;
|
33 |
|
|
|
34 |
7cb8d4b0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35 |
|
|
|
36 |
d3d639b1
|
Leszek Koltunski
|
public BandagedCreatorObjectView(final BandagedCreatorActivity act, String name, boolean leftmost)
|
37 |
e48ad1af
|
Leszek Koltunski
|
{
|
38 |
|
|
mName = name;
|
39 |
|
|
LayoutInflater inflater = act.getLayoutInflater();
|
40 |
|
|
mPane = (LinearLayout) inflater.inflate(R.layout.bandaged_pane, null);
|
41 |
|
|
|
42 |
35e32f0c
|
Leszek Koltunski
|
int height = act.getScreenHeightInPixels();
|
43 |
|
|
int textSize = (int)(height*TEXT_SIZE);
|
44 |
e48ad1af
|
Leszek Koltunski
|
|
45 |
2ceeb6b5
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = createPaneParams(height,leftmost,act.isRTL());
|
46 |
e48ad1af
|
Leszek Koltunski
|
mPane.setLayoutParams(params);
|
47 |
|
|
|
48 |
|
|
LinearLayout bottom = mPane.findViewById(R.id.bandagedCreatorObjectLayout);
|
49 |
|
|
|
50 |
c41c5ae3
|
Leszek Koltunski
|
TransparentButton plaButton = new TransparentButton(act, R.string.play, textSize);
|
51 |
83e021c5
|
Leszek Koltunski
|
plaButton.setSingleLine();
|
52 |
e48ad1af
|
Leszek Koltunski
|
|
53 |
83e021c5
|
Leszek Koltunski
|
final int icon = R.drawable.ui_trash;
|
54 |
c41c5ae3
|
Leszek Koltunski
|
LinearLayout.LayoutParams paramsB = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,3.0f);
|
55 |
e48ad1af
|
Leszek Koltunski
|
TransparentImageButton delButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, paramsB);
|
56 |
|
|
|
57 |
66cbab36
|
Leszek Koltunski
|
int iconHeight = (int)(RATIO_ICON*(BandagedCreatorActivity.RATIO_SCROLL-2*RubikActivity.PADDING)*height);
|
58 |
83e021c5
|
Leszek Koltunski
|
delButton.setIconSize(iconHeight);
|
59 |
|
|
|
60 |
e48ad1af
|
Leszek Koltunski
|
bottom.addView(plaButton);
|
61 |
|
|
bottom.addView(delButton);
|
62 |
7cb8d4b0
|
Leszek Koltunski
|
|
63 |
|
|
plaButton.setOnClickListener( new View.OnClickListener()
|
64 |
|
|
{
|
65 |
|
|
@Override
|
66 |
|
|
public void onClick(View v)
|
67 |
|
|
{
|
68 |
d3d639b1
|
Leszek Koltunski
|
act.playObject(mName);
|
69 |
7cb8d4b0
|
Leszek Koltunski
|
}
|
70 |
|
|
});
|
71 |
|
|
|
72 |
|
|
delButton.setOnClickListener( new View.OnClickListener()
|
73 |
|
|
{
|
74 |
|
|
@Override
|
75 |
|
|
public void onClick(View v)
|
76 |
|
|
{
|
77 |
6647b730
|
Leszek Koltunski
|
Bundle bundle = new Bundle();
|
78 |
c02fa107
|
Leszek Koltunski
|
bundle.putString("argument", mName );
|
79 |
6647b730
|
Leszek Koltunski
|
RubikDialogBandagedDelete dialog = new RubikDialogBandagedDelete();
|
80 |
|
|
dialog.setArguments(bundle);
|
81 |
|
|
dialog.show( act.getSupportFragmentManager(), RubikDialogBandagedDelete.getDialogTag() );
|
82 |
7cb8d4b0
|
Leszek Koltunski
|
}
|
83 |
|
|
});
|
84 |
e48ad1af
|
Leszek Koltunski
|
}
|
85 |
|
|
|
86 |
35e32f0c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87 |
|
|
|
88 |
2ceeb6b5
|
Leszek Koltunski
|
static LinearLayout.LayoutParams createPaneParams(int height, boolean leftmost, boolean rtl)
|
89 |
35e32f0c
|
Leszek Koltunski
|
{
|
90 |
|
|
int margin = (int)(height*MARGIN);
|
91 |
788701a7
|
Leszek Koltunski
|
int length = (int)(height*BandagedCreatorActivity.RATIO_SCROLL*0.65f);
|
92 |
35e32f0c
|
Leszek Koltunski
|
|
93 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( length, LinearLayout.LayoutParams.MATCH_PARENT);
|
94 |
|
|
params.bottomMargin = margin;
|
95 |
|
|
params.topMargin = margin;
|
96 |
2ceeb6b5
|
Leszek Koltunski
|
|
97 |
|
|
if( !rtl )
|
98 |
|
|
{
|
99 |
|
|
params.leftMargin = leftmost ? margin : 0;
|
100 |
|
|
params.rightMargin = margin;
|
101 |
|
|
}
|
102 |
|
|
else
|
103 |
|
|
{
|
104 |
|
|
params.rightMargin = leftmost ? margin : 0;
|
105 |
|
|
params.leftMargin = margin;
|
106 |
|
|
}
|
107 |
35e32f0c
|
Leszek Koltunski
|
|
108 |
|
|
return params;
|
109 |
|
|
}
|
110 |
|
|
|
111 |
e48ad1af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112 |
|
|
|
113 |
|
|
public LinearLayout getPane()
|
114 |
|
|
{
|
115 |
|
|
return mPane;
|
116 |
|
|
}
|
117 |
d3d639b1
|
Leszek Koltunski
|
|
118 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
119 |
|
|
|
120 |
66cbab36
|
Leszek Koltunski
|
public String getName()
|
121 |
d3d639b1
|
Leszek Koltunski
|
{
|
122 |
66cbab36
|
Leszek Koltunski
|
return mName;
|
123 |
d3d639b1
|
Leszek Koltunski
|
}
|
124 |
e48ad1af
|
Leszek Koltunski
|
}
|