Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedCreatorScreen.java @ 77efd5ad

1 9530f6b0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2 da56b12f Leszek Koltunski
// Copyright 2022 Leszek Koltunski                                                               //
3 9530f6b0 Leszek Koltunski
//                                                                                               //
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 f802924b Leszek Koltunski
    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 9530f6b0 Leszek Koltunski
    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 1b185a91 Leszek Koltunski
    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 9530f6b0 Leszek Koltunski
    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
94
        }
95
      });
96
    }
97
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99
100 bebd7af5 Leszek Koltunski
  void onAttachedToWindow(final BandagedCreatorActivity act)
101 9530f6b0 Leszek Koltunski
    {
102
    int width = act.getScreenWidthInPixels();
103
    mBarHeight = act.getHeightBar();
104
    mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
105
106
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
107
    LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
108
    LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
109
110
    LinearLayout layoutLeft = new LinearLayout(act);
111
    layoutLeft.setLayoutParams(paramsL);
112
    LinearLayout layoutMid  = new LinearLayout(act);
113
    layoutMid.setLayoutParams(paramsM);
114
    LinearLayout layoutRight= new LinearLayout(act);
115
    layoutRight.setLayoutParams(paramsR);
116
117
    setupBackButton(act);
118
    layoutRight.addView(mBackButton);
119
    setupDoneButton(act);
120
    layoutMid.addView(mDoneButton);
121
    setupResetButton(act);
122
    layoutLeft.addView(mResetButton);
123
124
    LinearLayout layout = act.findViewById(R.id.lowerBar);
125
    layout.removeAllViews();
126
    layout.addView(layoutLeft);
127
    layout.addView(layoutMid);
128
    layout.addView(layoutRight);
129
    }
130
}