Revision a41e3c94
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.bandaged; |
21 | 21 |
|
22 |
import android.content.SharedPreferences; |
|
22 | 23 |
import android.graphics.Bitmap; |
23 | 24 |
import android.os.Build; |
24 | 25 |
import android.os.Bundle; |
26 |
import android.preference.PreferenceManager; |
|
25 | 27 |
import android.util.DisplayMetrics; |
26 | 28 |
import android.view.View; |
27 | 29 |
import android.view.ViewGroup; |
... | ... | |
186 | 188 |
DistortedLibrary.onResume(ACTIVITY_NUMBER); |
187 | 189 |
BandagedCreatorView view = findViewById(R.id.bandagedCreatorObjectView); |
188 | 190 |
view.onResume(); |
189 |
restorePreferences(); |
|
190 | 191 |
|
191 | 192 |
if( mScreen==null ) mScreen = new BandagedCreatorScreen(); |
192 | 193 |
mScreen.onAttachedToWindow(this); |
193 | 194 |
|
195 |
restorePreferences(); |
|
194 | 196 |
BandagedCreatorWorkerThread.create(this); |
195 | 197 |
} |
196 | 198 |
|
... | ... | |
215 | 217 |
|
216 | 218 |
private void savePreferences() |
217 | 219 |
{ |
218 |
/* |
|
219 | 220 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
220 | 221 |
SharedPreferences.Editor editor = preferences.edit(); |
221 |
|
|
222 |
editor.putBoolean("policyAccepted", mPolicyAccepted); |
|
223 |
editor.putString("appVersion", getAppVers() ); |
|
224 |
|
|
222 |
String objects = mScreen.generateObjectStrings(); |
|
223 |
editor.putString("bandagedObjects", objects ); |
|
225 | 224 |
editor.apply(); |
226 |
*/ |
|
227 | 225 |
} |
228 | 226 |
|
229 | 227 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
230 | 228 |
|
231 | 229 |
private void restorePreferences() |
232 | 230 |
{ |
233 |
/* |
|
234 | 231 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
235 |
|
|
236 |
mPolicyAccepted = preferences.getBoolean("policyAccepted", false); |
|
237 |
String oldVersion = preferences.getString("appVersion",""); |
|
238 |
*/ |
|
232 |
String objects = preferences.getString("bandagedObjects",""); |
|
233 |
mScreen.addObjects(this,objects); |
|
239 | 234 |
} |
240 | 235 |
|
241 | 236 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
259 | 254 |
|
260 | 255 |
public void addObject(String name) |
261 | 256 |
{ |
262 |
mScreen.addObject(this,name); |
|
257 |
if( mScreen.objectDoesntExist(name) ) |
|
258 |
{ |
|
259 |
mScreen.addObject(this,name); |
|
260 |
} |
|
263 | 261 |
} |
264 | 262 |
|
265 | 263 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java | ||
---|---|---|
178 | 178 |
if( !mCubits[c].isAttached() ) |
179 | 179 |
{ |
180 | 180 |
mCubits[c].attach(); |
181 |
mCubits[c].setTexture( COLOR_DEFAULT); |
|
181 | 182 |
mScreen.attach(mCubits[c].getNode()); |
182 | 183 |
} |
183 | 184 |
if( mCubits[c].getPosition().length>3 ) |
src/main/java/org/distorted/bandaged/BandagedCreatorScreen.java | ||
---|---|---|
27 | 27 |
import android.widget.ImageView; |
28 | 28 |
import android.widget.LinearLayout; |
29 | 29 |
|
30 |
import org.distorted.external.RubikFiles; |
|
30 | 31 |
import org.distorted.helpers.TransparentImageButton; |
31 | 32 |
import org.distorted.main.R; |
32 | 33 |
import org.distorted.main.RubikActivity; |
... | ... | |
137 | 138 |
layout.addView(layoutRight); |
138 | 139 |
} |
139 | 140 |
|
141 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
142 |
|
|
143 |
boolean objectDoesntExist(String name) |
|
144 |
{ |
|
145 |
for( BandagedCreatorObjectView view : mViews ) |
|
146 |
{ |
|
147 |
String viewName = view.getName(); |
|
148 |
if( viewName.equals(name) ) return false; |
|
149 |
} |
|
150 |
|
|
151 |
return true; |
|
152 |
} |
|
153 |
|
|
154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
155 |
|
|
156 |
void addObjects(BandagedCreatorActivity act, String objectString) |
|
157 |
{ |
|
158 |
if( objectString.length()>0 ) |
|
159 |
{ |
|
160 |
String[] objects = objectString.split(" "); |
|
161 |
RubikFiles files = RubikFiles.getInstance(); |
|
162 |
|
|
163 |
for(String object : objects) |
|
164 |
{ |
|
165 |
if( objectDoesntExist(object) ) |
|
166 |
{ |
|
167 |
addObject(act, object); |
|
168 |
Bitmap bmp = files.getIcon(act, object + ".png"); |
|
169 |
iconCreationDone(act, bmp); |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
140 | 175 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
141 | 176 |
|
142 | 177 |
void addObject(BandagedCreatorActivity act, String name) |
... | ... | |
213 | 248 |
} |
214 | 249 |
} |
215 | 250 |
} |
251 |
|
|
252 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
253 |
|
|
254 |
String generateObjectStrings() |
|
255 |
{ |
|
256 |
String result = ""; |
|
257 |
int numViews = mViews.size(); |
|
258 |
|
|
259 |
for( int v=0; v<numViews; v++ ) |
|
260 |
{ |
|
261 |
BandagedCreatorObjectView view = mViews.get(v); |
|
262 |
String name = view.getName(); |
|
263 |
|
|
264 |
if( v>0 ) result += " "; |
|
265 |
result += name; |
|
266 |
} |
|
267 |
|
|
268 |
return result; |
|
269 |
} |
|
216 | 270 |
} |
Also available in: Unified diff
Remember the list of locally created Bandaged 3x3s.