Project

General

Profile

Download (17.8 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / main / MainActivity.java @ c820515c

1 0c52af30 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2 1c04d054 leszek
// Copyright 2023 Leszek Koltunski                                                               //
3 0c52af30 Leszek Koltunski
//                                                                                               //
4 fdec60a3 Leszek Koltunski
// This file is part of Magic Cube.                                                              //
5 0c52af30 Leszek Koltunski
//                                                                                               //
6 296219b4 Leszek Koltunski
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8 0c52af30 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10 1f9772f3 Leszek Koltunski
package org.distorted.main;
11 0c52af30 Leszek Koltunski
12 b6468abb Leszek Koltunski
import android.content.Intent;
13 33499c56 Leszek Koltunski
import android.content.SharedPreferences;
14 4c9947bd Leszek Koltunski
import android.content.pm.PackageInfo;
15
import android.content.pm.PackageManager;
16 b42c8399 leszek
import android.content.res.Configuration;
17 b1e9596b Leszek Koltunski
import android.os.Build;
18 0c52af30 Leszek Koltunski
import android.os.Bundle;
19 e3c74c0f Leszek Koltunski
import android.util.DisplayMetrics;
20 1c04d054 leszek
import android.util.TypedValue;
21 fd0b901a Leszek Koltunski
import android.view.DisplayCutout;
22 0254cfd7 Leszek Koltunski
import android.view.View;
23 1cb36646 Leszek Koltunski
import android.view.ViewGroup;
24 c9556e1e Leszek Koltunski
import android.view.WindowManager;
25 1cb36646 Leszek Koltunski
import android.widget.LinearLayout;
26 1c04d054 leszek
import android.widget.ScrollView;
27
import android.widget.TextView;
28 0c52af30 Leszek Koltunski
29 b42c8399 leszek
import androidx.annotation.NonNull;
30 e019c70b Leszek Koltunski
import androidx.appcompat.app.AppCompatActivity;
31 ada8ab26 leszek
import androidx.preference.PreferenceManager;
32 e019c70b Leszek Koltunski
33 1b3cbd5b Leszek Koltunski
import com.google.firebase.analytics.FirebaseAnalytics;
34 a59f38d6 Leszek Koltunski
import com.google.firebase.inappmessaging.FirebaseInAppMessaging;
35 1b3cbd5b Leszek Koltunski
36 7ee8337b leszek
import org.distorted.bandaged.BandagedActivity;
37 1c04d054 leszek
import org.distorted.config.ConfigActivity;
38 e71baee1 Leszek Koltunski
import org.distorted.dialogs.RubikDialogAbout;
39 1c04d054 leszek
import org.distorted.dialogs.RubikDialogCreators;
40
import org.distorted.dialogs.RubikDialogExit;
41
import org.distorted.dialogs.RubikDialogScores;
42
import org.distorted.dialogs.RubikDialogUpdates;
43 acabdd83 Leszek Koltunski
import org.distorted.external.RubikNetwork;
44 1c04d054 leszek
import org.distorted.external.RubikScores;
45
import org.distorted.external.RubikUpdates;
46
import org.distorted.messaging.RubikInAppMessanging;
47 7ee8337b leszek
import org.distorted.objects.RubikObject;
48 d433b50e Leszek Koltunski
import org.distorted.objects.RubikObjectList;
49 e9245b7b leszek
import org.distorted.patternui.PatternActivity;
50 7ee8337b leszek
import org.distorted.playui.PlayActivity;
51 cb30e768 leszek
import org.distorted.solverui.SolverActivity;
52 eaf87d1d Leszek Koltunski
import org.distorted.tutorials.TutorialActivity;
53 211b48f2 Leszek Koltunski
54 0c52af30 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
55
56 c02235d5 leszek
public class MainActivity extends AppCompatActivity implements RubikNetwork.Updatee, RubikDialogScores.ScoresInvoker
57 0c52af30 Leszek Koltunski
{
58 1c04d054 leszek
    public static final float RATIO_BAR = 0.080f;
59 af7b68e6 Leszek Koltunski
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
60 ffd68f35 Leszek Koltunski
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
61
                                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
62
                                   | View.SYSTEM_UI_FLAG_FULLSCREEN
63
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
64
65 c3ffcf58 Leszek Koltunski
    private boolean mJustStarted;
66 1b3cbd5b Leszek Koltunski
    private FirebaseAnalytics mFirebaseAnalytics;
67 0254cfd7 Leszek Koltunski
    private int mCurrentApiVersion;
68 d05e7629 Leszek Koltunski
    private String mOldVersion, mCurrVersion;
69 c820515c leszek
    private int mScreenWidth, mScreenHeight;
70 1c04d054 leszek
    private TextView mBubbleUpdates;
71
    private int mNumUpdates;
72 c02235d5 leszek
    private int mCurrentObject;
73 1c04d054 leszek
    private MainScrollGrid mGrid;
74 c3ffcf58 Leszek Koltunski
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76
77 0c52af30 Leszek Koltunski
    @Override
78 34747dd1 Leszek Koltunski
    protected void onCreate(Bundle savedState)
79 0c52af30 Leszek Koltunski
      {
80 34747dd1 Leszek Koltunski
      super.onCreate(savedState);
81 dd874ae8 Leszek Koltunski
      setTheme(R.style.MaterialThemeNoActionBar);
82 cb30e768 leszek
      setContentView(R.layout.main);
83 a7327225 leszek
      hideNavigationBar();
84 c3ffcf58 Leszek Koltunski
85 c02235d5 leszek
      mCurrentObject = 0;
86 c3ffcf58 Leszek Koltunski
      mJustStarted = true;
87 1b3cbd5b Leszek Koltunski
      mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
88 e3c74c0f Leszek Koltunski
89 e8f6670f Leszek Koltunski
      cutoutHack();
90 1c04d054 leszek
      computeHeights();
91 a59f38d6 Leszek Koltunski
92 e9e744f7 Leszek Koltunski
      mCurrVersion = getAppVers();
93
94 c02235d5 leszek
      mBubbleUpdates = findViewById(R.id.bubbleUpdates);
95
      mBubbleUpdates.setVisibility(View.INVISIBLE);
96
      mNumUpdates = 0;
97
98 83018ac4 Leszek Koltunski
      Thread thread = new Thread()
99
        {
100
        public void run()
101
          {
102
          RubikInAppMessanging listener = new RubikInAppMessanging();
103
          FirebaseInAppMessaging.getInstance().addClickListener(listener);
104
          }
105
        };
106
107
      thread.start();
108 0254cfd7 Leszek Koltunski
      }
109
110 598de3ee Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
111
// this does not include possible insets
112
113 1c04d054 leszek
    private void computeHeights()
114 598de3ee Leszek Koltunski
      {
115 b42c8399 leszek
      LinearLayout.LayoutParams pU = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, RATIO_BAR);
116 214e301a Leszek Koltunski
      LinearLayout layoutTop = findViewById(R.id.upperBar);
117 b42c8399 leszek
      layoutTop.setLayoutParams(pU);
118 1c04d054 leszek
119 b42c8399 leszek
      LinearLayout.LayoutParams pS = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1-2*RATIO_BAR);
120 1c04d054 leszek
      ScrollView scroll = findViewById(R.id.objectScroll);
121 b42c8399 leszek
      scroll.setLayoutParams(pS);
122
123
      LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, RATIO_BAR);
124
      LinearLayout layoutBot = findViewById(R.id.lowerBar);
125
      layoutBot.setLayoutParams(pL);
126 598de3ee Leszek Koltunski
      }
127
128 0254cfd7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
129
130
    private void hideNavigationBar()
131
      {
132 c9556e1e Leszek Koltunski
      mCurrentApiVersion = Build.VERSION.SDK_INT;
133 0254cfd7 Leszek Koltunski
134
      if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT)
135
        {
136
        final View decorView = getWindow().getDecorView();
137
138 c9556e1e Leszek Koltunski
        decorView.setSystemUiVisibility(FLAGS);
139
140 0254cfd7 Leszek Koltunski
        decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener()
141
          {
142
          @Override
143
          public void onSystemUiVisibilityChange(int visibility)
144
            {
145
            if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
146
              {
147 ffd68f35 Leszek Koltunski
              decorView.setSystemUiVisibility(FLAGS);
148 0254cfd7 Leszek Koltunski
              }
149
            }
150
          });
151
        }
152
      }
153
154 1cb36646 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
155
156
    @Override
157
    public void onAttachedToWindow()
158
      {
159 fd0b901a Leszek Koltunski
      super.onAttachedToWindow();
160
161 b42c8399 leszek
      getWindowWidth(getResources().getConfiguration());
162
      mGrid = new MainScrollGrid();
163
      mGrid.createGrid(this,mScreenWidth);
164
165 ada8ab26 leszek
      if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.P )
166 e8f6670f Leszek Koltunski
        {
167
        DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
168
        int insetHeight = cutout!=null ? cutout.getSafeInsetTop() : 0;
169
170 b42c8399 leszek
        if( insetHeight>0 )
171
          {
172
          LinearLayout.LayoutParams pH = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, RATIO_BAR);
173
          LinearLayout layoutHid = findViewById(R.id.hiddenBar);
174
          layoutHid.setLayoutParams(pH);
175
176
          LinearLayout.LayoutParams pS = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1-3*RATIO_BAR);
177
          ScrollView scroll = findViewById(R.id.objectScroll);
178
          scroll.setLayoutParams(pS);
179
          }
180 e8f6670f Leszek Koltunski
        }
181 1cb36646 Leszek Koltunski
      }
182
183 0254cfd7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
184 e8f6670f Leszek Koltunski
// do not avoid cutouts
185 c9556e1e Leszek Koltunski
186 e8f6670f Leszek Koltunski
    private void cutoutHack()
187 c9556e1e Leszek Koltunski
      {
188 ada8ab26 leszek
      if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.P )
189 c9556e1e Leszek Koltunski
        {
190
        getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
191
        }
192
      }
193
194 b42c8399 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
195
196
    private void getWindowWidth(Configuration conf)
197
      {
198
      int dpi = getResources().getDisplayMetrics().densityDpi;
199
      float conv = ((float) dpi/DisplayMetrics.DENSITY_DEFAULT);
200
201
      mScreenWidth = (int) (conf.screenWidthDp*conv + 0.5f);
202 c820515c leszek
      mScreenHeight= (int) (conf.screenHeightDp*conv + 0.5f);
203 b42c8399 leszek
      }
204
205 c9556e1e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
206 0254cfd7 Leszek Koltunski
207
    @Override
208
    public void onWindowFocusChanged(boolean hasFocus)
209
      {
210
      super.onWindowFocusChanged(hasFocus);
211
212 ada8ab26 leszek
      if( mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus )
213 0254cfd7 Leszek Koltunski
        {
214 ffd68f35 Leszek Koltunski
        getWindow().getDecorView().setSystemUiVisibility(FLAGS);
215 0254cfd7 Leszek Koltunski
        }
216
      }
217
218 b42c8399 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
219
220
    @Override
221
    public void onConfigurationChanged(@NonNull Configuration conf)
222
      {
223
      super.onConfigurationChanged(conf);
224
225
      getWindowWidth(conf);
226 9a092737 leszek
      if( mGrid!=null ) mGrid.updateGrid(this,mScreenWidth);
227 b42c8399 leszek
      }
228
229 0c52af30 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
230
    
231
    @Override
232
    protected void onPause() 
233
      {
234 82f42eeb Leszek Koltunski
      super.onPause();
235 6a083c6a Leszek Koltunski
      RubikNetwork.onPause();
236 33499c56 Leszek Koltunski
      savePreferences();
237 0c52af30 Leszek Koltunski
      }
238
239
///////////////////////////////////////////////////////////////////////////////////////////////////
240
    
241
    @Override
242
    protected void onResume() 
243
      {
244
      super.onResume();
245 51853bf2 Leszek Koltunski
246 6142069a Leszek Koltunski
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
247
      restorePreferences(preferences,mJustStarted);
248 1c04d054 leszek
249 c02235d5 leszek
      RubikNetwork network = RubikNetwork.getInstance();
250
      network.signUpForUpdates(this);
251 1c04d054 leszek
252 c3ffcf58 Leszek Koltunski
      if( mJustStarted )
253
        {
254
        mJustStarted = false;
255 72d3d383 leszek
256
        network.downloadUpdates(this);
257 82ce8e64 Leszek Koltunski
        RubikScores scores = RubikScores.getInstance();
258
        scores.incrementNumRuns();
259
        scores.setCountry(this);
260 c3ffcf58 Leszek Koltunski
        }
261
262 ada8ab26 leszek
      if( !mOldVersion.equals(mCurrVersion) ) displayNovelties();
263 0c52af30 Leszek Koltunski
      }
264 d05e7629 Leszek Koltunski
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266
267 1c89e2a7 Leszek Koltunski
    private void displayNovelties()
268 d05e7629 Leszek Koltunski
      {
269 1c89e2a7 Leszek Koltunski
      Bundle bundle = new Bundle();
270 34d6b123 Leszek Koltunski
      bundle.putString("argument",mOldVersion);
271 e71baee1 Leszek Koltunski
      RubikDialogAbout newDialog = new RubikDialogAbout();
272 1c89e2a7 Leszek Koltunski
      newDialog.setArguments(bundle);
273 e71baee1 Leszek Koltunski
      newDialog.show(getSupportFragmentManager(), RubikDialogAbout.getDialogTag() );
274 d05e7629 Leszek Koltunski
      }
275
276 0c52af30 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
277
    
278
    @Override
279
    protected void onDestroy() 
280
      {
281
      super.onDestroy();
282
      }
283
284 4c9947bd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
285
286 b20e89d2 Leszek Koltunski
    private String getAppVers()
287 4c9947bd Leszek Koltunski
      {
288 b20e89d2 Leszek Koltunski
      try
289
        {
290
        PackageInfo pInfo = getPackageManager().getPackageInfo( getPackageName(), 0);
291
        return pInfo.versionName;
292
        }
293 1c04d054 leszek
      catch( PackageManager.NameNotFoundException e )
294 b20e89d2 Leszek Koltunski
        {
295
        return "unknown";
296
        }
297 4c9947bd Leszek Koltunski
      }
298
299 33499c56 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
300
301
    private void savePreferences()
302
      {
303
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
304
      SharedPreferences.Editor editor = preferences.edit();
305
306 e9e744f7 Leszek Koltunski
      editor.putString("appVersion", mCurrVersion );
307 b1e9596b Leszek Koltunski
308 400ff34d Leszek Koltunski
      RubikObjectList.savePreferences(editor);
309 2e3488f6 Leszek Koltunski
310 abc1e5af leszek
      RubikScores scores = RubikScores.getInstance();
311
      scores.savePreferences(editor);
312
313 7480fbab Leszek Koltunski
      boolean success = editor.commit();
314
      if( !success ) android.util.Log.e("D", "Failed to save preferences");
315 33499c56 Leszek Koltunski
      }
316
317
///////////////////////////////////////////////////////////////////////////////////////////////////
318
319 6142069a Leszek Koltunski
    private void restorePreferences(SharedPreferences preferences, boolean justStarted)
320 33499c56 Leszek Koltunski
      {
321 d05e7629 Leszek Koltunski
      mOldVersion = preferences.getString("appVersion","");
322 872307fe Leszek Koltunski
323 7480fbab Leszek Koltunski
      RubikObjectList.restorePreferences(this,preferences,justStarted);
324 e9e744f7 Leszek Koltunski
      RubikScores scores = RubikScores.getInstance();
325 abc1e5af leszek
      scores.restorePreferences(preferences);
326 e9e744f7 Leszek Koltunski
327
      if( scores.isVerified() )
328
        {
329
        FirebaseAnalytics analytics = getAnalytics();
330
        analytics.setUserId(scores.getName());
331
        }
332
      }
333 ee4e7896 Leszek Koltunski
334 e9e744f7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
335 ee4e7896 Leszek Koltunski
336 b42c8399 leszek
    private void updateBubble(int num)
337 e9e744f7 Leszek Koltunski
      {
338 b42c8399 leszek
      runOnUiThread(new Runnable()
339
        {
340
        @Override
341
        public void run()
342
          {
343
          mNumUpdates = num;
344 00fcfefa Leszek Koltunski
345 b42c8399 leszek
          if( num>0 )
346
            {
347
            String shownNum = String.valueOf(num);
348
            mBubbleUpdates.setText(shownNum);
349
            mBubbleUpdates.setVisibility(View.VISIBLE);
350
            int height = (int)(0.05f*mScreenWidth);
351
            mBubbleUpdates.setTextSize(TypedValue.COMPLEX_UNIT_PX,height);
352
            }
353
          else
354
            {
355
            mBubbleUpdates.setVisibility(View.INVISIBLE);
356
            }
357
          }
358
        });
359 f3e12931 Leszek Koltunski
      }
360
361 2e3488f6 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
362 b42c8399 leszek
// PUBLIC API
363 2d9fc972 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
364
365 b42c8399 leszek
    public FirebaseAnalytics getAnalytics()
366 2d9fc972 Leszek Koltunski
      {
367 b42c8399 leszek
      return mFirebaseAnalytics;
368 2d9fc972 Leszek Koltunski
      }
369
370 c02235d5 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
371
372
    public int getObjectOrdinal()
373
      {
374
      return mCurrentObject;
375
      }
376
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378
379
    public void setCurrentObject(int current)
380
      {
381
      mCurrentObject = current;
382
      }
383
384 1b3cbd5b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
385
386 b710a574 leszek
    public void switchToTutorial(int objectOrdinal)
387 1b3cbd5b Leszek Koltunski
      {
388 1c04d054 leszek
      Intent intent = new Intent(this, TutorialActivity.class);
389
      intent.putExtra("obj", objectOrdinal);
390
      startActivity(intent);
391 1b3cbd5b Leszek Koltunski
      }
392
393 598de3ee Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
394
395 1c04d054 leszek
    public void switchToConfig(int objectOrdinal)
396 598de3ee Leszek Koltunski
      {
397 1c04d054 leszek
      Intent intent = new Intent(this, ConfigActivity.class);
398
      intent.putExtra("obj", objectOrdinal);
399
      startActivity(intent);
400 598de3ee Leszek Koltunski
      }
401
402 a6d3b158 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
403
404 1c04d054 leszek
    public void switchToBandagedCreator(int objectOrdinal)
405 aa171dee Leszek Koltunski
      {
406 7ee8337b leszek
      Intent intent = new Intent(this, BandagedActivity.class);
407 1c04d054 leszek
      intent.putExtra("obj", objectOrdinal);
408
      startActivity(intent);
409 8becce57 Leszek Koltunski
      }
410
411 d7f0c07d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
412
413 cb30e768 leszek
    public void switchToSolver(int objectOrdinal)
414 d7f0c07d Leszek Koltunski
      {
415 cb30e768 leszek
      Intent intent = new Intent(this, SolverActivity.class);
416 1c04d054 leszek
      intent.putExtra("obj", objectOrdinal);
417
      startActivity(intent);
418 d7f0c07d Leszek Koltunski
      }
419
420 e9245b7b leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
421
422
    public void switchToPattern(int objectOrdinal)
423
      {
424
      Intent intent = new Intent(this, PatternActivity.class);
425
      intent.putExtra("obj", objectOrdinal);
426
      startActivity(intent);
427
      }
428
429 7ee8337b leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
430
431 1a206525 leszek
    public void switchToPlay(RubikObject object, int ordinal, int scrambles, int level)
432 7ee8337b leszek
      {
433 5a2a7682 leszek
      boolean local = object.isLocal();
434
      String name = local ? object.getLowerName() : object.getUpperName();
435
436 7ee8337b leszek
      Intent intent = new Intent(this, PlayActivity.class);
437 7bb30586 leszek
      intent.putExtra("level", level);
438 5a2a7682 leszek
      intent.putExtra("name", name );
439 7ee8337b leszek
      intent.putExtra("scrambles", scrambles);
440 5a2a7682 leszek
      intent.putExtra("local", local );
441 1a206525 leszek
      intent.putExtra("ordinal", ordinal );
442 7ee8337b leszek
      startActivity(intent);
443
      }
444
445 8ba7aeb1 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
446
447 1c04d054 leszek
    public void onScores(View v)
448 8ba7aeb1 Leszek Koltunski
      {
449 1c04d054 leszek
      Bundle sBundle = new Bundle();
450
      sBundle.putString("argument", "false");
451
      RubikDialogScores scores = new RubikDialogScores();
452
      scores.setArguments(sBundle);
453
      scores.show(getSupportFragmentManager(), null);
454 aa171dee Leszek Koltunski
      }
455
456 12a991f2 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
457
458
    public void onSettings(View v)
459
      {
460 c820515c leszek
      int sw = (int)(mScreenWidth*0.7);
461
      int sh = (int)(mScreenHeight*0.2f);
462 12a991f2 leszek
463 c820515c leszek
      int vw = v.getWidth();
464
465
      MainSettingsPopup popup = new MainSettingsPopup(this,mScreenWidth,mScreenHeight);
466
      popup.displayPopup(this,v,sw,sh,(int)((vw-sw)/2),0);
467 12a991f2 leszek
      }
468
469 aa171dee Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
470
471 1c04d054 leszek
    public void onUpdates(View v)
472 769d7b9f Leszek Koltunski
      {
473 1c04d054 leszek
      RubikDialogUpdates diag = new RubikDialogUpdates();
474
      diag.show( getSupportFragmentManager(), RubikDialogUpdates.getDialogTag() );
475 b20e89d2 Leszek Koltunski
      }
476
477
///////////////////////////////////////////////////////////////////////////////////////////////////
478 7eae2d49 Leszek Koltunski
479 1c04d054 leszek
    public void onExit(View v)
480 b20e89d2 Leszek Koltunski
      {
481 1c04d054 leszek
      RubikDialogExit diag = new RubikDialogExit();
482
      diag.show(getSupportFragmentManager(), null);
483 2e8ec627 Leszek Koltunski
      }
484
485 b1e9596b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
486
487 1c04d054 leszek
    public void onAbout(View v)
488 b6468abb Leszek Koltunski
      {
489 1c04d054 leszek
      RubikDialogAbout diag = new RubikDialogAbout();
490
      diag.show(getSupportFragmentManager(), null);
491 b6468abb Leszek Koltunski
      }
492 1237d25d Leszek Koltunski
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494
495 1c04d054 leszek
    public void onBandage(View v)
496 1237d25d Leszek Koltunski
      {
497 1c04d054 leszek
      RubikDialogCreators diag = new RubikDialogCreators();
498
      diag.show(getSupportFragmentManager(), RubikDialogCreators.getDialogTag() );
499 9530f6b0 Leszek Koltunski
      }
500
501 c7238c67 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
502
503 1c04d054 leszek
    public void receiveUpdate(RubikUpdates updates)
504 c7238c67 Leszek Koltunski
      {
505 1c04d054 leszek
      int num = updates.getCompletedNumber();
506
      updateBubble(num);
507 c7238c67 Leszek Koltunski
      }
508
509 41a5dd89 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
510
511 1c04d054 leszek
    public void objectDownloaded(String shortName)
512 41a5dd89 Leszek Koltunski
      {
513 1c04d054 leszek
      mNumUpdates--;
514
      updateBubble(mNumUpdates);
515 b42c8399 leszek
      mGrid.updateGrid(this,mScreenWidth);
516 41a5dd89 Leszek Koltunski
      }
517 67d7fb28 Leszek Koltunski
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519
520 1c04d054 leszek
    public int getType()
521 67d7fb28 Leszek Koltunski
      {
522 1c04d054 leszek
      return 0;
523 67d7fb28 Leszek Koltunski
      }
524
525
///////////////////////////////////////////////////////////////////////////////////////////////////
526
527 1c04d054 leszek
    public void errorUpdate()
528 67d7fb28 Leszek Koltunski
      {
529 1c04d054 leszek
      android.util.Log.e("D", "NewRubikActivity: Error receiving downloaded objects update");
530 67d7fb28 Leszek Koltunski
      }
531 0c52af30 Leszek Koltunski
}