Project

General

Profile

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

magiccube / src / main / java / org / distorted / uistate / RubikStatePattern.java @ a6d3b158

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.uistate;
21

    
22
import android.content.SharedPreferences;
23
import android.support.v4.app.FragmentManager;
24
import android.util.DisplayMetrics;
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.dialog.RubikDialogPattern;
32
import org.distorted.magic.R;
33
import org.distorted.magic.RubikActivity;
34

    
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36

    
37
public class RubikStatePattern extends RubikStateAbstract
38
  {
39
  private TextView mText;
40

    
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

    
43
  RubikStatePattern()
44
    {
45

    
46
    }
47

    
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

    
50
  void leaveState(RubikActivity act)
51
    {
52
    act.setCanRotate(true);
53
    }
54

    
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

    
57
  void enterState(final RubikActivity act)
58
    {
59
    act.setCanRotate(false);
60

    
61
    LayoutInflater inflater = act.getLayoutInflater();
62

    
63
    // TOP ////////////////////////////
64
    LinearLayout layoutTop = act.findViewById(R.id.mainTitle);
65
    layoutTop.removeAllViews();
66
    mText = (TextView)inflater.inflate(R.layout.upper_text, null);
67
    mText.setText(R.string.patterns);
68
    layoutTop.addView(mText);
69

    
70
    // BOT ////////////////////////////
71
    LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
72
    layoutLeft.removeAllViews();
73
    LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
74
    layoutRight.removeAllViews();
75

    
76
    DisplayMetrics metrics = act.getResources().getDisplayMetrics();
77
    float scale = metrics.density;
78
    int padding = (int)(5*scale + 0.5f);
79
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
80

    
81
    Button button = new Button(act);
82
    button.setLayoutParams(params);
83
    button.setId(BUTTON_ID_BACK);
84
    button.setPadding(padding,0,padding,0);
85
    button.setText(R.string.back);
86

    
87
    button.setOnClickListener( new View.OnClickListener()
88
      {
89
      @Override
90
      public void onClick(View v)
91
        {
92
        RubikState.goBack(act);
93

    
94
        FragmentManager mana = act.getSupportFragmentManager();
95
        RubikDialogPattern diag = new RubikDialogPattern();
96
        diag.show( mana, RubikDialogPattern.getDialogTag() );
97
        }
98
      });
99

    
100
    layoutRight.addView(button);
101
    }
102

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  public void savePreferences(SharedPreferences.Editor editor)
106
    {
107

    
108
    }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
  public void restorePreferences(SharedPreferences preferences)
113
    {
114

    
115
    }
116
  }
(4-4/6)