Revision 3979a11d
Added by Leszek Koltunski 9 months ago
src/main/java/org/distorted/config/ConfigScreenPane.java | ||
---|---|---|
15 | 15 |
import android.view.ViewGroup; |
16 | 16 |
import android.widget.GridLayout; |
17 | 17 |
import android.widget.ImageButton; |
18 |
import android.widget.ImageView; |
|
18 | 19 |
import android.widget.LinearLayout; |
19 | 20 |
import android.widget.SeekBar; |
20 | 21 |
import android.widget.TextView; |
21 | 22 |
|
23 |
import androidx.appcompat.widget.AppCompatImageButton; |
|
24 |
|
|
22 | 25 |
import org.distorted.main.MainActivity; |
23 | 26 |
import org.distorted.main.R; |
24 | 27 |
|
... | ... | |
72 | 75 |
private final SeekBar mSeekBarBorders, mSeekBarCorners; |
73 | 76 |
private int mCurrentBorders, mCurrentCorners; |
74 | 77 |
private GridLayout mGrid; |
78 |
private int mRow, mCol; |
|
75 | 79 |
|
76 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 | 81 |
|
... | ... | |
80 | 84 |
mSeekBarBorders.setProgress(DEFAULT_BORDERS); |
81 | 85 |
mSeekBarCorners.setProgress(DEFAULT_CORNERS); |
82 | 86 |
|
83 |
// reset color grid
|
|
87 |
markButton(0,0);
|
|
84 | 88 |
} |
85 | 89 |
|
86 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
124 | 128 |
|
125 | 129 |
mGrid.addView(v,params); |
126 | 130 |
} |
131 |
|
|
132 |
markButton(mRow,mCol); |
|
127 | 133 |
} |
128 | 134 |
|
129 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
130 | 136 |
|
131 |
private View createView(Activity act, int row, int col)
|
|
137 |
private View createView(final Activity act, final int row, final int col)
|
|
132 | 138 |
{ |
133 |
ImageButton button = new ImageButton(act); |
|
134 |
button.setBackgroundColor( COLORS[row][col] ); |
|
139 |
AppCompatImageButton button = new AppCompatImageButton(act); |
|
140 |
|
|
141 |
int p = 10; |
|
142 |
button.setPadding(p,p,p,p); |
|
143 |
button.setScaleType(ImageView.ScaleType.FIT_CENTER); |
|
144 |
button.setBackgroundColor(COLORS[row][col]); |
|
145 |
|
|
146 |
button.setOnClickListener( new View.OnClickListener() |
|
147 |
{ |
|
148 |
@Override |
|
149 |
public void onClick(View v) |
|
150 |
{ |
|
151 |
markButton(row,col); |
|
152 |
} |
|
153 |
}); |
|
154 |
|
|
135 | 155 |
return button; |
136 | 156 |
} |
137 | 157 |
|
158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
159 |
|
|
160 |
private void markButton(int row, int col) |
|
161 |
{ |
|
162 |
int index = mRow*COLORS[0].length + mCol; |
|
163 |
ImageButton button = (ImageButton)mGrid.getChildAt(index); |
|
164 |
button.setImageResource(0); |
|
165 |
|
|
166 |
mRow = row; |
|
167 |
mCol = col; |
|
168 |
|
|
169 |
index = mRow*COLORS[0].length + mCol; |
|
170 |
button = (ImageButton)mGrid.getChildAt(index); |
|
171 |
button.setImageResource(R.drawable.check); |
|
172 |
} |
|
173 |
|
|
174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
175 |
|
|
176 |
int getCurrentColor() |
|
177 |
{ |
|
178 |
return COLORS[mRow][mCol]; |
|
179 |
} |
|
180 |
|
|
138 | 181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
139 | 182 |
|
140 | 183 |
ConfigScreenPane(final ConfigActivity act, int objectOrdinal) |
141 | 184 |
{ |
185 |
mRow = 0; |
|
186 |
mCol = 0; |
|
142 | 187 |
int width = act.getScreenWidthInPixels(); |
143 | 188 |
int height = act.getScreenHeightInPixels(); |
144 | 189 |
float textSize = height*TEXT_RATIO; |
Also available in: Unified diff
progress with configurable stickers