Project

General

Profile

« Previous | Next » 

Revision ea036986

Added by Leszek Koltunski almost 2 years ago

Block rotating layes of not free objects in the Tutorial Activity.

View differences:

src/main/java/org/distorted/helpers/TransparentImageButton.java
47 47
    context.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true);
48 48
    setBackgroundResource(outValue.resourceId);
49 49
    }
50

  
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

  
53
  public TransparentImageButton(Context context, LinearLayout.LayoutParams params)
54
    {
55
    super(context);
56

  
57
    setLayoutParams(params);
58
    setPadding(0,0,0,0);
59

  
60
    TypedValue outValue = new TypedValue();
61
    context.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true);
62
    setBackgroundResource(outValue.resourceId);
63
    }
50 64
}
src/main/java/org/distorted/tutorials/TutorialActivity.java
43 43
    private static final int ACTIVITY_NUMBER = 1;
44 44
    public static final float BAR_RATIO = 0.17f;
45 45
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
46
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
47 46

  
48 47
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
49 48
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
......
57 56
    private String mURL;
58 57
    private int mObjectOrdinal;
59 58
    private TutorialWebView mWebView;
59
    private boolean mIsFree;
60 60

  
61 61
///////////////////////////////////////////////////////////////////////////////////////////////////
62 62

  
......
68 68
      setTheme(R.style.MaterialThemeNoActionBar);
69 69
      setContentView(R.layout.tutorial);
70 70

  
71
      mIsFree = true;
72

  
71 73
      Bundle b = getIntent().getExtras();
72 74

  
73 75
      if(b != null)
74 76
        {
75 77
        mURL           = b.getString("url");
76 78
        mObjectOrdinal = b.getInt("obj");
79
        RubikObject obj= RubikObjectList.getObject(mObjectOrdinal);
80
        mIsFree = (obj!=null && obj.isFree());
77 81
        }
78 82

  
79 83
      DisplayMetrics displaymetrics = new DisplayMetrics();
......
181 185
      paramsR.width = (int)(width*BAR_RATIO);
182 186
      viewR.setLayoutParams(paramsR);
183 187

  
184
      if( mScreen==null ) mScreen = new TutorialScreen();
188
      if( mScreen==null ) mScreen = new TutorialScreen(mIsFree);
185 189

  
186 190
      mScreen.createRightPane(this);
187 191

  
......
247 251
      return mScreenHeight;
248 252
      }
249 253

  
254
///////////////////////////////////////////////////////////////////////////////////////////////////
255

  
256
    public boolean getIsFree()
257
      {
258
      return mIsFree;
259
      }
260

  
250 261
///////////////////////////////////////////////////////////////////////////////////////////////////
251 262

  
252 263
    public ObjectControl getControl()
src/main/java/org/distorted/tutorials/TutorialScreen.java
26 26
public class TutorialScreen
27 27
{
28 28
  private TransparentImageButton mSolveButton, mScrambleButton, mBackButton;
29
  private TransparentImageButton mLockButton, mEmptyButton1, mEmptyButton2, mEmptyButton3;
29 30
  private final LockController mLockController;
30 31
  private final MovesController mMovesController;
32
  private final boolean mFree;
33

  
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

  
36
  private void setupLockButton(final TutorialActivity act)
37
    {
38
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_locked_red,R.drawable.ui_medium_locked_red, R.drawable.ui_big_locked_red, R.drawable.ui_huge_locked_red);
39
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
40
    mLockButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
41
    mLockButton.setClickable(false);
42
    }
43

  
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

  
46
  private void setupEmptyButton1(final TutorialActivity act)
47
    {
48
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
49
    mEmptyButton1 = new TransparentImageButton(act, params);
50
    mEmptyButton1.setClickable(false);
51
    }
52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

  
55
  private void setupEmptyButton2(final TutorialActivity act)
56
    {
57
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
58
    mEmptyButton2 = new TransparentImageButton(act, params);
59
    mEmptyButton2.setClickable(false);
60
    }
61

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

  
64
  private void setupEmptyButton3(final TutorialActivity act)
65
    {
66
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
67
    mEmptyButton3 = new TransparentImageButton(act, params);
68
    mEmptyButton3.setClickable(false);
69
    }
31 70

  
32 71
///////////////////////////////////////////////////////////////////////////////////////////////////
33 72

  
......
94 133
    LinearLayout layout = act.findViewById(R.id.tutorialRightBar);
95 134
    layout.removeAllViews();
96 135

  
97
    ObjectControl control = act.getControl();
98
    mMovesController.setupButton(act,control);
99
    mLockController.setupButton(act,control);
100
    setupSolveButton(act);
101
    setupScrambleButton(act);
102
    setupBackButton(act);
136
    if( mFree )
137
      {
138
      ObjectControl control = act.getControl();
139
      mMovesController.setupButton(act,control);
140
      mLockController.setupButton(act,control);
141
      setupSolveButton(act);
142
      setupScrambleButton(act);
143
      layout.addView(mSolveButton);
144
      layout.addView(mScrambleButton);
145
      layout.addView(mMovesController.getButton());
146
      layout.addView(mLockController.getButton());
147
      }
148
    else
149
      {
150
      setupLockButton(act);
151
      setupEmptyButton1(act);
152
      setupEmptyButton2(act);
153
      setupEmptyButton3(act);
154
      layout.addView(mLockButton);
155
      layout.addView(mEmptyButton1);
156
      layout.addView(mEmptyButton2);
157
      layout.addView(mEmptyButton3);
158
      }
103 159

  
104
    layout.addView(mSolveButton);
105
    layout.addView(mScrambleButton);
106
    layout.addView(mMovesController.getButton());
107
    layout.addView(mLockController.getButton());
160
    setupBackButton(act);
108 161
    layout.addView(mBackButton);
109 162
    }
110 163

  
......
118 171
///////////////////////////////////////////////////////////////////////////////////////////////////
119 172
// PUBLIC API
120 173

  
121
  public TutorialScreen()
174
  public TutorialScreen(boolean free)
122 175
    {
176
    mFree = free;
123 177
    mLockController = new LockController();
124 178
    mMovesController = new MovesController();
125 179
    }
src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
7 7

  
8 8
package org.distorted.tutorials;
9 9

  
10
import android.annotation.SuppressLint;
10 11
import android.app.ActivityManager;
11 12
import android.content.Context;
12 13
import android.content.pm.ConfigurationInfo;
......
21 22
import org.distorted.objectlib.main.TwistyObjectNode;
22 23

  
23 24
import static org.distorted.objectlib.main.ObjectControl.MODE_ROTATE;
25
import static org.distorted.objectlib.main.ObjectControl.MODE_DRAG;
24 26

  
25 27
///////////////////////////////////////////////////////////////////////////////////////////////////
26 28

  
......
30 32
    private TutorialRenderer mRenderer;
31 33
    private int mScreenWidth, mScreenHeight;
32 34
    private boolean mCreated;
35
    private int mTouchMode;
33 36

  
34 37
///////////////////////////////////////////////////////////////////////////////////////////////////
35 38

  
......
47 50
        mObjectController.createNode(width,height);
48 51
        TwistyObjectNode objectNode = mObjectController.getNode();
49 52
        mRenderer.getScreen().attach(objectNode);
53

  
54
        TutorialActivity act = (TutorialActivity) getContext();
55
        mTouchMode = act.getIsFree() ? MODE_ROTATE : MODE_DRAG;
50 56
        }
51 57
      }
52 58

  
......
73 79
      super(context,attrs);
74 80

  
75 81
      mCreated = false;
82
      mTouchMode = MODE_ROTATE;
76 83

  
77 84
      if(!isInEditMode())
78 85
        {
......
129 136

  
130 137
///////////////////////////////////////////////////////////////////////////////////////////////////
131 138

  
139
    @SuppressLint("ClickableViewAccessibility")
132 140
    @Override
133 141
    public boolean onTouchEvent(MotionEvent event)
134 142
      {
135
      return mObjectController.onTouchEvent(event,MODE_ROTATE);
143
      return mObjectController.onTouchEvent(event,mTouchMode);
136 144
      }
137 145
}
138 146

  

Also available in: Unified diff