Project

General

Profile

« Previous | Next » 

Revision 377e1873

Added by Leszek Koltunski about 5 years ago

Rubik App: minor

View differences:

src/main/AndroidManifest.xml
8 8
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9 9
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10 10

  
11
    <application android:icon="@drawable/icon" android:label="@string/app_name" android:allowBackup="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
11
    <application
12
        android:icon="@drawable/icon"
13
        android:label="@string/app_name"
14
        android:allowBackup="true"
15
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
16

  
12 17
        <activity android:name=".TableOfContents">
13 18
            <intent-filter>
14 19
                <action android:name="android.intent.action.MAIN" />
src/main/java/org/distorted/examples/rubik/RubikActivity.java
21 21

  
22 22
import android.app.Activity;
23 23
import android.graphics.PorterDuff;
24
import android.graphics.drawable.Drawable;
24 25
import android.opengl.GLSurfaceView;
25 26
import android.os.Bundle;
26 27
import android.support.v4.content.ContextCompat;
27 28
import android.view.View;
28
import android.widget.ImageButton;
29 29

  
30 30
import org.distorted.examples.R;
31 31
import org.distorted.library.main.Distorted;
......
34 34

  
35 35
public class RubikActivity extends Activity
36 36
{
37
    static final int DEFAULT_CUBE_SIZE = 3;
37
            static final int DEFAULT_SIZE  = 3;
38 38
    private static final int STARTING_SIZE = 2;
39
    private static final int[] button_ids = {R.id.rubikSize2, R.id.rubikSize3, R.id.rubikSize4};
39
    private static final int[] button_ids  = {R.id.rubikSize2, R.id.rubikSize3, R.id.rubikSize4};
40 40

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

  
......
46 46
      super.onCreate(icicle);
47 47
      setContentView(R.layout.rubiklayout);
48 48

  
49
      markButton(DEFAULT_CUBE_SIZE);
49
      markButton(DEFAULT_SIZE);
50 50
      }
51 51

  
52 52
///////////////////////////////////////////////////////////////////////////////////////////////////
......
98 98

  
99 99
    public void setSize(View v)
100 100
      {
101
      int size=0;
102
      int id = v.getId();
103
      int numButtons = button_ids.length;
101
      int size=0, id = v.getId();
104 102

  
105
      for(int b=0; b<numButtons; b++)
103
      for(int b=0; b<button_ids.length; b++)
106 104
        if( button_ids[b] == id )
107 105
          {
108 106
          size = b+STARTING_SIZE;
......
119 117

  
120 118
   private void markButton(int size)
121 119
     {
122
     int color, numButtons = button_ids.length;
123
     ImageButton[] button = new ImageButton[numButtons];
124

  
125
     for(int b=0; b<numButtons; b++)
120
     for(int b=0; b<button_ids.length; b++)
126 121
       {
127
       button[b] = findViewById(button_ids[b]);
128
       color = (b==size-STARTING_SIZE ? R.color.red : R.color.gray);
129
       button[b].getBackground().setColorFilter(ContextCompat.getColor(this,color), PorterDuff.Mode.MULTIPLY);
122
       Drawable d = findViewById(button_ids[b]).getBackground();
123

  
124
       if( size == b+STARTING_SIZE )
125
         {
126
         d.setColorFilter(ContextCompat.getColor(this,R.color.red), PorterDuff.Mode.MULTIPLY);
127
         }
128
       else
129
         {
130
         d.clearColorFilter();
131
         }
130 132
       }
131 133
     }
132 134
}
src/main/java/org/distorted/examples/rubik/RubikRenderer.java
72 72

  
73 73
      mCanRotate = true;
74 74

  
75
      mCube = new RubikCube( RubikActivity.DEFAULT_CUBE_SIZE, mMove, mScale, mQuatCurrent, mQuatAccumulated);
75
      mCube = new RubikCube( RubikActivity.DEFAULT_SIZE, mMove, mScale, mQuatCurrent, mQuatAccumulated);
76 76
      }
77 77

  
78 78
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff