Revision b1e9596b
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
20 | 20 |
package org.distorted.main; |
21 | 21 |
|
22 | 22 |
import android.content.SharedPreferences; |
23 |
import android.os.Build; |
|
23 | 24 |
import android.os.Bundle; |
25 |
import android.os.LocaleList; |
|
24 | 26 |
import android.preference.PreferenceManager; |
25 | 27 |
import androidx.appcompat.app.AppCompatActivity; |
26 | 28 |
|
... | ... | |
29 | 31 |
import com.google.firebase.analytics.FirebaseAnalytics; |
30 | 32 |
|
31 | 33 |
import org.distorted.dialogs.RubikDialogError; |
34 |
import org.distorted.dialogs.RubikDialogPrivacy; |
|
32 | 35 |
import org.distorted.effects.BaseEffect; |
33 | 36 |
import org.distorted.library.main.DistortedLibrary; |
34 | 37 |
|
... | ... | |
39 | 42 |
import org.distorted.states.RubikState; |
40 | 43 |
import org.distorted.states.RubikStatePlay; |
41 | 44 |
|
45 |
import java.util.Locale; |
|
46 |
|
|
42 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 48 |
|
44 | 49 |
public class RubikActivity extends AppCompatActivity |
... | ... | |
62 | 67 |
private boolean mJustStarted; |
63 | 68 |
private FirebaseAnalytics mFirebaseAnalytics; |
64 | 69 |
private static int mScreenWidth, mScreenHeight; |
70 |
private boolean mPolicyAccepted, mIsChinese; |
|
65 | 71 |
|
66 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
67 | 73 |
|
... | ... | |
79 | 85 |
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
80 | 86 |
mScreenWidth =displaymetrics.widthPixels; |
81 | 87 |
mScreenHeight=displaymetrics.heightPixels; |
88 |
|
|
89 |
mIsChinese = localeIsChinese(); |
|
82 | 90 |
} |
83 | 91 |
|
84 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
141 | 149 |
play.setObjectAndSize(this,obj,s); |
142 | 150 |
view.getPreRender().changeObject(obj,s); |
143 | 151 |
} |
152 |
|
|
153 |
if( mIsChinese && !mPolicyAccepted ) PrivacyPolicy(); |
|
144 | 154 |
} |
145 | 155 |
|
146 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
159 | 169 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
160 | 170 |
SharedPreferences.Editor editor = preferences.edit(); |
161 | 171 |
|
172 |
editor.putBoolean("policyAccepted", mPolicyAccepted); |
|
173 |
|
|
162 | 174 |
for (int i=0; i<BaseEffect.Type.LENGTH; i++) |
163 | 175 |
{ |
164 | 176 |
BaseEffect.Type.getType(i).savePreferences(editor); |
... | ... | |
182 | 194 |
{ |
183 | 195 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
184 | 196 |
|
197 |
mPolicyAccepted = preferences.getBoolean("policyAccepted", false); |
|
198 |
|
|
185 | 199 |
for (int i=0; i< BaseEffect.Type.LENGTH; i++) |
186 | 200 |
{ |
187 | 201 |
BaseEffect.Type.getType(i).restorePreferences(preferences); |
... | ... | |
198 | 212 |
view.getPreRender().restorePreferences(preferences); |
199 | 213 |
} |
200 | 214 |
|
215 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
216 |
|
|
217 |
private void PrivacyPolicy() |
|
218 |
{ |
|
219 |
RubikDialogPrivacy priDiag = new RubikDialogPrivacy(); |
|
220 |
priDiag.show(getSupportFragmentManager(), null); |
|
221 |
} |
|
222 |
|
|
201 | 223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
202 | 224 |
|
203 | 225 |
void OpenGLError(String message) |
... | ... | |
309 | 331 |
{ |
310 | 332 |
if( mScreenHeight<1000 ) |
311 | 333 |
{ |
312 |
//android.util.Log.e("view", "returning small, mScrH="+mScreenHeight); |
|
313 | 334 |
return 0; |
314 | 335 |
} |
315 | 336 |
if( mScreenHeight<1600 ) |
316 | 337 |
{ |
317 |
//android.util.Log.e("view", "returning medium, mScrH="+mScreenHeight); |
|
318 | 338 |
return 1; |
319 | 339 |
} |
320 | 340 |
if( mScreenHeight<1900 ) |
321 | 341 |
{ |
322 |
//android.util.Log.e("view", "returning bug, mScrH="+mScreenHeight); |
|
323 | 342 |
return 2; |
324 | 343 |
} |
325 | 344 |
|
326 |
//android.util.Log.e("view", "returning huge, mScrH="+mScreenHeight); |
|
327 | 345 |
return 3; |
328 | 346 |
} |
329 | 347 |
|
... | ... | |
342 | 360 |
} |
343 | 361 |
} |
344 | 362 |
|
363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
364 |
|
|
365 |
public void acceptPrivacy() |
|
366 |
{ |
|
367 |
mPolicyAccepted = true; |
|
368 |
} |
|
369 |
|
|
370 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
371 |
|
|
372 |
public void declinePrivacy() |
|
373 |
{ |
|
374 |
finish(); |
|
375 |
} |
|
376 |
|
|
377 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
378 |
|
|
379 |
public static boolean localeIsChinese() |
|
380 |
{ |
|
381 |
String language; |
|
382 |
|
|
383 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) |
|
384 |
{ |
|
385 |
language= LocaleList.getDefault().get(0).getLanguage(); |
|
386 |
} |
|
387 |
else |
|
388 |
{ |
|
389 |
language= Locale.getDefault().getLanguage(); |
|
390 |
} |
|
391 |
|
|
392 |
return language.equals("zh"); |
|
393 |
} |
|
394 |
|
|
345 | 395 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
346 | 396 |
|
347 | 397 |
public boolean isVertical() |
Also available in: Unified diff
Display the 'Privacy Policy' dialog (only if locale is set to ZH - chinese requirement)