Project

General

Profile

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

magiccube / src / main / java / org / distorted / screens / RubikScreenBase.java @ 4483b119

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.screens;
11

    
12
import android.app.Activity;
13
import android.content.SharedPreferences;
14
import android.widget.LinearLayout;
15

    
16
import org.distorted.helpers.TransparentImageButton;
17
import org.distorted.main.RubikActivity;
18
import org.distorted.objectlib.main.ObjectControl;
19

    
20
import org.distorted.helpers.LockController;
21
import org.distorted.helpers.MovesController;
22
import org.distorted.main.R;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

    
26
abstract class RubikScreenBase extends RubikScreenAbstract
27
  {
28
  private final LockController mLockController;
29
  protected MovesController mMovesController;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
  void createBottomPane(final RubikActivity act, TransparentImageButton butt)
34
    {
35
    mMovesController.clearMoves(act);
36

    
37
    LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
38
    layoutBot.removeAllViews();
39

    
40
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
41

    
42
    LinearLayout layoutLeft = new LinearLayout(act);
43
    layoutLeft.setLayoutParams(params);
44
    LinearLayout layoutMid = new LinearLayout(act);
45
    layoutMid.setLayoutParams(params);
46
    LinearLayout layoutRight = new LinearLayout(act);
47
    layoutRight.setLayoutParams(params);
48

    
49
    ObjectControl control = act.getControl();
50
    mMovesController.setupButton(act,control);
51
    layoutLeft.addView(mMovesController.getButton());
52
    mLockController.setupButton(act,control);
53
    layoutMid.addView(mLockController.getButton());
54

    
55
    if( butt !=null ) layoutRight.addView(butt);
56

    
57
    layoutBot.addView(layoutLeft);
58
    layoutBot.addView(layoutMid);
59
    layoutBot.addView(layoutRight);
60
    }
61

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

    
64
  public void setLockState(final RubikActivity act)
65
    {
66
    boolean locked = act.getControl().retLocked();
67
    mLockController.setState(act,locked);
68
    }
69

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71
// PUBLIC API
72

    
73
  public RubikScreenBase()
74
    {
75
    mLockController = new LockController();
76
    mMovesController= new MovesController();
77
    }
78

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

    
81
  public void addMove(Activity act, int axis, int row, int angle)
82
    {
83
    mMovesController.addMove(act,axis,row,angle);
84
    }
85

    
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87

    
88
  public void reddenLock(final RubikActivity act)
89
    {
90
    ObjectControl control = act.getControl();
91
    mLockController.reddenLock(act,control);
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
  public void saveMovePreferences(String key,SharedPreferences.Editor editor)
97
    {
98
    mMovesController.savePreferences(key,editor);
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  public void restoreMovePreferences(Activity act, String key, SharedPreferences preferences)
104
    {
105
    mMovesController.restorePreferences(act,key,preferences);
106
    }
107
  }
(2-2/10)