Project

General

Profile

Download (3.97 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / bandaged / BandagedCreatorObjectView.java @ 298f3977

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 66cbab36 Leszek Koltunski
  static final float RATIO_PANE = 0.36f;
28
  static final float RATIO_ICON = 0.15f;
29
30 e48ad1af Leszek Koltunski
  private final LinearLayout mPane;
31
  private final String mName;
32
33 7cb8d4b0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
34
35 d3d639b1 Leszek Koltunski
  public BandagedCreatorObjectView(final BandagedCreatorActivity act, String name, boolean leftmost)
36 e48ad1af Leszek Koltunski
    {
37
    mName = name;
38
    LayoutInflater inflater = act.getLayoutInflater();
39
    mPane = (LinearLayout) inflater.inflate(R.layout.bandaged_pane, null);
40
41 c41c5ae3 Leszek Koltunski
    int width    = act.getScreenWidthInPixels();
42 66cbab36 Leszek Koltunski
    int margin   = (int)(width*RubikActivity.LARGE_MARGIN);
43 c41c5ae3 Leszek Koltunski
    int textSize = (int)(width*RubikActivity.BUTTON_TEXT_SIZE);
44 e48ad1af Leszek Koltunski
45 66cbab36 Leszek Koltunski
    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 e48ad1af Leszek Koltunski
51
    mPane.setLayoutParams(params);
52
53
    LinearLayout bottom = mPane.findViewById(R.id.bandagedCreatorObjectLayout);
54
55 c41c5ae3 Leszek Koltunski
    TransparentButton plaButton = new TransparentButton(act, R.string.play, textSize);
56 83e021c5 Leszek Koltunski
    plaButton.setSingleLine();
57 e48ad1af Leszek Koltunski
58 83e021c5 Leszek Koltunski
    final int icon = R.drawable.ui_trash;
59 c41c5ae3 Leszek Koltunski
    LinearLayout.LayoutParams paramsB = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,3.0f);
60 e48ad1af Leszek Koltunski
    TransparentImageButton delButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, paramsB);
61
62 83e021c5 Leszek Koltunski
    int height = act.getScreenHeightInPixels();
63 66cbab36 Leszek Koltunski
    int iconHeight = (int)(RATIO_ICON*(BandagedCreatorActivity.RATIO_SCROLL-2*RubikActivity.PADDING)*height);
64 83e021c5 Leszek Koltunski
    delButton.setIconSize(iconHeight);
65
66 e48ad1af Leszek Koltunski
    bottom.addView(plaButton);
67
    bottom.addView(delButton);
68 7cb8d4b0 Leszek Koltunski
69
    plaButton.setOnClickListener( new View.OnClickListener()
70
      {
71
      @Override
72
      public void onClick(View v)
73
        {
74 d3d639b1 Leszek Koltunski
        act.playObject(mName);
75 7cb8d4b0 Leszek Koltunski
        }
76
      });
77
78
    delButton.setOnClickListener( new View.OnClickListener()
79
      {
80
      @Override
81
      public void onClick(View v)
82
        {
83 6647b730 Leszek Koltunski
        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 7cb8d4b0 Leszek Koltunski
        }
89
      });
90 e48ad1af Leszek Koltunski
    }
91
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93
94
  public LinearLayout getPane()
95
    {
96
    return mPane;
97
    }
98 d3d639b1 Leszek Koltunski
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100
101 66cbab36 Leszek Koltunski
  public String getName()
102 d3d639b1 Leszek Koltunski
    {
103 66cbab36 Leszek Koltunski
    return mName;
104 d3d639b1 Leszek Koltunski
    }
105 e48ad1af Leszek Koltunski
}