Project

General

Profile

« Previous | Next » 

Revision 57dea1ac

Added by Leszek Koltunski almost 2 years ago

UI iimprovements inthe Solver screen.

View differences:

src/main/java/org/distorted/main/RubikActivity.java
70 70
    public static final float SMALL_MARGIN        = 0.004f;
71 71
    public static final float BUTTON_TEXT_SIZE    = 0.05f;
72 72
    public static final float TITLE_TEXT_SIZE     = 0.06f;
73
    public static final float SOLVER_BMP_H_SIZE   = 0.11f;
74
    public static final float SOLVER_BMP_V_SIZE   = 0.06f;
75 73
    public static final float PATTERN_GROUP_TEXT  = 0.03f;
76 74
    public static final float PATTERN_CHILD_TEXT  = 0.02f;
77 75
    public static final float SCORES_LEVEL_TEXT   = 0.035f;
......
80 78
    public static final float TAB_HEIGHT          = 0.066f;
81 79
    public static final float POPUP_PADDING       = 0.028f;
82 80
    public static final float POPUP_MARGIN        = 0.016f;
81
    public static final float RATIO_BAR           = 0.10f;
83 82

  
84 83
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
85 84
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
......
88 87
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
89 88

  
90 89
    private static final int ACTIVITY_NUMBER = 0;
91
    private static final float RATIO_BAR  = 0.10f;
92 90
    private static final float RATIO_INSET= 0.09f;
93 91

  
94 92
    private static final String KEY_PLAY = "movesController_play";
src/main/java/org/distorted/screens/RubikScreenSolver.java
50 50
  private boolean mSolving;
51 51
  private int mCurrentColor;
52 52
  private int[] mFaceColors;
53
  private int mNumFaces;
53
  private int mNumColors;
54 54
  private float mBitmapSize;
55 55
  private WeakReference<RubikActivity> mWeakAct;
56 56

  
......
72 72
    float width = act.getScreenWidthInPixels();
73 73
    float heigh = act.getScreenHeightInPixels();
74 74

  
75
    int sizeV = (int)(heigh*RubikActivity.SOLVER_BMP_V_SIZE);
76
    int sizeH = (int)(width*RubikActivity.SOLVER_BMP_H_SIZE);
77

  
78
    mBitmapSize = Math.min(sizeV,sizeH);
79 75
    mWeakAct = new WeakReference<>(act);
80 76
    mSolving = false;
81 77

  
......
88 84

  
89 85
    generateFaceColors(currentObject);
90 86

  
87
    final float BUTTON_RATIO = 0.75f;
88
    int sizeV = (int)(heigh*RubikActivity.RATIO_BAR*BUTTON_RATIO);
89
    int sizeH = (int)((width/mNumColors)*BUTTON_RATIO);
90
    mBitmapSize = Math.min(sizeV,sizeH);
91

  
91 92
    // TOP ////////////////////////////
92 93
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
93 94
    layoutTop.removeAllViews();
94 95

  
95
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
96

  
97
    LinearLayout layoutLeft = new LinearLayout(act);
98
    layoutLeft.setLayoutParams(paramsL);
99
    LinearLayout layoutMid = new LinearLayout(act);
100
    layoutMid.setLayoutParams(paramsL);
101
    LinearLayout layoutRight = new LinearLayout(act);
102
    layoutRight.setLayoutParams(paramsL);
103

  
104
    if( mNumFaces>0 )
96
    if( mNumColors>0 )
105 97
      {
106 98
      setupBitmaps();
107 99
      setupColorButtons(act,width);
......
111 103
    for(ImageButton button: mColorButton) layoutTop.addView(button);
112 104

  
113 105
    // BOT ////////////////////////////
106
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
107

  
108
    LinearLayout layoutL = new LinearLayout(act);
109
    layoutL.setLayoutParams(params);
110
    LinearLayout layoutM = new LinearLayout(act);
111
    layoutM.setLayoutParams(params);
112
    LinearLayout layoutR = new LinearLayout(act);
113
    layoutR.setLayoutParams(params);
114

  
114 115
    LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
115 116
    layoutBot.removeAllViews();
116 117

  
117 118
    setupSolveButton(act);
118 119
    setupBackButton(act);
119 120

  
120
    layoutLeft.addView(mSolveButton);
121
    layoutRight.addView(mBackButton);
121
    layoutL.addView(mSolveButton);
122
    layoutR.addView(mBackButton);
122 123

  
123
    layoutBot.addView(layoutLeft);
124
    layoutBot.addView(layoutMid);
125
    layoutBot.addView(layoutRight);
124
    layoutBot.addView(layoutL);
125
    layoutBot.addView(layoutM);
126
    layoutBot.addView(layoutR);
126 127
    }
127 128

  
128 129
///////////////////////////////////////////////////////////////////////////////////////////////////
......
140 141
        object== ObjectSignatures.MORP_3 ||
141 142
        object== ObjectSignatures.MORP_4  )
142 143
      {
143
      mNumFaces = ShapeTetrahedron.NUM_FACES;
144
      mNumColors  = ShapeTetrahedron.NUM_FACES;
144 145
      mFaceColors = ShapeTetrahedron.FACE_COLORS;
145 146
      }
146 147
    else if( object== ObjectSignatures.DIAM_2 ||
......
150 151
        object== ObjectSignatures.TRAJ_4 ||
151 152
        object== ObjectSignatures.PDIA_3  )
152 153
      {
153
      mNumFaces   = ShapeOctahedron.NUM_FACES;
154
      mNumColors  = ShapeOctahedron.NUM_FACES;
154 155
      mFaceColors = ShapeOctahedron.FACE_COLORS;
155 156
      }
156 157
    else if( object== ObjectSignatures.CRYS_3 ||
......
161 162
        object== ObjectSignatures.MEGA_3 ||
162 163
        object== ObjectSignatures.MEGA_5  )
163 164
      {
164
      mNumFaces   = ShapeDodecahedron.NUM_FACES;
165
      mNumColors  = ShapeDodecahedron.NUM_FACES;
165 166
      mFaceColors = ShapeDodecahedron.FACE_COLORS;
166 167
      }
167 168
    else if( object== ObjectSignatures.BALL_4 )
168 169
      {
169
      mNumFaces   = ShapeDiamond.NUM_FACES;
170
      mNumColors  = ShapeDiamond.NUM_FACES;
170 171
      mFaceColors = ShapeDiamond.FACE_COLORS;
171 172
      }
172 173
    else
173 174
      {
174
      mNumFaces   = ShapeHexahedron.NUM_FACES;
175
      mNumColors  = ShapeHexahedron.NUM_FACES;
175 176
      mFaceColors = ShapeHexahedron.FACE_COLORS;
176 177
      }
177 178
    }
......
184 185
    final float R = SIZE*0.15f;
185 186
    final float M = SIZE*0.08f;
186 187

  
187
    mBitmap = new Bitmap[mNumFaces];
188
    mBitmap = new Bitmap[mNumColors];
188 189

  
189 190
    Paint paint = new Paint();
190 191
    paint.setColor(0xff008800);
......
194 195
    paint.setTextAlign(Paint.Align.CENTER);
195 196
    paint.setStyle(Paint.Style.FILL);
196 197

  
197
    for(int i=0; i<mNumFaces; i++)
198
    for(int i=0; i<mNumColors; i++)
198 199
      {
199 200
      mBitmap[i] = Bitmap.createBitmap(SIZE, SIZE, Bitmap.Config.ARGB_8888);
200 201
      Canvas canvas = new Canvas(mBitmap[i]);
......
211 212

  
212 213
  private void setupColorButtons(final RubikActivity act, final float width)
213 214
    {
214
    mColorButton = new ImageButton[mNumFaces];
215
    mColorButton = new ImageButton[mNumColors];
215 216
    int padding = (int)(width*RubikActivity.PADDING);
216 217
    int margin  = (int)(width*RubikActivity.SMALL_MARGIN);
217 218

  
218
    for(int i=0; i<mNumFaces; i++)
219
    for(int i=0; i<mNumColors; i++)
219 220
      {
220 221
      final int ii = i;
221 222
      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.0f);
......
289 290

  
290 291
  private void markButton(RubikActivity act)
291 292
    {
292
    for(int b=0; b<mNumFaces; b++)
293
    for(int b=0; b<mNumColors; b++)
293 294
      {
294 295
      Drawable d = mColorButton[b].getBackground();
295 296

  

Also available in: Unified diff