Project

General

Profile

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

magiccube / src / main / java / org / distorted / states / RubikStateDone.java @ 9c2f0c91

1 807d82b7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 e3c74c0f Leszek Koltunski
import android.util.TypedValue;
24 807d82b7 Leszek Koltunski
import android.view.LayoutInflater;
25
import android.view.View;
26 4fb1fc0d Leszek Koltunski
import android.widget.ImageButton;
27 807d82b7 Leszek Koltunski
import android.widget.LinearLayout;
28
import android.widget.TextView;
29
30
import org.distorted.main.R;
31
import org.distorted.main.RubikActivity;
32
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34
35
public class RubikStateDone extends RubikStateAbstract
36
  {
37
  void leaveState(RubikActivity act)
38
    {
39
40
    }
41
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43
44
  void enterState(final RubikActivity act)
45
    {
46 e3c74c0f Leszek Koltunski
    float width = act.getScreenWidthInPixels();
47
    float buttonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
48
    float titleSize = width*RubikActivity.TITLE_TEXT_SIZE;
49
50 807d82b7 Leszek Koltunski
    LayoutInflater inflater = act.getLayoutInflater();
51
52
    // TOP ////////////////////////////
53
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
54
    layoutTop.removeAllViews();
55
    TextView label = (TextView)inflater.inflate(R.layout.upper_text, null);
56 e3c74c0f Leszek Koltunski
    label.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
57 807d82b7 Leszek Koltunski
    label.setText(R.string.solved);
58
    layoutTop.addView(label);
59
60
    // BOT ////////////////////////////
61 92843d3b Leszek Koltunski
    LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
62
    layoutBot.removeAllViews();
63 807d82b7 Leszek Koltunski
64 92843d3b Leszek Koltunski
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
65 4fb1fc0d Leszek Koltunski
    LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,2);
66
67 92843d3b Leszek Koltunski
    LinearLayout layoutLeft = new LinearLayout(act);
68
    layoutLeft.setLayoutParams(paramsL);
69
    LinearLayout layoutRight = new LinearLayout(act);
70 4fb1fc0d Leszek Koltunski
    layoutRight.setLayoutParams(paramsR);
71 807d82b7 Leszek Koltunski
72 ad0c8e0e Leszek Koltunski
    int padding = (int)(width*RubikActivity.PADDING);
73
    int margin  = (int)(width*RubikActivity.MARGIN);
74
75 807d82b7 Leszek Koltunski
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
76 ad0c8e0e Leszek Koltunski
    params.topMargin    = margin;
77
    params.bottomMargin = margin;
78
    params.leftMargin   = margin;
79
    params.rightMargin  = margin;
80 807d82b7 Leszek Koltunski
81 4fb1fc0d Leszek Koltunski
    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);
82
83
    ImageButton back = new ImageButton(act);
84 807d82b7 Leszek Koltunski
    back.setLayoutParams(params);
85
    back.setPadding(padding,0,padding,0);
86 4fb1fc0d Leszek Koltunski
    back.setImageResource(icon);
87 807d82b7 Leszek Koltunski
88
    back.setOnClickListener( new View.OnClickListener()
89
      {
90
      @Override
91
      public void onClick(View v)
92
        {
93
        RubikState.goBack(act);
94
        }
95
      });
96
97
    layoutRight.addView(back);
98 92843d3b Leszek Koltunski
    layoutBot.addView(layoutLeft);
99
    layoutBot.addView(layoutRight);
100 807d82b7 Leszek Koltunski
    }
101
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103
104
  public void savePreferences(SharedPreferences.Editor editor)
105
    {
106
107
    }
108
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110
111
  public void restorePreferences(SharedPreferences preferences)
112
    {
113
114
    }
115
  }