Project

General

Profile

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

magiccube / src / main / java / org / distorted / states / RubikStateReady.java @ 6d4d56cb

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 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.states;
21

    
22
import android.content.SharedPreferences;
23
import android.util.TypedValue;
24
import android.view.LayoutInflater;
25
import android.view.View;
26
import android.widget.Button;
27
import android.widget.ImageButton;
28
import android.widget.LinearLayout;
29
import android.widget.TextView;
30

    
31
import org.distorted.main.R;
32
import org.distorted.main.RubikActivity;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
public class RubikStateReady extends RubikStateAbstract
37
  {
38
  private ImageButton mPrevButton;
39

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

    
42
  void leaveState(RubikActivity act)
43
    {
44

    
45
    }
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
  void enterState(final RubikActivity act)
50
    {
51
    float width = act.getScreenWidthInPixels();
52
    float buttonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
53
    float titleSize  = width*RubikActivity.TITLE_TEXT_SIZE;
54

    
55
    LayoutInflater inflater = act.getLayoutInflater();
56

    
57
    // TOP ////////////////////////////
58
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
59
    layoutTop.removeAllViews();
60
    TextView label = (TextView)inflater.inflate(R.layout.upper_text, null);
61
    label.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
62
    label.setText(R.string.ready);
63
    layoutTop.addView(label);
64

    
65
    // BOT ////////////////////////////
66
    LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
67
    layoutLeft.removeAllViews();
68

    
69
    setupPrevMoveButtom(act,width);
70
    layoutLeft.addView(mPrevButton);
71

    
72
    LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
73
    layoutRight.removeAllViews();
74

    
75
    int padding = (int)(width*RubikActivity.PADDING);
76
    int margin  = (int)(width*RubikActivity.MARGIN);
77
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
78
    params.topMargin    = margin;
79
    params.bottomMargin = margin;
80
    params.leftMargin   = margin;
81
    params.rightMargin  = margin;
82

    
83
    Button back = new Button(act);
84
    back.setLayoutParams(params);
85
    back.setPadding(padding,0,padding,0);
86
    back.setTextSize(TypedValue.COMPLEX_UNIT_PX, buttonSize);
87
    back.setText(R.string.back);
88

    
89
    back.setOnClickListener( new View.OnClickListener()
90
      {
91
      @Override
92
      public void onClick(View v)
93
        {
94
        RubikState.goBack(act);
95
        }
96
      });
97

    
98
    layoutRight.addView(back);
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  private void setupPrevMoveButtom(final RubikActivity act, float width)
104
    {
105
    int padding = (int)(width*RubikActivity.PADDING);
106
    int widthBut= (int)(width/6);
107
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back, R.drawable.ui_huge_cube_back);
108

    
109
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut,LinearLayout.LayoutParams.MATCH_PARENT);
110
    mPrevButton = new ImageButton(act);
111
    mPrevButton.setLayoutParams(params);
112
    mPrevButton.setPadding(padding,0,padding,0);
113
    mPrevButton.setImageResource(icon);
114

    
115
    mPrevButton.setOnClickListener( new View.OnClickListener()
116
      {
117
      @Override
118
      public void onClick(View v)
119
        {
120
        // empty
121
        }
122
      });
123
    }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

    
127
  public void savePreferences(SharedPreferences.Editor editor)
128
    {
129

    
130
    }
131

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

    
134
  public void restorePreferences(SharedPreferences preferences)
135
    {
136

    
137
    }
138
  }
(6-6/9)