Project

General

Profile

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

magiccube / src / main / java / org / distorted / states / RubikStateDone.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.DisplayMetrics;
24
import android.util.TypedValue;
25
import android.view.LayoutInflater;
26
import android.view.View;
27
import android.widget.Button;
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 RubikStateDone extends RubikStateAbstract
37
  {
38
  void leaveState(RubikActivity act)
39
    {
40

    
41
    }
42

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

    
45
  void enterState(final RubikActivity act)
46
    {
47
    float width = act.getScreenWidthInPixels();
48
    float buttonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
49
    float titleSize = width*RubikActivity.TITLE_TEXT_SIZE;
50

    
51
    LayoutInflater inflater = act.getLayoutInflater();
52

    
53
    // TOP ////////////////////////////
54
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
55
    layoutTop.removeAllViews();
56
    TextView label = (TextView)inflater.inflate(R.layout.upper_text, null);
57
    label.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
58
    label.setText(R.string.solved);
59
    layoutTop.addView(label);
60

    
61
    // BOT ////////////////////////////
62
    LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
63
    layoutLeft.removeAllViews();
64

    
65
    LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
66
    layoutRight.removeAllViews();
67

    
68
    int padding = (int)(width*RubikActivity.PADDING);
69
    int margin  = (int)(width*RubikActivity.MARGIN);
70

    
71
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
72
    params.topMargin    = margin;
73
    params.bottomMargin = margin;
74
    params.leftMargin   = margin;
75
    params.rightMargin  = margin;
76

    
77
    Button back = new Button(act);
78
    back.setLayoutParams(params);
79
    back.setPadding(padding,0,padding,0);
80
    back.setTextSize(TypedValue.COMPLEX_UNIT_PX, buttonSize);
81
    back.setText(R.string.back);
82

    
83
    back.setOnClickListener( new View.OnClickListener()
84
      {
85
      @Override
86
      public void onClick(View v)
87
        {
88
        RubikState.goBack(act);
89
        }
90
      });
91

    
92
    layoutRight.addView(back);
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

    
97
  public void savePreferences(SharedPreferences.Editor editor)
98
    {
99

    
100
    }
101

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
  public void restorePreferences(SharedPreferences preferences)
105
    {
106

    
107
    }
108
  }
(3-3/9)