Revision 8375250f
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/config/ConfigScreenPane.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.io.InputStream; |
13 | 13 |
|
14 |
import android.graphics.PorterDuff; |
|
14 | 15 |
import android.util.TypedValue; |
15 | 16 |
import android.widget.ImageView; |
16 | 17 |
import android.widget.LinearLayout; |
... | ... | |
30 | 31 |
|
31 | 32 |
public class ConfigScreenPane |
32 | 33 |
{ |
33 |
private static final int[] IMAGES =
|
|
34 |
private static final int[] IDS =
|
|
34 | 35 |
{ |
35 | 36 |
R.id.configDifficulty0, |
36 | 37 |
R.id.configDifficulty1, |
... | ... | |
39 | 40 |
R.id.configDifficulty4 |
40 | 41 |
}; |
41 | 42 |
|
42 |
private static final int NUM_IMAGES = IMAGES.length; |
|
43 |
private static final int[] IMAGES = |
|
44 |
{ |
|
45 |
R.drawable.difficulty1, |
|
46 |
R.drawable.difficulty2, |
|
47 |
R.drawable.difficulty3, |
|
48 |
R.drawable.difficulty4, |
|
49 |
R.drawable.difficulty5, |
|
50 |
}; |
|
51 |
|
|
52 |
private static final int NUM_IDS = IDS.length; |
|
43 | 53 |
public static final float PADDING_RATIO = 0.025f; |
44 | 54 |
private static final float TEXT_RATIO = 0.042f; |
45 | 55 |
private static final float RADIO_RATIO = 0.900f; |
... | ... | |
95 | 105 |
view = layout.findViewById(R.id.configDetailsAuthor2); |
96 | 106 |
view.setText(both); |
97 | 107 |
|
98 |
if( difficulty<0 ) difficulty=0;
|
|
99 |
if( difficulty>NUM_IMAGES ) difficulty=NUM_IMAGES;
|
|
108 |
if( difficulty<0 ) difficulty=0; |
|
109 |
if( difficulty>NUM_IDS ) difficulty=NUM_IDS;
|
|
100 | 110 |
|
101 |
for(int i=0; i<NUM_IMAGES; i++)
|
|
111 |
for(int i=0; i<NUM_IDS; i++)
|
|
102 | 112 |
{ |
103 |
ImageView image = layout.findViewById(IMAGES[i]); |
|
104 |
image.setImageResource( i==difficulty ? R.drawable.ui_difficulty_checked : R.drawable.ui_difficulty_unchecked ); |
|
113 |
ImageView image = layout.findViewById(IDS[i]); |
|
114 |
image.setImageResource(IMAGES[i]); |
|
115 |
image.setColorFilter( difficulty==i ? 0xffff0000 : 0xffffffff, PorterDuff.Mode.MULTIPLY ); |
|
105 | 116 |
} |
106 | 117 |
|
107 | 118 |
int meshState = object.getMeshState(); |
src/main/res/layout-ldrtl/config.xml | ||
---|---|---|
125 | 125 |
android:id="@+id/configDifficulty0" |
126 | 126 |
android:layout_width="0dp" |
127 | 127 |
android:layout_height="match_parent" |
128 |
android:layout_weight="1" |
|
129 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
128 |
android:layout_weight="1"/> |
|
130 | 129 |
|
131 | 130 |
<ImageView |
132 | 131 |
android:id="@+id/configDifficulty1" |
133 | 132 |
android:layout_width="0dp" |
134 | 133 |
android:layout_height="match_parent" |
135 |
android:layout_weight="1" |
|
136 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
134 |
android:layout_weight="1"/> |
|
137 | 135 |
|
138 | 136 |
<ImageView |
139 | 137 |
android:id="@+id/configDifficulty2" |
140 | 138 |
android:layout_width="0dp" |
141 | 139 |
android:layout_height="match_parent" |
142 |
android:layout_weight="1" |
|
143 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
140 |
android:layout_weight="1"/> |
|
144 | 141 |
|
145 | 142 |
<ImageView |
146 | 143 |
android:id="@+id/configDifficulty3" |
147 | 144 |
android:layout_width="0dp" |
148 | 145 |
android:layout_height="match_parent" |
149 |
android:layout_weight="1" |
|
150 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
146 |
android:layout_weight="1"/> |
|
151 | 147 |
|
152 | 148 |
<ImageView |
153 | 149 |
android:id="@+id/configDifficulty4" |
154 | 150 |
android:layout_width="0dp" |
155 | 151 |
android:layout_height="match_parent" |
156 |
android:layout_weight="1" |
|
157 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
152 |
android:layout_weight="1"/> |
|
158 | 153 |
|
159 | 154 |
</LinearLayout> |
160 | 155 |
|
src/main/res/layout/config.xml | ||
---|---|---|
125 | 125 |
android:id="@+id/configDifficulty0" |
126 | 126 |
android:layout_width="0dp" |
127 | 127 |
android:layout_height="match_parent" |
128 |
android:layout_weight="1" |
|
129 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
128 |
android:layout_weight="1"/> |
|
130 | 129 |
|
131 | 130 |
<ImageView |
132 | 131 |
android:id="@+id/configDifficulty1" |
133 | 132 |
android:layout_width="0dp" |
134 | 133 |
android:layout_height="match_parent" |
135 |
android:layout_weight="1" |
|
136 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
134 |
android:layout_weight="1"/> |
|
137 | 135 |
|
138 | 136 |
<ImageView |
139 | 137 |
android:id="@+id/configDifficulty2" |
140 | 138 |
android:layout_width="0dp" |
141 | 139 |
android:layout_height="match_parent" |
142 |
android:layout_weight="1" |
|
143 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
140 |
android:layout_weight="1"/> |
|
144 | 141 |
|
145 | 142 |
<ImageView |
146 | 143 |
android:id="@+id/configDifficulty3" |
147 | 144 |
android:layout_width="0dp" |
148 | 145 |
android:layout_height="match_parent" |
149 |
android:layout_weight="1" |
|
150 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
146 |
android:layout_weight="1"/> |
|
151 | 147 |
|
152 | 148 |
<ImageView |
153 | 149 |
android:id="@+id/configDifficulty4" |
154 | 150 |
android:layout_width="0dp" |
155 | 151 |
android:layout_height="match_parent" |
156 |
android:layout_weight="1" |
|
157 |
android:src="@drawable/ui_difficulty_unchecked"/> |
|
152 |
android:layout_weight="1"/> |
|
158 | 153 |
|
159 | 154 |
</LinearLayout> |
160 | 155 |
|
Also available in: Unified diff
difficulty icons.