Project

General

Profile

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

magiccube / src / main / java / org / distorted / screens / RubikScreenBase.java @ fad10885

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 left, TransparentImageButton right)
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( left !=null ) layoutRight.addView(left);
56
    if( right!=null ) layoutRight.addView(right);
57

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

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

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

    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72
// PUBLIC API
73

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

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

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

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

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

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

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

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

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