Project

General

Profile

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

magiccube / src / main / java / org / distorted / states / RubikStateDone.java @ e3c74c0f

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
    DisplayMetrics metrics = act.getResources().getDisplayMetrics();
53
    float scale = metrics.density;
54

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

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

    
67
    LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
68
    layoutRight.removeAllViews();
69

    
70
    int padding = (int)(5*scale + 0.5f);
71
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
72

    
73
    Button back = new Button(act);
74
    back.setLayoutParams(params);
75
    back.setPadding(padding,0,padding,0);
76
    back.setTextSize(TypedValue.COMPLEX_UNIT_PX, buttonSize);
77
    back.setText(R.string.back);
78

    
79
    back.setOnClickListener( new View.OnClickListener()
80
      {
81
      @Override
82
      public void onClick(View v)
83
        {
84
        RubikState.goBack(act);
85
        }
86
      });
87

    
88
    layoutRight.addView(back);
89
    }
90

    
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92

    
93
  public void savePreferences(SharedPreferences.Editor editor)
94
    {
95

    
96
    }
97

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

    
100
  public void restorePreferences(SharedPreferences preferences)
101
    {
102

    
103
    }
104
  }
(3-3/10)