Project

General

Profile

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

magiccube / src / main / java / org / distorted / states / RubikStateReady.java @ 4fb1fc0d

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 layoutBot = act.findViewById(R.id.lowerBar);
67
    layoutBot.removeAllViews();
68

    
69
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
70

    
71
    LinearLayout layoutLeft = new LinearLayout(act);
72
    layoutLeft.setLayoutParams(paramsL);
73
    LinearLayout layoutMid = new LinearLayout(act);
74
    layoutMid.setLayoutParams(paramsL);
75
    LinearLayout layoutRight = new LinearLayout(act);
76
    layoutRight.setLayoutParams(paramsL);
77

    
78
    setupPrevMoveButtom(act,width);
79
    layoutLeft.addView(mPrevButton);
80

    
81
    int padding = (int)(width*RubikActivity.PADDING);
82
    int margin  = (int)(width*RubikActivity.MARGIN);
83
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
84
    params.topMargin    = margin;
85
    params.bottomMargin = margin;
86
    params.leftMargin   = margin;
87
    params.rightMargin  = margin;
88

    
89
    final int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back);
90

    
91
    ImageButton back = new ImageButton(act);
92
    back.setLayoutParams(params);
93
    back.setPadding(padding,0,padding,0);
94
    back.setImageResource(icon);
95

    
96
    back.setOnClickListener( new View.OnClickListener()
97
      {
98
      @Override
99
      public void onClick(View v)
100
        {
101
        RubikState.goBack(act);
102
        }
103
      });
104

    
105
    layoutRight.addView(back);
106

    
107
    layoutBot.addView(layoutLeft);
108
    layoutBot.addView(layoutMid);
109
    layoutBot.addView(layoutRight);
110
    }
111

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

    
114
  private void setupPrevMoveButtom(final RubikActivity act, float width)
115
    {
116
    int padding = (int)(width*RubikActivity.PADDING);
117
    int margin  = (int)(width*RubikActivity.MARGIN);
118
    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);
119

    
120
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
121
    params.topMargin    = margin;
122
    params.bottomMargin = margin;
123
    params.leftMargin   = margin;
124
    params.rightMargin  = margin;
125

    
126
    mPrevButton = new ImageButton(act);
127
    mPrevButton.setLayoutParams(params);
128
    mPrevButton.setPadding(padding,0,padding,0);
129
    mPrevButton.setImageResource(icon);
130

    
131
    mPrevButton.setOnClickListener( new View.OnClickListener()
132
      {
133
      @Override
134
      public void onClick(View v)
135
        {
136
        // empty
137
        }
138
      });
139
    }
140

    
141
///////////////////////////////////////////////////////////////////////////////////////////////////
142

    
143
  public void savePreferences(SharedPreferences.Editor editor)
144
    {
145

    
146
    }
147

    
148
///////////////////////////////////////////////////////////////////////////////////////////////////
149

    
150
  public void restorePreferences(SharedPreferences preferences)
151
    {
152

    
153
    }
154
  }
(6-6/9)