Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedCreatorScreen.java @ 50ec342b

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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.View;
23
import android.widget.LinearLayout;
24

    
25
import org.distorted.helpers.TransparentImageButton;
26
import org.distorted.main.R;
27
import org.distorted.main.RubikActivity;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
public class BandagedCreatorScreen
32
{
33
  private TransparentImageButton mBackButton, mResetButton, mDoneButton;
34
  private int mBarHeight;
35
  private float mButtonSize;
36

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

    
39
  public BandagedCreatorScreen()
40
    {
41

    
42
    }
43

    
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

    
46
  private void setupBackButton(final BandagedCreatorActivity act)
47
    {
48
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback);
49
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
50
    mBackButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
51

    
52
    mBackButton.setOnClickListener( new View.OnClickListener()
53
      {
54
      @Override
55
      public void onClick(View v)
56
        {
57
        act.finish();
58
        }
59
      });
60
    }
61

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

    
64
  private void setupDoneButton(final BandagedCreatorActivity act)
65
    {
66
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_done,R.drawable.ui_medium_done, R.drawable.ui_big_done, R.drawable.ui_huge_done);
67
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
68
    mDoneButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
69

    
70
    mDoneButton.setOnClickListener( new View.OnClickListener()
71
      {
72
      @Override
73
      public void onClick(View v)
74
        {
75

    
76
        }
77
      });
78
    }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

    
82
  private void setupResetButton(final BandagedCreatorActivity act)
83
    {
84
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_reset,R.drawable.ui_medium_reset, R.drawable.ui_big_reset, R.drawable.ui_huge_reset);
85
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
86
    mResetButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
87

    
88
    mResetButton.setOnClickListener( new View.OnClickListener()
89
      {
90
      @Override
91
      public void onClick(View v)
92
        {
93
        BandagedCreatorRenderer renderer = act.getRenderer();
94
        renderer.reset();
95
        }
96
      });
97
    }
98

    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100

    
101
  void onAttachedToWindow(final BandagedCreatorActivity act)
102
    {
103
    int width = act.getScreenWidthInPixels();
104
    mBarHeight = act.getHeightBar();
105
    mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
106

    
107
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
108
    LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
109
    LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
110

    
111
    LinearLayout layoutLeft = new LinearLayout(act);
112
    layoutLeft.setLayoutParams(paramsL);
113
    LinearLayout layoutMid  = new LinearLayout(act);
114
    layoutMid.setLayoutParams(paramsM);
115
    LinearLayout layoutRight= new LinearLayout(act);
116
    layoutRight.setLayoutParams(paramsR);
117

    
118
    setupBackButton(act);
119
    layoutRight.addView(mBackButton);
120
    setupDoneButton(act);
121
    layoutMid.addView(mDoneButton);
122
    setupResetButton(act);
123
    layoutLeft.addView(mResetButton);
124

    
125
    LinearLayout layout = act.findViewById(R.id.lowerBar);
126
    layout.removeAllViews();
127
    layout.addView(layoutLeft);
128
    layout.addView(layoutMid);
129
    layout.addView(layoutRight);
130
    }
131
}
(3-3/11)