Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedCreatorObjectView.java @ ab19c113

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
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23
24
public class BandagedCreatorObjectView
25
{
26 35e32f0c Leszek Koltunski
  private static final float MARGIN    = 0.015f;
27
  private static final float TEXT_SIZE = 0.032f;
28
  private static final float RATIO_ICON= 0.15f;
29 66cbab36 Leszek Koltunski
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 35e32f0c Leszek Koltunski
    int height   = act.getScreenHeightInPixels();
42
    int textSize = (int)(height*TEXT_SIZE);
43 e48ad1af Leszek Koltunski
44 2ceeb6b5 Leszek Koltunski
    LinearLayout.LayoutParams params = createPaneParams(height,leftmost,act.isRTL());
45 e48ad1af Leszek Koltunski
    mPane.setLayoutParams(params);
46
47
    LinearLayout bottom = mPane.findViewById(R.id.bandagedCreatorObjectLayout);
48
49 c41c5ae3 Leszek Koltunski
    TransparentButton plaButton = new TransparentButton(act, R.string.play, textSize);
50 83e021c5 Leszek Koltunski
    plaButton.setSingleLine();
51 e48ad1af Leszek Koltunski
52 83e021c5 Leszek Koltunski
    final int icon = R.drawable.ui_trash;
53 c41c5ae3 Leszek Koltunski
    LinearLayout.LayoutParams paramsB = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,3.0f);
54 464ade4a leszek
    TransparentImageButton delButton = new TransparentImageButton(act,icon,paramsB);
55 83e021c5 Leszek Koltunski
56 e48ad1af Leszek Koltunski
    bottom.addView(plaButton);
57
    bottom.addView(delButton);
58 7cb8d4b0 Leszek Koltunski
59
    plaButton.setOnClickListener( new View.OnClickListener()
60
      {
61
      @Override
62
      public void onClick(View v)
63
        {
64 d3d639b1 Leszek Koltunski
        act.playObject(mName);
65 7cb8d4b0 Leszek Koltunski
        }
66
      });
67
68
    delButton.setOnClickListener( new View.OnClickListener()
69
      {
70
      @Override
71
      public void onClick(View v)
72
        {
73 6647b730 Leszek Koltunski
        Bundle bundle = new Bundle();
74 c02fa107 Leszek Koltunski
        bundle.putString("argument", mName );
75 6647b730 Leszek Koltunski
        RubikDialogBandagedDelete dialog = new RubikDialogBandagedDelete();
76
        dialog.setArguments(bundle);
77
        dialog.show( act.getSupportFragmentManager(), RubikDialogBandagedDelete.getDialogTag() );
78 7cb8d4b0 Leszek Koltunski
        }
79
      });
80 e48ad1af Leszek Koltunski
    }
81
82 35e32f0c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
83
84 2ceeb6b5 Leszek Koltunski
  static LinearLayout.LayoutParams createPaneParams(int height, boolean leftmost, boolean rtl)
85 35e32f0c Leszek Koltunski
    {
86
    int margin = (int)(height*MARGIN);
87 788701a7 Leszek Koltunski
    int length = (int)(height*BandagedCreatorActivity.RATIO_SCROLL*0.65f);
88 35e32f0c Leszek Koltunski
89
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( length, LinearLayout.LayoutParams.MATCH_PARENT);
90
    params.bottomMargin = margin;
91
    params.topMargin    = margin;
92 2ceeb6b5 Leszek Koltunski
93
    if( !rtl )
94
      {
95
      params.leftMargin   = leftmost ? margin : 0;
96
      params.rightMargin  = margin;
97
      }
98
    else
99
      {
100
      params.rightMargin  = leftmost ? margin : 0;
101
      params.leftMargin   = margin;
102
      }
103 35e32f0c Leszek Koltunski
104
    return params;
105
    }
106
107 e48ad1af Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
108
109
  public LinearLayout getPane()
110
    {
111
    return mPane;
112
    }
113 d3d639b1 Leszek Koltunski
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115
116 66cbab36 Leszek Koltunski
  public String getName()
117 d3d639b1 Leszek Koltunski
    {
118 66cbab36 Leszek Koltunski
    return mName;
119 d3d639b1 Leszek Koltunski
    }
120 e48ad1af Leszek Koltunski
}