Project

General

Profile

« Previous | Next » 

Revision b45b986a

Added by Leszek Koltunski 7 months ago

Major progress with version 2.0.0.

View differences:

src/main/java/org/distorted/config/ConfigScreenPane.java
15 15
import android.util.TypedValue;
16 16
import android.widget.ImageView;
17 17
import android.widget.LinearLayout;
18
import android.widget.RadioButton;
19
import android.widget.RadioGroup;
20 18
import android.widget.TextView;
21 19

  
22 20
import org.distorted.main.R;
......
24 22
import org.distorted.objects.RubikObject;
25 23
import org.distorted.objects.RubikObjectList;
26 24

  
27
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
28
import static org.distorted.objectlib.main.TwistyObject.MESH_FAST;
29

  
30 25
///////////////////////////////////////////////////////////////////////////////////////////////////
31 26

  
32 27
public class ConfigScreenPane
......
52 47
  private static final int NUM_IDS         = IDS.length;
53 48
  private static final float PADDING_RATIO = 0.016f;
54 49
  private static final float TEXT_RATIO    = 0.025f;
55
  private static final float RADIO_RATIO   = 0.900f;
56

  
57
  private int mObjectOrdinal;
58
  private boolean mProgramatic;
59

  
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

  
62
  private void switchMeshState(ConfigActivity act, int meshState)
63
    {
64
    RubikObjectList.setMeshState(mObjectOrdinal,meshState);
65
    RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
66
    act.changeMeshState(object,mObjectOrdinal);
67
    }
68 50

  
69 51
///////////////////////////////////////////////////////////////////////////////////////////////////
70 52

  
......
76 58
      {
77 59
      InputStream stream = object.getObjectStream(act);
78 60

  
79
      mObjectOrdinal = objectOrdinal;
80 61
      JsonReader reader = new JsonReader();
81 62
      String name,author;
82 63
      int year, difficulty;
......
97 78
        difficulty = 0;
98 79
        }
99 80

  
100
      String both = year>0 ? author+" "+year : author;
101

  
102 81
      LinearLayout layout = act.findViewById(R.id.configLayout);
103 82
      TextView view = layout.findViewById(R.id.configDetailsName2);
104 83
      view.setText(name);
105 84
      view = layout.findViewById(R.id.configDetailsAuthor2);
106
      view.setText(both);
85
      view.setText(author);
86
      view = layout.findViewById(R.id.configDetailsYear2);
87
      view.setText( year>0 ? String.valueOf(year) : "?" );
107 88

  
108 89
      if( difficulty<0        ) difficulty=0;
109 90
      if( difficulty>=NUM_IDS ) difficulty=NUM_IDS-1;
......
114 95
        image.setImageResource(IMAGES[i]);
115 96
        image.setColorFilter( difficulty==i ? 0xffff0000 : 0xffffffff, PorterDuff.Mode.MULTIPLY );
116 97
        }
117

  
118
      int meshState = object.getMeshState();
119
      int id = meshState==MESH_NICE ? R.id.meshNice : R.id.meshSimple;
120
      RadioButton button = act.findViewById(id);
121

  
122
      mProgramatic = true;
123
      button.setChecked(true);
124
      mProgramatic = false;
125 98
      }
126 99
    }
127 100

  
......
135 108

  
136 109
    LinearLayout configLayout    = act.findViewById(R.id.configLayout);
137 110
    LinearLayout nameLayout      = configLayout.findViewById(R.id.configLayoutName);
138
    LinearLayout authorLayout    = configLayout.findViewById(R.id.configLayoutAuthor);
139 111
    LinearLayout difficultyLayout= configLayout.findViewById(R.id.configLayoutDifficulty);
140
    LinearLayout meshLayout      = configLayout.findViewById(R.id.configLayoutMesh);
112
    LinearLayout authorLayout    = configLayout.findViewById(R.id.configLayoutAuthor);
113
    LinearLayout yearLayout      = configLayout.findViewById(R.id.configLayoutYear);
141 114

  
142 115
    nameLayout.setPadding(padding,padding,padding,padding/2);
143
    authorLayout.setPadding(padding,padding/2,padding,padding/2);
144 116
    difficultyLayout.setPadding(padding,padding/2,padding,padding/2);
145
    meshLayout.setPadding(padding,padding/2,padding,padding);
117
    authorLayout.setPadding(padding,padding/2,padding,padding/2);
118
    yearLayout.setPadding(padding,padding/2,padding,padding);
146 119

  
147 120
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.00f);
148 121
    params.bottomMargin = 0;
......
151 124
    params.rightMargin  = padding;
152 125

  
153 126
    nameLayout.setLayoutParams(params);
154
    authorLayout.setLayoutParams(params);
155 127
    difficultyLayout.setLayoutParams(params);
156
    meshLayout.setLayoutParams(params);
128
    authorLayout.setLayoutParams(params);
129
    yearLayout.setLayoutParams(params);
157 130

  
158 131
    TextView text;
159 132
    text = nameLayout.findViewById(R.id.configDetailsName1);
......
166 139
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
167 140
    text = difficultyLayout.findViewById(R.id.configDifficultyTitle);
168 141
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
169
    text = meshLayout.findViewById(R.id.configMeshTitle);
142
    text = yearLayout.findViewById(R.id.configDetailsYear1);
143
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
144
    text = yearLayout.findViewById(R.id.configDetailsYear2);
170 145
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
171

  
172
    RadioButton butt1 = meshLayout.findViewById(R.id.meshNice);
173
    butt1.setTextSize(TypedValue.COMPLEX_UNIT_PX, RADIO_RATIO*textSize);
174
    RadioButton butt2 = meshLayout.findViewById(R.id.meshSimple);
175
    butt2.setTextSize(TypedValue.COMPLEX_UNIT_PX, RADIO_RATIO*textSize);
176 146

  
177 147
    LinearLayout layoutDiff = difficultyLayout.findViewById(R.id.configDifficultyLayout);
178 148
    layoutDiff.setPadding(padding,padding,padding,padding);
179 149

  
180
    RadioGroup radioGroup = meshLayout.findViewById(R.id.meshRadioGroup);
181

  
182
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
183
      {
184
      @Override
185
      public void onCheckedChanged(RadioGroup group, int checkedId)
186
        {
187
        if( !mProgramatic )
188
          {
189
          int meshState = checkedId == R.id.meshNice ? MESH_NICE : MESH_FAST;
190
          switchMeshState( act, meshState );
191
          }
192
        }
193
      });
194

  
195 150
    updatePane(act,objectOrdinal);
196 151
    }
197 152
}

Also available in: Unified diff